EVOLUTION-MANAGER
Edit File: projector_binary.js
var CLOSURE_NO_DEPS = true; window.polymerSkipLoadingFontRoboto = true; (function(){window.ga=function(){}, /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ window.JSCompiler_renameProperty=function(e,t){return e}; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ let CSS_URL_RX=/(url\()([^)]*)(\))/g,ABS_URL=/(^\/[^\/])|(^#)|(^[\w-\d]*:)/,workingURL,resolveDoc;function resolveUrl(e,t){if(e&&ABS_URL.test(e))return e;if("//"===e)return e;if(void 0===workingURL){workingURL=!1;try{const e=new URL("b","http://a");e.pathname="c%20d",workingURL="http://a/c%20d"===e.href}catch(e){}}if(t||(t=document.baseURI||window.location.href),workingURL)try{return new URL(e,t).href}catch(t){return e}return resolveDoc||(resolveDoc=document.implementation.createHTMLDocument("temp"),resolveDoc.base=resolveDoc.createElement("base"),resolveDoc.head.appendChild(resolveDoc.base),resolveDoc.anchor=resolveDoc.createElement("a"),resolveDoc.body.appendChild(resolveDoc.anchor)),resolveDoc.base.href=t,resolveDoc.anchor.href=e,resolveDoc.anchor.href||e}function resolveCss(e,t){return e.replace(CSS_URL_RX,(function(e,n,i,r){return n+"'"+resolveUrl(i.replace(/["']/g,""),t)+"'"+r}))}function pathFromUrl(e){return e.substring(0,e.lastIndexOf("/")+1)} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const useShadow=!window.ShadyDOM||!window.ShadyDOM.inUse;Boolean(!window.ShadyCSS||window.ShadyCSS.nativeCss);const supportsAdoptingStyleSheets=useShadow&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype&&(()=>{try{const e=new CSSStyleSheet;e.replaceSync("");const t=document.createElement("div");return t.attachShadow({mode:"open"}),t.shadowRoot.adoptedStyleSheets=[e],t.shadowRoot.adoptedStyleSheets[0]===e}catch(e){return!1}})();let rootPath=window.Polymer&&window.Polymer.rootPath||pathFromUrl(document.baseURI||window.location.href),sanitizeDOMValue=window.Polymer&&window.Polymer.sanitizeDOMValue||void 0,passiveTouchGestures=window.Polymer&&window.Polymer.setPassiveTouchGestures||!1,strictTemplatePolicy=window.Polymer&&window.Polymer.strictTemplatePolicy||!1;const setStrictTemplatePolicy=function(e){strictTemplatePolicy=e};let allowTemplateFromDomModule=window.Polymer&&window.Polymer.allowTemplateFromDomModule||!1,legacyOptimizations=window.Polymer&&window.Polymer.legacyOptimizations||!1,legacyWarnings=window.Polymer&&window.Polymer.legacyWarnings||!1,syncInitialRender=window.Polymer&&window.Polymer.syncInitialRender||!1,legacyUndefined=window.Polymer&&window.Polymer.legacyUndefined||!1,orderedComputed=window.Polymer&&window.Polymer.orderedComputed||!1,removeNestedTemplates=window.Polymer&&window.Polymer.removeNestedTemplates||!1,fastDomIf=window.Polymer&&window.Polymer.fastDomIf||!1,suppressTemplateNotifications=window.Polymer&&window.Polymer.suppressTemplateNotifications||!1,legacyNoObservedAttributes=window.Polymer&&window.Polymer.legacyNoObservedAttributes||!1,useAdoptedStyleSheetsWithBuiltCSS=window.Polymer&&window.Polymer.useAdoptedStyleSheetsWithBuiltCSS||!1;setStrictTemplatePolicy(!0); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ let modules={},lcModules={};function setModule(e,t){modules[e]=lcModules[e.toLowerCase()]=t}function findModule(e){return modules[e]||lcModules[e.toLowerCase()]}function styleOutsideTemplateCheck(e){e.querySelector("style")&&console.warn("dom-module %s has style outside template",e.id)}class DomModule extends HTMLElement{static get observedAttributes(){return["id"]}static import(e,t){if(e){let n=findModule(e);return n&&t?n.querySelector(t):n}return null}attributeChangedCallback(e,t,n,i){t!==n&&this.register()}get assetpath(){if(!this.__assetpath){const e=window.HTMLImports&&HTMLImports.importForElement?HTMLImports.importForElement(this)||document:this.ownerDocument,t=resolveUrl(this.getAttribute("assetpath")||"",e.baseURI);this.__assetpath=pathFromUrl(t)}return this.__assetpath}register(e){if(e=e||this.id){if(strictTemplatePolicy&&void 0!==findModule(e))throw setModule(e,null),new Error(`strictTemplatePolicy: dom-module ${e} re-registered`);this.id=e,setModule(e,this),styleOutsideTemplateCheck(this)}}}function registerStyleDomModule(e){const{moduleName:t,styleContent:n}=e,i=document.createElement("dom-module"),r=document.createElement("template"),o=[];e.styleDependencies&&e.styleDependencies.forEach((e=>{const t=document.createElement("style");t.setAttribute("include",e),o.push(t)}));const a=document.createElement("style");Object.assign(a,{textContent:n}),o.forEach((e=>{r.content.appendChild(e)})),r.content.appendChild(a),i.appendChild(r),i.register(t)} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ function __decorate(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function __metadata(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function __awaiter(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{l(i.next(e))}catch(e){o(e)}}function s(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){e.done?r(e.value):(function t(e){return e instanceof n?e:new n((function(t){t(e)}))})(e.value).then(a,s)}l((i=i.apply(e,t||[])).next())}))} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */DomModule.prototype.modules=modules,customElements.define("dom-module",DomModule),registerStyleDomModule({moduleName:"vz-projector-styles",styleContent:"\n :host {\n --paper-input-container-label: {\n font-size: 14px;\n }\n --paper-input-container-input: {\n font-size: 14px;\n }\n /* TODO: Figure out why this doesn't work */\n --paper-dropdown-menu-input: {\n font-size: 14px;\n }\n }\n\n paper-button {\n background: #e3e3e3;\n margin-left: 0;\n text-transform: none;\n }\n\n paper-dropdown-menu paper-item {\n font-size: 13px;\n }\n\n paper-tooltip {\n max-width: 200px;\n --paper-tooltip: {\n font-size: 12px;\n }\n }\n\n paper-checkbox {\n --paper-checkbox-checked-color: #880e4f;\n }\n\n paper-toggle-button {\n --paper-toggle-button-checked-bar-color: #880e4f;\n --paper-toggle-button-checked-button-color: #880e4f;\n --paper-toggle-button-checked-ink-color: #880e4f;\n }\n\n paper-icon-button {\n border-radius: 50%;\n }\n\n paper-icon-button[active] {\n color: white;\n background-color: #880e4f;\n }\n\n .slider {\n display: flex;\n align-items: center;\n margin-bottom: 10px;\n justify-content: space-between;\n }\n\n .slider span {\n width: 35px;\n text-align: right;\n }\n\n .slider label {\n align-items: center;\n display: flex;\n }\n\n .help-icon {\n height: 15px;\n left: 2px;\n min-width: 15px;\n min-height: 15px;\n margin: 0;\n padding: 0;\n top: -2px;\n width: 15px;\n }\n\n .ink-panel {\n display: flex;\n flex-direction: column;\n font-size: 14px;\n }\n\n .ink-panel h4 {\n border-bottom: 1px solid #ddd;\n font-size: 14px;\n font-weight: 500;\n margin: 0;\n margin-bottom: 10px;\n padding-bottom: 5px;\n }\n\n .ink-panel-header {\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-top: 1px solid rgba(0, 0, 0, 0.1);\n height: 50px;\n }\n\n .ink-panel-content {\n display: none;\n height: 100%;\n }\n\n .ink-panel-content.active {\n display: block;\n }\n\n .ink-panel-content h3 {\n font-weight: 500;\n font-size: 14px;\n margin-top: 20px;\n margin-bottom: 5px;\n text-transform: uppercase;\n }\n\n .ink-panel-header h3 {\n font-weight: 500;\n font-size: 14px;\n margin: 0;\n padding: 0 24px;\n text-transform: uppercase;\n }\n\n /* - Tabs */\n .ink-tab-group {\n align-items: center;\n box-sizing: border-box;\n display: flex;\n height: 100%;\n justify-content: space-around;\n }\n\n .ink-tab-group .projection-tab {\n color: rgba(0, 0, 0, 0.5);\n cursor: pointer;\n font-weight: 300;\n line-height: 49px;\n padding: 0 12px;\n text-align: center;\n text-transform: uppercase;\n }\n\n .ink-tab-group .projection-tab:hover {\n color: black;\n }\n\n .ink-tab-group .projection-tab.active {\n border-bottom: 2px solid black;\n color: black;\n font-weight: 500;\n }\n\n h4 {\n margin: 30px 0 10px 0;\n }\n\n .dismiss-dialog-note {\n margin-top: 25px;\n font-size: 11px;\n text-align: right;\n }\n "});let dedupeId$1=0;const dedupingMixin=function(e){let t=e.__mixinApplications;t||(t=new WeakMap,e.__mixinApplications=t);let n=dedupeId$1++;return function i(r){let o=r.__mixinSet;if(o&&o[n])return r;let a=t,s=a.get(r);if(!s){s=e(r),a.set(r,s);let t=Object.create(s.__mixinSet||o||null);t[n]=!0,s.__mixinSet=t}return s}},MODULE_STYLE_LINK_SELECTOR="link[rel=import][type~=css]",INCLUDE_ATTR="include",SHADY_UNSCOPED_ATTR="shady-unscoped"; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function importModule(e){return DomModule.import(e)}function styleForImport(e){const t=resolveCss((e.body?e.body:e).textContent,e.baseURI),n=document.createElement("style");return n.textContent=t,n}function stylesFromModules(e){const t=e.trim().split(/\s+/),n=[];for(let e=0;e<t.length;e++)n.push(...stylesFromModule(t[e]));return n}function stylesFromModule(e){const t=importModule(e);if(!t)return console.warn("Could not find style data in module named",e),[];if(void 0===t._styles){const e=[];e.push(..._stylesFromModuleImports(t));const n=t.querySelector("template");n&&e.push(...stylesFromTemplate(n,t.assetpath)),t._styles=e}return t._styles}function stylesFromTemplate(e,t){if(!e._styles){const n=[],i=e.content.querySelectorAll("style");for(let e=0;e<i.length;e++){let r=i[e],o=r.getAttribute(INCLUDE_ATTR);o&&n.push(...stylesFromModules(o).filter((function(e,t,n){return n.indexOf(e)===t}))),t&&(r.textContent=resolveCss(r.textContent,t)),n.push(r)}e._styles=n}return e._styles}function stylesFromModuleImports(e){let t=importModule(e);return t?_stylesFromModuleImports(t):[]}function _stylesFromModuleImports(e){const t=[],n=e.querySelectorAll(MODULE_STYLE_LINK_SELECTOR);for(let e=0;e<n.length;e++){let i=n[e];if(i.import){const e=i.import,n=i.hasAttribute(SHADY_UNSCOPED_ATTR);if(n&&!e._unscopedStyle){const t=styleForImport(e);t.setAttribute(SHADY_UNSCOPED_ATTR,""),e._unscopedStyle=t}else e._style||(e._style=styleForImport(e));t.push(n?e._unscopedStyle:e._style)}}return t}function cssFromModules(e){let t=e.trim().split(/\s+/),n="";for(let e=0;e<t.length;e++)n+=cssFromModule(t[e]);return n}function cssFromModule(e){let t=importModule(e);if(t&&void 0===t._cssText){let e=_cssFromModuleImports(t),n=t.querySelector("template");n&&(e+=cssFromTemplate(n,t.assetpath)),t._cssText=e||null}return t||console.warn("Could not find style data in module named",e),t&&t._cssText||""}function cssFromTemplate(e,t){let n="";const i=stylesFromTemplate(e,t);for(let e=0;e<i.length;e++){let t=i[e];t.parentNode&&t.parentNode.removeChild(t),n+=t.textContent}return n}function _cssFromModuleImports(e){let t="",n=_stylesFromModuleImports(e);for(let e=0;e<n.length;e++)t+=n[e].textContent;return t} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const wrap=window.ShadyDOM&&window.ShadyDOM.noPatch&&window.ShadyDOM.wrap?window.ShadyDOM.wrap:window.ShadyDOM?e=>ShadyDOM.patch(e):e=>e; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function isPath(e){return e.indexOf(".")>=0}function root(e){let t=e.indexOf(".");return-1===t?e:e.slice(0,t)}function isAncestor(e,t){return 0===e.indexOf(t+".")}function isDescendant(e,t){return 0===t.indexOf(e+".")}function translate(e,t,n){return t+n.slice(e.length)}function matches$1(e,t){return e===t||isAncestor(e,t)||isDescendant(e,t)}function normalize$1(e){if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let i=e[n].toString().split(".");for(let e=0;e<i.length;e++)t.push(i[e])}return t.join(".")}return e}function split$1(e){return Array.isArray(e)?normalize$1(e).split("."):e.toString().split(".")}function get$1(e,t,n){let i=e,r=split$1(t);for(let e=0;e<r.length;e++){if(!i)return;i=i[r[e]]}return n&&(n.path=r.join(".")),i}function set$1(e,t,n){let i=e,r=split$1(t),o=r[r.length-1];if(r.length>1){for(let e=0;e<r.length-1;e++)if(i=i[r[e]],!i)return;i[o]=n}else i[t]=n;return r.join(".")} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const caseMap={},DASH_TO_CAMEL=/-[a-z]/g,CAMEL_TO_DASH=/([A-Z])/g;function dashToCamelCase(e){return caseMap[e]||(caseMap[e]=e.indexOf("-")<0?e:e.replace(DASH_TO_CAMEL,(e=>e[1].toUpperCase())))}function camelToDashCase(e){return caseMap[e]||(caseMap[e]=e.replace(CAMEL_TO_DASH,"-$1").toLowerCase())} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */let microtaskCurrHandle=0,microtaskLastHandle=0,microtaskCallbacks=[],microtaskNodeContent=0,microtaskScheduled=!1,microtaskNode=document.createTextNode("");function microtaskFlush(){microtaskScheduled=!1;const e=microtaskCallbacks.length;for(let t=0;t<e;t++){let e=microtaskCallbacks[t];if(e)try{e()}catch(e){setTimeout((()=>{throw e}))}}microtaskCallbacks.splice(0,e),microtaskLastHandle+=e}new window.MutationObserver(microtaskFlush).observe(microtaskNode,{characterData:!0});const timeOut={after:e=>({run:t=>window.setTimeout(t,e),cancel(e){window.clearTimeout(e)}}),run:(e,t)=>window.setTimeout(e,t),cancel(e){window.clearTimeout(e)}},animationFrame={run:e=>window.requestAnimationFrame(e),cancel(e){window.cancelAnimationFrame(e)}},idlePeriod={run:e=>window.requestIdleCallback?window.requestIdleCallback(e):window.setTimeout(e,16),cancel(e){window.cancelIdleCallback?window.cancelIdleCallback(e):window.clearTimeout(e)}},microTask={run:e=>(microtaskScheduled||(microtaskScheduled=!0,microtaskNode.textContent=microtaskNodeContent++),microtaskCallbacks.push(e),microtaskCurrHandle++),cancel(e){const t=e-microtaskLastHandle;if(t>=0){if(!microtaskCallbacks[t])throw new Error("invalid async handle: "+e);microtaskCallbacks[t]=null}}},microtask=microTask,PropertiesChanged=dedupingMixin((e=>class extends e{static createProperties(e){const t=this.prototype;for(let n in e)n in t||t._createPropertyAccessor(n)}static attributeNameForProperty(e){return e.toLowerCase()}static typeForProperty(e){}_createPropertyAccessor(e,t){this._addPropertyToAttributeMap(e),this.hasOwnProperty(JSCompiler_renameProperty("__dataHasAccessor",this))||(this.__dataHasAccessor=Object.assign({},this.__dataHasAccessor)),this.__dataHasAccessor[e]||(this.__dataHasAccessor[e]=!0,this._definePropertyAccessor(e,t))}_addPropertyToAttributeMap(e){this.hasOwnProperty(JSCompiler_renameProperty("__dataAttributes",this))||(this.__dataAttributes=Object.assign({},this.__dataAttributes));let t=this.__dataAttributes[e];return t||(t=this.constructor.attributeNameForProperty(e),this.__dataAttributes[t]=e),t}_definePropertyAccessor(e,t){Object.defineProperty(this,e,{get(){return this.__data[e]},set:t?function(){}:function(t){this._setPendingProperty(e,t,!0)&&this._invalidateProperties()}})}constructor(){super(),this.__dataEnabled=!1,this.__dataReady=!1,this.__dataInvalid=!1,this.__data={},this.__dataPending=null,this.__dataOld=null,this.__dataInstanceProps=null,this.__dataCounter=0,this.__serializing=!1,this._initializeProperties()}ready(){this.__dataReady=!0,this._flushProperties()}_initializeProperties(){for(let e in this.__dataHasAccessor)this.hasOwnProperty(e)&&(this.__dataInstanceProps=this.__dataInstanceProps||{},this.__dataInstanceProps[e]=this[e],delete this[e])}_initializeInstanceProperties(e){Object.assign(this,e)}_setProperty(e,t){this._setPendingProperty(e,t)&&this._invalidateProperties()}_getProperty(e){return this.__data[e]}_setPendingProperty(e,t,n){let i=this.__data[e],r=this._shouldPropertyChange(e,t,i);return r&&(this.__dataPending||(this.__dataPending={},this.__dataOld={}),this.__dataOld&&!(e in this.__dataOld)&&(this.__dataOld[e]=i),this.__data[e]=t,this.__dataPending[e]=t),r}_isPropertyPending(e){return!(!this.__dataPending||!this.__dataPending.hasOwnProperty(e))}_invalidateProperties(){!this.__dataInvalid&&this.__dataReady&&(this.__dataInvalid=!0,microtask.run((()=>{this.__dataInvalid&&(this.__dataInvalid=!1,this._flushProperties())})))}_enableProperties(){this.__dataEnabled||(this.__dataEnabled=!0,this.__dataInstanceProps&&(this._initializeInstanceProperties(this.__dataInstanceProps),this.__dataInstanceProps=null),this.ready())}_flushProperties(){this.__dataCounter++;const e=this.__data,t=this.__dataPending,n=this.__dataOld;this._shouldPropertiesChange(e,t,n)&&(this.__dataPending=null,this.__dataOld=null,this._propertiesChanged(e,t,n)),this.__dataCounter--}_shouldPropertiesChange(e,t,n){return Boolean(t)}_propertiesChanged(e,t,n){}_shouldPropertyChange(e,t,n){return n!==t&&(n==n||t==t)}attributeChangedCallback(e,t,n,i){t!==n&&this._attributeToProperty(e,n),super.attributeChangedCallback&&super.attributeChangedCallback(e,t,n,i)}_attributeToProperty(e,t,n){if(!this.__serializing){const i=this.__dataAttributes,r=i&&i[e]||e;this[r]=this._deserializeValue(t,n||this.constructor.typeForProperty(r))}}_propertyToAttribute(e,t,n){this.__serializing=!0,this._valueToNodeAttribute(this,n=arguments.length<3?this[e]:n,t||this.constructor.attributeNameForProperty(e)),this.__serializing=!1}_valueToNodeAttribute(e,t,n){const i=this._serializeValue(t);"class"!==n&&"name"!==n&&"slot"!==n||(e=wrap(e)),void 0===i?e.removeAttribute(n):e.setAttribute(n,i)}_serializeValue(e){switch(typeof e){case"boolean":return e?"":void 0;default:return null!=e?e.toString():void 0}}_deserializeValue(e,t){switch(t){case Boolean:return null!==e;case Number:return Number(e);default:return e}}})),nativeProperties={};let proto$1=HTMLElement.prototype;for(;proto$1;){let e=Object.getOwnPropertyNames(proto$1);for(let t=0;t<e.length;t++)nativeProperties[e[t]]=!0;proto$1=Object.getPrototypeOf(proto$1)}function saveAccessorValue(e,t){if(!nativeProperties[t]){let n=e[t];void 0!==n&&(e.__data?e._setPendingProperty(t,n):(e.__dataProto?e.hasOwnProperty(JSCompiler_renameProperty("__dataProto",e))||(e.__dataProto=Object.create(e.__dataProto)):e.__dataProto={},e.__dataProto[t]=n))}}const PropertyAccessors=dedupingMixin((e=>{const t=PropertiesChanged(e);return class extends t{static createPropertiesForAttributes(){let e=this.observedAttributes;for(let t=0;t<e.length;t++)this.prototype._createPropertyAccessor(dashToCamelCase(e[t]))}static attributeNameForProperty(e){return camelToDashCase(e)}_initializeProperties(){this.__dataProto&&(this._initializeProtoProperties(this.__dataProto),this.__dataProto=null),super._initializeProperties()}_initializeProtoProperties(e){for(let t in e)this._setProperty(t,e[t])}_ensureAttribute(e,t){this.hasAttribute(e)||this._valueToNodeAttribute(this,t,e)}_serializeValue(e){switch(typeof e){case"object":if(e instanceof Date)return e.toString();if(e)try{return JSON.stringify(e)}catch(e){return""}default:return super._serializeValue(e)}}_deserializeValue(e,t){let n;switch(t){case Object:try{n=JSON.parse(e)}catch(t){n=e}break;case Array:try{n=JSON.parse(e)}catch(t){n=null,console.warn(`Polymer::Attributes: couldn't decode Array as JSON: ${e}`)}break;case Date:n=isNaN(e)?String(e):Number(e),n=new Date(n);break;default:n=super._deserializeValue(e,t)}return n}_definePropertyAccessor(e,t){saveAccessorValue(this,e),super._definePropertyAccessor(e,t)}_hasAccessor(e){return this.__dataHasAccessor&&this.__dataHasAccessor[e]}_isPropertyPending(e){return Boolean(this.__dataPending&&e in this.__dataPending)}}})),templateExtensions={"dom-if":!0,"dom-repeat":!0}; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */let placeholderBugDetect=!1,placeholderBug=!1;function hasPlaceholderBug(){if(!placeholderBugDetect){placeholderBugDetect=!0;const e=document.createElement("textarea");e.placeholder="a",placeholderBug=e.placeholder===e.textContent}return placeholderBug}function fixPlaceholder(e){hasPlaceholderBug()&&"textarea"===e.localName&&e.placeholder&&e.placeholder===e.textContent&&(e.textContent=null)}function wrapTemplateExtension(e){let t=e.getAttribute("is");if(t&&templateExtensions[t]){let n=e;for(n.removeAttribute("is"),e=n.ownerDocument.createElement(t),n.parentNode.replaceChild(e,n),e.appendChild(n);n.attributes.length;)e.setAttribute(n.attributes[0].name,n.attributes[0].value),n.removeAttribute(n.attributes[0].name)}return e}function findTemplateNode(e,t){let n=t.parentInfo&&findTemplateNode(e,t.parentInfo);if(!n)return e;for(let e=n.firstChild,i=0;e;e=e.nextSibling)if(t.parentIndex===i++)return e}function applyIdToMap(e,t,n,i){i.id&&(t[i.id]=n)}function applyEventListener(e,t,n){if(n.events&&n.events.length)for(let i,r=0,o=n.events;r<o.length&&(i=o[r]);r++)e._addMethodEventListenerToNode(t,i.name,i.value,e)}function applyTemplateInfo(e,t,n,i){n.templateInfo&&(t._templateInfo=n.templateInfo,t._parentTemplateInfo=i)}function createNodeEventHandler(e,t,n){return e=e._methodHost||e,function(t){e[n]?e[n](t,t.detail):console.warn("listener method `"+n+"` not defined")}}const TemplateStamp=dedupingMixin((e=>class extends e{static _parseTemplate(e,t){if(!e._templateInfo){let n=e._templateInfo={};n.nodeInfoList=[],n.nestedTemplate=Boolean(t),n.stripWhiteSpace=t&&t.stripWhiteSpace||e.hasAttribute("strip-whitespace"),this._parseTemplateContent(e,n,{parent:null})}return e._templateInfo}static _parseTemplateContent(e,t,n){return this._parseTemplateNode(e.content,t,n)}static _parseTemplateNode(e,t,n){let i=!1,r=e;return"template"!=r.localName||r.hasAttribute("preserve-content")?"slot"===r.localName&&(t.hasInsertionPoint=!0):i=this._parseTemplateNestedTemplate(r,t,n)||i,fixPlaceholder(r),r.firstChild&&this._parseTemplateChildNodes(r,t,n),r.hasAttributes&&r.hasAttributes()&&(i=this._parseTemplateNodeAttributes(r,t,n)||i),i||n.noted}static _parseTemplateChildNodes(e,t,n){if("script"!==e.localName&&"style"!==e.localName)for(let i,r=e.firstChild,o=0;r;r=i){if("template"==r.localName&&(r=wrapTemplateExtension(r)),i=r.nextSibling,r.nodeType===Node.TEXT_NODE){let n=i;for(;n&&n.nodeType===Node.TEXT_NODE;)r.textContent+=n.textContent,i=n.nextSibling,e.removeChild(n),n=i;if(t.stripWhiteSpace&&!r.textContent.trim()){e.removeChild(r);continue}}let a={parentIndex:o,parentInfo:n};this._parseTemplateNode(r,t,a)&&(a.infoIndex=t.nodeInfoList.push(a)-1),r.parentNode&&o++}}static _parseTemplateNestedTemplate(e,t,n){let i=e,r=this._parseTemplate(i,t);return(r.content=i.content.ownerDocument.createDocumentFragment()).appendChild(i.content),n.templateInfo=r,!0}static _parseTemplateNodeAttributes(e,t,n){let i=!1,r=Array.from(e.attributes);for(let o,a=r.length-1;o=r[a];a--)i=this._parseTemplateNodeAttribute(e,t,n,o.name,o.value)||i;return i}static _parseTemplateNodeAttribute(e,t,n,i,r){return"on-"===i.slice(0,3)?(e.removeAttribute(i),n.events=n.events||[],n.events.push({name:i.slice(3),value:r}),!0):"id"===i&&(n.id=r,!0)}static _contentForTemplate(e){let t=e._templateInfo;return t&&t.content||e.content}_stampTemplate(e,t){e&&!e.content&&window.HTMLTemplateElement&&HTMLTemplateElement.decorate&&HTMLTemplateElement.decorate(e);let n=(t=t||this.constructor._parseTemplate(e)).nodeInfoList,i=document.importNode(t.content||e.content,!0);i.__noInsertionPoint=!t.hasInsertionPoint;let r=i.nodeList=new Array(n.length);i.$={};for(let e,o=0,a=n.length;o<a&&(e=n[o]);o++){let n=r[o]=findTemplateNode(i,e);applyIdToMap(this,i.$,n,e),applyTemplateInfo(this,n,e,t),applyEventListener(this,n,e)}return i=i,i}_addMethodEventListenerToNode(e,t,n,i){let r=createNodeEventHandler(i=i||e,t,n);return this._addEventListenerToNode(e,t,r),r}_addEventListenerToNode(e,t,n){e.addEventListener(t,n)}_removeEventListenerFromNode(e,t,n){e.removeEventListener(t,n)}})); /** * @fileoverview * @suppress {checkPrototypalTypes} * @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt The complete set of authors may be found * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by * Google as part of the polymer project is also subject to an additional IP * rights grant found at http://polymer.github.io/PATENTS.txt */let dedupeId=0;const NOOP=[],TYPES={COMPUTE:"__computeEffects",REFLECT:"__reflectEffects",NOTIFY:"__notifyEffects",PROPAGATE:"__propagateEffects",OBSERVE:"__observeEffects",READ_ONLY:"__readOnly"},COMPUTE_INFO="__computeInfo",capitalAttributeRegex=/[A-Z]/;function ensureOwnEffectMap(e,t,n){let i=e[t];if(i){if(!e.hasOwnProperty(t)&&(i=e[t]=Object.create(e[t]),n))for(let e in i){let t=i[e],n=i[e]=Array(t.length);for(let e=0;e<t.length;e++)n[e]=t[e]}}else i=e[t]={};return i}function runEffects(e,t,n,i,r,o){if(t){let a=!1;const s=dedupeId++;for(let l in n){let c=t[r?root(l):l];if(c)for(let t,h=0,u=c.length;h<u&&(t=c[h]);h++)t.info&&t.info.lastRun===s||r&&!pathMatchesTrigger(l,t.trigger)||(t.info&&(t.info.lastRun=s),t.fn(e,l,n,i,t.info,r,o),a=!0)}return a}return!1}function runEffectsForProperty(e,t,n,i,r,o,a,s){let l=!1,c=t[a?root(i):i];if(c)for(let t,h=0,u=c.length;h<u&&(t=c[h]);h++)t.info&&t.info.lastRun===n||a&&!pathMatchesTrigger(i,t.trigger)||(t.info&&(t.info.lastRun=n),t.fn(e,i,r,o,t.info,a,s),l=!0);return l}function pathMatchesTrigger(e,t){if(t){let n=t.name;return n==e||!(!t.structured||!isAncestor(n,e))||!(!t.wildcard||!isDescendant(n,e))}return!0}function runObserverEffect(e,t,n,i,r){let o="string"==typeof r.method?e[r.method]:r.method,a=r.property;o?o.call(e,e.__data[a],i[a]):r.dynamicFn||console.warn("observer method `"+r.method+"` not defined")}function runNotifyEffects(e,t,n,i,r){let o,a,s=e[TYPES.NOTIFY],l=dedupeId++;for(let a in t)t[a]&&(s&&runEffectsForProperty(e,s,l,a,n,i,r)||r&¬ifyPath(e,a,n))&&(o=!0);o&&(a=e.__dataHost)&&a._invalidateProperties&&a._invalidateProperties()}function notifyPath(e,t,n){let i=root(t);return i!==t&&(dispatchNotifyEvent(e,camelToDashCase(i)+"-changed",n[t],t),!0)}function dispatchNotifyEvent(e,t,n,i){let r={value:n,queueProperty:!0};i&&(r.path=i),wrap(e).dispatchEvent(new CustomEvent(t,{detail:r}))}function runNotifyEffect(e,t,n,i,r,o){let a=(o?root(t):t)!=t?t:null,s=a?get$1(e,a):e.__data[t];a&&void 0===s&&(s=n[t]),dispatchNotifyEvent(e,r.eventName,s,a)}function handleNotification(e,t,n,i,r){let o,a=e.detail,s=a&&a.path;s?(i=translate(n,i,s),o=a&&a.value):o=e.currentTarget[n],o=r?!o:o,t[TYPES.READ_ONLY]&&t[TYPES.READ_ONLY][i]||!t._setPendingPropertyOrPath(i,o,!0,Boolean(s))||a&&a.queueProperty||t._invalidateProperties()}function runReflectEffect(e,t,n,i,r){let o=e.__data[t];sanitizeDOMValue&&(o=sanitizeDOMValue(o,r.attrName,"attribute",e)),e._propertyToAttribute(t,r.attrName,o)}function runComputedEffects(e,t,n,i){let r=e[TYPES.COMPUTE];if(r)if(orderedComputed){dedupeId++;const o=getComputedOrder(e),a=[];for(let e in t)enqueueEffectsFor(e,r,a,o,i);let s;for(;s=a.shift();)runComputedEffect(e,"",t,n,s)&&enqueueEffectsFor(s.methodInfo,r,a,o,i);Object.assign(n,e.__dataOld),Object.assign(t,e.__dataPending),e.__dataPending=null}else{let o=t;for(;runEffects(e,r,o,n,i);)Object.assign(n,e.__dataOld),Object.assign(t,e.__dataPending),o=e.__dataPending,e.__dataPending=null}}const insertEffect=(e,t,n)=>{let i=0,r=t.length-1,o=-1;for(;i<=r;){const a=i+r>>1,s=n.get(t[a].methodInfo)-n.get(e.methodInfo);if(s<0)i=a+1;else{if(!(s>0)){o=a;break}r=a-1}}o<0&&(o=r+1),t.splice(o,0,e)},enqueueEffectsFor=(e,t,n,i,r)=>{const o=t[r?root(e):e];if(o)for(let t=0;t<o.length;t++){const a=o[t];a.info.lastRun===dedupeId||r&&!pathMatchesTrigger(e,a.trigger)||(a.info.lastRun=dedupeId,insertEffect(a.info,n,i))}};function getComputedOrder(e){let t=e.constructor.__orderedComputedDeps;if(!t){t=new Map;const n=e[TYPES.COMPUTE];let i,{counts:r,ready:o,total:a}=dependencyCounts(e);for(;i=o.shift();){t.set(i,t.size);const e=n[i];e&&e.forEach((e=>{const t=e.info.methodInfo;--a,0==--r[t]&&o.push(t)}))}0!==a&&console.warn(`Computed graph for ${e.localName} incomplete; circular?`),e.constructor.__orderedComputedDeps=t}return t}function dependencyCounts(e){const t=e[COMPUTE_INFO],n={},i=e[TYPES.COMPUTE],r=[];let o=0;for(let e in t){const i=t[e];o+=n[e]=i.args.filter((e=>!e.literal)).length+(i.dynamicFn?1:0)}for(let e in i)t[e]||r.push(e);return{counts:n,ready:r,total:o}}function runComputedEffect(e,t,n,i,r){let o=runMethodEffect(e,t,n,i,r);if(o===NOOP)return!1;let a=r.methodInfo;return e.__dataHasAccessor&&e.__dataHasAccessor[a]?e._setPendingProperty(a,o,!0):(e[a]=o,!1)}function computeLinkedPaths(e,t,n){let i=e.__dataLinkedPaths;if(i){let r;for(let o in i){let a=i[o];isDescendant(o,t)?(r=translate(o,a,t),e._setPendingPropertyOrPath(r,n,!0,!0)):isDescendant(a,t)&&(r=translate(a,o,t),e._setPendingPropertyOrPath(r,n,!0,!0))}}}function addBinding(e,t,n,i,r,o,a){n.bindings=n.bindings||[];let s={kind:i,target:r,parts:o,literal:a,isCompound:1!==o.length};if(n.bindings.push(s),shouldAddListener(s)){let{event:e,negate:t}=s.parts[0];s.listenerEvent=e||camelToDashCase(r)+"-changed",s.listenerNegate=t}let l=t.nodeInfoList.length;for(let n=0;n<s.parts.length;n++){let i=s.parts[n];i.compoundIndex=n,addEffectForBindingPart(e,t,s,i,l)}}function addEffectForBindingPart(e,t,n,i,r){if(!i.literal)if("attribute"===n.kind&&"-"===n.target[0])console.warn("Cannot set attribute "+n.target+' because "-" is not a valid attribute starting character');else{let o=i.dependencies,a={index:r,binding:n,part:i,evaluator:e};for(let n=0;n<o.length;n++){let i=o[n];"string"==typeof i&&(i=parseArg(i),i.wildcard=!0),e._addTemplatePropertyEffect(t,i.rootProperty,{fn:runBindingEffect,info:a,trigger:i})}}}function runBindingEffect(e,t,n,i,r,o,a){let s=a[r.index],l=r.binding,c=r.part;if(o&&c.source&&t.length>c.source.length&&"property"==l.kind&&!l.isCompound&&s.__isPropertyEffectsClient&&s.__dataHasAccessor&&s.__dataHasAccessor[l.target]){let i=n[t];t=translate(c.source,l.target,t),s._setPendingPropertyOrPath(t,i,!1,!0)&&e._enqueueClient(s)}else{let a=r.evaluator._evaluateBinding(e,c,t,n,i,o);a!==NOOP&&applyBindingValue(e,s,l,c,a)}}function applyBindingValue(e,t,n,i,r){if(r=computeBindingValue(t,r,n,i),sanitizeDOMValue&&(r=sanitizeDOMValue(r,n.target,n.kind,t)),"attribute"==n.kind)e._valueToNodeAttribute(t,r,n.target);else{let i=n.target;t.__isPropertyEffectsClient&&t.__dataHasAccessor&&t.__dataHasAccessor[i]?t[TYPES.READ_ONLY]&&t[TYPES.READ_ONLY][i]||t._setPendingProperty(i,r)&&e._enqueueClient(t):e._setUnmanagedPropertyToNode(t,i,r)}}function computeBindingValue(e,t,n,i){if(n.isCompound){let r=e.__dataCompoundStorage[n.target];r[i.compoundIndex]=t,t=r.join("")}return"attribute"!==n.kind&&("textContent"!==n.target&&("value"!==n.target||"input"!==e.localName&&"textarea"!==e.localName)||(t=null==t?"":t)),t}function shouldAddListener(e){return Boolean(e.target)&&"attribute"!=e.kind&&"text"!=e.kind&&!e.isCompound&&"{"===e.parts[0].mode}function setupBindings(e,t){let{nodeList:n,nodeInfoList:i}=t;if(i.length)for(let t=0;t<i.length;t++){let r=n[t],o=i[t].bindings;if(o)for(let t=0;t<o.length;t++){let n=o[t];setupCompoundStorage(r,n),addNotifyListener(r,e,n)}r.__dataHost=e}}function setupCompoundStorage(e,t){if(t.isCompound){let n=e.__dataCompoundStorage||(e.__dataCompoundStorage={}),i=t.parts,r=new Array(i.length);for(let e=0;e<i.length;e++)r[e]=i[e].literal;let o=t.target;n[o]=r,t.literal&&"property"==t.kind&&("className"===o&&(e=wrap(e)),e[o]=t.literal)}}function addNotifyListener(e,t,n){if(n.listenerEvent){let i=n.parts[0];e.addEventListener(n.listenerEvent,(function(e){handleNotification(e,t,n.target,i.source,i.negate)}))}}function createMethodEffect(e,t,n,i,r,o){let a={methodName:t.methodName,args:t.args,methodInfo:r,dynamicFn:o=t.static||o&&("object"!=typeof o||o[t.methodName])};for(let r,o=0;o<t.args.length&&(r=t.args[o]);o++)r.literal||e._addPropertyEffect(r.rootProperty,n,{fn:i,info:a,trigger:r});return o&&e._addPropertyEffect(t.methodName,n,{fn:i,info:a}),a}function runMethodEffect(e,t,n,i,r){let o=e._methodHost||e,a=o[r.methodName];if(a){let i=e._marshalArgs(r.args,t,n);return i===NOOP?NOOP:a.apply(o,i)}r.dynamicFn||console.warn("method `"+r.methodName+"` not defined")}const emptyArray=[],IDENT="(?:[a-zA-Z_$][\\w.:$\\-*]*)",NUMBER="(?:[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)",SQUOTE_STRING="(?:'(?:[^'\\\\]|\\\\.)*')",DQUOTE_STRING='(?:"(?:[^"\\\\]|\\\\.)*")',STRING="(?:"+SQUOTE_STRING+"|"+DQUOTE_STRING+")",ARGUMENT="(?:("+IDENT+"|"+NUMBER+"|"+STRING+")\\s*)",ARGUMENTS="(?:"+ARGUMENT+"(?:,\\s*"+ARGUMENT+")*)",ARGUMENT_LIST="(?:\\(\\s*(?:"+ARGUMENTS+"?)\\)\\s*)",BINDING="("+IDENT+"\\s*"+ARGUMENT_LIST+"?)",OPEN_BRACKET="(\\[\\[|{{)\\s*",CLOSE_BRACKET="(?:]]|}})",NEGATE="(?:(!)\\s*)?",EXPRESSION=OPEN_BRACKET+NEGATE+BINDING+CLOSE_BRACKET,bindingRegex=new RegExp(EXPRESSION,"g");function literalFromParts(e){let t="";for(let n=0;n<e.length;n++)t+=e[n].literal||"";return t}function parseMethod(e){let t=e.match(/([^\s]+?)\(([\s\S]*)\)/);if(t){let e={methodName:t[1],static:!0,args:emptyArray};return t[2].trim()?parseArgs(t[2].replace(/\\,/g,",").split(","),e):e}return null}function parseArgs(e,t){return t.args=e.map((function(e){let n=parseArg(e);return n.literal||(t.static=!1),n}),this),t}function parseArg(e){let t=e.trim().replace(/,/g,",").replace(/\\(.)/g,"$1"),n={name:t,value:"",literal:!1},i=t[0];switch("-"===i&&(i=t[1]),i>="0"&&i<="9"&&(i="#"),i){case"'":case'"':n.value=t.slice(1,-1),n.literal=!0;break;case"#":n.value=Number(t),n.literal=!0}return n.literal||(n.rootProperty=root(t),n.structured=isPath(t),n.structured&&(n.wildcard=".*"==t.slice(-2),n.wildcard&&(n.name=t.slice(0,-2)))),n}function getArgValue(e,t,n){let i=get$1(e,n);return void 0===i&&(i=t[n]),i}function notifySplices(e,t,n,i){const r={indexSplices:i};legacyUndefined&&!e._overrideLegacyUndefined&&(t.splices=r),e.notifyPath(n+".splices",r),e.notifyPath(n+".length",t.length),legacyUndefined&&!e._overrideLegacyUndefined&&(r.indexSplices=[])}function notifySplice(e,t,n,i,r,o){notifySplices(e,t,n,[{index:i,addedCount:r,removed:o,object:t,type:"splice"}])}function upper(e){return e[0].toUpperCase()+e.substring(1)}const PropertyEffects=dedupingMixin((e=>{const t=TemplateStamp(PropertyAccessors(e));return class extends t{constructor(){super(),this.__isPropertyEffectsClient=!0}get PROPERTY_EFFECT_TYPES(){return TYPES}_initializeProperties(){super._initializeProperties(),this._registerHost(),this.__dataClientsReady=!1,this.__dataPendingClients=null,this.__dataToNotify=null,this.__dataLinkedPaths=null,this.__dataHasPaths=!1,this.__dataCompoundStorage=this.__dataCompoundStorage||null,this.__dataHost=this.__dataHost||null,this.__dataTemp={},this.__dataClientsInitialized=!1}_registerHost(){if(hostStack.length){let e=hostStack[hostStack.length-1];e._enqueueClient(this),this.__dataHost=e}}_initializeProtoProperties(e){this.__data=Object.create(e),this.__dataPending=Object.create(e),this.__dataOld={}}_initializeInstanceProperties(e){let t=this[TYPES.READ_ONLY];for(let n in e)t&&t[n]||(this.__dataPending=this.__dataPending||{},this.__dataOld=this.__dataOld||{},this.__data[n]=this.__dataPending[n]=e[n])}_addPropertyEffect(e,t,n){this._createPropertyAccessor(e,t==TYPES.READ_ONLY);let i=ensureOwnEffectMap(this,t,!0)[e];i||(i=this[t][e]=[]),i.push(n)}_removePropertyEffect(e,t,n){let i=ensureOwnEffectMap(this,t,!0)[e],r=i.indexOf(n);r>=0&&i.splice(r,1)}_hasPropertyEffect(e,t){let n=this[t];return Boolean(n&&n[e])}_hasReadOnlyEffect(e){return this._hasPropertyEffect(e,TYPES.READ_ONLY)}_hasNotifyEffect(e){return this._hasPropertyEffect(e,TYPES.NOTIFY)}_hasReflectEffect(e){return this._hasPropertyEffect(e,TYPES.REFLECT)}_hasComputedEffect(e){return this._hasPropertyEffect(e,TYPES.COMPUTE)}_setPendingPropertyOrPath(e,t,n,i){if(i||root(Array.isArray(e)?e[0]:e)!==e){if(!i){let n=get$1(this,e);if(!(e=set$1(this,e,t))||!super._shouldPropertyChange(e,t,n))return!1}if(this.__dataHasPaths=!0,this._setPendingProperty(e,t,n))return computeLinkedPaths(this,e,t),!0}else{if(this.__dataHasAccessor&&this.__dataHasAccessor[e])return this._setPendingProperty(e,t,n);this[e]=t}return!1}_setUnmanagedPropertyToNode(e,t,n){n===e[t]&&"object"!=typeof n||("className"===t&&(e=wrap(e)),e[t]=n)}_setPendingProperty(e,t,n){let i=this.__dataHasPaths&&isPath(e);return!!this._shouldPropertyChange(e,t,(i?this.__dataTemp:this.__data)[e])&&(this.__dataPending||(this.__dataPending={},this.__dataOld={}),e in this.__dataOld||(this.__dataOld[e]=this.__data[e]),i?this.__dataTemp[e]=t:this.__data[e]=t,this.__dataPending[e]=t,(i||this[TYPES.NOTIFY]&&this[TYPES.NOTIFY][e])&&(this.__dataToNotify=this.__dataToNotify||{},this.__dataToNotify[e]=n),!0)}_setProperty(e,t){this._setPendingProperty(e,t,!0)&&this._invalidateProperties()}_invalidateProperties(){this.__dataReady&&this._flushProperties()}_enqueueClient(e){this.__dataPendingClients=this.__dataPendingClients||[],e!==this&&this.__dataPendingClients.push(e)}_flushClients(){this.__dataClientsReady?this.__enableOrFlushClients():(this.__dataClientsReady=!0,this._readyClients(),this.__dataReady=!0)}__enableOrFlushClients(){let e=this.__dataPendingClients;if(e){this.__dataPendingClients=null;for(let t=0;t<e.length;t++){let n=e[t];n.__dataEnabled?n.__dataPending&&n._flushProperties():n._enableProperties()}}}_readyClients(){this.__enableOrFlushClients()}setProperties(e,t){for(let n in e)!t&&this[TYPES.READ_ONLY]&&this[TYPES.READ_ONLY][n]||this._setPendingPropertyOrPath(n,e[n],!0);this._invalidateProperties()}ready(){this._flushProperties(),this.__dataClientsReady||this._flushClients(),this.__dataPending&&this._flushProperties()}_propertiesChanged(e,t,n){let i,r=this.__dataHasPaths;this.__dataHasPaths=!1,runComputedEffects(this,t,n,r),i=this.__dataToNotify,this.__dataToNotify=null,this._propagatePropertyChanges(t,n,r),this._flushClients(),runEffects(this,this[TYPES.REFLECT],t,n,r),runEffects(this,this[TYPES.OBSERVE],t,n,r),i&&runNotifyEffects(this,i,t,n,r),1==this.__dataCounter&&(this.__dataTemp={})}_propagatePropertyChanges(e,t,n){this[TYPES.PROPAGATE]&&runEffects(this,this[TYPES.PROPAGATE],e,t,n),this.__templateInfo&&this._runEffectsForTemplate(this.__templateInfo,e,t,n)}_runEffectsForTemplate(e,t,n,i){const r=(t,i)=>{runEffects(this,e.propertyEffects,t,n,i,e.nodeList);for(let r=e.firstChild;r;r=r.nextSibling)this._runEffectsForTemplate(r,t,n,i)};e.runEffects?e.runEffects(r,t,i):r(t,i)}linkPaths(e,t){e=normalize$1(e),t=normalize$1(t),this.__dataLinkedPaths=this.__dataLinkedPaths||{},this.__dataLinkedPaths[e]=t}unlinkPaths(e){e=normalize$1(e),this.__dataLinkedPaths&&delete this.__dataLinkedPaths[e]}notifySplices(e,t){let n={path:""};notifySplices(this,get$1(this,e,n),n.path,t)}get(e,t){return get$1(t||this,e)}set(e,t,n){n?set$1(n,e,t):this[TYPES.READ_ONLY]&&this[TYPES.READ_ONLY][e]||this._setPendingPropertyOrPath(e,t,!0)&&this._invalidateProperties()}push(e,...t){let n={path:""},i=get$1(this,e,n),r=i.length,o=i.push(...t);return t.length&¬ifySplice(this,i,n.path,r,t.length,[]),o}pop(e){let t={path:""},n=get$1(this,e,t),i=Boolean(n.length),r=n.pop();return i&¬ifySplice(this,n,t.path,n.length,0,[r]),r}splice(e,t,n,...i){let r,o={path:""},a=get$1(this,e,o);return t<0?t=a.length-Math.floor(-t):t&&(t=Math.floor(t)),r=2===arguments.length?a.splice(t):a.splice(t,n,...i),(i.length||r.length)&¬ifySplice(this,a,o.path,t,i.length,r),r}shift(e){let t={path:""},n=get$1(this,e,t),i=Boolean(n.length),r=n.shift();return i&¬ifySplice(this,n,t.path,0,0,[r]),r}unshift(e,...t){let n={path:""},i=get$1(this,e,n),r=i.unshift(...t);return t.length&¬ifySplice(this,i,n.path,0,t.length,[]),r}notifyPath(e,t){let n;if(1==arguments.length){let i={path:""};t=get$1(this,e,i),n=i.path}else n=Array.isArray(e)?normalize$1(e):e;this._setPendingPropertyOrPath(n,t,!0,!0)&&this._invalidateProperties()}_createReadOnlyProperty(e,t){this._addPropertyEffect(e,TYPES.READ_ONLY),t&&(this["_set"+upper(e)]=function(t){this._setProperty(e,t)})}_createPropertyObserver(e,t,n){let i={property:e,method:t,dynamicFn:Boolean(n)};this._addPropertyEffect(e,TYPES.OBSERVE,{fn:runObserverEffect,info:i,trigger:{name:e}}),n&&this._addPropertyEffect(t,TYPES.OBSERVE,{fn:runObserverEffect,info:i,trigger:{name:t}})}_createMethodObserver(e,t){let n=parseMethod(e);if(!n)throw new Error("Malformed observer expression '"+e+"'");createMethodEffect(this,n,TYPES.OBSERVE,runMethodEffect,null,t)}_createNotifyingProperty(e){this._addPropertyEffect(e,TYPES.NOTIFY,{fn:runNotifyEffect,info:{eventName:camelToDashCase(e)+"-changed",property:e}})}_createReflectedProperty(e){let t=this.constructor.attributeNameForProperty(e);"-"===t[0]?console.warn("Property "+e+" cannot be reflected to attribute "+t+' because "-" is not a valid starting attribute name. Use a lowercase first letter for the property instead.'):this._addPropertyEffect(e,TYPES.REFLECT,{fn:runReflectEffect,info:{attrName:t}})}_createComputedProperty(e,t,n){let i=parseMethod(t);if(!i)throw new Error("Malformed computed expression '"+t+"'");const r=createMethodEffect(this,i,TYPES.COMPUTE,runComputedEffect,e,n);ensureOwnEffectMap(this,COMPUTE_INFO)[e]=r}_marshalArgs(e,t,n){const i=this.__data,r=[];for(let o=0,a=e.length;o<a;o++){let{name:a,structured:s,wildcard:l,value:c,literal:h}=e[o];if(!h)if(l){const e=isDescendant(a,t),r=getArgValue(i,n,e?t:a);c={path:e?t:a,value:r,base:e?get$1(i,a):r}}else c=s?getArgValue(i,n,a):i[a];if(legacyUndefined&&!this._overrideLegacyUndefined&&void 0===c&&e.length>1)return NOOP;r[o]=c}return r}static addPropertyEffect(e,t,n){this.prototype._addPropertyEffect(e,t,n)}static createPropertyObserver(e,t,n){this.prototype._createPropertyObserver(e,t,n)}static createMethodObserver(e,t){this.prototype._createMethodObserver(e,t)}static createNotifyingProperty(e){this.prototype._createNotifyingProperty(e)}static createReadOnlyProperty(e,t){this.prototype._createReadOnlyProperty(e,t)}static createReflectedProperty(e){this.prototype._createReflectedProperty(e)}static createComputedProperty(e,t,n){this.prototype._createComputedProperty(e,t,n)}static bindTemplate(e){return this.prototype._bindTemplate(e)}_bindTemplate(e,t){let n=this.constructor._parseTemplate(e),i=this.__preBoundTemplateInfo==n;if(!i)for(let e in n.propertyEffects)this._createPropertyAccessor(e);if(t)if(n=Object.create(n),n.wasPreBound=i,this.__templateInfo){const t=e._parentTemplateInfo||this.__templateInfo,i=t.lastChild;n.parent=t,t.lastChild=n,n.previousSibling=i,i?i.nextSibling=n:t.firstChild=n}else this.__templateInfo=n;else this.__preBoundTemplateInfo=n;return n}static _addTemplatePropertyEffect(e,t,n){(e.hostProps=e.hostProps||{})[t]=!0;let i=e.propertyEffects=e.propertyEffects||{};(i[t]=i[t]||[]).push(n)}_stampTemplate(e,t){t=t||this._bindTemplate(e,!0),hostStack.push(this);let n=super._stampTemplate(e,t);if(hostStack.pop(),t.nodeList=n.nodeList,!t.wasPreBound){let e=t.childNodes=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t)}return n.templateInfo=t,setupBindings(this,t),this.__dataClientsReady&&(this._runEffectsForTemplate(t,this.__data,null,!1),this._flushClients()),n}_removeBoundDom(e){const t=e.templateInfo,{previousSibling:n,nextSibling:i,parent:r}=t;n?n.nextSibling=i:r&&(r.firstChild=i),i?i.previousSibling=n:r&&(r.lastChild=n),t.nextSibling=t.previousSibling=null;let o=t.childNodes;for(let e=0;e<o.length;e++){let t=o[e];wrap(wrap(t).parentNode).removeChild(t)}}static _parseTemplateNode(e,n,i){let r=t._parseTemplateNode.call(this,e,n,i);if(e.nodeType===Node.TEXT_NODE){let t=this._parseBindings(e.textContent,n);t&&(e.textContent=literalFromParts(t)||" ",addBinding(this,n,i,"text","textContent",t),r=!0)}return r}static _parseTemplateNodeAttribute(e,n,i,r,o){let a=this._parseBindings(o,n);if(a){let t=r,o="property";capitalAttributeRegex.test(r)?o="attribute":"$"==r[r.length-1]&&(r=r.slice(0,-1),o="attribute");let s=literalFromParts(a);return s&&"attribute"==o&&("class"==r&&e.hasAttribute("class")&&(s+=" "+e.getAttribute(r)),e.setAttribute(r,s)),"attribute"==o&&"disable-upgrade$"==t&&e.setAttribute(r,""),"input"===e.localName&&"value"===t&&e.setAttribute(t,""),e.removeAttribute(t),"property"===o&&(r=dashToCamelCase(r)),addBinding(this,n,i,o,r,a,s),!0}return t._parseTemplateNodeAttribute.call(this,e,n,i,r,o)}static _parseTemplateNestedTemplate(e,n,i){let r=t._parseTemplateNestedTemplate.call(this,e,n,i);const o=e.parentNode,a=i.templateInfo,s="dom-if"===o.localName;removeNestedTemplates&&(s||"dom-repeat"===o.localName)&&(o.removeChild(e),(i=i.parentInfo).templateInfo=a,i.noted=!0,r=!1);let l=a.hostProps;if(fastDomIf&&s)l&&(n.hostProps=Object.assign(n.hostProps||{},l),removeNestedTemplates||(i.parentInfo.noted=!0));else{let e="{";for(let t in l)addBinding(this,n,i,"property","_host_"+t,[{mode:e,source:t,dependencies:[t],hostProp:!0}])}return r}static _parseBindings(e,t){let n,i=[],r=0;for(;null!==(n=bindingRegex.exec(e));){n.index>r&&i.push({literal:e.slice(r,n.index)});let o=n[1][0],a=Boolean(n[2]),s=n[3].trim(),l=!1,c="",h=-1;"{"==o&&(h=s.indexOf("::"))>0&&(c=s.substring(h+2),s=s.substring(0,h),l=!0);let u=parseMethod(s),d=[];if(u){let{args:e,methodName:n}=u;for(let t=0;t<e.length;t++){let n=e[t];n.literal||d.push(n)}let i=t.dynamicFns;(i&&i[n]||u.static)&&(d.push(n),u.dynamicFn=!0)}else d.push(s);i.push({source:s,mode:o,negate:a,customEvent:l,signature:u,dependencies:d,event:c}),r=bindingRegex.lastIndex}if(r&&r<e.length){let t=e.substring(r);t&&i.push({literal:t})}return i.length?i:null}static _evaluateBinding(e,t,n,i,r,o){let a;return a=t.signature?runMethodEffect(e,n,i,r,t.signature):n!=t.source?get$1(e,t.source):o&&isPath(n)?get$1(e,n):e.__data[n],t.negate&&(a=!a),a}}})),hostStack=[]; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ function register$1(e){} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function normalizeProperties(e){const t={};for(let n in e){const i=e[n];t[n]="function"==typeof i?{type:i}:i}return t}const PropertiesMixin=dedupingMixin((e=>{const t=PropertiesChanged(e);function n(e){const t=Object.getPrototypeOf(e);return t.prototype instanceof r?t:null}function i(e){if(!e.hasOwnProperty(JSCompiler_renameProperty("__ownProperties",e))){let t=null;if(e.hasOwnProperty(JSCompiler_renameProperty("properties",e))){const n=e.properties;n&&(t=normalizeProperties(n))}e.__ownProperties=t}return e.__ownProperties}class r extends t{static get observedAttributes(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__observedAttributes",this))){register$1(this.prototype);const e=this._properties;this.__observedAttributes=e?Object.keys(e).map((e=>this.prototype._addPropertyToAttributeMap(e))):[]}return this.__observedAttributes}static finalize(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__finalized",this))){const e=n(this);e&&e.finalize(),this.__finalized=!0,this._finalizeClass()}}static _finalizeClass(){const e=i(this);e&&this.createProperties(e)}static get _properties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__properties",this))){const e=n(this);this.__properties=Object.assign({},e&&e._properties,i(this))}return this.__properties}static typeForProperty(e){const t=this._properties[e];return t&&t.type}_initializeProperties(){this.constructor.finalize(),super._initializeProperties()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._enableProperties()}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback()}}return r})),version="3.4.1",builtCSS=window.ShadyCSS&&window.ShadyCSS.cssBuild,ElementMixin=dedupingMixin((e=>{const t=PropertiesMixin(PropertyEffects(e));function n(e,t,n,i){n.computed&&(n.readOnly=!0),n.computed&&(e._hasReadOnlyEffect(t)?console.warn(`Cannot redefine computed property '${t}'.`):e._createComputedProperty(t,n.computed,i)),n.readOnly&&!e._hasReadOnlyEffect(t)?e._createReadOnlyProperty(t,!n.computed):!1===n.readOnly&&e._hasReadOnlyEffect(t)&&console.warn(`Cannot make readOnly property '${t}' non-readOnly.`),n.reflectToAttribute&&!e._hasReflectEffect(t)?e._createReflectedProperty(t):!1===n.reflectToAttribute&&e._hasReflectEffect(t)&&console.warn(`Cannot make reflected property '${t}' non-reflected.`),n.notify&&!e._hasNotifyEffect(t)?e._createNotifyingProperty(t):!1===n.notify&&e._hasNotifyEffect(t)&&console.warn(`Cannot make notify property '${t}' non-notify.`),n.observer&&e._createPropertyObserver(t,n.observer,i[n.observer]),e._addPropertyToAttributeMap(t)}return class extends t{static get polymerElementVersion(){return version}static _finalizeClass(){t._finalizeClass.call(this);const e=(function n(e){return e.hasOwnProperty(JSCompiler_renameProperty("__ownObservers",e))||(e.__ownObservers=e.hasOwnProperty(JSCompiler_renameProperty("observers",e))?e.observers:null),e.__ownObservers})(this);e&&this.createObservers(e,this._properties),this._prepareTemplate()}static _prepareTemplate(){let e=this.template;e&&("string"==typeof e?(console.error("template getter must return HTMLTemplateElement"),e=null):legacyOptimizations||(e=e.cloneNode(!0))),this.prototype._template=e}static createProperties(e){for(let t in e)n(this.prototype,t,e[t],e)}static createObservers(e,t){const n=this.prototype;for(let i=0;i<e.length;i++)n._createMethodObserver(e[i],t)}static get template(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_template",this))){const e=this.prototype.hasOwnProperty(JSCompiler_renameProperty("_template",this.prototype))?this.prototype._template:void 0;this._template=void 0!==e?e:this.hasOwnProperty(JSCompiler_renameProperty("is",this))&&(function e(t){let n=null;if(t&&(!strictTemplatePolicy||allowTemplateFromDomModule)&&(n=DomModule.import(t,"template"),strictTemplatePolicy&&!n))throw new Error(`strictTemplatePolicy: expecting dom-module or null template for ${t}`);return n})(this.is)||Object.getPrototypeOf(this.prototype).constructor.template}return this._template}static set template(e){this._template=e}static get importPath(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_importPath",this))){const e=this.importMeta;if(e)this._importPath=pathFromUrl(e.url);else{const e=DomModule.import(this.is);this._importPath=e&&e.assetpath||Object.getPrototypeOf(this.prototype).constructor.importPath}}return this._importPath}constructor(){super()}_initializeProperties(){this.constructor.finalize(),this.constructor._finalizeTemplate(this.localName),super._initializeProperties(),this.rootPath=rootPath,this.importPath=this.constructor.importPath;let e=(function t(e){if(!e.hasOwnProperty(JSCompiler_renameProperty("__propertyDefaults",e))){e.__propertyDefaults=null;let t=e._properties;for(let n in t){let i=t[n];"value"in i&&(e.__propertyDefaults=e.__propertyDefaults||{},e.__propertyDefaults[n]=i)}}return e.__propertyDefaults})(this.constructor);if(e)for(let t in e){let n=e[t];if(this._canApplyPropertyDefault(t)){let e="function"==typeof n.value?n.value.call(this):n.value;this._hasAccessor(t)?this._setPendingProperty(t,e,!0):this[t]=e}}}_canApplyPropertyDefault(e){return!this.hasOwnProperty(e)}static _processStyleText(e,t){return resolveCss(e,t)}static _finalizeTemplate(e){const t=this.prototype._template;if(t&&!t.__polymerFinalized){t.__polymerFinalized=!0;const n=this.importPath;!(function n(e,t,i,r){if(!builtCSS){const n=t.content.querySelectorAll("style"),o=stylesFromTemplate(t),a=stylesFromModuleImports(i),s=t.content.firstElementChild;for(let n=0;n<a.length;n++){let i=a[n];i.textContent=e._processStyleText(i.textContent,r),t.content.insertBefore(i,s)}let l=0;for(let t=0;t<o.length;t++){let i=o[t],a=n[l];a!==i?(i=i.cloneNode(!0),a.parentNode.insertBefore(i,a)):l++,i.textContent=e._processStyleText(i.textContent,r)}}if(window.ShadyCSS&&window.ShadyCSS.prepareTemplate(t,i),useAdoptedStyleSheetsWithBuiltCSS&&builtCSS&&supportsAdoptingStyleSheets){const n=t.content.querySelectorAll("style");if(n){let t="";Array.from(n).forEach((e=>{t+=e.textContent,e.parentNode.removeChild(e)})),e._styleSheet=new CSSStyleSheet,e._styleSheet.replaceSync(t)}}})(this,t,e,n?resolveUrl(n):""),this.prototype._bindTemplate(t)}}connectedCallback(){window.ShadyCSS&&this._template&&window.ShadyCSS.styleElement(this),super.connectedCallback()}ready(){this._template&&(this.root=this._stampTemplate(this._template),this.$=this.root.$),super.ready()}_readyClients(){this._template&&(this.root=this._attachDom(this.root)),super._readyClients()}_attachDom(e){const t=wrap(this);if(t.attachShadow)return e?(t.shadowRoot||(t.attachShadow({mode:"open",shadyUpgradeFragment:e}),t.shadowRoot.appendChild(e),this.constructor._styleSheet&&(t.shadowRoot.adoptedStyleSheets=[this.constructor._styleSheet])),syncInitialRender&&window.ShadyDOM&&window.ShadyDOM.flushInitial(t.shadowRoot),t.shadowRoot):null;throw new Error("ShadowDOM not available. PolymerElement can create dom as children instead of in ShadowDOM by setting `this.root = this;` before `ready`.")}updateStyles(e){window.ShadyCSS&&window.ShadyCSS.styleSubtree(this,e)}resolveUrl(e,t){return!t&&this.importPath&&(t=resolveUrl(this.importPath)),resolveUrl(e,t)}static _parseTemplateContent(e,n,i){return n.dynamicFns=n.dynamicFns||this._properties,t._parseTemplateContent.call(this,e,n,i)}static _addTemplatePropertyEffect(e,n,i){return!legacyWarnings||n in this._properties||i.info.part.signature&&i.info.part.signature.static||i.info.part.hostProp||e.nestedTemplate||console.warn(`Property '${n}' used in template but not declared in 'properties'; attribute will not be observed.`),t._addTemplatePropertyEffect.call(this,e,n,i)}}})); /** * @fileoverview * @suppress {checkPrototypalTypes} * @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt The complete set of authors may be found * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by * Google as part of the polymer project is also subject to an additional IP * rights grant found at http://polymer.github.io/PATENTS.txt */ /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ class LiteralString{constructor(e){this.value=e.toString()}toString(){return this.value}}function literalValue(e){if(e instanceof LiteralString)return e.value;throw new Error(`non-literal value passed to Polymer's htmlLiteral function: ${e}`)}function htmlValue(e){if(e instanceof HTMLTemplateElement)return e.innerHTML;if(e instanceof LiteralString)return literalValue(e);throw new Error(`non-template value passed to Polymer's html function: ${e}`)}const html=function e(t,...n){const i=document.createElement("template");return i.innerHTML=n.reduce(((e,n,i)=>e+htmlValue(n)+t[i+1]),t[0]),i},PolymerElement=ElementMixin(HTMLElement); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ /** * @license * Copyright (c) 2016 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt The complete set of authors may be found * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by * Google as part of the polymer project is also subject to an additional IP * rights grant found at http://polymer.github.io/PATENTS.txt */ function customElement(e){return t=>{if(e)if(t.hasOwnProperty("is")){if(e!==t.is)throw new Error(`custom element tag names do not match: (${e} !== ${t.is})`)}else Object.defineProperty(t,"is",{value:e});window.customElements.define(t.is,t)}}function createProperty(e,t,n){e.constructor.hasOwnProperty("properties")||Object.defineProperty(e.constructor,"properties",{value:{}}),e.constructor.properties[t]=Object.assign({},e.constructor.properties[t],n)}function property(e){return(t,n)=>{createProperty(t,n,e)}}function observe(...e){return(t,n)=>{t.constructor.hasOwnProperty("observers")||Object.defineProperty(t.constructor,"observers",{value:[]}),t.constructor.observers.push(`${n}(${e.join(",")})`)}}function computed(e,...t){return(n,i,r)=>{const o=`__compute${i}`;Object.defineProperty(n,o,{value:r.get}),r.get=void 0,createProperty(n,i,{computed:`${o}(${[e,...t].join(",")})`})}} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const nativeShadow=!(window.ShadyDOM&&window.ShadyDOM.inUse);let nativeCssVariables_,cssBuild;function calcCssVariables(e){nativeCssVariables_=(!e||!e.shimcssproperties)&&(nativeShadow||Boolean(!navigator.userAgent.match(/AppleWebKit\/601|Edge\/15/)&&window.CSS&&CSS.supports&&CSS.supports("box-shadow","0 0 0 var(--foo)")))}window.ShadyCSS&&void 0!==window.ShadyCSS.cssBuild&&(cssBuild=window.ShadyCSS.cssBuild);const disableRuntime=Boolean(window.ShadyCSS&&window.ShadyCSS.disableRuntime);window.ShadyCSS&&void 0!==window.ShadyCSS.nativeCss?nativeCssVariables_=window.ShadyCSS.nativeCss:window.ShadyCSS?(calcCssVariables(window.ShadyCSS),window.ShadyCSS=void 0):calcCssVariables(window.WebComponents&&window.WebComponents.flags);const nativeCssVariables=nativeCssVariables_; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */class StyleNode{constructor(){this.start=0,this.end=0,this.previous=null,this.parent=null,this.rules=null,this.parsedCssText="",this.cssText="",this.atRule=!1,this.type=0,this.keyframesName="",this.selector="",this.parsedSelector=""}}function parse(e){return parseCss(lex(e=clean(e)),e)}function clean(e){return e.replace(RX.comments,"").replace(RX.port,"")}function lex(e){let t=new StyleNode;t.start=0,t.end=e.length;let n=t;for(let i=0,r=e.length;i<r;i++)if(e[i]===OPEN_BRACE){n.rules||(n.rules=[]);let e=n,t=e.rules[e.rules.length-1]||null;n=new StyleNode,n.start=i+1,n.parent=e,n.previous=t,e.rules.push(n)}else e[i]===CLOSE_BRACE&&(n.end=i+1,n=n.parent||t);return t}function parseCss(e,t){let n=t.substring(e.start,e.end-1);if(e.parsedCssText=e.cssText=n.trim(),e.parent){n=t.substring(e.previous?e.previous.end:e.parent.start,e.start-1),n=_expandUnicodeEscapes(n),n=n.replace(RX.multipleSpaces," "),n=n.substring(n.lastIndexOf(";")+1);let i=e.parsedSelector=e.selector=n.trim();e.atRule=0===i.indexOf(AT_START),e.atRule?0===i.indexOf(MEDIA_START)?e.type=types.MEDIA_RULE:i.match(RX.keyframesRule)&&(e.type=types.KEYFRAMES_RULE,e.keyframesName=e.selector.split(RX.multipleSpaces).pop()):e.type=0===i.indexOf(VAR_START)?types.MIXIN_RULE:types.STYLE_RULE}let i=e.rules;if(i)for(let e,n=0,r=i.length;n<r&&(e=i[n]);n++)parseCss(e,t);return e}function _expandUnicodeEscapes(e){return e.replace(/\\([0-9a-f]{1,6})\s/gi,(function(){let e=arguments[1],t=6-e.length;for(;t--;)e="0"+e;return"\\"+e}))}function stringify(e,t,n=""){let i="";if(e.cssText||e.rules){let n=e.rules;if(n&&!_hasMixinRules(n))for(let e,r=0,o=n.length;r<o&&(e=n[r]);r++)i=stringify(e,t,i);else i=t?e.cssText:removeCustomProps(e.cssText),i=i.trim(),i&&(i=" "+i+"\n")}return i&&(e.selector&&(n+=e.selector+" "+OPEN_BRACE+"\n"),n+=i,e.selector&&(n+=CLOSE_BRACE+"\n\n")),n}function _hasMixinRules(e){let t=e[0];return Boolean(t)&&Boolean(t.selector)&&0===t.selector.indexOf(VAR_START)}function removeCustomProps(e){return removeCustomPropApply(e=removeCustomPropAssignment(e))}function removeCustomPropAssignment(e){return e.replace(RX.customProp,"").replace(RX.mixinProp,"")}function removeCustomPropApply(e){return e.replace(RX.mixinApply,"").replace(RX.varApply,"")}const types={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3},OPEN_BRACE="{",CLOSE_BRACE="}",RX={comments:/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,port:/@import[^;]*;/gim,customProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,mixinProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,mixinApply:/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,varApply:/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,keyframesRule:/^@[^\s]*keyframes/,multipleSpaces:/\s+/g},VAR_START="--",MEDIA_START="@media",AT_START="@",VAR_ASSIGN=/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gi,MIXIN_MATCH=/(?:^|\W+)@apply\s*\(?([^);\n]*)\)?/gi,MEDIA_MATCH=/@media\s(.*)/,styleTextSet=new Set,scopingAttribute="shady-unscoped";function processUnscopedStyle(e){const t=e.textContent;if(!styleTextSet.has(t)){styleTextSet.add(t);const e=document.createElement("style");e.setAttribute("shady-unscoped",""),e.textContent=t,document.head.appendChild(e)}}function isUnscopedStyle(e){return e.hasAttribute(scopingAttribute)} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function toCssText(e,t){return e?("string"==typeof e&&(e=parse(e)),t&&forEachRule(e,t),stringify(e,nativeCssVariables)):""}function rulesForStyle(e){return!e.__cssRules&&e.textContent&&(e.__cssRules=parse(e.textContent)),e.__cssRules||null}function forEachRule(e,t,n,i){if(!e)return;let r=!1,o=e.type;if(i&&o===types.MEDIA_RULE){let t=e.selector.match(MEDIA_MATCH);t&&(window.matchMedia(t[1]).matches||(r=!0))}o===types.STYLE_RULE?t(e):n&&o===types.KEYFRAMES_RULE?n(e):o===types.MIXIN_RULE&&(r=!0);let a=e.rules;if(a&&!r)for(let e,r=0,o=a.length;r<o&&(e=a[r]);r++)forEachRule(e,t,n,i)}function findMatchingParen(e,t){let n=0;for(let i=t,r=e.length;i<r;i++)if("("===e[i])n++;else if(")"===e[i]&&0==--n)return i;return-1}function processVariableAndFallback(e,t){let n=e.indexOf("var(");if(-1===n)return t(e,"","","");let i=findMatchingParen(e,n+3),r=e.substring(n+4,i),o=e.substring(0,n),a=processVariableAndFallback(e.substring(i+1),t),s=r.indexOf(",");return-1===s?t(o,r.trim(),"",a):t(o,r.substring(0,s).trim(),r.substring(s+1).trim(),a)}function getIsExtends(e){let t=e.localName,n="",i="";return t?t.indexOf("-")>-1?n=t:(i=t,n=e.getAttribute&&e.getAttribute("is")||""):(n=e.is,i=e.extends),{is:n,typeExtension:i}}function gatherStyleText(e){const t=[],n=e.querySelectorAll("style");for(let e=0;e<n.length;e++){const i=n[e];isUnscopedStyle(i)?nativeShadow||(processUnscopedStyle(i),i.parentNode.removeChild(i)):(t.push(i.textContent),i.parentNode.removeChild(i))}return t.join("").trim()}window.ShadyDOM&&window;const CSS_BUILD_ATTR="css-build";function getCssBuild(e){if(void 0!==cssBuild)return cssBuild;if(void 0===e.__cssBuild){const t=e.getAttribute(CSS_BUILD_ATTR);if(t)e.__cssBuild=t;else{const t=getBuildComment(e);""!==t&&removeBuildComment(e),e.__cssBuild=t}}return e.__cssBuild||""}function elementHasBuiltCss(e){return""!==getCssBuild(e)}function getBuildComment(e){const t="template"===e.localName?e.content.firstChild:e.firstChild;if(t instanceof Comment){const e=t.textContent.trim().split(":");if(e[0]===CSS_BUILD_ATTR)return e[1]}return""}function removeBuildComment(e){const t="template"===e.localName?e.content.firstChild:e.firstChild;t.parentNode.removeChild(t)} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function updateNativeProperties(e,t){for(let n in t)null===n?e.style.removeProperty(n):e.style.setProperty(n,t[n])}function getComputedStyleValue(e,t){const n=window.getComputedStyle(e).getPropertyValue(t);return n?n.trim():""}function detectMixin(e){const t=MIXIN_MATCH.test(e)||VAR_ASSIGN.test(e);return MIXIN_MATCH.lastIndex=0,VAR_ASSIGN.lastIndex=0,t} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const APPLY_NAME_CLEAN=/;\s*/m,INITIAL_INHERIT=/^\s*(initial)|(inherit)\s*$/,IMPORTANT=/\s*!important/,MIXIN_VAR_SEP="_-_";class MixinMap{constructor(){this._map={}}set(e,t){e=e.trim(),this._map[e]={properties:t,dependants:{}}}get(e){return e=e.trim(),this._map[e]||null}}let invalidCallback=null;class ApplyShim{constructor(){this._currentElement=null,this._measureElement=null,this._map=new MixinMap}detectMixin(e){return detectMixin(e)}gatherStyles(e){const t=gatherStyleText(e.content);if(t){const n=document.createElement("style");return n.textContent=t,e.content.insertBefore(n,e.content.firstChild),n}return null}transformTemplate(e,t){void 0===e._gatheredStyle&&(e._gatheredStyle=this.gatherStyles(e));const n=e._gatheredStyle;return n?this.transformStyle(n,t):null}transformStyle(e,t=""){let n=rulesForStyle(e);return this.transformRules(n,t),e.textContent=toCssText(n),n}transformCustomStyle(e){let t=rulesForStyle(e);return forEachRule(t,(e=>{":root"===e.selector&&(e.selector="html"),this.transformRule(e)})),e.textContent=toCssText(t),t}transformRules(e,t){this._currentElement=t,forEachRule(e,(e=>{this.transformRule(e)})),this._currentElement=null}transformRule(e){e.cssText=this.transformCssText(e.parsedCssText,e),":root"===e.selector&&(e.selector=":host > *")}transformCssText(e,t){return e=e.replace(VAR_ASSIGN,((e,n,i,r)=>this._produceCssProperties(e,n,i,r,t))),this._consumeCssProperties(e,t)}_getInitialValueForProperty(e){return this._measureElement||(this._measureElement=document.createElement("meta"),this._measureElement.setAttribute("apply-shim-measure",""),this._measureElement.style.all="initial",document.head.appendChild(this._measureElement)),window.getComputedStyle(this._measureElement).getPropertyValue(e)}_fallbacksFromPreviousRules(e){let t=e;for(;t.parent;)t=t.parent;const n={};let i=!1;return forEachRule(t,(t=>{i=i||t===e,i||t.selector===e.selector&&Object.assign(n,this._cssTextToMap(t.parsedCssText))})),n}_consumeCssProperties(e,t){let n=null;for(;n=MIXIN_MATCH.exec(e);){let i=n[0],r=n[1],o=n.index,a=o+i.indexOf("@apply"),s=o+i.length,l=e.slice(0,a),c=e.slice(s),h=t?this._fallbacksFromPreviousRules(t):{};Object.assign(h,this._cssTextToMap(l));let u=this._atApplyToCssProperties(r,h);e=`${l}${u}${c}`,MIXIN_MATCH.lastIndex=o+u.length}return e}_atApplyToCssProperties(e,t){e=e.replace(APPLY_NAME_CLEAN,"");let n=[],i=this._map.get(e);if(i||(this._map.set(e,{}),i=this._map.get(e)),i){let r,o,a;this._currentElement&&(i.dependants[this._currentElement]=!0);const s=i.properties;for(r in s)a=t&&t[r],o=[r,": var(",e,MIXIN_VAR_SEP,r],a&&o.push(",",a.replace(IMPORTANT,"")),o.push(")"),IMPORTANT.test(s[r])&&o.push(" !important"),n.push(o.join(""))}return n.join("; ")}_replaceInitialOrInherit(e,t){let n=INITIAL_INHERIT.exec(t);return n&&(t=n[1]?this._getInitialValueForProperty(e):"apply-shim-inherit"),t}_cssTextToMap(e,t=!1){let n,i,r=e.split(";"),o={};for(let e,a,s=0;s<r.length;s++)e=r[s],e&&(a=e.split(":"),a.length>1&&(n=a[0].trim(),i=a.slice(1).join(":"),t&&(i=this._replaceInitialOrInherit(n,i)),o[n]=i));return o}_invalidateMixinEntry(e){if(invalidCallback)for(let t in e.dependants)t!==this._currentElement&&invalidCallback(t)}_produceCssProperties(e,t,n,i,r){if(n&&processVariableAndFallback(n,((e,t)=>{t&&this._map.get(t)&&(i=`@apply ${t};`)})),!i)return e;let o=this._consumeCssProperties(""+i,r),a=e.slice(0,e.indexOf("--")),s=this._cssTextToMap(o,!0),l=s,c=this._map.get(t),h=c&&c.properties;h?l=Object.assign(Object.create(h),s):this._map.set(t,l);let u,d,p=[],m=!1;for(u in l)d=s[u],void 0===d&&(d="initial"),h&&!(u in h)&&(m=!0),p.push(`${t}${MIXIN_VAR_SEP}${u}: ${d}`);return m&&this._invalidateMixinEntry(c),c&&(c.properties=l),n&&(a=`${e};${a}`),`${a}${p.join("; ")};`}}ApplyShim.prototype.detectMixin=ApplyShim.prototype.detectMixin,ApplyShim.prototype.transformStyle=ApplyShim.prototype.transformStyle,ApplyShim.prototype.transformCustomStyle=ApplyShim.prototype.transformCustomStyle,ApplyShim.prototype.transformRules=ApplyShim.prototype.transformRules,ApplyShim.prototype.transformRule=ApplyShim.prototype.transformRule,ApplyShim.prototype.transformTemplate=ApplyShim.prototype.transformTemplate,ApplyShim.prototype._separator=MIXIN_VAR_SEP,Object.defineProperty(ApplyShim.prototype,"invalidCallback",{get:()=>invalidCallback,set(e){invalidCallback=e}}); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const templateMap={},CURRENT_VERSION="_applyShimCurrentVersion",NEXT_VERSION="_applyShimNextVersion",VALIDATING_VERSION="_applyShimValidatingVersion",promise=Promise.resolve(); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function invalidate(e){let t=templateMap[e];t&&invalidateTemplate(t)}function invalidateTemplate(e){e[CURRENT_VERSION]=e[CURRENT_VERSION]||0,e[VALIDATING_VERSION]=e[VALIDATING_VERSION]||0,e[NEXT_VERSION]=(e[NEXT_VERSION]||0)+1}function templateIsValid(e){return e[CURRENT_VERSION]===e[NEXT_VERSION]}function templateIsValidating(e){return!templateIsValid(e)&&e[VALIDATING_VERSION]===e[NEXT_VERSION]}function startValidatingTemplate(e){e[VALIDATING_VERSION]=e[NEXT_VERSION],e._validating||(e._validating=!0,promise.then((function(){e[CURRENT_VERSION]=e[NEXT_VERSION],e._validating=!1})))} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */let readyPromise=null,whenReady=window.HTMLImports&&window.HTMLImports.whenReady||null,resolveFn;function documentWait(e){requestAnimationFrame((function(){whenReady?whenReady(e):(readyPromise||(readyPromise=new Promise((e=>{resolveFn=e})),"complete"===document.readyState?resolveFn():document.addEventListener("readystatechange",(()=>{"complete"===document.readyState&&resolveFn()}))),readyPromise.then((function(){e&&e()})))}))} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const SEEN_MARKER="__seenByShadyCSS",CACHED_STYLE="__shadyCSSCachedStyle";let transformFn=null,validateFn=null;class CustomStyleInterface$1{constructor(){this.customStyles=[],this.enqueued=!1,documentWait((()=>{window.ShadyCSS.flushCustomStyles&&window.ShadyCSS.flushCustomStyles()}))}enqueueDocumentValidation(){!this.enqueued&&validateFn&&(this.enqueued=!0,documentWait(validateFn))}addCustomStyle(e){e[SEEN_MARKER]||(e[SEEN_MARKER]=!0,this.customStyles.push(e),this.enqueueDocumentValidation())}getStyleForCustomStyle(e){if(e[CACHED_STYLE])return e[CACHED_STYLE];let t;return t=e.getStyle?e.getStyle():e,t}processStyles(){const e=this.customStyles;for(let t=0;t<e.length;t++){const n=e[t];if(n[CACHED_STYLE])continue;const i=this.getStyleForCustomStyle(n);if(i){const e=i.__appliedElement||i;transformFn&&transformFn(e),n[CACHED_STYLE]=e}}return e}}CustomStyleInterface$1.prototype.addCustomStyle=CustomStyleInterface$1.prototype.addCustomStyle,CustomStyleInterface$1.prototype.getStyleForCustomStyle=CustomStyleInterface$1.prototype.getStyleForCustomStyle,CustomStyleInterface$1.prototype.processStyles=CustomStyleInterface$1.prototype.processStyles,Object.defineProperties(CustomStyleInterface$1.prototype,{transformCallback:{get:()=>transformFn,set(e){transformFn=e}},validateCallback:{get:()=>validateFn,set(e){let t=!1;validateFn||(t=!0),validateFn=e,t&&this.enqueueDocumentValidation()}}}); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const applyShim=new ApplyShim;class ApplyShimInterface{constructor(){this.customStyleInterface=null,applyShim.invalidCallback=invalidate}ensure(){this.customStyleInterface||window.ShadyCSS.CustomStyleInterface&&(this.customStyleInterface=window.ShadyCSS.CustomStyleInterface,this.customStyleInterface.transformCallback=e=>{applyShim.transformCustomStyle(e)},this.customStyleInterface.validateCallback=()=>{requestAnimationFrame((()=>{this.customStyleInterface.enqueued&&this.flushCustomStyles()}))})}prepareTemplate(e,t){if(this.ensure(),elementHasBuiltCss(e))return;templateMap[t]=e;let n=applyShim.transformTemplate(e,t);e._styleAst=n}flushCustomStyles(){if(this.ensure(),!this.customStyleInterface)return;let e=this.customStyleInterface.processStyles();if(this.customStyleInterface.enqueued){for(let t=0;t<e.length;t++){let n=this.customStyleInterface.getStyleForCustomStyle(e[t]);n&&applyShim.transformCustomStyle(n)}this.customStyleInterface.enqueued=!1}}styleSubtree(e,t){if(this.ensure(),t&&updateNativeProperties(e,t),e.shadowRoot){this.styleElement(e);let t=e.shadowRoot.children||e.shadowRoot.childNodes;for(let e=0;e<t.length;e++)this.styleSubtree(t[e])}else{let t=e.children||e.childNodes;for(let e=0;e<t.length;e++)this.styleSubtree(t[e])}}styleElement(e){this.ensure();let{is:t}=getIsExtends(e),n=templateMap[t];if((!n||!elementHasBuiltCss(n))&&n&&!templateIsValid(n)){templateIsValidating(n)||(this.prepareTemplate(n,t),startValidatingTemplate(n));let i=e.shadowRoot;if(i){let e=i.querySelector("style");e&&(e.__cssRules=n._styleAst,e.textContent=toCssText(n._styleAst))}}}styleDocument(e){this.ensure(),this.styleSubtree(document.body,e)}}if(!window.ShadyCSS||!window.ShadyCSS.ScopingShim){const e=new ApplyShimInterface;let t=window.ShadyCSS&&window.ShadyCSS.CustomStyleInterface;window.ShadyCSS={prepareTemplate(t,n,i){e.flushCustomStyles(),e.prepareTemplate(t,n)},prepareTemplateStyles(e,t,n){window.ShadyCSS.prepareTemplate(e,t,n)},prepareTemplateDom(e,t){},styleSubtree(t,n){e.flushCustomStyles(),e.styleSubtree(t,n)},styleElement(t){e.flushCustomStyles(),e.styleElement(t)},styleDocument(t){e.flushCustomStyles(),e.styleDocument(t)},getComputedStyleValue:(e,t)=>getComputedStyleValue(e,t),flushCustomStyles(){e.flushCustomStyles()},nativeCss:nativeCssVariables,nativeShadow:nativeShadow,cssBuild:cssBuild,disableRuntime:disableRuntime},t&&(window.ShadyCSS.CustomStyleInterface=t)}window.ShadyCSS.ApplyShim=applyShim; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ class Debouncer{constructor(){this._asyncModule=null,this._callback=null,this._timer=null}setConfig(e,t){this._asyncModule=e,this._callback=t,this._timer=this._asyncModule.run((()=>{this._timer=null,debouncerQueue.delete(this),this._callback()}))}cancel(){this.isActive()&&(this._cancelAsync(),debouncerQueue.delete(this))}_cancelAsync(){this.isActive()&&(this._asyncModule.cancel(this._timer),this._timer=null)}flush(){this.isActive()&&(this.cancel(),this._callback())}isActive(){return null!=this._timer}static debounce(e,t,n){return e instanceof Debouncer?e._cancelAsync():e=new Debouncer,e.setConfig(t,n),e}}let debouncerQueue=new Set;const enqueueDebouncer=function(e){debouncerQueue.add(e)},flushDebouncers=function(){const e=Boolean(debouncerQueue.size);return debouncerQueue.forEach((e=>{try{e.flush()}catch(e){setTimeout((()=>{throw e}))}})),e}; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ let HAS_NATIVE_TA="string"==typeof document.head.style.touchAction,GESTURE_KEY="__polymerGestures",HANDLED_OBJ="__polymerGesturesHandled",TOUCH_ACTION="__polymerGesturesTouchAction",TAP_DISTANCE=25,TRACK_DISTANCE=5,TRACK_LENGTH=2,MOUSE_TIMEOUT=2500,MOUSE_EVENTS=["mousedown","mousemove","mouseup","click"],MOUSE_WHICH_TO_BUTTONS=[0,1,4,2],MOUSE_HAS_BUTTONS=(function(){try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(e){return!1}})();function isMouseEvent(e){return MOUSE_EVENTS.indexOf(e)>-1}let supportsPassive=!1;function PASSIVE_TOUCH(e){if(!isMouseEvent(e)&&"touchend"!==e)return HAS_NATIVE_TA&&supportsPassive&&passiveTouchGestures?{passive:!0}:void 0}!(function(){try{let e=Object.defineProperty({},"passive",{get(){supportsPassive=!0}});window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(e){}})();let IS_TOUCH_ONLY=navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);const clickedLabels=[],labellable={button:!0,input:!0,keygen:!0,meter:!0,output:!0,textarea:!0,progress:!0,select:!0},canBeDisabled={button:!0,command:!0,fieldset:!0,input:!0,keygen:!0,optgroup:!0,option:!0,select:!0,textarea:!0};function canBeLabelled(e){return labellable[e.localName]||!1}function matchingLabels(e){let t=Array.prototype.slice.call(e.labels||[]);if(!t.length){t=[];let n=e.getRootNode();if(e.id){let i=n.querySelectorAll(`label[for = ${e.id}]`);for(let e=0;e<i.length;e++)t.push(i[e])}}return t}let mouseCanceller=function(e){let t=e.sourceCapabilities;if((!t||t.firesTouchEvents)&&(e[HANDLED_OBJ]={skip:!0},"click"===e.type)){let t=!1,n=getComposedPath(e);for(let e=0;e<n.length;e++){if(n[e].nodeType===Node.ELEMENT_NODE)if("label"===n[e].localName)clickedLabels.push(n[e]);else if(canBeLabelled(n[e])){let i=matchingLabels(n[e]);for(let e=0;e<i.length;e++)t=t||clickedLabels.indexOf(i[e])>-1}if(n[e]===POINTERSTATE.mouse.target)return}if(t)return;e.preventDefault(),e.stopPropagation()}};function setupTeardownMouseCanceller(e){let t=IS_TOUCH_ONLY?["click"]:MOUSE_EVENTS;for(let n,i=0;i<t.length;i++)n=t[i],e?(clickedLabels.length=0,document.addEventListener(n,mouseCanceller,!0)):document.removeEventListener(n,mouseCanceller,!0)}function ignoreMouse(e){POINTERSTATE.mouse.mouseIgnoreJob||setupTeardownMouseCanceller(!0),POINTERSTATE.mouse.target=getComposedPath(e)[0],POINTERSTATE.mouse.mouseIgnoreJob=Debouncer.debounce(POINTERSTATE.mouse.mouseIgnoreJob,timeOut.after(MOUSE_TIMEOUT),(function(){setupTeardownMouseCanceller(),POINTERSTATE.mouse.target=null,POINTERSTATE.mouse.mouseIgnoreJob=null}))}function hasLeftMouseButton(e){let t=e.type;if(!isMouseEvent(t))return!1;if("mousemove"===t){let t=void 0===e.buttons?1:e.buttons;return e instanceof window.MouseEvent&&!MOUSE_HAS_BUTTONS&&(t=MOUSE_WHICH_TO_BUTTONS[e.which]||0),Boolean(1&t)}return 0===(void 0===e.button?0:e.button)}function isSyntheticClick(e){if("click"===e.type){if(0===e.detail)return!0;let t=_findOriginalTarget(e);if(!t.nodeType||t.nodeType!==Node.ELEMENT_NODE)return!0;let n=t.getBoundingClientRect(),i=e.pageX,r=e.pageY;return!(i>=n.left&&i<=n.right&&r>=n.top&&r<=n.bottom)}return!1}let POINTERSTATE={mouse:{target:null,mouseIgnoreJob:null},touch:{x:0,y:0,id:-1,scrollDecided:!1}};function firstTouchAction(e){let t="auto",n=getComposedPath(e);for(let e,i=0;i<n.length;i++)if(e=n[i],e[TOUCH_ACTION]){t=e[TOUCH_ACTION];break}return t}function trackDocument(e,t,n){e.movefn=t,e.upfn=n,document.addEventListener("mousemove",t),document.addEventListener("mouseup",n)}function untrackDocument(e){document.removeEventListener("mousemove",e.movefn),document.removeEventListener("mouseup",e.upfn),e.movefn=null,e.upfn=null}document.addEventListener("touchend",ignoreMouse,!!supportsPassive&&{passive:!0});const getComposedPath=window.ShadyDOM&&window.ShadyDOM.noPatch?window.ShadyDOM.composedPath:e=>e.composedPath&&e.composedPath()||[],gestures={},recognizers=[];function deepTargetFind(e,t){let n=document.elementFromPoint(e,t),i=n;for(;i&&i.shadowRoot&&!window.ShadyDOM;){let r=i;if(i=i.shadowRoot.elementFromPoint(e,t),r===i)break;i&&(n=i)}return n}function _findOriginalTarget(e){const t=getComposedPath(e);return t.length>0?t[0]:e.target}function _handleNative(e){let t,n=e.type,i=e.currentTarget[GESTURE_KEY];if(!i)return;let r=i[n];if(r){if(!e[HANDLED_OBJ]&&(e[HANDLED_OBJ]={},"touch"===n.slice(0,5))){let t=(e=e).changedTouches[0];if("touchstart"===n&&1===e.touches.length&&(POINTERSTATE.touch.id=t.identifier),POINTERSTATE.touch.id!==t.identifier)return;HAS_NATIVE_TA||"touchstart"!==n&&"touchmove"!==n||_handleTouchAction(e)}if(t=e[HANDLED_OBJ],!t.skip){for(let n,i=0;i<recognizers.length;i++)n=recognizers[i],r[n.name]&&!t[n.name]&&n.flow&&n.flow.start.indexOf(e.type)>-1&&n.reset&&n.reset();for(let i,o=0;o<recognizers.length;o++)i=recognizers[o],r[i.name]&&!t[i.name]&&(t[i.name]=!0,i[n](e))}}}function _handleTouchAction(e){let t=e.changedTouches[0],n=e.type;if("touchstart"===n)POINTERSTATE.touch.x=t.clientX,POINTERSTATE.touch.y=t.clientY,POINTERSTATE.touch.scrollDecided=!1;else if("touchmove"===n){if(POINTERSTATE.touch.scrollDecided)return;POINTERSTATE.touch.scrollDecided=!0;let n=firstTouchAction(e),i=!1,r=Math.abs(POINTERSTATE.touch.x-t.clientX),o=Math.abs(POINTERSTATE.touch.y-t.clientY);e.cancelable&&("none"===n?i=!0:"pan-x"===n?i=o>r:"pan-y"===n&&(i=r>o)),i?e.preventDefault():prevent("track")}}function addListener(e,t,n){return!!gestures[t]&&(_add(e,t,n),!0)}function removeListener(e,t,n){return!!gestures[t]&&(_remove(e,t,n),!0)}function _add(e,t,n){let i=gestures[t],r=i.deps,o=i.name,a=e[GESTURE_KEY];a||(e[GESTURE_KEY]=a={});for(let t,n,i=0;i<r.length;i++)t=r[i],IS_TOUCH_ONLY&&isMouseEvent(t)&&"click"!==t||(n=a[t],n||(a[t]=n={_count:0}),0===n._count&&e.addEventListener(t,_handleNative,PASSIVE_TOUCH(t)),n[o]=(n[o]||0)+1,n._count=(n._count||0)+1);e.addEventListener(t,n),i.touchAction&&setTouchAction(e,i.touchAction)}function _remove(e,t,n){let i=gestures[t],r=i.deps,o=i.name,a=e[GESTURE_KEY];if(a)for(let t,n,i=0;i<r.length;i++)t=r[i],n=a[t],n&&n[o]&&(n[o]=(n[o]||1)-1,n._count=(n._count||1)-1,0===n._count&&e.removeEventListener(t,_handleNative,PASSIVE_TOUCH(t)));e.removeEventListener(t,n)}function register(e){recognizers.push(e);for(let t=0;t<e.emits.length;t++)gestures[e.emits[t]]=e}function _findRecognizerByEvent(e){for(let t,n=0;n<recognizers.length;n++){t=recognizers[n];for(let n,i=0;i<t.emits.length;i++)if(n=t.emits[i],n===e)return t}return null}function setTouchAction(e,t){HAS_NATIVE_TA&&e instanceof HTMLElement&µTask.run((()=>{e.style.touchAction=t})),e[TOUCH_ACTION]=t}function _fire(e,t,n){let i=new Event(t,{bubbles:!0,cancelable:!0,composed:!0});if(i.detail=n,wrap(e).dispatchEvent(i),i.defaultPrevented){let e=n.preventer||n.sourceEvent;e&&e.preventDefault&&e.preventDefault()}}function prevent(e){let t=_findRecognizerByEvent(e);t.info&&(t.info.prevent=!0)}function downupFire(e,t,n,i){t&&_fire(t,e,{x:n.clientX,y:n.clientY,sourceEvent:n,preventer:i,prevent:function(e){return prevent(e)}})}function trackHasMovedEnough(e,t,n){if(e.prevent)return!1;if(e.started)return!0;let i=Math.abs(e.x-t),r=Math.abs(e.y-n);return i>=TRACK_DISTANCE||r>=TRACK_DISTANCE}function trackFire(e,t,n){if(!t)return;let i,r=e.moves[e.moves.length-2],o=e.moves[e.moves.length-1],a=0;r&&(i=o.x-r.x,a=o.y-r.y),_fire(t,"track",{state:e.state,x:n.clientX,y:n.clientY,dx:o.x-e.x,dy:o.y-e.y,ddx:i,ddy:a,sourceEvent:n,hover:function(){return deepTargetFind(n.clientX,n.clientY)}})}function trackForward(e,t,n){let i=Math.abs(t.clientX-e.x),r=Math.abs(t.clientY-e.y),o=_findOriginalTarget(n||t);!o||canBeDisabled[o.localName]&&o.hasAttribute("disabled")||(isNaN(i)||isNaN(r)||i<=TAP_DISTANCE&&r<=TAP_DISTANCE||isSyntheticClick(t))&&(e.prevent||_fire(o,"tap",{x:t.clientX,y:t.clientY,sourceEvent:t,preventer:n}))}register({name:"downup",deps:["mousedown","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["down","up"],info:{movefn:null,upfn:null},reset:function(){untrackDocument(this.info)},mousedown:function(e){if(!hasLeftMouseButton(e))return;let t=_findOriginalTarget(e),n=this;trackDocument(this.info,(function e(i){hasLeftMouseButton(i)||(downupFire("up",t,i),untrackDocument(n.info))}),(function e(i){hasLeftMouseButton(i)&&downupFire("up",t,i),untrackDocument(n.info)})),downupFire("down",t,e)},touchstart:function(e){downupFire("down",_findOriginalTarget(e),e.changedTouches[0],e)},touchend:function(e){downupFire("up",_findOriginalTarget(e),e.changedTouches[0],e)}}),register({name:"track",touchAction:"none",deps:["mousedown","touchstart","touchmove","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["track"],info:{x:0,y:0,state:"start",started:!1,moves:[],addMove:function(e){this.moves.length>TRACK_LENGTH&&this.moves.shift(),this.moves.push(e)},movefn:null,upfn:null,prevent:!1},reset:function(){this.info.state="start",this.info.started=!1,this.info.moves=[],this.info.x=0,this.info.y=0,this.info.prevent=!1,untrackDocument(this.info)},mousedown:function(e){if(!hasLeftMouseButton(e))return;let t=_findOriginalTarget(e),n=this,i=function e(i){let r=i.clientX,o=i.clientY;trackHasMovedEnough(n.info,r,o)&&(n.info.state=n.info.started?"mouseup"===i.type?"end":"track":"start","start"===n.info.state&&prevent("tap"),n.info.addMove({x:r,y:o}),hasLeftMouseButton(i)||(n.info.state="end",untrackDocument(n.info)),t&&trackFire(n.info,t,i),n.info.started=!0)};trackDocument(this.info,i,(function e(t){n.info.started&&i(t),untrackDocument(n.info)})),this.info.x=e.clientX,this.info.y=e.clientY},touchstart:function(e){let t=e.changedTouches[0];this.info.x=t.clientX,this.info.y=t.clientY},touchmove:function(e){let t=_findOriginalTarget(e),n=e.changedTouches[0],i=n.clientX,r=n.clientY;trackHasMovedEnough(this.info,i,r)&&("start"===this.info.state&&prevent("tap"),this.info.addMove({x:i,y:r}),trackFire(this.info,t,n),this.info.state="track",this.info.started=!0)},touchend:function(e){let t=_findOriginalTarget(e),n=e.changedTouches[0];this.info.started&&(this.info.state="end",this.info.addMove({x:n.clientX,y:n.clientY}),trackFire(this.info,t,n))}}),register({name:"tap",deps:["mousedown","click","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["click","touchend"]},emits:["tap"],info:{x:NaN,y:NaN,prevent:!1},reset:function(){this.info.x=NaN,this.info.y=NaN,this.info.prevent=!1},mousedown:function(e){hasLeftMouseButton(e)&&(this.info.x=e.clientX,this.info.y=e.clientY)},click:function(e){hasLeftMouseButton(e)&&trackForward(this.info,e)},touchstart:function(e){const t=e.changedTouches[0];this.info.x=t.clientX,this.info.y=t.clientY},touchend:function(e){trackForward(this.info,e.changedTouches[0],e)}});const findOriginalTarget=_findOriginalTarget,GestureEventListeners=dedupingMixin((e=>class extends e{_addEventListenerToNode(e,t,n){addListener(e,t,n)||super._addEventListenerToNode(e,t,n)}_removeEventListenerFromNode(e,t,n){removeListener(e,t,n)||super._removeEventListenerFromNode(e,t,n)}})),HOST_DIR=/:host\(:dir\((ltr|rtl)\)\)/g,HOST_DIR_REPLACMENT=':host([dir="$1"])',EL_DIR=/([\s\w-#\.\[\]\*]*):dir\((ltr|rtl)\)/g,EL_DIR_REPLACMENT=':host([dir="$2"]) $1',DIR_CHECK=/:dir\((?:ltr|rtl)\)/,SHIM_SHADOW=Boolean(window.ShadyDOM&&window.ShadyDOM.inUse),DIR_INSTANCES=[]; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */let observer=null,documentDir="";function getRTL(){documentDir=document.documentElement.getAttribute("dir")}function setRTL(e){e.__autoDirOptOut||e.setAttribute("dir",documentDir)}function updateDirection(){getRTL(),documentDir=document.documentElement.getAttribute("dir");for(let e=0;e<DIR_INSTANCES.length;e++)setRTL(DIR_INSTANCES[e])}function takeRecords(){observer&&observer.takeRecords().length&&updateDirection()}const DirMixin=dedupingMixin((e=>{SHIM_SHADOW||observer||(getRTL(),observer=new MutationObserver(updateDirection),observer.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}));const t=PropertyAccessors(e);class n extends t{static _processStyleText(e,n){return e=t._processStyleText.call(this,e,n),!SHIM_SHADOW&&DIR_CHECK.test(e)&&(e=this._replaceDirInCssText(e),this.__activateDir=!0),e}static _replaceDirInCssText(e){let t=e;return t=t.replace(HOST_DIR,HOST_DIR_REPLACMENT),t=t.replace(EL_DIR,EL_DIR_REPLACMENT),t}constructor(){super(),this.__autoDirOptOut=!1}ready(){super.ready(),this.__autoDirOptOut=this.hasAttribute("dir")}connectedCallback(){t.prototype.connectedCallback&&super.connectedCallback(),this.constructor.__activateDir&&(takeRecords(),DIR_INSTANCES.push(this),setRTL(this))}disconnectedCallback(){if(t.prototype.disconnectedCallback&&super.disconnectedCallback(),this.constructor.__activateDir){const e=DIR_INSTANCES.indexOf(this);e>-1&&DIR_INSTANCES.splice(e,1)}}}return n.__activateDir=!1,n})); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */let scheduled=!1,beforeRenderQueue=[],afterRenderQueue=[];function schedule(){scheduled=!0,requestAnimationFrame((function(){scheduled=!1,flushQueue(beforeRenderQueue),setTimeout((function(){runQueue(afterRenderQueue)}))}))}function flushQueue(e){for(;e.length;)callMethod(e.shift())}function runQueue(e){for(let t=0,n=e.length;t<n;t++)callMethod(e.shift())}function callMethod(e){const t=e[0],n=e[1],i=e[2];try{n.apply(t,i)}catch(e){setTimeout((()=>{throw e}))}}function afterNextRender(e,t,n){scheduled||schedule(),afterRenderQueue.push([e,t,n])} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function resolve(){document.body.removeAttribute("unresolved")} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ function newSplice(e,t,n){return{index:e,removed:t,addedCount:n}}"interactive"===document.readyState||"complete"===document.readyState?resolve():window.addEventListener("DOMContentLoaded",resolve);const EDIT_LEAVE=0,EDIT_UPDATE=1,EDIT_ADD=2,EDIT_DELETE=3;function calcEditDistances(e,t,n,i,r,o){let a=o-r+1,s=n-t+1,l=new Array(a);for(let e=0;e<a;e++)l[e]=new Array(s),l[e][0]=e;for(let e=0;e<s;e++)l[0][e]=e;for(let n=1;n<a;n++)for(let o=1;o<s;o++)if(equals$1(e[t+o-1],i[r+n-1]))l[n][o]=l[n-1][o-1];else{let e=l[n-1][o]+1,t=l[n][o-1]+1;l[n][o]=e<t?e:t}return l}function spliceOperationsFromEditDistances(e){let t=e.length-1,n=e[0].length-1,i=e[t][n],r=[];for(;t>0||n>0;){if(0==t){r.push(EDIT_ADD),n--;continue}if(0==n){r.push(EDIT_DELETE),t--;continue}let o,a=e[t-1][n-1],s=e[t-1][n],l=e[t][n-1];o=s<l?s<a?s:a:l<a?l:a,o==a?(a==i?r.push(EDIT_LEAVE):(r.push(EDIT_UPDATE),i=a),t--,n--):o==s?(r.push(EDIT_DELETE),t--,i=s):(r.push(EDIT_ADD),n--,i=l)}return r.reverse(),r}function calcSplices(e,t,n,i,r,o){let a,s=0,l=0,c=Math.min(n-t,o-r);if(0==t&&0==r&&(s=sharedPrefix(e,i,c)),n==e.length&&o==i.length&&(l=sharedSuffix(e,i,c-s)),r+=s,o-=l,(n-=l)-(t+=s)==0&&o-r==0)return[];if(t==n){for(a=newSplice(t,[],0);r<o;)a.removed.push(i[r++]);return[a]}if(r==o)return[newSplice(t,[],n-t)];let h=spliceOperationsFromEditDistances(calcEditDistances(e,t,n,i,r,o));a=void 0;let u=[],d=t,p=r;for(let e=0;e<h.length;e++)switch(h[e]){case EDIT_LEAVE:a&&(u.push(a),a=void 0),d++,p++;break;case EDIT_UPDATE:a||(a=newSplice(d,[],0)),a.addedCount++,d++,a.removed.push(i[p]),p++;break;case EDIT_ADD:a||(a=newSplice(d,[],0)),a.addedCount++,d++;break;case EDIT_DELETE:a||(a=newSplice(d,[],0)),a.removed.push(i[p]),p++}return a&&u.push(a),u}function sharedPrefix(e,t,n){for(let i=0;i<n;i++)if(!equals$1(e[i],t[i]))return i;return n}function sharedSuffix(e,t,n){let i=e.length,r=t.length,o=0;for(;o<n&&equals$1(e[--i],t[--r]);)o++;return o}function calculateSplices(e,t){return calcSplices(e,0,e.length,t,0,t.length)}function equals$1(e,t){return e===t} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function isSlot(e){return"slot"===e.localName}let FlattenedNodesObserver=class{static getFlattenedNodes(e){const t=wrap(e);return isSlot(e)?(e=e,t.assignedNodes({flatten:!0})):Array.from(t.childNodes).map((e=>isSlot(e)?wrap(e=e).assignedNodes({flatten:!0}):[e])).reduce(((e,t)=>e.concat(t)),[])}constructor(e,t){this._shadyChildrenObserver=null,this._nativeChildrenObserver=null,this._connected=!1,this._target=e,this.callback=t,this._effectiveNodes=[],this._observer=null,this._scheduled=!1,this._boundSchedule=()=>{this._schedule()},this.connect(),this._schedule()}connect(){isSlot(this._target)?this._listenSlots([this._target]):wrap(this._target).children&&(this._listenSlots(wrap(this._target).children),window.ShadyDOM?this._shadyChildrenObserver=window.ShadyDOM.observeChildren(this._target,(e=>{this._processMutations(e)})):(this._nativeChildrenObserver=new MutationObserver((e=>{this._processMutations(e)})),this._nativeChildrenObserver.observe(this._target,{childList:!0}))),this._connected=!0}disconnect(){isSlot(this._target)?this._unlistenSlots([this._target]):wrap(this._target).children&&(this._unlistenSlots(wrap(this._target).children),window.ShadyDOM&&this._shadyChildrenObserver?(window.ShadyDOM.unobserveChildren(this._shadyChildrenObserver),this._shadyChildrenObserver=null):this._nativeChildrenObserver&&(this._nativeChildrenObserver.disconnect(),this._nativeChildrenObserver=null)),this._connected=!1}_schedule(){this._scheduled||(this._scheduled=!0,microTask.run((()=>this.flush())))}_processMutations(e){this._processSlotMutations(e),this.flush()}_processSlotMutations(e){if(e)for(let t=0;t<e.length;t++){let n=e[t];n.addedNodes&&this._listenSlots(n.addedNodes),n.removedNodes&&this._unlistenSlots(n.removedNodes)}}flush(){if(!this._connected)return!1;window.ShadyDOM&&ShadyDOM.flush(),this._nativeChildrenObserver?this._processSlotMutations(this._nativeChildrenObserver.takeRecords()):this._shadyChildrenObserver&&this._processSlotMutations(this._shadyChildrenObserver.takeRecords()),this._scheduled=!1;let e={target:this._target,addedNodes:[],removedNodes:[]},t=this.constructor.getFlattenedNodes(this._target),n=calculateSplices(t,this._effectiveNodes);for(let t,i=0;i<n.length&&(t=n[i]);i++)for(let n,i=0;i<t.removed.length&&(n=t.removed[i]);i++)e.removedNodes.push(n);for(let i,r=0;r<n.length&&(i=n[r]);r++)for(let n=i.index;n<i.index+i.addedCount;n++)e.addedNodes.push(t[n]);this._effectiveNodes=t;let i=!1;return(e.addedNodes.length||e.removedNodes.length)&&(i=!0,this.callback.call(this._target,e)),i}_listenSlots(e){for(let t=0;t<e.length;t++){let n=e[t];isSlot(n)&&n.addEventListener("slotchange",this._boundSchedule)}}_unlistenSlots(e){for(let t=0;t<e.length;t++){let n=e[t];isSlot(n)&&n.removeEventListener("slotchange",this._boundSchedule)}}}; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const flush=function(){let e,t;do{e=window.ShadyDOM&&ShadyDOM.flush(),window.ShadyCSS&&window.ShadyCSS.ScopingShim&&window.ShadyCSS.ScopingShim.flush(),t=flushDebouncers()}while(e||t)},p$2=Element.prototype,normalizedMatchesSelector=p$2.matches||p$2.matchesSelector||p$2.mozMatchesSelector||p$2.msMatchesSelector||p$2.oMatchesSelector||p$2.webkitMatchesSelector,matchesSelector=function(e,t){return normalizedMatchesSelector.call(e,t)}; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */class DomApiNative{constructor(e){window.ShadyDOM&&window.ShadyDOM.inUse&&window.ShadyDOM.patch(e),this.node=e}observeNodes(e){return new FlattenedNodesObserver(this.node,e)}unobserveNodes(e){e.disconnect()}notifyObserver(){}deepContains(e){if(wrap(this.node).contains(e))return!0;let t=e,n=e.ownerDocument;for(;t&&t!==n&&t!==this.node;)t=wrap(t).parentNode||wrap(t).host;return t===this.node}getOwnerRoot(){return wrap(this.node).getRootNode()}getDistributedNodes(){return"slot"===this.node.localName?wrap(this.node).assignedNodes({flatten:!0}):[]}getDestinationInsertionPoints(){let e=[],t=wrap(this.node).assignedSlot;for(;t;)e.push(t),t=wrap(t).assignedSlot;return e}importNode(e,t){let n=this.node instanceof Document?this.node:this.node.ownerDocument;return wrap(n).importNode(e,t)}getEffectiveChildNodes(){return FlattenedNodesObserver.getFlattenedNodes(this.node)}queryDistributedElements(e){let t=this.getEffectiveChildNodes(),n=[];for(let i,r=0,o=t.length;r<o&&(i=t[r]);r++)i.nodeType===Node.ELEMENT_NODE&&matchesSelector(i,e)&&n.push(i);return n}get activeElement(){let e=this.node;return void 0!==e._activeElement?e._activeElement:e.activeElement}}function forwardMethods(e,t){for(let n=0;n<t.length;n++){let i=t[n];e[i]=function(){return this.node[i].apply(this.node,arguments)}}}function forwardReadOnlyProperties(e,t){for(let n=0;n<t.length;n++){let i=t[n];Object.defineProperty(e,i,{get:function(){return this.node[i]},configurable:!0})}}function forwardProperties(e,t){for(let n=0;n<t.length;n++){let i=t[n];Object.defineProperty(e,i,{get:function(){return this.node[i]},set:function(e){this.node[i]=e},configurable:!0})}}class EventApi{constructor(e){this.event=e}get rootTarget(){return this.path[0]}get localTarget(){return this.event.target}get path(){return this.event.composedPath()}}let DomApiImpl=DomApiNative;if(window.ShadyDOM&&window.ShadyDOM.inUse&&window.ShadyDOM.noPatch&&window.ShadyDOM.Wrapper){class e extends window.ShadyDOM.Wrapper{}Object.getOwnPropertyNames(DomApiNative.prototype).forEach((t=>{"activeElement"!=t&&(e.prototype[t]=DomApiNative.prototype[t])})),forwardReadOnlyProperties(e.prototype,["classList"]),DomApiImpl=e,Object.defineProperties(EventApi.prototype,{localTarget:{get(){const e=this.event.currentTarget,t=e&&dom$1(e).getOwnerRoot(),n=this.path;for(let e=0;e<n.length;e++){const i=n[e];if(dom$1(i).getOwnerRoot()===t)return i}},configurable:!0},path:{get(){return window.ShadyDOM.composedPath(this.event)},configurable:!0}})}else forwardMethods(DomApiNative.prototype,["cloneNode","appendChild","insertBefore","removeChild","replaceChild","setAttribute","removeAttribute","querySelector","querySelectorAll"]),forwardReadOnlyProperties(DomApiNative.prototype,["parentNode","firstChild","lastChild","nextSibling","previousSibling","firstElementChild","lastElementChild","nextElementSibling","previousElementSibling","childNodes","children","classList"]),forwardProperties(DomApiNative.prototype,["textContent","innerHTML","className"]);const dom$1=function(e){if((e=e||document)instanceof DomApiImpl)return e;if(e instanceof EventApi)return e;let t=e.__domApi;return t||(t=e instanceof Event?new EventApi(e):new DomApiImpl(e),e.__domApi=t),t},ShadyDOM$1=window.ShadyDOM,ShadyCSS=window.ShadyCSS; /** @license Copyright (c) 2019 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function sameScope(e,t){return wrap(e).getRootNode()===t}function scopeSubtree(e,t=!1){if(!ShadyDOM$1||!ShadyCSS)return null;if(!ShadyDOM$1.handlesDynamicScoping)return null;const n=ShadyCSS.ScopingShim;if(!n)return null;const i=n.scopeForNode(e),r=wrap(e).getRootNode(),o=e=>{if(!sameScope(e,r))return;const t=Array.from(ShadyDOM$1.nativeMethods.querySelectorAll.call(e,"*"));t.push(e);for(let e=0;e<t.length;e++){const o=t[e];if(!sameScope(o,r))continue;const a=n.currentScopeForNode(o);a!==i&&(""!==a&&n.unscopeNode(o,a),n.scopeNode(o,i))}};if(o(e),t){const t=new MutationObserver((e=>{for(let t=0;t<e.length;t++){const n=e[t];for(let e=0;e<n.addedNodes.length;e++){const t=n.addedNodes[e];t.nodeType===Node.ELEMENT_NODE&&o(t)}}}));return t.observe(e,{childList:!0,subtree:!0}),t}return null} /** * @fileoverview * @suppress {checkPrototypalTypes} * @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt The complete set of authors may be found * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by * Google as part of the polymer project is also subject to an additional IP * rights grant found at http://polymer.github.io/PATENTS.txt */const DISABLED_ATTR$1="disable-upgrade",findObservedAttributesGetter=e=>{for(;e;){const t=Object.getOwnPropertyDescriptor(e,"observedAttributes");if(t)return t.get;e=Object.getPrototypeOf(e.prototype).constructor}return()=>[]};dedupingMixin((e=>{const t=ElementMixin(e);let n=findObservedAttributesGetter(t);return class extends t{constructor(){super()}static get observedAttributes(){return n.call(this).concat(DISABLED_ATTR$1)}_initializeProperties(){this.hasAttribute(DISABLED_ATTR$1)?this.__isUpgradeDisabled=!0:super._initializeProperties()}_enableProperties(){this.__isUpgradeDisabled||super._enableProperties()}_canApplyPropertyDefault(e){return super._canApplyPropertyDefault(e)&&!(this.__isUpgradeDisabled&&this._isPropertyPending(e))}attributeChangedCallback(e,t,n,i){e==DISABLED_ATTR$1?this.__isUpgradeDisabled&&null==n&&(super._initializeProperties(),this.__isUpgradeDisabled=!1,wrap(this).isConnected&&super.connectedCallback()):super.attributeChangedCallback(e,t,n,i)}connectedCallback(){this.__isUpgradeDisabled||super.connectedCallback()}disconnectedCallback(){this.__isUpgradeDisabled||super.disconnectedCallback()}}})); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const DISABLED_ATTR="disable-upgrade";let styleInterface=window.ShadyCSS;const LegacyElementMixin=dedupingMixin((e=>{const t=GestureEventListeners(ElementMixin(e)),n=builtCSS?t:DirMixin(t),i=findObservedAttributesGetter(n),r={x:"pan-x",y:"pan-y",none:"none",all:"auto"};class o extends n{constructor(){super()}static get importMeta(){return this.prototype.importMeta}created(){}__attributeReaction(e,t,n){(this.__dataAttributes&&this.__dataAttributes[e]||e===DISABLED_ATTR)&&this.attributeChangedCallback(e,t,n,null)}setAttribute(e,t){if(legacyNoObservedAttributes&&!this._legacyForceObservedAttributes){const n=this.getAttribute(e);super.setAttribute(e,t),this.__attributeReaction(e,n,String(t))}else super.setAttribute(e,t)}removeAttribute(e){if(legacyNoObservedAttributes&&!this._legacyForceObservedAttributes){const t=this.getAttribute(e);super.removeAttribute(e),this.__attributeReaction(e,t,null)}else super.removeAttribute(e)}static get observedAttributes(){return legacyNoObservedAttributes&&!this.prototype._legacyForceObservedAttributes?(this.hasOwnProperty(JSCompiler_renameProperty("__observedAttributes",this))||(this.__observedAttributes=[],register$1(this.prototype)),this.__observedAttributes):i.call(this).concat(DISABLED_ATTR)}_enableProperties(){this.__isUpgradeDisabled||super._enableProperties()}_canApplyPropertyDefault(e){return super._canApplyPropertyDefault(e)&&!(this.__isUpgradeDisabled&&this._isPropertyPending(e))}connectedCallback(){this.__needsAttributesAtConnected&&this._takeAttributes(),this.__isUpgradeDisabled||(super.connectedCallback(),this.isAttached=!0,this.attached())}attached(){}disconnectedCallback(){this.__isUpgradeDisabled||(super.disconnectedCallback(),this.isAttached=!1,this.detached())}detached(){}attributeChangedCallback(e,t,n,i){t!==n&&(e==DISABLED_ATTR?this.__isUpgradeDisabled&&null==n&&(this._initializeProperties(),this.__isUpgradeDisabled=!1,wrap(this).isConnected&&this.connectedCallback()):(super.attributeChangedCallback(e,t,n,i),this.attributeChanged(e,t,n)))}attributeChanged(e,t,n){}_initializeProperties(){if(legacyOptimizations&&this.hasAttribute(DISABLED_ATTR))this.__isUpgradeDisabled=!0;else{let e=Object.getPrototypeOf(this);e.hasOwnProperty(JSCompiler_renameProperty("__hasRegisterFinished",e))||(this._registered(),e.__hasRegisterFinished=!0),super._initializeProperties(),this.root=this,this.created(),legacyNoObservedAttributes&&!this._legacyForceObservedAttributes&&(this.hasAttributes()?this._takeAttributes():this.parentNode||(this.__needsAttributesAtConnected=!0)),this._applyListeners()}}_takeAttributes(){const e=this.attributes;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.__attributeReaction(n.name,null,n.value)}}_registered(){}ready(){this._ensureAttributes(),super.ready()}_ensureAttributes(){}_applyListeners(){}serialize(e){return this._serializeValue(e)}deserialize(e,t){return this._deserializeValue(e,t)}reflectPropertyToAttribute(e,t,n){this._propertyToAttribute(e,t,n)}serializeValueToAttribute(e,t,n){this._valueToNodeAttribute(n||this,e,t)}extend(e,t){if(!e||!t)return e||t;let n=Object.getOwnPropertyNames(t);for(let i,r=0;r<n.length&&(i=n[r]);r++){let n=Object.getOwnPropertyDescriptor(t,i);n&&Object.defineProperty(e,i,n)}return e}mixin(e,t){for(let n in t)e[n]=t[n];return e}chainObject(e,t){return e&&t&&e!==t&&(e.__proto__=t),e}instanceTemplate(e){let t=this.constructor._contentForTemplate(e);return document.importNode(t,!0)}fire(e,t,n){n=n||{},t=null==t?{}:t;let i=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return i.detail=t,wrap(n.node||this).dispatchEvent(i),i}listen(e,t,n){e=e||this;let i=this.__boundListeners||(this.__boundListeners=new WeakMap),r=i.get(e);r||(r={},i.set(e,r));let o=t+n;r[o]||(r[o]=this._addMethodEventListenerToNode(e,t,n,this))}unlisten(e,t,n){e=e||this;let i=this.__boundListeners&&this.__boundListeners.get(e),r=t+n,o=i&&i[r];o&&(this._removeEventListenerFromNode(e,t,o),i[r]=null)}setScrollDirection(e,t){setTouchAction(t||this,r[e]||"auto")}$$(e){return this.root.querySelector(e)}get domHost(){let e=wrap(this).getRootNode();return e instanceof DocumentFragment?e.host:e}distributeContent(){const e=dom$1(this);window.ShadyDOM&&e.shadowRoot&&ShadyDOM.flush()}getEffectiveChildNodes(){return dom$1(this).getEffectiveChildNodes()}queryDistributedElements(e){return dom$1(this).queryDistributedElements(e)}getEffectiveChildren(){return this.getEffectiveChildNodes().filter((function(e){return e.nodeType===Node.ELEMENT_NODE}))}getEffectiveTextContent(){let e=this.getEffectiveChildNodes(),t=[];for(let n,i=0;n=e[i];i++)n.nodeType!==Node.COMMENT_NODE&&t.push(n.textContent);return t.join("")}queryEffectiveChildren(e){let t=this.queryDistributedElements(e);return t&&t[0]}queryAllEffectiveChildren(e){return this.queryDistributedElements(e)}getContentChildNodes(e){let t=this.root.querySelector(e||"slot");return t?dom$1(t).getDistributedNodes():[]}getContentChildren(e){return this.getContentChildNodes(e).filter((function(e){return e.nodeType===Node.ELEMENT_NODE}))}isLightDescendant(e){const t=this;return t!==e&&wrap(t).contains(e)&&wrap(t).getRootNode()===wrap(e).getRootNode()}isLocalDescendant(e){return this.root===wrap(e).getRootNode()}scopeSubtree(e,t=!1){return scopeSubtree(e,t)}getComputedStyleValue(e){return styleInterface.getComputedStyleValue(this,e)}debounce(e,t,n){return this._debouncers=this._debouncers||{},this._debouncers[e]=Debouncer.debounce(this._debouncers[e],n>0?timeOut.after(n):microTask,t.bind(this))}isDebouncerActive(e){this._debouncers=this._debouncers||{};let t=this._debouncers[e];return!(!t||!t.isActive())}flushDebouncer(e){this._debouncers=this._debouncers||{};let t=this._debouncers[e];t&&t.flush()}cancelDebouncer(e){this._debouncers=this._debouncers||{};let t=this._debouncers[e];t&&t.cancel()}async(e,t){return t>0?timeOut.run(e.bind(this),t):~microTask.run(e.bind(this))}cancelAsync(e){e<0?microTask.cancel(~e):timeOut.cancel(e)}create(e,t){let n=document.createElement(e);if(t)if(n.setProperties)n.setProperties(t);else for(let e in t)n[e]=t[e];return n}elementMatches(e,t){return matchesSelector(t||this,e)}toggleAttribute(e,t){let n=this;return 3===arguments.length&&(n=arguments[2]),1==arguments.length&&(t=!n.hasAttribute(e)),t?(wrap(n).setAttribute(e,""),!0):(wrap(n).removeAttribute(e),!1)}toggleClass(e,t,n){n=n||this,1==arguments.length&&(t=!n.classList.contains(e)),t?n.classList.add(e):n.classList.remove(e)}transform(e,t){(t=t||this).style.webkitTransform=e,t.style.transform=e}translate3d(e,t,n,i){this.transform("translate3d("+e+","+t+","+n+")",i=i||this)}arrayDelete(e,t){let n;if(Array.isArray(e)){if(n=e.indexOf(t),n>=0)return e.splice(n,1)}else if(n=get$1(this,e).indexOf(t),n>=0)return this.splice(e,n,1);return null}_logger(e,t){switch(Array.isArray(t)&&1===t.length&&Array.isArray(t[0])&&(t=t[0]),e){case"log":case"warn":case"error":console[e](...t)}}_log(...e){this._logger("log",e)}_warn(...e){this._logger("warn",e)}_error(...e){this._logger("error",e)}_logf(e,...t){return["[%s::%s]",this.is,e,...t]}}return o.prototype.is="",o})),lifecycleProps={attached:!0,detached:!0,ready:!0,created:!0,beforeRegister:!0,registered:!0,attributeChanged:!0,listeners:!0,hostAttributes:!0},excludeOnInfo={attached:!0,detached:!0,ready:!0,created:!0,beforeRegister:!0,registered:!0,attributeChanged:!0,behaviors:!0,_noAccessors:!0},excludeOnBehaviors=Object.assign({listeners:!0,hostAttributes:!0,properties:!0,observers:!0},excludeOnInfo); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */function copyProperties(e,t,n){const i=e._noAccessors,r=Object.getOwnPropertyNames(e);for(let o=0;o<r.length;o++){let a=r[o];if(!(a in n))if(i)t[a]=e[a];else{let n=Object.getOwnPropertyDescriptor(e,a);n&&(n.configurable=!0,Object.defineProperty(t,a,n))}}}function applyBehaviors(e,t,n){for(let i=0;i<t.length;i++)applyInfo(e,t[i],n,excludeOnBehaviors)}function applyInfo(e,t,n,i){copyProperties(t,e,i);for(let e in lifecycleProps)t[e]&&(n[e]=n[e]||[],n[e].push(t[e]))}function flattenBehaviors(e,t,n){t=t||[];for(let i=e.length-1;i>=0;i--){let r=e[i];r?Array.isArray(r)?flattenBehaviors(r,t):t.indexOf(r)<0&&(!n||n.indexOf(r)<0)&&t.unshift(r):console.warn("behavior is null, check for missing or 404 import")}return t}function mergeProperties(e,t){for(const n in t){const i=e[n],r=t[n];e[n]=!("value"in r)&&i&&"value"in i?Object.assign({value:i.value},r):r}}const LegacyElement=LegacyElementMixin(HTMLElement);function GenerateClassFromInfo(e,t,n){let i;const r={};class o extends t{static _finalizeClass(){if(this.hasOwnProperty(JSCompiler_renameProperty("generatedFrom",this))){if(i)for(let e,t=0;t<i.length;t++)e=i[t],e.properties&&this.createProperties(e.properties),e.observers&&this.createObservers(e.observers,e.properties);e.properties&&this.createProperties(e.properties),e.observers&&this.createObservers(e.observers,e.properties),this._prepareTemplate()}else t._finalizeClass.call(this)}static get properties(){const t={};if(i)for(let e=0;e<i.length;e++)mergeProperties(t,i[e].properties);return mergeProperties(t,e.properties),t}static get observers(){let t=[];if(i)for(let e,n=0;n<i.length;n++)e=i[n],e.observers&&(t=t.concat(e.observers));return e.observers&&(t=t.concat(e.observers)),t}created(){super.created();const e=r.created;if(e)for(let t=0;t<e.length;t++)e[t].call(this)}_registered(){const e=o.prototype;if(!e.hasOwnProperty(JSCompiler_renameProperty("__hasRegisterFinished",e))){e.__hasRegisterFinished=!0,super._registered(),legacyOptimizations&&a(e);const t=Object.getPrototypeOf(this);let n=r.beforeRegister;if(n)for(let e=0;e<n.length;e++)n[e].call(t);if(n=r.registered,n)for(let e=0;e<n.length;e++)n[e].call(t)}}_applyListeners(){super._applyListeners();const e=r.listeners;if(e)for(let t=0;t<e.length;t++){const n=e[t];if(n)for(let e in n)this._addMethodEventListenerToNode(this,e,n[e])}}_ensureAttributes(){const e=r.hostAttributes;if(e)for(let t=e.length-1;t>=0;t--){const n=e[t];for(let e in n)this._ensureAttribute(e,n[e])}super._ensureAttributes()}ready(){super.ready();let e=r.ready;if(e)for(let t=0;t<e.length;t++)e[t].call(this)}attached(){super.attached();let e=r.attached;if(e)for(let t=0;t<e.length;t++)e[t].call(this)}detached(){super.detached();let e=r.detached;if(e)for(let t=0;t<e.length;t++)e[t].call(this)}attributeChanged(e,t,n){super.attributeChanged();let i=r.attributeChanged;if(i)for(let r=0;r<i.length;r++)i[r].call(this,e,t,n)}}if(n){Array.isArray(n)||(n=[n]);let e=t.prototype.behaviors;i=flattenBehaviors(n,null,e),o.prototype.behaviors=e?e.concat(n):i}const a=t=>{i&&applyBehaviors(t,i,r),applyInfo(t,e,r,excludeOnInfo)};return legacyOptimizations||a(o.prototype),o.generatedFrom=e,o}const Class=function(e,t){e||console.warn("Polymer.Class requires `info` argument");let n=t?t(LegacyElement):LegacyElement;return n=GenerateClassFromInfo(e,n,e.behaviors),n.is=n.prototype.is=e.is,n},Polymer=function(e){let t;return t="function"==typeof e?e:Polymer.Class(e),e._legacyForceObservedAttributes&&(t.prototype._legacyForceObservedAttributes=e._legacyForceObservedAttributes),customElements.define(t.is,t),t}; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ function mutablePropertyChange$1(e,t,n,i,r){let o;r&&(o="object"==typeof n&&null!==n,o&&(i=e.__dataTemp[t]));let a=i!==n&&(i==i||n==n);return o&&a&&(e.__dataTemp[t]=n),a}Polymer.Class=Class;const MutableData=dedupingMixin((e=>class extends e{_shouldPropertyChange(e,t,n){return mutablePropertyChange$1(this,e,t,n,!0)}})),OptionalMutableData=dedupingMixin((e=>class extends e{static get properties(){return{mutableData:Boolean}}_shouldPropertyChange(e,t,n){return mutablePropertyChange$1(this,e,t,n,this.mutableData)}}));MutableData._mutablePropertyChange=mutablePropertyChange$1; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ let newInstance=null;function HTMLTemplateElementExtension(){return newInstance}HTMLTemplateElementExtension.prototype=Object.create(HTMLTemplateElement.prototype,{constructor:{value:HTMLTemplateElementExtension,writable:!0}});const DataTemplate=PropertyEffects(HTMLTemplateElementExtension),MutableDataTemplate=MutableData(DataTemplate);function upgradeTemplate(e,t){newInstance=e,Object.setPrototypeOf(e,t.prototype),new t,newInstance=null}const templateInstanceBase=PropertyEffects(class{});function showHideChildren(e,t){for(let n=0;n<t.length;n++){let i=t[n];if(Boolean(e)!=Boolean(i.__hideTemplateChildren__))if(i.nodeType===Node.TEXT_NODE)e?(i.__polymerTextContent__=i.textContent,i.textContent=""):i.textContent=i.__polymerTextContent__;else if("slot"===i.localName)if(e)i.__polymerReplaced__=document.createComment("hidden-slot"),wrap(wrap(i).parentNode).replaceChild(i.__polymerReplaced__,i);else{const e=i.__polymerReplaced__;e&&wrap(wrap(e).parentNode).replaceChild(i,e)}else i.style&&(e?(i.__polymerDisplay__=i.style.display,i.style.display="none"):i.style.display=i.__polymerDisplay__);i.__hideTemplateChildren__=e,i._showHideChildren&&i._showHideChildren(e)}}class TemplateInstanceBase extends templateInstanceBase{constructor(e){super(),this._configureProperties(e),this.root=this._stampTemplate(this.__dataHost);let t=[];this.children=t;for(let e=this.root.firstChild;e;e=e.nextSibling)t.push(e),e.__templatizeInstance=this;this.__templatizeOwner&&this.__templatizeOwner.__hideTemplateChildren__&&this._showHideChildren(!0);let n=this.__templatizeOptions;(e&&n.instanceProps||!n.instanceProps)&&this._enableProperties()}_configureProperties(e){if(this.__templatizeOptions.forwardHostProp)for(let e in this.__hostProps)this._setPendingProperty(e,this.__dataHost["_host_"+e]);for(let t in e)this._setPendingProperty(t,e[t])}forwardHostProp(e,t){this._setPendingPropertyOrPath(e,t,!1,!0)&&this.__dataHost._enqueueClient(this)}_addEventListenerToNode(e,t,n){if(this._methodHost&&this.__templatizeOptions.parentModel)this._methodHost._addEventListenerToNode(e,t,(e=>{e.model=this,n(e)}));else{let i=this.__dataHost.__dataHost;i&&i._addEventListenerToNode(e,t,n)}}_showHideChildren(e){showHideChildren(e,this.children)}_setUnmanagedPropertyToNode(e,t,n){e.__hideTemplateChildren__&&e.nodeType==Node.TEXT_NODE&&"textContent"==t?e.__polymerTextContent__=n:super._setUnmanagedPropertyToNode(e,t,n)}get parentModel(){let e=this.__parentModel;if(!e){let t;e=this;do{e=e.__dataHost.__dataHost}while((t=e.__templatizeOptions)&&!t.parentModel);this.__parentModel=e}return e}dispatchEvent(e){return!0}}const MutableTemplateInstanceBase=MutableData(TemplateInstanceBase);function findMethodHost(e){let t=e.__dataHost;return t&&t._methodHost||t}function createTemplatizerClass(e,t,n){let i=n.mutableData?MutableTemplateInstanceBase:TemplateInstanceBase;templatize.mixin&&(i=templatize.mixin(i));let r=class extends i{};return r.prototype.__templatizeOptions=n,r.prototype._bindTemplate(e),addNotifyEffects(r,e,t,n),r}function addPropagateEffects(e,t,n,i){let r=n.forwardHostProp;if(r&&t.hasHostProps){const o="template"==e.localName;let a=t.templatizeTemplateClass;if(!a){if(o){let e=n.mutableData?MutableDataTemplate:DataTemplate;class i extends e{}a=t.templatizeTemplateClass=i}else{const n=e.constructor;class i extends n{}a=t.templatizeTemplateClass=i}let s=t.hostProps;for(let e in s)a.prototype._addPropertyEffect("_host_"+e,a.prototype.PROPERTY_EFFECT_TYPES.PROPAGATE,{fn:createForwardHostPropEffect(e,r)}),a.prototype._createNotifyingProperty("_host_"+e);legacyWarnings&&i&&warnOnUndeclaredProperties(t,n,i)}if(e.__dataProto&&Object.assign(e.__data,e.__dataProto),o)upgradeTemplate(e,a),e.__dataTemp={},e.__dataPending=null,e.__dataOld=null,e._enableProperties();else{Object.setPrototypeOf(e,a.prototype);const n=t.hostProps;for(let t in n)if(t="_host_"+t,t in e){const n=e[t];delete e[t],e.__data[t]=n}}}}function createForwardHostPropEffect(e,t){return function e(n,i,r){t.call(n.__templatizeOwner,i.substring("_host_".length),r[i])}}function addNotifyEffects(e,t,n,i){let r=n.hostProps||{};for(let t in i.instanceProps){delete r[t];let n=i.notifyInstanceProp;n&&e.prototype._addPropertyEffect(t,e.prototype.PROPERTY_EFFECT_TYPES.NOTIFY,{fn:createNotifyInstancePropEffect(t,n)})}if(i.forwardHostProp&&t.__dataHost)for(let t in r)n.hasHostProps||(n.hasHostProps=!0),e.prototype._addPropertyEffect(t,e.prototype.PROPERTY_EFFECT_TYPES.NOTIFY,{fn:createNotifyHostPropEffect()})}function createNotifyInstancePropEffect(e,t){return function e(n,i,r){t.call(n.__templatizeOwner,n,i,r[i])}}function createNotifyHostPropEffect(){return function e(t,n,i){t.__dataHost._setPendingPropertyOrPath("_host_"+n,i[n],!0,!0)}}function templatize(e,t,n){if(strictTemplatePolicy&&!findMethodHost(e))throw new Error("strictTemplatePolicy: template owner not trusted");if(n=n||{},e.__templatizeOwner)throw new Error("A <template> can only be templatized once");e.__templatizeOwner=t;let i=(t?t.constructor:TemplateInstanceBase)._parseTemplate(e),r=i.templatizeInstanceClass;r||(r=createTemplatizerClass(e,i,n),i.templatizeInstanceClass=r);const o=findMethodHost(e);addPropagateEffects(e,i,n,o);let a=class extends r{};return a.prototype._methodHost=o,a.prototype.__dataHost=e,a.prototype.__templatizeOwner=t,a.prototype.__hostProps=i.hostProps,a=a,a}function warnOnUndeclaredProperties(e,t,n){const i=n.constructor._properties,{propertyEffects:r}=e,{instanceProps:o}=t;for(let e in r)if(!(i[e]||o&&o[e])){const t=r[e];for(let n=0;n<t.length;n++){const{part:i}=t[n].info;if(!i.signature||!i.signature.static){console.warn(`Property '${e}' used in template but not declared in 'properties'; attribute will not be observed.`);break}}}}function modelForElement(e,t){let n;for(;t;)if(n=t.__dataHost?t:t.__templatizeInstance){if(n.__dataHost==e)return n;t=n.__dataHost}else t=wrap(t).parentNode;return null} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const Templatizer={templatize(e,t){this._templatizerTemplate=e,this.ctor=templatize(e,this,{mutableData:Boolean(t),parentModel:this._parentModel,instanceProps:this._instanceProps,forwardHostProp:this._forwardHostPropV2,notifyInstanceProp:this._notifyInstancePropV2})},stamp(e){return new this.ctor(e)},modelForElement(e){return modelForElement(this._templatizerTemplate,e)}}; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */let elementsHidden=!1;function hideElementsGlobally(){if(legacyOptimizations&&!useShadow){if(!elementsHidden){elementsHidden=!0;const e=document.createElement("style");e.textContent="dom-bind,dom-if,dom-repeat{display:none;}",document.head.appendChild(e)}return!0}return!1} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const domBindBase=GestureEventListeners(OptionalMutableData(PropertyEffects(HTMLElement)));class DomBind extends domBindBase{static get observedAttributes(){return["mutable-data"]}constructor(){if(super(),strictTemplatePolicy)throw new Error("strictTemplatePolicy: dom-bind not allowed");this.root=null,this.$=null,this.__children=null}attributeChangedCallback(e,t,n,i){this.mutableData=!0}connectedCallback(){hideElementsGlobally()||(this.style.display="none"),this.render()}disconnectedCallback(){this.__removeChildren()}__insertChildren(){wrap(wrap(this).parentNode).insertBefore(this.root,this)}__removeChildren(){if(this.__children)for(let e=0;e<this.__children.length;e++)this.root.appendChild(this.__children[e])}render(){let e;if(!this.__children){if(e=e||this.querySelector("template"),!e){let t=new MutationObserver((()=>{if(e=this.querySelector("template"),!e)throw new Error("dom-bind requires a <template> child");t.disconnect(),this.render()}));return void t.observe(this,{childList:!0})}this.root=this._stampTemplate(e),this.$=this.root.$,this.__children=[];for(let e=this.root.firstChild;e;e=e.nextSibling)this.__children[this.__children.length]=e;this._enableProperties()}this.__insertChildren(),this.dispatchEvent(new CustomEvent("dom-change",{bubbles:!0,composed:!0}))}}customElements.define("dom-bind",DomBind); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const domRepeatBase=OptionalMutableData(PolymerElement);class DomRepeat extends domRepeatBase{static get is(){return"dom-repeat"}static get template(){return null}static get properties(){return{items:{type:Array},as:{type:String,value:"item"},indexAs:{type:String,value:"index"},itemsIndexAs:{type:String,value:"itemsIndex"},sort:{type:Function,observer:"__sortChanged"},filter:{type:Function,observer:"__filterChanged"},observe:{type:String,observer:"__observeChanged"},delay:Number,renderedItemCount:{type:Number,notify:!suppressTemplateNotifications,readOnly:!0},initialCount:{type:Number},targetFramerate:{type:Number,value:20},_targetFrameTime:{type:Number,computed:"__computeFrameTime(targetFramerate)"},notifyDomChange:{type:Boolean},reuseChunkedInstances:{type:Boolean}}}static get observers(){return["__itemsChanged(items.*)"]}constructor(){super(),this.__instances=[],this.__renderDebouncer=null,this.__itemsIdxToInstIdx={},this.__chunkCount=null,this.__renderStartTime=null,this.__itemsArrayChanged=!1,this.__shouldMeasureChunk=!1,this.__shouldContinueChunking=!1,this.__chunkingId=0,this.__sortFn=null,this.__filterFn=null,this.__observePaths=null,this.__ctor=null,this.__isDetached=!0,this.template=null}disconnectedCallback(){super.disconnectedCallback(),this.__isDetached=!0;for(let e=0;e<this.__instances.length;e++)this.__detachInstance(e)}connectedCallback(){if(super.connectedCallback(),hideElementsGlobally()||(this.style.display="none"),this.__isDetached){this.__isDetached=!1;let e=wrap(wrap(this).parentNode);for(let t=0;t<this.__instances.length;t++)this.__attachInstance(t,e)}}__ensureTemplatized(){if(!this.__ctor){const e=this;let t=this.template=e._templateInfo?e:this.querySelector("template");if(!t){let e=new MutationObserver((()=>{if(!this.querySelector("template"))throw new Error("dom-repeat requires a <template> child");e.disconnect(),this.__render()}));return e.observe(this,{childList:!0}),!1}let n={};n[this.as]=!0,n[this.indexAs]=!0,n[this.itemsIndexAs]=!0,this.__ctor=templatize(t,this,{mutableData:this.mutableData,parentModel:!0,instanceProps:n,forwardHostProp:function(e,t){let n=this.__instances;for(let i,r=0;r<n.length&&(i=n[r]);r++)i.forwardHostProp(e,t)},notifyInstanceProp:function(e,t,n){if(matches$1(this.as,t)){let i=e[this.itemsIndexAs];t==this.as&&(this.items[i]=n);let r=translate(this.as,`${JSCompiler_renameProperty("items",this)}.${i}`,t);this.notifyPath(r,n)}}})}return!0}__getMethodHost(){return this.__dataHost._methodHost||this.__dataHost}__functionFromPropertyValue(e){if("string"==typeof e){let t=e,n=this.__getMethodHost();return function(){return n[t].apply(n,arguments)}}return e}__sortChanged(e){this.__sortFn=this.__functionFromPropertyValue(e),this.items&&this.__debounceRender(this.__render)}__filterChanged(e){this.__filterFn=this.__functionFromPropertyValue(e),this.items&&this.__debounceRender(this.__render)}__computeFrameTime(e){return Math.ceil(1e3/e)}__observeChanged(){this.__observePaths=this.observe&&this.observe.replace(".*",".").split(" ")}__handleObservedPaths(e){if(this.__sortFn||this.__filterFn)if(e){if(this.__observePaths){let t=this.__observePaths;for(let n=0;n<t.length;n++)0===e.indexOf(t[n])&&this.__debounceRender(this.__render,this.delay)}}else this.__debounceRender(this.__render,this.delay)}__itemsChanged(e){this.items&&!Array.isArray(this.items)&&console.warn("dom-repeat expected array for `items`, found",this.items),this.__handleItemPath(e.path,e.value)||("items"===e.path&&(this.__itemsArrayChanged=!0),this.__debounceRender(this.__render))}__debounceRender(e,t=0){this.__renderDebouncer=Debouncer.debounce(this.__renderDebouncer,t>0?timeOut.after(t):microTask,e.bind(this)),enqueueDebouncer(this.__renderDebouncer)}render(){this.__debounceRender(this.__render),flush()}__render(){if(!this.__ensureTemplatized())return;let e=this.items||[];const t=this.__sortAndFilterItems(e),n=this.__calculateLimit(t.length);this.__updateInstances(e,n,t),this.initialCount&&(this.__shouldMeasureChunk||this.__shouldContinueChunking)&&(cancelAnimationFrame(this.__chunkingId),this.__chunkingId=requestAnimationFrame((()=>this.__continueChunking()))),this._setRenderedItemCount(this.__instances.length),suppressTemplateNotifications&&!this.notifyDomChange||this.dispatchEvent(new CustomEvent("dom-change",{bubbles:!0,composed:!0}))}__sortAndFilterItems(e){let t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=n;return this.__filterFn&&(t=t.filter(((t,n,i)=>this.__filterFn(e[t],n,i)))),this.__sortFn&&t.sort(((t,n)=>this.__sortFn(e[t],e[n]))),t}__calculateLimit(e){let t=e;const n=this.__instances.length;if(this.initialCount){let i;!this.__chunkCount||this.__itemsArrayChanged&&!this.reuseChunkedInstances?(t=Math.min(e,this.initialCount),i=Math.max(t-n,0),this.__chunkCount=i||1):(i=Math.min(Math.max(e-n,0),this.__chunkCount),t=Math.min(n+i,e)),this.__shouldMeasureChunk=i===this.__chunkCount,this.__shouldContinueChunking=t<e,this.__renderStartTime=performance.now()}return this.__itemsArrayChanged=!1,t}__continueChunking(){if(this.__shouldMeasureChunk){const e=performance.now()-this.__renderStartTime;this.__chunkCount=Math.round(this.__chunkCount*(this._targetFrameTime/e))||1}this.__shouldContinueChunking&&this.__debounceRender(this.__render)}__updateInstances(e,t,n){const i=this.__itemsIdxToInstIdx={};let r;for(r=0;r<t;r++){let t=this.__instances[r],o=n[r],a=e[o];i[o]=r,t?(t._setPendingProperty(this.as,a),t._setPendingProperty(this.indexAs,r),t._setPendingProperty(this.itemsIndexAs,o),t._flushProperties()):this.__insertInstance(a,r,o)}for(let e=this.__instances.length-1;e>=r;e--)this.__detachAndRemoveInstance(e)}__detachInstance(e){let t=this.__instances[e];const n=wrap(t.root);for(let e=0;e<t.children.length;e++)n.appendChild(t.children[e]);return t}__attachInstance(e,t){t.insertBefore(this.__instances[e].root,this)}__detachAndRemoveInstance(e){this.__detachInstance(e),this.__instances.splice(e,1)}__stampInstance(e,t,n){let i={};return i[this.as]=e,i[this.indexAs]=t,i[this.itemsIndexAs]=n,new this.__ctor(i)}__insertInstance(e,t,n){const i=this.__stampInstance(e,t,n);let r=this.__instances[t+1],o=r?r.children[0]:this;return wrap(wrap(this).parentNode).insertBefore(i.root,o),this.__instances[t]=i,i}_showHideChildren(e){for(let t=0;t<this.__instances.length;t++)this.__instances[t]._showHideChildren(e)}__handleItemPath(e,t){let n=e.slice(6),i=n.indexOf("."),r=i<0?n:n.substring(0,i);if(r==parseInt(r,10)){let e=i<0?"":n.substring(i+1);this.__handleObservedPaths(e);let o=this.__instances[this.__itemsIdxToInstIdx[r]];return o&&(o._setPendingPropertyOrPath(this.as+(e?"."+e:""),t,!1,!0),o._flushProperties()),!0}}itemForElement(e){let t=this.modelForElement(e);return t&&t[this.as]}indexForElement(e){let t=this.modelForElement(e);return t&&t[this.indexAs]}modelForElement(e){return modelForElement(this.template,e)}}customElements.define(DomRepeat.is,DomRepeat); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ class DomIfBase extends PolymerElement{static get is(){return"dom-if"}static get template(){return null}static get properties(){return{if:{type:Boolean,observer:"__debounceRender"},restamp:{type:Boolean,observer:"__debounceRender"},notifyDomChange:{type:Boolean}}}constructor(){super(),this.__renderDebouncer=null,this._lastIf=!1,this.__hideTemplateChildren__=!1}__debounceRender(){this.__renderDebouncer=Debouncer.debounce(this.__renderDebouncer,microTask,(()=>this.__render())),enqueueDebouncer(this.__renderDebouncer)}disconnectedCallback(){super.disconnectedCallback();const e=wrap(this).parentNode;e&&(e.nodeType!=Node.DOCUMENT_FRAGMENT_NODE||wrap(e).host)||this.__teardownInstance()}connectedCallback(){super.connectedCallback(),hideElementsGlobally()||(this.style.display="none"),this.if&&this.__debounceRender()}__ensureTemplate(){if(!this.__template){const e=this;let t=e._templateInfo?e:wrap(e).querySelector("template");if(!t){let e=new MutationObserver((()=>{if(!wrap(this).querySelector("template"))throw new Error("dom-if requires a <template> child");e.disconnect(),this.__render()}));return e.observe(this,{childList:!0}),!1}this.__template=t}return!0}__ensureInstance(){let e=wrap(this).parentNode;if(this.__hasInstance()){let t=this.__getInstanceNodes();if(t&&t.length&&wrap(this).previousSibling!==t[t.length-1])for(let n,i=0;i<t.length&&(n=t[i]);i++)wrap(e).insertBefore(n,this)}else{if(!e)return!1;if(!this.__ensureTemplate())return!1;this.__createAndInsertInstance(e)}return!0}render(){flush()}__render(){if(this.if){if(!this.__ensureInstance())return}else this.restamp&&this.__teardownInstance();this._showHideChildren(),suppressTemplateNotifications&&!this.notifyDomChange||this.if==this._lastIf||(this.dispatchEvent(new CustomEvent("dom-change",{bubbles:!0,composed:!0})),this._lastIf=this.if)}__hasInstance(){}__getInstanceNodes(){}__createAndInsertInstance(e){}__teardownInstance(){}_showHideChildren(){}}class DomIfFast extends DomIfBase{constructor(){super(),this.__instance=null,this.__syncInfo=null}__hasInstance(){return Boolean(this.__instance)}__getInstanceNodes(){return this.__instance.templateInfo.childNodes}__createAndInsertInstance(e){const t=this.__dataHost||this;if(strictTemplatePolicy&&!this.__dataHost)throw new Error("strictTemplatePolicy: template owner not trusted");const n=t._bindTemplate(this.__template,!0);n.runEffects=(e,t,n)=>{let i=this.__syncInfo;if(this.if)i&&(this.__syncInfo=null,this._showHideChildren(),t=Object.assign(i.changedProps,t)),e(t,n);else if(this.__instance)if(i||(i=this.__syncInfo={runEffects:e,changedProps:{}}),n)for(const e in t){const t=root(e);i.changedProps[t]=this.__dataHost[t]}else Object.assign(i.changedProps,t)},this.__instance=t._stampTemplate(this.__template,n),wrap(e).insertBefore(this.__instance,this)}__syncHostProperties(){const e=this.__syncInfo;e&&(this.__syncInfo=null,e.runEffects(e.changedProps,!1))}__teardownInstance(){this.__instance&&((this.__dataHost||this)._removeBoundDom(this.__instance),this.__instance=null,this.__syncInfo=null)}_showHideChildren(){const e=this.__hideTemplateChildren__||!this.if;this.__instance&&Boolean(this.__instance.__hidden)!==e&&(this.__instance.__hidden=e,showHideChildren(e,this.__instance.templateInfo.childNodes)),e||this.__syncHostProperties()}}class DomIfLegacy extends DomIfBase{constructor(){super(),this.__ctor=null,this.__instance=null,this.__invalidProps=null}__hasInstance(){return Boolean(this.__instance)}__getInstanceNodes(){return this.__instance.children}__createAndInsertInstance(e){this.__ctor||(this.__ctor=templatize(this.__template,this,{mutableData:!0,forwardHostProp:function(e,t){this.__instance&&(this.if?this.__instance.forwardHostProp(e,t):(this.__invalidProps=this.__invalidProps||Object.create(null),this.__invalidProps[root(e)]=!0))}})),this.__instance=new this.__ctor,wrap(e).insertBefore(this.__instance.root,this)}__teardownInstance(){if(this.__instance){let e=this.__instance.children;if(e&&e.length){let t=wrap(e[0]).parentNode;if(t){t=wrap(t);for(let n,i=0;i<e.length&&(n=e[i]);i++)t.removeChild(n)}}this.__invalidProps=null,this.__instance=null}}__syncHostProperties(){let e=this.__invalidProps;if(e){this.__invalidProps=null;for(let t in e)this.__instance._setPendingProperty(t,this.__dataHost[t]);this.__instance._flushProperties()}}_showHideChildren(){const e=this.__hideTemplateChildren__||!this.if;this.__instance&&Boolean(this.__instance.__hidden)!==e&&(this.__instance.__hidden=e,this.__instance._showHideChildren(e)),e||this.__syncHostProperties()}}const DomIf=fastDomIf?DomIfFast:DomIfLegacy;customElements.define(DomIf.is,DomIf); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ let ArraySelectorMixin=dedupingMixin((e=>{let t=ElementMixin(e);return class extends t{static get properties(){return{items:{type:Array},multi:{type:Boolean,value:!1},selected:{type:Object,notify:!0},selectedItem:{type:Object,notify:!0},toggle:{type:Boolean,value:!1}}}static get observers(){return["__updateSelection(multi, items.*)"]}constructor(){super(),this.__lastItems=null,this.__lastMulti=null,this.__selectedMap=null}__updateSelection(e,t){let n=t.path;if(n==JSCompiler_renameProperty("items",this)){let n=t.base||[],i=this.__lastItems;if(e!==this.__lastMulti&&this.clearSelection(),i){let e=calculateSplices(n,i);this.__applySplices(e)}this.__lastItems=n,this.__lastMulti=e}else if(t.path==`${JSCompiler_renameProperty("items",this)}.splices`)this.__applySplices(t.value.indexSplices);else{let e=n.slice(`${JSCompiler_renameProperty("items",this)}.`.length),t=parseInt(e,10);e.indexOf(".")<0&&e==t&&this.__deselectChangedIdx(t)}}__applySplices(e){let t=this.__selectedMap;for(let n=0;n<e.length;n++){let i=e[n];t.forEach(((e,n)=>{e<i.index||t.set(n,e>=i.index+i.removed.length?e+i.addedCount-i.removed.length:-1)}));for(let e=0;e<i.addedCount;e++){let n=i.index+e;t.has(this.items[n])&&t.set(this.items[n],n)}}this.__updateLinks();let n=0;t.forEach(((e,i)=>{e<0?(this.multi?this.splice(JSCompiler_renameProperty("selected",this),n,1):this.selected=this.selectedItem=null,t.delete(i)):n++}))}__updateLinks(){if(this.__dataLinkedPaths={},this.multi){let e=0;this.__selectedMap.forEach((t=>{t>=0&&this.linkPaths(`${JSCompiler_renameProperty("items",this)}.${t}`,`${JSCompiler_renameProperty("selected",this)}.${e++}`)}))}else this.__selectedMap.forEach((e=>{this.linkPaths(JSCompiler_renameProperty("selected",this),`${JSCompiler_renameProperty("items",this)}.${e}`),this.linkPaths(JSCompiler_renameProperty("selectedItem",this),`${JSCompiler_renameProperty("items",this)}.${e}`)}))}clearSelection(){this.__dataLinkedPaths={},this.__selectedMap=new Map,this.selected=this.multi?[]:null,this.selectedItem=null}isSelected(e){return this.__selectedMap.has(e)}isIndexSelected(e){return this.isSelected(this.items[e])}__deselectChangedIdx(e){let t=this.__selectedIndexForItemIndex(e);if(t>=0){let e=0;this.__selectedMap.forEach(((n,i)=>{t==e++&&this.deselect(i)}))}}__selectedIndexForItemIndex(e){let t=this.__dataLinkedPaths[`${JSCompiler_renameProperty("items",this)}.${e}`];if(t)return parseInt(t.slice(`${JSCompiler_renameProperty("selected",this)}.`.length),10)}deselect(e){let t=this.__selectedMap.get(e);if(t>=0){let n;this.__selectedMap.delete(e),this.multi&&(n=this.__selectedIndexForItemIndex(t)),this.__updateLinks(),this.multi?this.splice(JSCompiler_renameProperty("selected",this),n,1):this.selected=this.selectedItem=null}}deselectIndex(e){this.deselect(this.items[e])}select(e){this.selectIndex(this.items.indexOf(e))}selectIndex(e){let t=this.items[e];this.isSelected(t)?this.toggle&&this.deselectIndex(e):(this.multi||this.__selectedMap.clear(),this.__selectedMap.set(t,e),this.__updateLinks(),this.multi?this.push(JSCompiler_renameProperty("selected",this),t):this.selected=this.selectedItem=t)}}})),baseArraySelector=ArraySelectorMixin(PolymerElement);class ArraySelector extends baseArraySelector{static get is(){return"array-selector"}static get template(){return null}}customElements.define(ArraySelector.is,ArraySelector); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const customStyleInterface=new CustomStyleInterface$1;window.ShadyCSS||(window.ShadyCSS={prepareTemplate(e,t,n){},prepareTemplateDom(e,t){},prepareTemplateStyles(e,t,n){},styleSubtree(e,t){customStyleInterface.processStyles(),updateNativeProperties(e,t)},styleElement(e){customStyleInterface.processStyles()},styleDocument(e){customStyleInterface.processStyles(),updateNativeProperties(document.body,e)},getComputedStyleValue:(e,t)=>getComputedStyleValue(e,t),flushCustomStyles(){},nativeCss:nativeCssVariables,nativeShadow:nativeShadow,cssBuild:cssBuild,disableRuntime:disableRuntime}),window.ShadyCSS.CustomStyleInterface=customStyleInterface; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const attr="include",CustomStyleInterface=window.ShadyCSS.CustomStyleInterface;class CustomStyle extends HTMLElement{constructor(){super(),this._style=null,CustomStyleInterface.addCustomStyle(this)}getStyle(){if(this._style)return this._style;const e=this.querySelector("style");if(!e)return null;this._style=e;const t=e.getAttribute(attr);return t&&(e.removeAttribute(attr),e.textContent=cssFromModules(t)+e.textContent),this.ownerDocument!==window.document&&window.document.head.appendChild(this),this._style}} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ let mutablePropertyChange;window.customElements.define("custom-style",CustomStyle),mutablePropertyChange=MutableData._mutablePropertyChange;const OptionalMutableDataBehavior={properties:{mutableData:Boolean},_shouldPropertyChange(e,t,n){return mutablePropertyChange(this,e,t,n,this.mutableData)}},Base=LegacyElementMixin(HTMLElement).prototype; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ var ORPHANS=new Set;const IronResizableBehavior={properties:{_parentResizable:{type:Object,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,value:!1}},listeners:{"iron-request-resize-notifications":"_onIronRequestResizeNotifications"},created:function(){this._interestedResizables=[],this._boundNotifyResize=this.notifyResize.bind(this),this._boundOnDescendantIronResize=this._onDescendantIronResize.bind(this)},attached:function(){this._requestResizeNotifications()},detached:function(){this._parentResizable?this._parentResizable.stopResizeNotificationsFor(this):(ORPHANS.delete(this),window.removeEventListener("resize",this._boundNotifyResize)),this._parentResizable=null},notifyResize:function(){this.isAttached&&(this._interestedResizables.forEach((function(e){this.resizerShouldNotify(e)&&this._notifyDescendant(e)}),this),this._fireResize())},assignParentResizable:function(e){this._parentResizable&&this._parentResizable.stopResizeNotificationsFor(this),this._parentResizable=e,e&&-1===e._interestedResizables.indexOf(this)&&(e._interestedResizables.push(this),e._subscribeIronResize(this))},stopResizeNotificationsFor:function(e){var t=this._interestedResizables.indexOf(e);t>-1&&(this._interestedResizables.splice(t,1),this._unsubscribeIronResize(e))},_subscribeIronResize:function(e){e.addEventListener("iron-resize",this._boundOnDescendantIronResize)},_unsubscribeIronResize:function(e){e.removeEventListener("iron-resize",this._boundOnDescendantIronResize)},resizerShouldNotify:function(e){return!0},_onDescendantIronResize:function(e){this._notifyingDescendant?e.stopPropagation():useShadow||this._fireResize()},_fireResize:function(){this.fire("iron-resize",null,{node:this,bubbles:!1})},_onIronRequestResizeNotifications:function(e){var t=dom$1(e).rootTarget;t!==this&&(t.assignParentResizable(this),this._notifyDescendant(t),e.stopPropagation())},_parentResizableChanged:function(e){e&&window.removeEventListener("resize",this._boundNotifyResize)},_notifyDescendant:function(e){this.isAttached&&(this._notifyingDescendant=!0,e.notifyResize(),this._notifyingDescendant=!1)},_requestResizeNotifications:function(){if(this.isAttached)if("loading"===document.readyState){var e=this._requestResizeNotifications.bind(this);document.addEventListener("readystatechange",(function t(){document.removeEventListener("readystatechange",t),e()}))}else this._findParent(),this._parentResizable?this._parentResizable._interestedResizables.forEach((function(e){e!==this&&e._findParent()}),this):(ORPHANS.forEach((function(e){e!==this&&e._findParent()}),this),window.addEventListener("resize",this._boundNotifyResize),this.notifyResize())},_findParent:function(){this.assignParentResizable(null),this.fire("iron-request-resize-notifications",null,{node:this,bubbles:!0,cancelable:!0}),this._parentResizable?ORPHANS.delete(this):ORPHANS.add(this)}}; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */Polymer({_template:html` <style> :host { display: block; transition-duration: var(--iron-collapse-transition-duration, 300ms); /* Safari 10 needs this property prefixed to correctly apply the custom property */ -webkit-transition-duration: var(--iron-collapse-transition-duration, 300ms); overflow: visible; } :host(.iron-collapse-closed) { display: none; } :host(:not(.iron-collapse-opened)) { overflow: hidden; } </style> <slot></slot> `,is:"iron-collapse",behaviors:[IronResizableBehavior],properties:{horizontal:{type:Boolean,value:!1,observer:"_horizontalChanged"},opened:{type:Boolean,value:!1,notify:!0,observer:"_openedChanged"},transitioning:{type:Boolean,notify:!0,readOnly:!0},noAnimation:{type:Boolean},_desiredSize:{type:String,value:""}},get dimension(){return this.horizontal?"width":"height"},get _dimensionMax(){return this.horizontal?"maxWidth":"maxHeight"},get _dimensionMaxCss(){return this.horizontal?"max-width":"max-height"},hostAttributes:{role:"group","aria-hidden":"true"},listeners:{transitionend:"_onTransitionEnd"},toggle:function(){this.opened=!this.opened},show:function(){this.opened=!0},hide:function(){this.opened=!1},updateSize:function(e,t){e="auto"===e?"":e;var n=t&&!this.noAnimation&&this.isAttached&&this._desiredSize!==e;if(this._desiredSize=e,this._updateTransition(!1),n){var i=this._calcSize();""===e&&(this.style[this._dimensionMax]="",e=this._calcSize()),this.style[this._dimensionMax]=i,this.scrollTop=this.scrollTop,this._updateTransition(!0),n=e!==i}this.style[this._dimensionMax]=e,n||this._transitionEnd()},enableTransition:function(e){Base._warn("`enableTransition()` is deprecated, use `noAnimation` instead."),this.noAnimation=!e},_updateTransition:function(e){this.style.transitionDuration=e&&!this.noAnimation?"":"0s"},_horizontalChanged:function(){this.style.transitionProperty=this._dimensionMaxCss,this.style["maxWidth"===this._dimensionMax?"maxHeight":"maxWidth"]="",this.updateSize(this.opened?"auto":"0px",!1)},_openedChanged:function(){this.setAttribute("aria-hidden",!this.opened),this._setTransitioning(!0),this.toggleClass("iron-collapse-closed",!1),this.toggleClass("iron-collapse-opened",!1),this.updateSize(this.opened?"auto":"0px",!0),this.opened&&this.focus()},_transitionEnd:function(){this.style[this._dimensionMax]=this._desiredSize,this.toggleClass("iron-collapse-closed",!this.opened),this.toggleClass("iron-collapse-opened",this.opened),this._updateTransition(!1),this.notifyResize(),this._setTransitioning(!1)},_onTransitionEnd:function(e){dom$1(e).rootTarget===this&&this._transitionEnd()},_calcSize:function(){return this.getBoundingClientRect()[this.dimension]+"px"}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$n=html` /* Most common used flex styles*/ <dom-module id="iron-flex"> <template> <style> .layout.horizontal, .layout.vertical { display: -ms-flexbox; display: -webkit-flex; display: flex; } .layout.inline { display: -ms-inline-flexbox; display: -webkit-inline-flex; display: inline-flex; } .layout.horizontal { -ms-flex-direction: row; -webkit-flex-direction: row; flex-direction: row; } .layout.vertical { -ms-flex-direction: column; -webkit-flex-direction: column; flex-direction: column; } .layout.wrap { -ms-flex-wrap: wrap; -webkit-flex-wrap: wrap; flex-wrap: wrap; } .layout.no-wrap { -ms-flex-wrap: nowrap; -webkit-flex-wrap: nowrap; flex-wrap: nowrap; } .layout.center, .layout.center-center { -ms-flex-align: center; -webkit-align-items: center; align-items: center; } .layout.center-justified, .layout.center-center { -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; } .flex { -ms-flex: 1 1 0.000000001px; -webkit-flex: 1; flex: 1; -webkit-flex-basis: 0.000000001px; flex-basis: 0.000000001px; } .flex-auto { -ms-flex: 1 1 auto; -webkit-flex: 1 1 auto; flex: 1 1 auto; } .flex-none { -ms-flex: none; -webkit-flex: none; flex: none; } </style> </template> </dom-module> /* Basic flexbox reverse styles */ <dom-module id="iron-flex-reverse"> <template> <style> .layout.horizontal-reverse, .layout.vertical-reverse { display: -ms-flexbox; display: -webkit-flex; display: flex; } .layout.horizontal-reverse { -ms-flex-direction: row-reverse; -webkit-flex-direction: row-reverse; flex-direction: row-reverse; } .layout.vertical-reverse { -ms-flex-direction: column-reverse; -webkit-flex-direction: column-reverse; flex-direction: column-reverse; } .layout.wrap-reverse { -ms-flex-wrap: wrap-reverse; -webkit-flex-wrap: wrap-reverse; flex-wrap: wrap-reverse; } </style> </template> </dom-module> /* Flexbox alignment */ <dom-module id="iron-flex-alignment"> <template> <style> /** * Alignment in cross axis. */ .layout.start { -ms-flex-align: start; -webkit-align-items: flex-start; align-items: flex-start; } .layout.center, .layout.center-center { -ms-flex-align: center; -webkit-align-items: center; align-items: center; } .layout.end { -ms-flex-align: end; -webkit-align-items: flex-end; align-items: flex-end; } .layout.baseline { -ms-flex-align: baseline; -webkit-align-items: baseline; align-items: baseline; } /** * Alignment in main axis. */ .layout.start-justified { -ms-flex-pack: start; -webkit-justify-content: flex-start; justify-content: flex-start; } .layout.center-justified, .layout.center-center { -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; } .layout.end-justified { -ms-flex-pack: end; -webkit-justify-content: flex-end; justify-content: flex-end; } .layout.around-justified { -ms-flex-pack: distribute; -webkit-justify-content: space-around; justify-content: space-around; } .layout.justified { -ms-flex-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; } /** * Self alignment. */ .self-start { -ms-align-self: flex-start; -webkit-align-self: flex-start; align-self: flex-start; } .self-center { -ms-align-self: center; -webkit-align-self: center; align-self: center; } .self-end { -ms-align-self: flex-end; -webkit-align-self: flex-end; align-self: flex-end; } .self-stretch { -ms-align-self: stretch; -webkit-align-self: stretch; align-self: stretch; } .self-baseline { -ms-align-self: baseline; -webkit-align-self: baseline; align-self: baseline; } /** * multi-line alignment in main axis. */ .layout.start-aligned { -ms-flex-line-pack: start; /* IE10 */ -ms-align-content: flex-start; -webkit-align-content: flex-start; align-content: flex-start; } .layout.end-aligned { -ms-flex-line-pack: end; /* IE10 */ -ms-align-content: flex-end; -webkit-align-content: flex-end; align-content: flex-end; } .layout.center-aligned { -ms-flex-line-pack: center; /* IE10 */ -ms-align-content: center; -webkit-align-content: center; align-content: center; } .layout.between-aligned { -ms-flex-line-pack: justify; /* IE10 */ -ms-align-content: space-between; -webkit-align-content: space-between; align-content: space-between; } .layout.around-aligned { -ms-flex-line-pack: distribute; /* IE10 */ -ms-align-content: space-around; -webkit-align-content: space-around; align-content: space-around; } </style> </template> </dom-module> /* Non-flexbox positioning helper styles */ <dom-module id="iron-flex-factors"> <template> <style> .flex, .flex-1 { -ms-flex: 1 1 0.000000001px; -webkit-flex: 1; flex: 1; -webkit-flex-basis: 0.000000001px; flex-basis: 0.000000001px; } .flex-2 { -ms-flex: 2; -webkit-flex: 2; flex: 2; } .flex-3 { -ms-flex: 3; -webkit-flex: 3; flex: 3; } .flex-4 { -ms-flex: 4; -webkit-flex: 4; flex: 4; } .flex-5 { -ms-flex: 5; -webkit-flex: 5; flex: 5; } .flex-6 { -ms-flex: 6; -webkit-flex: 6; flex: 6; } .flex-7 { -ms-flex: 7; -webkit-flex: 7; flex: 7; } .flex-8 { -ms-flex: 8; -webkit-flex: 8; flex: 8; } .flex-9 { -ms-flex: 9; -webkit-flex: 9; flex: 9; } .flex-10 { -ms-flex: 10; -webkit-flex: 10; flex: 10; } .flex-11 { -ms-flex: 11; -webkit-flex: 11; flex: 11; } .flex-12 { -ms-flex: 12; -webkit-flex: 12; flex: 12; } </style> </template> </dom-module> <dom-module id="iron-positioning"> <template> <style> .block { display: block; } [hidden] { display: none !important; } .invisible { visibility: hidden !important; } .relative { position: relative; } .fit { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } body.fullbleed { margin: 0; height: 100vh; } .scroll { -webkit-overflow-scrolling: touch; overflow: auto; } /* fixed position */ .fixed-bottom, .fixed-left, .fixed-right, .fixed-top { position: fixed; } .fixed-top { top: 0; left: 0; right: 0; } .fixed-right { top: 0; right: 0; bottom: 0; } .fixed-bottom { right: 0; bottom: 0; left: 0; } .fixed-left { top: 0; bottom: 0; left: 0; } </style> </template> </dom-module> `;template$n.setAttribute("style","display: none;"),document.head.appendChild(template$n.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$m=html` <custom-style> <style is="custom-style"> [hidden] { display: none !important; } </style> </custom-style> <custom-style> <style is="custom-style"> html { --layout: { display: -ms-flexbox; display: -webkit-flex; display: flex; }; --layout-inline: { display: -ms-inline-flexbox; display: -webkit-inline-flex; display: inline-flex; }; --layout-horizontal: { @apply --layout; -ms-flex-direction: row; -webkit-flex-direction: row; flex-direction: row; }; --layout-horizontal-reverse: { @apply --layout; -ms-flex-direction: row-reverse; -webkit-flex-direction: row-reverse; flex-direction: row-reverse; }; --layout-vertical: { @apply --layout; -ms-flex-direction: column; -webkit-flex-direction: column; flex-direction: column; }; --layout-vertical-reverse: { @apply --layout; -ms-flex-direction: column-reverse; -webkit-flex-direction: column-reverse; flex-direction: column-reverse; }; --layout-wrap: { -ms-flex-wrap: wrap; -webkit-flex-wrap: wrap; flex-wrap: wrap; }; --layout-wrap-reverse: { -ms-flex-wrap: wrap-reverse; -webkit-flex-wrap: wrap-reverse; flex-wrap: wrap-reverse; }; --layout-flex-auto: { -ms-flex: 1 1 auto; -webkit-flex: 1 1 auto; flex: 1 1 auto; }; --layout-flex-none: { -ms-flex: none; -webkit-flex: none; flex: none; }; --layout-flex: { -ms-flex: 1 1 0.000000001px; -webkit-flex: 1; flex: 1; -webkit-flex-basis: 0.000000001px; flex-basis: 0.000000001px; }; --layout-flex-2: { -ms-flex: 2; -webkit-flex: 2; flex: 2; }; --layout-flex-3: { -ms-flex: 3; -webkit-flex: 3; flex: 3; }; --layout-flex-4: { -ms-flex: 4; -webkit-flex: 4; flex: 4; }; --layout-flex-5: { -ms-flex: 5; -webkit-flex: 5; flex: 5; }; --layout-flex-6: { -ms-flex: 6; -webkit-flex: 6; flex: 6; }; --layout-flex-7: { -ms-flex: 7; -webkit-flex: 7; flex: 7; }; --layout-flex-8: { -ms-flex: 8; -webkit-flex: 8; flex: 8; }; --layout-flex-9: { -ms-flex: 9; -webkit-flex: 9; flex: 9; }; --layout-flex-10: { -ms-flex: 10; -webkit-flex: 10; flex: 10; }; --layout-flex-11: { -ms-flex: 11; -webkit-flex: 11; flex: 11; }; --layout-flex-12: { -ms-flex: 12; -webkit-flex: 12; flex: 12; }; /* alignment in cross axis */ --layout-start: { -ms-flex-align: start; -webkit-align-items: flex-start; align-items: flex-start; }; --layout-center: { -ms-flex-align: center; -webkit-align-items: center; align-items: center; }; --layout-end: { -ms-flex-align: end; -webkit-align-items: flex-end; align-items: flex-end; }; --layout-baseline: { -ms-flex-align: baseline; -webkit-align-items: baseline; align-items: baseline; }; /* alignment in main axis */ --layout-start-justified: { -ms-flex-pack: start; -webkit-justify-content: flex-start; justify-content: flex-start; }; --layout-center-justified: { -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; }; --layout-end-justified: { -ms-flex-pack: end; -webkit-justify-content: flex-end; justify-content: flex-end; }; --layout-around-justified: { -ms-flex-pack: distribute; -webkit-justify-content: space-around; justify-content: space-around; }; --layout-justified: { -ms-flex-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; }; --layout-center-center: { @apply --layout-center; @apply --layout-center-justified; }; /* self alignment */ --layout-self-start: { -ms-align-self: flex-start; -webkit-align-self: flex-start; align-self: flex-start; }; --layout-self-center: { -ms-align-self: center; -webkit-align-self: center; align-self: center; }; --layout-self-end: { -ms-align-self: flex-end; -webkit-align-self: flex-end; align-self: flex-end; }; --layout-self-stretch: { -ms-align-self: stretch; -webkit-align-self: stretch; align-self: stretch; }; --layout-self-baseline: { -ms-align-self: baseline; -webkit-align-self: baseline; align-self: baseline; }; /* multi-line alignment in main axis */ --layout-start-aligned: { -ms-flex-line-pack: start; /* IE10 */ -ms-align-content: flex-start; -webkit-align-content: flex-start; align-content: flex-start; }; --layout-end-aligned: { -ms-flex-line-pack: end; /* IE10 */ -ms-align-content: flex-end; -webkit-align-content: flex-end; align-content: flex-end; }; --layout-center-aligned: { -ms-flex-line-pack: center; /* IE10 */ -ms-align-content: center; -webkit-align-content: center; align-content: center; }; --layout-between-aligned: { -ms-flex-line-pack: justify; /* IE10 */ -ms-align-content: space-between; -webkit-align-content: space-between; align-content: space-between; }; --layout-around-aligned: { -ms-flex-line-pack: distribute; /* IE10 */ -ms-align-content: space-around; -webkit-align-content: space-around; align-content: space-around; }; /******************************* Other Layout *******************************/ --layout-block: { display: block; }; --layout-invisible: { visibility: hidden !important; }; --layout-relative: { position: relative; }; --layout-fit: { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }; --layout-scroll: { -webkit-overflow-scrolling: touch; overflow: auto; }; --layout-fullbleed: { margin: 0; height: 100vh; }; /* fixed position */ --layout-fixed-top: { position: fixed; top: 0; left: 0; right: 0; }; --layout-fixed-right: { position: fixed; top: 0; right: 0; bottom: 0; }; --layout-fixed-bottom: { position: fixed; right: 0; bottom: 0; left: 0; }; --layout-fixed-left: { position: fixed; top: 0; bottom: 0; left: 0; }; } </style> </custom-style>`;template$m.setAttribute("style","display: none;"),document.head.appendChild(template$m.content);var style=document.createElement("style");style.textContent="[hidden] { display: none !important; }",document.head.appendChild(style); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ class IronMeta{constructor(e){IronMeta[" "](e),this.type=e&&e.type||"default",this.key=e&&e.key,e&&"value"in e&&(this.value=e.value)}get value(){var e=this.type,t=this.key;if(e&&t)return IronMeta.types[e]&&IronMeta.types[e][t]}set value(e){var t=this.type,n=this.key;t&&n&&(t=IronMeta.types[t]=IronMeta.types[t]||{},null==e?delete t[n]:t[n]=e)}get list(){if(this.type){var e=IronMeta.types[this.type];return e?Object.keys(e).map((function(e){return metaDatas[this.type][e]}),this):[]}}byKey(e){return this.key=e,this.value}}IronMeta[" "]=function(){},IronMeta.types={};var metaDatas=IronMeta.types;Polymer({is:"iron-meta",properties:{type:{type:String,value:"default"},key:{type:String},value:{type:String,notify:!0},self:{type:Boolean,observer:"_selfChanged"},__meta:{type:Boolean,computed:"__computeMeta(type, key, value)"}},hostAttributes:{hidden:!0},__computeMeta:function(e,t,n){var i=new IronMeta({type:e,key:t});return void 0!==n&&n!==i.value?i.value=n:this.value!==i.value&&(this.value=i.value),i},get list(){return this.__meta&&this.__meta.list},_selfChanged:function(e){e&&(this.value=this)},byKey:function(e){return new IronMeta({type:this.type,key:e}).value}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { @apply --layout-inline; @apply --layout-center-center; position: relative; vertical-align: middle; fill: var(--iron-icon-fill-color, currentcolor); stroke: var(--iron-icon-stroke-color, none); width: var(--iron-icon-width, 24px); height: var(--iron-icon-height, 24px); @apply --iron-icon; } :host([hidden]) { display: none; } </style> `,is:"iron-icon",properties:{icon:{type:String},theme:{type:String},src:{type:String},_meta:{value:Base.create("iron-meta",{type:"iconset"})}},observers:["_updateIcon(_meta, isAttached)","_updateIcon(theme, isAttached)","_srcChanged(src, isAttached)","_iconChanged(icon, isAttached)"],_DEFAULT_ICONSET:"icons",_iconChanged:function(e){var t=(e||"").split(":");this._iconName=t.pop(),this._iconsetName=t.pop()||this._DEFAULT_ICONSET,this._updateIcon()},_srcChanged:function(e){this._updateIcon()},_usesIconset:function(){return this.icon||!this.src},_updateIcon:function(){this._usesIconset()?(this._img&&this._img.parentNode&&dom$1(this.root).removeChild(this._img),""===this._iconName?this._iconset&&this._iconset.removeIcon(this):this._iconsetName&&this._meta&&(this._iconset=this._meta.byKey(this._iconsetName),this._iconset?(this._iconset.applyIcon(this,this._iconName,this.theme),this.unlisten(window,"iron-iconset-added","_updateIcon")):this.listen(window,"iron-iconset-added","_updateIcon"))):(this._iconset&&this._iconset.removeIcon(this),this._img||(this._img=document.createElement("img"),this._img.style.width="100%",this._img.style.height="100%",this._img.draggable=!1),this._img.src=this.src,dom$1(this.root).appendChild(this._img))}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({is:"iron-iconset-svg",properties:{name:{type:String,observer:"_nameChanged"},size:{type:Number,value:24},rtlMirroring:{type:Boolean,value:!1},useGlobalRtlAttribute:{type:Boolean,value:!1}},created:function(){this._meta=new IronMeta({type:"iconset",key:null,value:null})},attached:function(){this.style.display="none"},getIconNames:function(){return this._icons=this._createIconMap(),Object.keys(this._icons).map((function(e){return this.name+":"+e}),this)},applyIcon:function(e,t){this.removeIcon(e);var n=this._cloneIcon(t,this.rtlMirroring&&this._targetIsRTL(e));if(n){var i=dom$1(e.root||e);return i.insertBefore(n,i.childNodes[0]),e._svgIcon=n}return null},removeIcon:function(e){e._svgIcon&&(dom$1(e.root||e).removeChild(e._svgIcon),e._svgIcon=null)},_targetIsRTL:function(e){if(null==this.__targetIsRTL)if(this.useGlobalRtlAttribute){var t=document.body&&document.body.hasAttribute("dir")?document.body:document.documentElement;this.__targetIsRTL="rtl"===t.getAttribute("dir")}else e&&e.nodeType!==Node.ELEMENT_NODE&&(e=e.host),this.__targetIsRTL=e&&"rtl"===window.getComputedStyle(e).direction;return this.__targetIsRTL},_nameChanged:function(){this._meta.value=null,this._meta.key=this.name,this._meta.value=this,this.async((function(){this.fire("iron-iconset-added",this,{node:window})}))},_createIconMap:function(){var e=Object.create(null);return dom$1(this).querySelectorAll("[id]").forEach((function(t){e[t.id]=t})),e},_cloneIcon:function(e,t){return this._icons=this._icons||this._createIconMap(),this._prepareSvgClone(this._icons[e],this.size,t)},_prepareSvgClone:function(e,t,n){if(e){var i=e.cloneNode(!0),r=document.createElementNS("http://www.w3.org/2000/svg","svg"),o=i.getAttribute("viewBox")||"0 0 "+t+" "+t,a="pointer-events: none; display: block; width: 100%; height: 100%;";return n&&i.hasAttribute("mirror-in-rtl")&&(a+="-webkit-transform:scale(-1,1);transform:scale(-1,1);transform-origin:center;"),r.setAttribute("viewBox",o),r.setAttribute("preserveAspectRatio","xMidYMid meet"),r.setAttribute("focusable","false"),r.style.cssText=a,r.appendChild(i).removeAttribute("id"),r}return null}}); /** @license Copyright (c) 2014 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$l=html`<iron-iconset-svg name="image" size="24"> <svg><defs> <g id="add-a-photo"><path d="M3 4V1h2v3h3v2H5v3H3V6H0V4h3zm3 6V7h3V4h7l1.83 2H21c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2V10h3zm7 9c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-3.2-5c0 1.77 1.43 3.2 3.2 3.2s3.2-1.43 3.2-3.2-1.43-3.2-3.2-3.2-3.2 1.43-3.2 3.2z"></path></g> <g id="add-to-photos"><path d="M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z"></path></g> <g id="adjust"><path d="M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10 10-4.49 10-10S17.51 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3-8c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3z"></path></g> <g id="assistant"><path d="M19 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h4l3 3 3-3h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-5.12 10.88L12 17l-1.88-4.12L6 11l4.12-1.88L12 5l1.88 4.12L18 11l-4.12 1.88z"></path></g> <g id="assistant-photo"><path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"></path></g> <g id="audiotrack"><path d="M12 3v9.28c-.47-.17-.97-.28-1.5-.28C8.01 12 6 14.01 6 16.5S8.01 21 10.5 21c2.31 0 4.2-1.75 4.45-4H15V6h4V3h-7z"></path></g> <g id="blur-circular"><path d="M10 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM7 9.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm3 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-3-3c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm3-6c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-1.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm3 6c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-4c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm2-3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-3.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"></path></g> <g id="blur-linear"><path d="M5 17.5c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5.67 1.5 1.5 1.5zM9 13c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zM3 21h18v-2H3v2zM5 9.5c.83 0 1.5-.67 1.5-1.5S5.83 6.5 5 6.5 3.5 7.17 3.5 8 4.17 9.5 5 9.5zm0 4c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5.67 1.5 1.5 1.5zM9 17c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm8-.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM3 3v2h18V3H3zm14 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm0 4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM13 9c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1z"></path></g> <g id="blur-off"><path d="M14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm-.2 4.48l.2.02c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5l.02.2c.09.67.61 1.19 1.28 1.28zM14 3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-4 0c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm11 7c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm8 8c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm-4 13.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM2.5 5.27l3.78 3.78L6 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.03-.19-.06-.28l2.81 2.81c-.71.11-1.25.73-1.25 1.47 0 .83.67 1.5 1.5 1.5.74 0 1.36-.54 1.47-1.25l2.81 2.81c-.09-.03-.18-.06-.28-.06-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.03-.19-.06-.28l3.78 3.78L20 20.23 3.77 4 2.5 5.27zM10 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm11-3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM3 9.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 11c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3-3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5z"></path></g> <g id="blur-on"><path d="M6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3 .5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-11 10c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-17c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 5.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm8 .5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3 8.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM14 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-4-12c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0 8.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-4.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-4c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"></path></g> <g id="brightness-1"><circle cx="12" cy="12" r="10"></circle></g> <g id="brightness-2"><path d="M10 2c-1.82 0-3.53.5-5 1.35C7.99 5.08 10 8.3 10 12s-2.01 6.92-5 8.65C6.47 21.5 8.18 22 10 22c5.52 0 10-4.48 10-10S15.52 2 10 2z"></path></g> <g id="brightness-3"><path d="M9 2c-1.05 0-2.05.16-3 .46 4.06 1.27 7 5.06 7 9.54 0 4.48-2.94 8.27-7 9.54.95.3 1.95.46 3 .46 5.52 0 10-4.48 10-10S14.52 2 9 2z"></path></g> <g id="brightness-4"><path d="M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12 20 8.69zM12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6z"></path></g> <g id="brightness-5"><path d="M20 15.31L23.31 12 20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"></path></g> <g id="brightness-6"><path d="M20 15.31L23.31 12 20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69zM12 18V6c3.31 0 6 2.69 6 6s-2.69 6-6 6z"></path></g> <g id="brightness-7"><path d="M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12 20 8.69zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm0-10c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4z"></path></g> <g id="broken-image"><path d="M21 5v6.59l-3-3.01-4 4.01-4-4-4 4-3-3.01V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42l3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l3 2.99 4-4 4 4 4-3.99z"></path></g> <g id="brush"><path d="M7 14c-1.66 0-3 1.34-3 3 0 1.31-1.16 2-2 2 .92 1.22 2.49 2 4 2 2.21 0 4-1.79 4-4 0-1.66-1.34-3-3-3zm13.71-9.37l-1.34-1.34c-.39-.39-1.02-.39-1.41 0L9 12.25 11.75 15l8.96-8.96c.39-.39.39-1.02 0-1.41z"></path></g> <g id="burst-mode"><path d="M1 5h2v14H1zm4 0h2v14H5zm17 0H10c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zM11 17l2.5-3.15L15.29 16l2.5-3.22L21 17H11z"></path></g> <g id="camera"><path d="M9.4 10.5l4.77-8.26C13.47 2.09 12.75 2 12 2c-2.4 0-4.6.85-6.32 2.25l3.66 6.35.06-.1zM21.54 9c-.92-2.92-3.15-5.26-6-6.34L11.88 9h9.66zm.26 1h-7.49l.29.5 4.76 8.25C21 16.97 22 14.61 22 12c0-.69-.07-1.35-.2-2zM8.54 12l-3.9-6.75C3.01 7.03 2 9.39 2 12c0 .69.07 1.35.2 2h7.49l-1.15-2zm-6.08 3c.92 2.92 3.15 5.26 6 6.34L12.12 15H2.46zm11.27 0l-3.9 6.76c.7.15 1.42.24 2.17.24 2.4 0 4.6-.85 6.32-2.25l-3.66-6.35-.93 1.6z"></path></g> <g id="camera-alt"><circle cx="12" cy="12" r="3.2"></circle><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path></g> <g id="camera-front"><path d="M10 20H5v2h5v2l3-3-3-3v2zm4 0v2h5v-2h-5zM12 8c1.1 0 2-.9 2-2s-.9-2-2-2-1.99.9-1.99 2S10.9 8 12 8zm5-8H7C5.9 0 5 .9 5 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zM7 2h10v10.5c0-1.67-3.33-2.5-5-2.5s-5 .83-5 2.5V2z"></path></g> <g id="camera-rear"><path d="M10 20H5v2h5v2l3-3-3-3v2zm4 0v2h5v-2h-5zm3-20H7C5.9 0 5 .9 5 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zm-5 6c-1.11 0-2-.9-2-2s.89-2 1.99-2 2 .9 2 2C14 5.1 13.1 6 12 6z"></path></g> <g id="camera-roll"><path d="M14 5c0-1.1-.9-2-2-2h-1V2c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v1H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2h8V5h-8zm-2 13h-2v-2h2v2zm0-9h-2V7h2v2zm4 9h-2v-2h2v2zm0-9h-2V7h2v2zm4 9h-2v-2h2v2zm0-9h-2V7h2v2z"></path></g> <g id="center-focus-strong"><path d="M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm-7 7H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4z"></path></g> <g id="center-focus-weak"><path d="M5 15H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></g> <g id="collections"><path d="M22 16V4c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2zm-11-4l2.03 2.71L16 11l4 5H8l3-4zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"></path></g> <g id="collections-bookmark"><path d="M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 10l-2.5-1.5L15 12V4h5v8z"></path></g> <g id="color-lens"><path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></g> <g id="colorize"><path d="M20.71 5.63l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-3.12 3.12-1.93-1.91-1.41 1.41 1.42 1.42L3 16.25V21h4.75l8.92-8.92 1.42 1.42 1.41-1.41-1.92-1.92 3.12-3.12c.4-.4.4-1.03.01-1.42zM6.92 19L5 17.08l8.06-8.06 1.92 1.92L6.92 19z"></path></g> <g id="compare"><path d="M10 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h5v2h2V1h-2v2zm0 15H5l5-6v6zm9-15h-5v2h5v13l-5-6v9h5c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path></g> <g id="control-point"><path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.49 2 2 6.49 2 12s4.49 10 10 10 10-4.49 10-10S17.51 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g> <g id="control-point-duplicate"><path d="M16 8h-2v3h-3v2h3v3h2v-3h3v-2h-3zM2 12c0-2.79 1.64-5.2 4.01-6.32V3.52C2.52 4.76 0 8.09 0 12s2.52 7.24 6.01 8.48v-2.16C3.64 17.2 2 14.79 2 12zm13-9c-4.96 0-9 4.04-9 9s4.04 9 9 9 9-4.04 9-9-4.04-9-9-9zm0 16c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7z"></path></g> <g id="crop"><path d="M17 15h2V7c0-1.1-.9-2-2-2H9v2h8v8zM7 17V1H5v4H1v2h4v10c0 1.1.9 2 2 2h10v4h2v-4h4v-2H7z"></path></g> <g id="crop-16-9"><path d="M19 6H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 10H5V8h14v8z"></path></g> <g id="crop-3-2"><path d="M19 4H5c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H5V6h14v12z"></path></g> <g id="crop-5-4"><path d="M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H5V7h14v10z"></path></g> <g id="crop-7-5"><path d="M19 7H5c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zm0 8H5V9h14v6z"></path></g> <g id="crop-din"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"></path></g> <g id="crop-free"><path d="M3 5v4h2V5h4V3H5c-1.1 0-2 .9-2 2zm2 10H3v4c0 1.1.9 2 2 2h4v-2H5v-4zm14 4h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zm0-16h-4v2h4v4h2V5c0-1.1-.9-2-2-2z"></path></g> <g id="crop-landscape"><path d="M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H5V7h14v10z"></path></g> <g id="crop-original"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zm-5.04-6.71l-2.75 3.54-1.96-2.36L6.5 17h11l-3.54-4.71z"></path></g> <g id="crop-portrait"><path d="M17 3H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7V5h10v14z"></path></g> <g id="crop-rotate"><path d="M7.47 21.49C4.2 19.93 1.86 16.76 1.5 13H0c.51 6.16 5.66 11 11.95 11 .23 0 .44-.02.66-.03L8.8 20.15l-1.33 1.34zM12.05 0c-.23 0-.44.02-.66.04l3.81 3.81 1.33-1.33C19.8 4.07 22.14 7.24 22.5 11H24c-.51-6.16-5.66-11-11.95-11zM16 14h2V8c0-1.11-.9-2-2-2h-6v2h6v6zm-8 2V4H6v2H4v2h2v8c0 1.1.89 2 2 2h8v2h2v-2h2v-2H8z"></path></g> <g id="crop-square"><path d="M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H6V6h12v12z"></path></g> <g id="dehaze"><path d="M2 15.5v2h20v-2H2zm0-5v2h20v-2H2zm0-5v2h20v-2H2z"></path></g> <g id="details"><path d="M3 4l9 16 9-16H3zm3.38 2h11.25L12 16 6.38 6z"></path></g> <g id="edit"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></g> <g id="exposure"><path d="M15 17v2h2v-2h2v-2h-2v-2h-2v2h-2v2h2zm5-15H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM5 5h6v2H5V5zm15 15H4L20 4v16z"></path></g> <g id="exposure-neg-1"><path d="M4 11v2h8v-2H4zm15 7h-2V7.38L14 8.4V6.7L18.7 5h.3v13z"></path></g> <g id="exposure-neg-2"><path d="M15.05 16.29l2.86-3.07c.38-.39.72-.79 1.04-1.18.32-.39.59-.78.82-1.17.23-.39.41-.78.54-1.17s.19-.79.19-1.18c0-.53-.09-1.02-.27-1.46-.18-.44-.44-.81-.78-1.11-.34-.31-.77-.54-1.26-.71-.51-.16-1.08-.24-1.72-.24-.69 0-1.31.11-1.85.32-.54.21-1 .51-1.36.88-.37.37-.65.8-.84 1.3-.18.47-.27.97-.28 1.5h2.14c.01-.31.05-.6.13-.87.09-.29.23-.54.4-.75.18-.21.41-.37.68-.49.27-.12.6-.18.96-.18.31 0 .58.05.81.15.23.1.43.25.59.43.16.18.28.4.37.65.08.25.13.52.13.81 0 .22-.03.43-.08.65-.06.22-.15.45-.29.7-.14.25-.32.53-.56.83-.23.3-.52.65-.88 1.03l-4.17 4.55V18H21v-1.71h-5.95zM2 11v2h8v-2H2z"></path></g> <g id="exposure-plus-1"><path d="M10 7H8v4H4v2h4v4h2v-4h4v-2h-4V7zm10 11h-2V7.38L15 8.4V6.7L19.7 5h.3v13z"></path></g> <g id="exposure-plus-2"><path d="M16.05 16.29l2.86-3.07c.38-.39.72-.79 1.04-1.18.32-.39.59-.78.82-1.17.23-.39.41-.78.54-1.17.13-.39.19-.79.19-1.18 0-.53-.09-1.02-.27-1.46-.18-.44-.44-.81-.78-1.11-.34-.31-.77-.54-1.26-.71-.51-.16-1.08-.24-1.72-.24-.69 0-1.31.11-1.85.32-.54.21-1 .51-1.36.88-.37.37-.65.8-.84 1.3-.18.47-.27.97-.28 1.5h2.14c.01-.31.05-.6.13-.87.09-.29.23-.54.4-.75.18-.21.41-.37.68-.49.27-.12.6-.18.96-.18.31 0 .58.05.81.15.23.1.43.25.59.43.16.18.28.4.37.65.08.25.13.52.13.81 0 .22-.03.43-.08.65-.06.22-.15.45-.29.7-.14.25-.32.53-.56.83-.23.3-.52.65-.88 1.03l-4.17 4.55V18H22v-1.71h-5.95zM8 7H6v4H2v2h4v4h2v-4h4v-2H8V7z"></path></g> <g id="exposure-zero"><path d="M16.14 12.5c0 1-.1 1.85-.3 2.55-.2.7-.48 1.27-.83 1.7-.36.44-.79.75-1.3.95-.51.2-1.07.3-1.7.3-.62 0-1.18-.1-1.69-.3-.51-.2-.95-.51-1.31-.95-.36-.44-.65-1.01-.85-1.7-.2-.7-.3-1.55-.3-2.55v-2.04c0-1 .1-1.85.3-2.55.2-.7.48-1.26.84-1.69.36-.43.8-.74 1.31-.93C10.81 5.1 11.38 5 12 5c.63 0 1.19.1 1.7.29.51.19.95.5 1.31.93.36.43.64.99.84 1.69.2.7.3 1.54.3 2.55v2.04zm-2.11-2.36c0-.64-.05-1.18-.13-1.62-.09-.44-.22-.79-.4-1.06-.17-.27-.39-.46-.64-.58-.25-.13-.54-.19-.86-.19-.32 0-.61.06-.86.18s-.47.31-.64.58c-.17.27-.31.62-.4 1.06s-.13.98-.13 1.62v2.67c0 .64.05 1.18.14 1.62.09.45.23.81.4 1.09s.39.48.64.61.54.19.87.19c.33 0 .62-.06.87-.19s.46-.33.63-.61c.17-.28.3-.64.39-1.09.09-.45.13-.99.13-1.62v-2.66z"></path></g> <g id="filter"><path d="M15.96 10.29l-2.75 3.54-1.96-2.36L8.5 15h11l-3.54-4.71zM3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"></path></g> <g id="filter-1"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm11 10h2V5h-4v2h2v8zm7-14H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"></path></g> <g id="filter-2"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zm-4-4h-4v-2h2c1.1 0 2-.89 2-2V7c0-1.11-.9-2-2-2h-4v2h4v2h-2c-1.1 0-2 .89-2 2v4h6v-2z"></path></g> <g id="filter-3"><path d="M21 1H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zM3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm14 8v-1.5c0-.83-.67-1.5-1.5-1.5.83 0 1.5-.67 1.5-1.5V7c0-1.11-.9-2-2-2h-4v2h4v2h-2v2h2v2h-4v2h4c1.1 0 2-.89 2-2z"></path></g> <g id="filter-4"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm12 10h2V5h-2v4h-2V5h-2v6h4v4zm6-14H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"></path></g> <g id="filter-5"><path d="M21 1H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zM3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm14 8v-2c0-1.11-.9-2-2-2h-2V7h4V5h-6v6h4v2h-4v2h4c1.1 0 2-.89 2-2z"></path></g> <g id="filter-6"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zm-8-2h2c1.1 0 2-.89 2-2v-2c0-1.11-.9-2-2-2h-2V7h4V5h-4c-1.1 0-2 .89-2 2v6c0 1.11.9 2 2 2zm0-4h2v2h-2v-2z"></path></g> <g id="filter-7"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zm-8-2l4-8V5h-6v2h4l-4 8h2z"></path></g> <g id="filter-8"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zm-8-2h2c1.1 0 2-.89 2-2v-1.5c0-.83-.67-1.5-1.5-1.5.83 0 1.5-.67 1.5-1.5V7c0-1.11-.9-2-2-2h-2c-1.1 0-2 .89-2 2v1.5c0 .83.67 1.5 1.5 1.5-.83 0-1.5.67-1.5 1.5V13c0 1.11.9 2 2 2zm0-8h2v2h-2V7zm0 4h2v2h-2v-2z"></path></g> <g id="filter-9"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zM15 5h-2c-1.1 0-2 .89-2 2v2c0 1.11.9 2 2 2h2v2h-4v2h4c1.1 0 2-.89 2-2V7c0-1.11-.9-2-2-2zm0 4h-2V7h2v2z"></path></g> <g id="filter-9-plus"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm11 7V8c0-1.11-.9-2-2-2h-1c-1.1 0-2 .89-2 2v1c0 1.11.9 2 2 2h1v1H9v2h3c1.1 0 2-.89 2-2zm-3-3V8h1v1h-1zm10-8H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 8h-2V7h-2v2h-2v2h2v2h2v-2h2v6H7V3h14v6z"></path></g> <g id="filter-b-and-w"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16l-7-8v8H5l7-8V5h7v14z"></path></g> <g id="filter-center-focus"><path d="M5 15H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zM12 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"></path></g> <g id="filter-drama"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.61 5.64 5.36 8.04 2.35 8.36 0 10.9 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4h2c0-2.76-1.86-5.08-4.4-5.78C8.61 6.88 10.2 6 12 6c3.03 0 5.5 2.47 5.5 5.5v.5H19c1.65 0 3 1.35 3 3s-1.35 3-3 3z"></path></g> <g id="filter-frames"><path d="M20 4h-4l-4-4-4 4H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H4V6h4.52l3.52-3.5L15.52 6H20v14zM18 8H6v10h12"></path></g> <g id="filter-hdr"><path d="M14 6l-3.75 5 2.85 3.8-1.6 1.2C9.81 13.75 7 10 7 10l-6 8h22L14 6z"></path></g> <g id="filter-none"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"></path></g> <g id="filter-tilt-shift"><path d="M11 4.07V2.05c-2.01.2-3.84 1-5.32 2.21L7.1 5.69c1.11-.86 2.44-1.44 3.9-1.62zm7.32.19C16.84 3.05 15.01 2.25 13 2.05v2.02c1.46.18 2.79.76 3.9 1.62l1.42-1.43zM19.93 11h2.02c-.2-2.01-1-3.84-2.21-5.32L18.31 7.1c.86 1.11 1.44 2.44 1.62 3.9zM5.69 7.1L4.26 5.68C3.05 7.16 2.25 8.99 2.05 11h2.02c.18-1.46.76-2.79 1.62-3.9zM4.07 13H2.05c.2 2.01 1 3.84 2.21 5.32l1.43-1.43c-.86-1.1-1.44-2.43-1.62-3.89zM15 12c0-1.66-1.34-3-3-3s-3 1.34-3 3 1.34 3 3 3 3-1.34 3-3zm3.31 4.9l1.43 1.43c1.21-1.48 2.01-3.32 2.21-5.32h-2.02c-.18 1.45-.76 2.78-1.62 3.89zM13 19.93v2.02c2.01-.2 3.84-1 5.32-2.21l-1.43-1.43c-1.1.86-2.43 1.44-3.89 1.62zm-7.32-.19C7.16 20.95 9 21.75 11 21.95v-2.02c-1.46-.18-2.79-.76-3.9-1.62l-1.42 1.43z"></path></g> <g id="filter-vintage"><path d="M18.7 12.4c-.28-.16-.57-.29-.86-.4.29-.11.58-.24.86-.4 1.92-1.11 2.99-3.12 3-5.19-1.79-1.03-4.07-1.11-6 0-.28.16-.54.35-.78.54.05-.31.08-.63.08-.95 0-2.22-1.21-4.15-3-5.19C10.21 1.85 9 3.78 9 6c0 .32.03.64.08.95-.24-.2-.5-.39-.78-.55-1.92-1.11-4.2-1.03-6 0 0 2.07 1.07 4.08 3 5.19.28.16.57.29.86.4-.29.11-.58.24-.86.4-1.92 1.11-2.99 3.12-3 5.19 1.79 1.03 4.07 1.11 6 0 .28-.16.54-.35.78-.54-.05.32-.08.64-.08.96 0 2.22 1.21 4.15 3 5.19 1.79-1.04 3-2.97 3-5.19 0-.32-.03-.64-.08-.95.24.2.5.38.78.54 1.92 1.11 4.2 1.03 6 0-.01-2.07-1.08-4.08-3-5.19zM12 16c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"></path></g> <g id="flare"><path d="M7 11H1v2h6v-2zm2.17-3.24L7.05 5.64 5.64 7.05l2.12 2.12 1.41-1.41zM13 1h-2v6h2V1zm5.36 6.05l-1.41-1.41-2.12 2.12 1.41 1.41 2.12-2.12zM17 11v2h6v-2h-6zm-5-2c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zm2.83 7.24l2.12 2.12 1.41-1.41-2.12-2.12-1.41 1.41zm-9.19.71l1.41 1.41 2.12-2.12-1.41-1.41-2.12 2.12zM11 23h2v-6h-2v6z"></path></g> <g id="flash-auto"><path d="M3 2v12h3v9l7-12H9l4-9H3zm16 0h-2l-3.2 9h1.9l.7-2h3.2l.7 2h1.9L19 2zm-2.15 5.65L18 4l1.15 3.65h-2.3z"></path></g> <g id="flash-off"><path d="M3.27 3L2 4.27l5 5V13h3v9l3.58-6.14L17.73 20 19 18.73 3.27 3zM17 10h-4l4-8H7v2.18l8.46 8.46L17 10z"></path></g> <g id="flash-on"><path d="M7 2v11h3v9l7-12h-4l4-8z"></path></g> <g id="flip"><path d="M15 21h2v-2h-2v2zm4-12h2V7h-2v2zM3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2zm16-2v2h2c0-1.1-.9-2-2-2zm-8 20h2V1h-2v22zm8-6h2v-2h-2v2zM15 5h2V3h-2v2zm4 8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2z"></path></g> <g id="gradient"><path d="M11 9h2v2h-2zm-2 2h2v2H9zm4 0h2v2h-2zm2-2h2v2h-2zM7 9h2v2H7zm12-6H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 18H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm2-7h-2v2h2v2h-2v-2h-2v2h-2v-2h-2v2H9v-2H7v2H5v-2h2v-2H5V5h14v6z"></path></g> <g id="grain"><path d="M10 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM6 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12-8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm-4 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm4-4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-4-4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-4-4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></g> <g id="grid-off"><path d="M8 4v1.45l2 2V4h4v4h-3.45l2 2H14v1.45l2 2V10h4v4h-3.45l2 2H20v1.45l2 2V4c0-1.1-.9-2-2-2H4.55l2 2H8zm8 0h4v4h-4V4zM1.27 1.27L0 2.55l2 2V20c0 1.1.9 2 2 2h15.46l2 2 1.27-1.27L1.27 1.27zM10 12.55L11.45 14H10v-1.45zm-6-6L5.45 8H4V6.55zM8 20H4v-4h4v4zm0-6H4v-4h3.45l.55.55V14zm6 6h-4v-4h3.45l.55.54V20zm2 0v-1.46L17.46 20H16z"></path></g> <g id="grid-on"><path d="M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"></path></g> <g id="hdr-off"><path d="M17.5 15v-2h1.1l.9 2H21l-.9-2.1c.5-.2.9-.8.9-1.4v-1c0-.8-.7-1.5-1.5-1.5H16v4.9l1.1 1.1h.4zm0-4.5h2v1h-2v-1zm-4.5 0v.4l1.5 1.5v-1.9c0-.8-.7-1.5-1.5-1.5h-1.9l1.5 1.5h.4zm-3.5-1l-7-7-1.1 1L6.9 9h-.4v2h-2V9H3v6h1.5v-2.5h2V15H8v-4.9l1.5 1.5V15h3.4l7.6 7.6 1.1-1.1-12.1-12z"></path></g> <g id="hdr-on"><path d="M21 11.5v-1c0-.8-.7-1.5-1.5-1.5H16v6h1.5v-2h1.1l.9 2H21l-.9-2.1c.5-.3.9-.8.9-1.4zm-1.5 0h-2v-1h2v1zm-13-.5h-2V9H3v6h1.5v-2.5h2V15H8V9H6.5v2zM13 9H9.5v6H13c.8 0 1.5-.7 1.5-1.5v-3c0-.8-.7-1.5-1.5-1.5zm0 4.5h-2v-3h2v3z"></path></g> <g id="hdr-strong"><path d="M17 6c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zM5 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></g> <g id="hdr-weak"><path d="M5 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm12-2c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm0 10c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"></path></g> <g id="healing"><path d="M17.73 12.02l3.98-3.98c.39-.39.39-1.02 0-1.41l-4.34-4.34c-.39-.39-1.02-.39-1.41 0l-3.98 3.98L8 2.29C7.8 2.1 7.55 2 7.29 2c-.25 0-.51.1-.7.29L2.25 6.63c-.39.39-.39 1.02 0 1.41l3.98 3.98L2.25 16c-.39.39-.39 1.02 0 1.41l4.34 4.34c.39.39 1.02.39 1.41 0l3.98-3.98 3.98 3.98c.2.2.45.29.71.29.26 0 .51-.1.71-.29l4.34-4.34c.39-.39.39-1.02 0-1.41l-3.99-3.98zM12 9c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm-4.71 1.96L3.66 7.34l3.63-3.63 3.62 3.62-3.62 3.63zM10 13c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm2 2c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm2-4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm2.66 9.34l-3.63-3.62 3.63-3.63 3.62 3.62-3.62 3.63z"></path></g> <g id="image"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"></path></g> <g id="image-aspect-ratio"><path d="M16 10h-2v2h2v-2zm0 4h-2v2h2v-2zm-8-4H6v2h2v-2zm4 0h-2v2h2v-2zm8-6H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V6h16v12z"></path></g> <g id="iso"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5.5 7.5h2v-2H9v2h2V9H9v2H7.5V9h-2V7.5zM19 19H5L19 5v14zm-2-2v-1.5h-5V17h5z"></path></g> <g id="landscape"><path d="M14 6l-3.75 5 2.85 3.8-1.6 1.2C9.81 13.75 7 10 7 10l-6 8h22L14 6z"></path></g> <g id="leak-add"><path d="M6 3H3v3c1.66 0 3-1.34 3-3zm8 0h-2c0 4.97-4.03 9-9 9v2c6.08 0 11-4.93 11-11zm-4 0H8c0 2.76-2.24 5-5 5v2c3.87 0 7-3.13 7-7zm0 18h2c0-4.97 4.03-9 9-9v-2c-6.07 0-11 4.93-11 11zm8 0h3v-3c-1.66 0-3 1.34-3 3zm-4 0h2c0-2.76 2.24-5 5-5v-2c-3.87 0-7 3.13-7 7z"></path></g> <g id="leak-remove"><path d="M10 3H8c0 .37-.04.72-.12 1.06l1.59 1.59C9.81 4.84 10 3.94 10 3zM3 4.27l2.84 2.84C5.03 7.67 4.06 8 3 8v2c1.61 0 3.09-.55 4.27-1.46L8.7 9.97C7.14 11.24 5.16 12 3 12v2c2.71 0 5.19-.99 7.11-2.62l2.5 2.5C10.99 15.81 10 18.29 10 21h2c0-2.16.76-4.14 2.03-5.69l1.43 1.43C14.55 17.91 14 19.39 14 21h2c0-1.06.33-2.03.89-2.84L19.73 21 21 19.73 4.27 3 3 4.27zM14 3h-2c0 1.5-.37 2.91-1.02 4.16l1.46 1.46C13.42 6.98 14 5.06 14 3zm5.94 13.12c.34-.08.69-.12 1.06-.12v-2c-.94 0-1.84.19-2.66.52l1.6 1.6zm-4.56-4.56l1.46 1.46C18.09 12.37 19.5 12 21 12v-2c-2.06 0-3.98.58-5.62 1.56z"></path></g> <g id="lens"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"></path></g> <g id="linked-camera"><circle cx="12" cy="14" r="3.2"></circle><path d="M16 3.33c2.58 0 4.67 2.09 4.67 4.67H22c0-3.31-2.69-6-6-6v1.33M16 6c1.11 0 2 .89 2 2h1.33c0-1.84-1.49-3.33-3.33-3.33V6"></path><path d="M17 9c0-1.11-.89-2-2-2V4H9L7.17 6H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V9h-5zm-5 10c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path></g> <g id="looks"><path d="M12 10c-3.86 0-7 3.14-7 7h2c0-2.76 2.24-5 5-5s5 2.24 5 5h2c0-3.86-3.14-7-7-7zm0-4C5.93 6 1 10.93 1 17h2c0-4.96 4.04-9 9-9s9 4.04 9 9h2c0-6.07-4.93-11-11-11z"></path></g> <g id="looks-3"><path d="M19.01 3h-14c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 7.5c0 .83-.67 1.5-1.5 1.5.83 0 1.5.67 1.5 1.5V15c0 1.11-.9 2-2 2h-4v-2h4v-2h-2v-2h2V9h-4V7h4c1.1 0 2 .89 2 2v1.5z"></path></g> <g id="looks-4"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 14h-2v-4H9V7h2v4h2V7h2v10z"></path></g> <g id="looks-5"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 6h-4v2h2c1.1 0 2 .89 2 2v2c0 1.11-.9 2-2 2H9v-2h4v-2H9V7h6v2z"></path></g> <g id="looks-6"><path d="M11 15h2v-2h-2v2zm8-12H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 6h-4v2h2c1.1 0 2 .89 2 2v2c0 1.11-.9 2-2 2h-2c-1.1 0-2-.89-2-2V9c0-1.11.9-2 2-2h4v2z"></path></g> <g id="looks-one"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14h-2V9h-2V7h4v10z"></path></g> <g id="looks-two"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 8c0 1.11-.9 2-2 2h-2v2h4v2H9v-4c0-1.11.9-2 2-2h2V9H9V7h4c1.1 0 2 .89 2 2v2z"></path></g> <g id="loupe"><path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.49 2 2 6.49 2 12s4.49 10 10 10h8c1.1 0 2-.9 2-2v-8c0-5.51-4.49-10-10-10zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g> <g id="monochrome-photos"><path d="M20 5h-3.2L15 3H9L7.2 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 14h-8v-1c-2.8 0-5-2.2-5-5s2.2-5 5-5V7h8v12zm-3-6c0-2.8-2.2-5-5-5v1.8c1.8 0 3.2 1.4 3.2 3.2s-1.4 3.2-3.2 3.2V18c2.8 0 5-2.2 5-5zm-8.2 0c0 1.8 1.4 3.2 3.2 3.2V9.8c-1.8 0-3.2 1.4-3.2 3.2z"></path></g> <g id="movie-creation"><path d="M18 4l2 4h-3l-2-4h-2l2 4h-3l-2-4H8l2 4H7L5 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4h-4z"></path></g> <g id="movie-filter"><path d="M18 4l2 3h-3l-2-3h-2l2 3h-3l-2-3H8l2 3H7L5 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4h-4zm-6.75 11.25L10 18l-1.25-2.75L6 14l2.75-1.25L10 10l1.25 2.75L14 14l-2.75 1.25zm5.69-3.31L16 14l-.94-2.06L13 11l2.06-.94L16 8l.94 2.06L19 11l-2.06.94z"></path></g> <g id="music-note"><path d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"></path></g> <g id="nature"><path d="M13 16.12c3.47-.41 6.17-3.36 6.17-6.95 0-3.87-3.13-7-7-7s-7 3.13-7 7c0 3.47 2.52 6.34 5.83 6.89V20H5v2h14v-2h-6v-3.88z"></path></g> <g id="nature-people"><path d="M22.17 9.17c0-3.87-3.13-7-7-7s-7 3.13-7 7c0 3.47 2.52 6.34 5.83 6.89V20H6v-3h1v-4c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v4h1v5h16v-2h-3v-3.88c3.47-.41 6.17-3.36 6.17-6.95zM4.5 11c.83 0 1.5-.67 1.5-1.5S5.33 8 4.5 8 3 8.67 3 9.5 3.67 11 4.5 11z"></path></g> <g id="navigate-before"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path></g> <g id="navigate-next"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g> <g id="palette"><path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></g> <g id="panorama"><path d="M23 18V6c0-1.1-.9-2-2-2H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zM8.5 12.5l2.5 3.01L14.5 11l4.5 6H5l3.5-4.5z"></path></g> <g id="panorama-fish-eye"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g> <g id="panorama-horizontal"><path d="M20 6.54v10.91c-2.6-.77-5.28-1.16-8-1.16-2.72 0-5.4.39-8 1.16V6.54c2.6.77 5.28 1.16 8 1.16 2.72.01 5.4-.38 8-1.16M21.43 4c-.1 0-.2.02-.31.06C18.18 5.16 15.09 5.7 12 5.7c-3.09 0-6.18-.55-9.12-1.64-.11-.04-.22-.06-.31-.06-.34 0-.57.23-.57.63v14.75c0 .39.23.62.57.62.1 0 .2-.02.31-.06 2.94-1.1 6.03-1.64 9.12-1.64 3.09 0 6.18.55 9.12 1.64.11.04.21.06.31.06.33 0 .57-.23.57-.63V4.63c0-.4-.24-.63-.57-.63z"></path></g> <g id="panorama-vertical"><path d="M19.94 21.12c-1.1-2.94-1.64-6.03-1.64-9.12 0-3.09.55-6.18 1.64-9.12.04-.11.06-.22.06-.31 0-.34-.23-.57-.63-.57H4.63c-.4 0-.63.23-.63.57 0 .1.02.2.06.31C5.16 5.82 5.71 8.91 5.71 12c0 3.09-.55 6.18-1.64 9.12-.05.11-.07.22-.07.31 0 .33.23.57.63.57h14.75c.39 0 .63-.24.63-.57-.01-.1-.03-.2-.07-.31zM6.54 20c.77-2.6 1.16-5.28 1.16-8 0-2.72-.39-5.4-1.16-8h10.91c-.77 2.6-1.16 5.28-1.16 8 0 2.72.39 5.4 1.16 8H6.54z"></path></g> <g id="panorama-wide-angle"><path d="M12 6c2.45 0 4.71.2 7.29.64.47 1.78.71 3.58.71 5.36 0 1.78-.24 3.58-.71 5.36-2.58.44-4.84.64-7.29.64s-4.71-.2-7.29-.64C4.24 15.58 4 13.78 4 12c0-1.78.24-3.58.71-5.36C7.29 6.2 9.55 6 12 6m0-2c-2.73 0-5.22.24-7.95.72l-.93.16-.25.9C2.29 7.85 2 9.93 2 12s.29 4.15.87 6.22l.25.89.93.16c2.73.49 5.22.73 7.95.73s5.22-.24 7.95-.72l.93-.16.25-.89c.58-2.08.87-4.16.87-6.23s-.29-4.15-.87-6.22l-.25-.89-.93-.16C17.22 4.24 14.73 4 12 4z"></path></g> <g id="photo"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"></path></g> <g id="photo-album"><path d="M18 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 4h5v8l-2.5-1.5L6 12V4zm0 15l3-3.86 2.14 2.58 3-3.86L18 19H6z"></path></g> <g id="photo-camera"><circle cx="12" cy="12" r="3.2"></circle><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path></g> <g id="photo-filter"><path d="M19.02 10v9H5V5h9V3H5.02c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-9h-2zM17 10l.94-2.06L20 7l-2.06-.94L17 4l-.94 2.06L14 7l2.06.94zm-3.75.75L12 8l-1.25 2.75L8 12l2.75 1.25L12 16l1.25-2.75L16 12z"></path></g> <g id="photo-library"><path d="M22 16V4c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2zm-11-4l2.03 2.71L16 11l4 5H8l3-4zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"></path></g> <g id="photo-size-select-actual"><path d="M21 3H3C2 3 1 4 1 5v14c0 1.1.9 2 2 2h18c1 0 2-1 2-2V5c0-1-1-2-2-2zM5 17l3.5-4.5 2.5 3.01L14.5 11l4.5 6H5z"></path></g> <g id="photo-size-select-large"><path d="M21 15h2v2h-2v-2zm0-4h2v2h-2v-2zm2 8h-2v2c1 0 2-1 2-2zM13 3h2v2h-2V3zm8 4h2v2h-2V7zm0-4v2h2c0-1-1-2-2-2zM1 7h2v2H1V7zm16-4h2v2h-2V3zm0 16h2v2h-2v-2zM3 3C2 3 1 4 1 5h2V3zm6 0h2v2H9V3zM5 3h2v2H5V3zm-4 8v8c0 1.1.9 2 2 2h12V11H1zm2 8l2.5-3.21 1.79 2.15 2.5-3.22L13 19H3z"></path></g> <g id="photo-size-select-small"><path d="M23 15h-2v2h2v-2zm0-4h-2v2h2v-2zm0 8h-2v2c1 0 2-1 2-2zM15 3h-2v2h2V3zm8 4h-2v2h2V7zm-2-4v2h2c0-1-1-2-2-2zM3 21h8v-6H1v4c0 1.1.9 2 2 2zM3 7H1v2h2V7zm12 12h-2v2h2v-2zm4-16h-2v2h2V3zm0 16h-2v2h2v-2zM3 3C2 3 1 4 1 5h2V3zm0 8H1v2h2v-2zm8-8H9v2h2V3zM7 3H5v2h2V3z"></path></g> <g id="picture-as-pdf"><path d="M20 2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-8.5 7.5c0 .83-.67 1.5-1.5 1.5H9v2H7.5V7H10c.83 0 1.5.67 1.5 1.5v1zm5 2c0 .83-.67 1.5-1.5 1.5h-2.5V7H15c.83 0 1.5.67 1.5 1.5v3zm4-3H19v1h1.5V11H19v2h-1.5V7h3v1.5zM9 9.5h1v-1H9v1zM4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm10 5.5h1v-3h-1v3z"></path></g> <g id="portrait"><path d="M12 12.25c1.24 0 2.25-1.01 2.25-2.25S13.24 7.75 12 7.75 9.75 8.76 9.75 10s1.01 2.25 2.25 2.25zm4.5 4c0-1.5-3-2.25-4.5-2.25s-4.5.75-4.5 2.25V17h9v-.75zM19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"></path></g> <g id="remove-red-eye"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"></path></g> <g id="rotate-90-degrees-ccw"><path d="M7.34 6.41L.86 12.9l6.49 6.48 6.49-6.48-6.5-6.49zM3.69 12.9l3.66-3.66L11 12.9l-3.66 3.66-3.65-3.66zm15.67-6.26C17.61 4.88 15.3 4 13 4V.76L8.76 5 13 9.24V6c1.79 0 3.58.68 4.95 2.05 2.73 2.73 2.73 7.17 0 9.9C16.58 19.32 14.79 20 13 20c-.97 0-1.94-.21-2.84-.61l-1.49 1.49C10.02 21.62 11.51 22 13 22c2.3 0 4.61-.88 6.36-2.64 3.52-3.51 3.52-9.21 0-12.72z"></path></g> <g id="rotate-left"><path d="M7.11 8.53L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47zM6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47zm1.01 5.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32zM13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93z"></path></g> <g id="rotate-right"><path d="M15.55 5.55L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42l1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"></path></g> <g id="slideshow"><path d="M10 8v8l5-4-5-4zm9-5H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"></path></g> <g id="straighten"><path d="M21 6H3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 10H3V8h2v4h2V8h2v4h2V8h2v4h2V8h2v4h2V8h2v8z"></path></g> <g id="style"><path d="M2.53 19.65l1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zM7.88 8.75c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-2 11c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"></path></g> <g id="switch-camera"><path d="M20 4h-3.17L15 2H9L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-5 11.5V13H9v2.5L5.5 12 9 8.5V11h6V8.5l3.5 3.5-3.5 3.5z"></path></g> <g id="switch-video"><path d="M18 9.5V6c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3.5l4 4v-13l-4 4zm-5 6V13H7v2.5L3.5 12 7 8.5V11h6V8.5l3.5 3.5-3.5 3.5z"></path></g> <g id="tag-faces"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"></path></g> <g id="texture"><path d="M19.51 3.08L3.08 19.51c.09.34.27.65.51.9.25.24.56.42.9.51L20.93 4.49c-.19-.69-.73-1.23-1.42-1.41zM11.88 3L3 11.88v2.83L14.71 3h-2.83zM5 3c-1.1 0-2 .9-2 2v2l4-4H5zm14 18c.55 0 1.05-.22 1.41-.59.37-.36.59-.86.59-1.41v-2l-4 4h2zm-9.71 0h2.83L21 12.12V9.29L9.29 21z"></path></g> <g id="timelapse"><path d="M16.24 7.76C15.07 6.59 13.54 6 12 6v6l-4.24 4.24c2.34 2.34 6.14 2.34 8.49 0 2.34-2.34 2.34-6.14-.01-8.48zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g> <g id="timer"><path d="M15 1H9v2h6V1zm-4 13h2V8h-2v6zm8.03-6.61l1.42-1.42c-.43-.51-.9-.99-1.41-1.41l-1.42 1.42C16.07 4.74 14.12 4 12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9 9-4.03 9-9c0-2.12-.74-4.07-1.97-5.61zM12 20c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"></path></g> <g id="timer-10"><path d="M0 7.72V9.4l3-1V18h2V6h-.25L0 7.72zm23.78 6.65c-.14-.28-.35-.53-.63-.74-.28-.21-.61-.39-1.01-.53s-.85-.27-1.35-.38c-.35-.07-.64-.15-.87-.23-.23-.08-.41-.16-.55-.25-.14-.09-.23-.19-.28-.3-.05-.11-.08-.24-.08-.39 0-.14.03-.28.09-.41.06-.13.15-.25.27-.34.12-.1.27-.18.45-.24s.4-.09.64-.09c.25 0 .47.04.66.11.19.07.35.17.48.29.13.12.22.26.29.42.06.16.1.32.1.49h1.95c0-.39-.08-.75-.24-1.09-.16-.34-.39-.63-.69-.88-.3-.25-.66-.44-1.09-.59C21.49 9.07 21 9 20.46 9c-.51 0-.98.07-1.39.21-.41.14-.77.33-1.06.57-.29.24-.51.52-.67.84-.16.32-.23.65-.23 1.01s.08.69.23.96c.15.28.36.52.64.73.27.21.6.38.98.53.38.14.81.26 1.27.36.39.08.71.17.95.26s.43.19.57.29c.13.1.22.22.27.34.05.12.07.25.07.39 0 .32-.13.57-.4.77-.27.2-.66.29-1.17.29-.22 0-.43-.02-.64-.08-.21-.05-.4-.13-.56-.24-.17-.11-.3-.26-.41-.44-.11-.18-.17-.41-.18-.67h-1.89c0 .36.08.71.24 1.05.16.34.39.65.7.93.31.27.69.49 1.15.66.46.17.98.25 1.58.25.53 0 1.01-.06 1.44-.19.43-.13.8-.31 1.11-.54.31-.23.54-.51.71-.83.17-.32.25-.67.25-1.06-.02-.4-.09-.74-.24-1.02zm-9.96-7.32c-.34-.4-.75-.7-1.23-.88-.47-.18-1.01-.27-1.59-.27-.58 0-1.11.09-1.59.27-.48.18-.89.47-1.23.88-.34.41-.6.93-.79 1.59-.18.65-.28 1.45-.28 2.39v1.92c0 .94.09 1.74.28 2.39.19.66.45 1.19.8 1.6.34.41.75.71 1.23.89.48.18 1.01.28 1.59.28.59 0 1.12-.09 1.59-.28.48-.18.88-.48 1.22-.89.34-.41.6-.94.78-1.6.18-.65.28-1.45.28-2.39v-1.92c0-.94-.09-1.74-.28-2.39-.18-.66-.44-1.19-.78-1.59zm-.92 6.17c0 .6-.04 1.11-.12 1.53-.08.42-.2.76-.36 1.02-.16.26-.36.45-.59.57-.23.12-.51.18-.82.18-.3 0-.58-.06-.82-.18s-.44-.31-.6-.57c-.16-.26-.29-.6-.38-1.02-.09-.42-.13-.93-.13-1.53v-2.5c0-.6.04-1.11.13-1.52.09-.41.21-.74.38-1 .16-.25.36-.43.6-.55.24-.11.51-.17.81-.17.31 0 .58.06.81.17.24.11.44.29.6.55.16.25.29.58.37.99.08.41.13.92.13 1.52v2.51z"></path></g> <g id="timer-3"><path d="M11.61 12.97c-.16-.24-.36-.46-.62-.65-.25-.19-.56-.35-.93-.48.3-.14.57-.3.8-.5.23-.2.42-.41.57-.64.15-.23.27-.46.34-.71.08-.24.11-.49.11-.73 0-.55-.09-1.04-.28-1.46-.18-.42-.44-.77-.78-1.06-.33-.28-.73-.5-1.2-.64-.45-.13-.97-.2-1.53-.2-.55 0-1.06.08-1.52.24-.47.17-.87.4-1.2.69-.33.29-.6.63-.78 1.03-.2.39-.29.83-.29 1.29h1.98c0-.26.05-.49.14-.69.09-.2.22-.38.38-.52.17-.14.36-.25.58-.33.22-.08.46-.12.73-.12.61 0 1.06.16 1.36.47.3.31.44.75.44 1.32 0 .27-.04.52-.12.74-.08.22-.21.41-.38.57-.17.16-.38.28-.63.37-.25.09-.55.13-.89.13H6.72v1.57H7.9c.34 0 .64.04.91.11.27.08.5.19.69.35.19.16.34.36.44.61.1.24.16.54.16.87 0 .62-.18 1.09-.53 1.42-.35.33-.84.49-1.45.49-.29 0-.56-.04-.8-.13-.24-.08-.44-.2-.61-.36-.17-.16-.3-.34-.39-.56-.09-.22-.14-.46-.14-.72H4.19c0 .55.11 1.03.32 1.45.21.42.5.77.86 1.05s.77.49 1.24.63.96.21 1.48.21c.57 0 1.09-.08 1.58-.23.49-.15.91-.38 1.26-.68.36-.3.64-.66.84-1.1.2-.43.3-.93.3-1.48 0-.29-.04-.58-.11-.86-.08-.25-.19-.51-.35-.76zm9.26 1.4c-.14-.28-.35-.53-.63-.74-.28-.21-.61-.39-1.01-.53s-.85-.27-1.35-.38c-.35-.07-.64-.15-.87-.23-.23-.08-.41-.16-.55-.25-.14-.09-.23-.19-.28-.3-.05-.11-.08-.24-.08-.39s.03-.28.09-.41c.06-.13.15-.25.27-.34.12-.1.27-.18.45-.24s.4-.09.64-.09c.25 0 .47.04.66.11.19.07.35.17.48.29.13.12.22.26.29.42.06.16.1.32.1.49h1.95c0-.39-.08-.75-.24-1.09-.16-.34-.39-.63-.69-.88-.3-.25-.66-.44-1.09-.59-.43-.15-.92-.22-1.46-.22-.51 0-.98.07-1.39.21-.41.14-.77.33-1.06.57-.29.24-.51.52-.67.84-.16.32-.23.65-.23 1.01s.08.68.23.96c.15.28.37.52.64.73.27.21.6.38.98.53.38.14.81.26 1.27.36.39.08.71.17.95.26s.43.19.57.29c.13.1.22.22.27.34.05.12.07.25.07.39 0 .32-.13.57-.4.77-.27.2-.66.29-1.17.29-.22 0-.43-.02-.64-.08-.21-.05-.4-.13-.56-.24-.17-.11-.3-.26-.41-.44-.11-.18-.17-.41-.18-.67h-1.89c0 .36.08.71.24 1.05.16.34.39.65.7.93.31.27.69.49 1.15.66.46.17.98.25 1.58.25.53 0 1.01-.06 1.44-.19.43-.13.8-.31 1.11-.54.31-.23.54-.51.71-.83.17-.32.25-.67.25-1.06-.02-.4-.09-.74-.24-1.02z"></path></g> <g id="timer-off"><path d="M19.04 4.55l-1.42 1.42C16.07 4.74 14.12 4 12 4c-1.83 0-3.53.55-4.95 1.48l1.46 1.46C9.53 6.35 10.73 6 12 6c3.87 0 7 3.13 7 7 0 1.27-.35 2.47-.94 3.49l1.45 1.45C20.45 16.53 21 14.83 21 13c0-2.12-.74-4.07-1.97-5.61l1.42-1.42-1.41-1.42zM15 1H9v2h6V1zm-4 8.44l2 2V8h-2v1.44zM3.02 4L1.75 5.27 4.5 8.03C3.55 9.45 3 11.16 3 13c0 4.97 4.02 9 9 9 1.84 0 3.55-.55 4.98-1.5l2.5 2.5 1.27-1.27-7.71-7.71L3.02 4zM12 20c-3.87 0-7-3.13-7-7 0-1.28.35-2.48.95-3.52l9.56 9.56c-1.03.61-2.23.96-3.51.96z"></path></g> <g id="tonality"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.94-.49-7-3.85-7-7.93s3.05-7.44 7-7.93v15.86zm2-15.86c1.03.13 2 .45 2.87.93H13v-.93zM13 7h5.24c.25.31.48.65.68 1H13V7zm0 3h6.74c.08.33.15.66.19 1H13v-1zm0 9.93V19h2.87c-.87.48-1.84.8-2.87.93zM18.24 17H13v-1h5.92c-.2.35-.43.69-.68 1zm1.5-3H13v-1h6.93c-.04.34-.11.67-.19 1z"></path></g> <g id="transform"><path d="M22 18v-2H8V4h2L7 1 4 4h2v2H2v2h4v8c0 1.1.9 2 2 2h8v2h-2l3 3 3-3h-2v-2h4zM10 8h6v6h2V8c0-1.1-.9-2-2-2h-6v2z"></path></g> <g id="tune"><path d="M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"></path></g> <g id="view-comfy"><path d="M3 9h4V5H3v4zm0 5h4v-4H3v4zm5 0h4v-4H8v4zm5 0h4v-4h-4v4zM8 9h4V5H8v4zm5-4v4h4V5h-4zm5 9h4v-4h-4v4zM3 19h4v-4H3v4zm5 0h4v-4H8v4zm5 0h4v-4h-4v4zm5 0h4v-4h-4v4zm0-14v4h4V5h-4z"></path></g> <g id="view-compact"><path d="M3 19h6v-7H3v7zm7 0h12v-7H10v7zM3 5v6h19V5H3z"></path></g> <g id="vignette"><path d="M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-9 15c-4.42 0-8-2.69-8-6s3.58-6 8-6 8 2.69 8 6-3.58 6-8 6z"></path></g> <g id="wb-auto"><path d="M6.85 12.65h2.3L8 9l-1.15 3.65zM22 7l-1.2 6.29L19.3 7h-1.6l-1.49 6.29L15 7h-.76C12.77 5.17 10.53 4 8 4c-4.42 0-8 3.58-8 8s3.58 8 8 8c3.13 0 5.84-1.81 7.15-4.43l.1.43H17l1.5-6.1L20 16h1.75l2.05-9H22zm-11.7 9l-.7-2H6.4l-.7 2H3.8L7 7h2l3.2 9h-1.9z"></path></g> <g id="wb-cloudy"><path d="M19.36 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.64-4.96z"></path></g> <g id="wb-incandescent"><path d="M3.55 18.54l1.41 1.41 1.79-1.8-1.41-1.41-1.79 1.8zM11 22.45h2V19.5h-2v2.95zM4 10.5H1v2h3v-2zm11-4.19V1.5H9v4.81C7.21 7.35 6 9.28 6 11.5c0 3.31 2.69 6 6 6s6-2.69 6-6c0-2.22-1.21-4.15-3-5.19zm5 4.19v2h3v-2h-3zm-2.76 7.66l1.79 1.8 1.41-1.41-1.8-1.79-1.4 1.4z"></path></g> <g id="wb-iridescent"><path d="M5 14.5h14v-6H5v6zM11 .55V3.5h2V.55h-2zm8.04 2.5l-1.79 1.79 1.41 1.41 1.8-1.79-1.42-1.41zM13 22.45V19.5h-2v2.95h2zm7.45-3.91l-1.8-1.79-1.41 1.41 1.79 1.8 1.42-1.42zM3.55 4.46l1.79 1.79 1.41-1.41-1.79-1.79-1.41 1.41zm1.41 15.49l1.79-1.8-1.41-1.41-1.79 1.79 1.41 1.42z"></path></g> <g id="wb-sunny"><path d="M6.76 4.84l-1.8-1.79-1.41 1.41 1.79 1.79 1.42-1.41zM4 10.5H1v2h3v-2zm9-9.95h-2V3.5h2V.55zm7.45 3.91l-1.41-1.41-1.79 1.79 1.41 1.41 1.79-1.79zm-3.21 13.7l1.79 1.8 1.41-1.41-1.8-1.79-1.4 1.4zM20 10.5v2h3v-2h-3zm-8-5c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm-1 16.95h2V19.5h-2v2.95zm-7.45-3.91l1.41 1.41 1.79-1.8-1.41-1.41-1.79 1.8z"></path></g> </defs></svg> </iron-iconset-svg>`;document.head.appendChild(template$l.content); /** @license Copyright (c) 2014 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$k=html`<iron-iconset-svg name="icons" size="24"> <svg><defs> <g id="3d-rotation"><path d="M7.52 21.48C4.25 19.94 1.91 16.76 1.55 13H.05C.56 19.16 5.71 24 12 24l.66-.03-3.81-3.81-1.33 1.32zm.89-6.52c-.19 0-.37-.03-.52-.08-.16-.06-.29-.13-.4-.24-.11-.1-.2-.22-.26-.37-.06-.14-.09-.3-.09-.47h-1.3c0 .36.07.68.21.95.14.27.33.5.56.69.24.18.51.32.82.41.3.1.62.15.96.15.37 0 .72-.05 1.03-.15.32-.1.6-.25.83-.44s.42-.43.55-.72c.13-.29.2-.61.2-.97 0-.19-.02-.38-.07-.56-.05-.18-.12-.35-.23-.51-.1-.16-.24-.3-.4-.43-.17-.13-.37-.23-.61-.31.2-.09.37-.2.52-.33.15-.13.27-.27.37-.42.1-.15.17-.3.22-.46.05-.16.07-.32.07-.48 0-.36-.06-.68-.18-.96-.12-.28-.29-.51-.51-.69-.2-.19-.47-.33-.77-.43C9.1 8.05 8.76 8 8.39 8c-.36 0-.69.05-1 .16-.3.11-.57.26-.79.45-.21.19-.38.41-.51.67-.12.26-.18.54-.18.85h1.3c0-.17.03-.32.09-.45s.14-.25.25-.34c.11-.09.23-.17.38-.22.15-.05.3-.08.48-.08.4 0 .7.1.89.31.19.2.29.49.29.86 0 .18-.03.34-.08.49-.05.15-.14.27-.25.37-.11.1-.25.18-.41.24-.16.06-.36.09-.58.09H7.5v1.03h.77c.22 0 .42.02.6.07s.33.13.45.23c.12.11.22.24.29.4.07.16.1.35.1.57 0 .41-.12.72-.35.93-.23.23-.55.33-.95.33zm8.55-5.92c-.32-.33-.7-.59-1.14-.77-.43-.18-.92-.27-1.46-.27H12v8h2.3c.55 0 1.06-.09 1.51-.27.45-.18.84-.43 1.16-.76.32-.33.57-.73.74-1.19.17-.47.26-.99.26-1.57v-.4c0-.58-.09-1.1-.26-1.57-.18-.47-.43-.87-.75-1.2zm-.39 3.16c0 .42-.05.79-.14 1.13-.1.33-.24.62-.43.85-.19.23-.43.41-.71.53-.29.12-.62.18-.99.18h-.91V9.12h.97c.72 0 1.27.23 1.64.69.38.46.57 1.12.57 1.99v.4zM12 0l-.66.03 3.81 3.81 1.33-1.33c3.27 1.55 5.61 4.72 5.96 8.48h1.5C23.44 4.84 18.29 0 12 0z"></path></g> <g id="accessibility"><path d="M12 2c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm9 7h-6v13h-2v-6h-2v6H9V9H3V7h18v2z"></path></g> <g id="accessible"><circle cx="12" cy="4" r="2"></circle><path d="M19 13v-2c-1.54.02-3.09-.75-4.07-1.83l-1.29-1.43c-.17-.19-.38-.34-.61-.45-.01 0-.01-.01-.02-.01H13c-.35-.2-.75-.3-1.19-.26C10.76 7.11 10 8.04 10 9.09V15c0 1.1.9 2 2 2h5v5h2v-5.5c0-1.1-.9-2-2-2h-3v-3.45c1.29 1.07 3.25 1.94 5 1.95zm-6.17 5c-.41 1.16-1.52 2-2.83 2-1.66 0-3-1.34-3-3 0-1.31.84-2.41 2-2.83V12.1c-2.28.46-4 2.48-4 4.9 0 2.76 2.24 5 5 5 2.42 0 4.44-1.72 4.9-4h-2.07z"></path></g> <g id="account-balance"><path d="M4 10v7h3v-7H4zm6 0v7h3v-7h-3zM2 22h19v-3H2v3zm14-12v7h3v-7h-3zm-4.5-9L2 6v2h19V6l-9.5-5z"></path></g> <g id="account-balance-wallet"><path d="M21 18v1c0 1.1-.9 2-2 2H5c-1.11 0-2-.9-2-2V5c0-1.1.89-2 2-2h14c1.1 0 2 .9 2 2v1h-9c-1.11 0-2 .9-2 2v8c0 1.1.89 2 2 2h9zm-9-2h10V8H12v8zm4-2.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></g> <g id="account-box"><path d="M3 5v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3zm-9 8c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6v-1z"></path></g> <g id="account-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"></path></g> <g id="add"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path></g> <g id="add-alert"><path d="M10.01 21.01c0 1.1.89 1.99 1.99 1.99s1.99-.89 1.99-1.99h-3.98zm8.87-4.19V11c0-3.25-2.25-5.97-5.29-6.69v-.72C13.59 2.71 12.88 2 12 2s-1.59.71-1.59 1.59v.72C7.37 5.03 5.12 7.75 5.12 11v5.82L3 18.94V20h18v-1.06l-2.12-2.12zM16 13.01h-3v3h-2v-3H8V11h3V8h2v3h3v2.01z"></path></g> <g id="add-box"><path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"></path></g> <g id="add-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"></path></g> <g id="add-circle-outline"><path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g> <g id="add-shopping-cart"><path d="M11 9h2V6h3V4h-3V1h-2v3H8v2h3v3zm-4 9c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zm10 0c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2zm-9.83-3.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.86-7.01L19.42 4h-.01l-1.1 2-2.76 5H8.53l-.13-.27L6.16 6l-.95-2-.94-2H1v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.13 0-.25-.11-.25-.25z"></path></g> <g id="alarm"><path d="M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12.5 8H11v6l4.75 2.85.75-1.23-4-2.37V8zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"></path></g> <g id="alarm-add"><path d="M7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm1-11h-2v3H8v2h3v3h2v-3h3v-2h-3V9z"></path></g> <g id="alarm-off"><path d="M12 6c3.87 0 7 3.13 7 7 0 .84-.16 1.65-.43 2.4l1.52 1.52c.58-1.19.91-2.51.91-3.92 0-4.97-4.03-9-9-9-1.41 0-2.73.33-3.92.91L9.6 6.43C10.35 6.16 11.16 6 12 6zm10-.28l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM2.92 2.29L1.65 3.57 2.98 4.9l-1.11.93 1.42 1.42 1.11-.94.8.8C3.83 8.69 3 10.75 3 13c0 4.97 4.02 9 9 9 2.25 0 4.31-.83 5.89-2.2l2.2 2.2 1.27-1.27L3.89 3.27l-.97-.98zm13.55 16.1C15.26 19.39 13.7 20 12 20c-3.87 0-7-3.13-7-7 0-1.7.61-3.26 1.61-4.47l9.86 9.86zM8.02 3.28L6.6 1.86l-.86.71 1.42 1.42.86-.71z"></path></g> <g id="alarm-on"><path d="M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm-1.46-5.47L8.41 12.4l-1.06 1.06 3.18 3.18 6-6-1.06-1.06-4.93 4.95z"></path></g> <g id="all-out"><path d="M16.21 4.16l4 4v-4zm4 12l-4 4h4zm-12 4l-4-4v4zm-4-12l4-4h-4zm12.95-.95c-2.73-2.73-7.17-2.73-9.9 0s-2.73 7.17 0 9.9 7.17 2.73 9.9 0 2.73-7.16 0-9.9zm-1.1 8.8c-2.13 2.13-5.57 2.13-7.7 0s-2.13-5.57 0-7.7 5.57-2.13 7.7 0 2.13 5.57 0 7.7z"></path></g> <g id="android"><path d="M6 18c0 .55.45 1 1 1h1v3.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V19h2v3.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V19h1c.55 0 1-.45 1-1V8H6v10zM3.5 8C2.67 8 2 8.67 2 9.5v7c0 .83.67 1.5 1.5 1.5S5 17.33 5 16.5v-7C5 8.67 4.33 8 3.5 8zm17 0c-.83 0-1.5.67-1.5 1.5v7c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5v-7c0-.83-.67-1.5-1.5-1.5zm-4.97-5.84l1.3-1.3c.2-.2.2-.51 0-.71-.2-.2-.51-.2-.71 0l-1.48 1.48C13.85 1.23 12.95 1 12 1c-.96 0-1.86.23-2.66.63L7.85.15c-.2-.2-.51-.2-.71 0-.2.2-.2.51 0 .71l1.31 1.31C6.97 3.26 6 5.01 6 7h12c0-1.99-.97-3.75-2.47-4.84zM10 5H9V4h1v1zm5 0h-1V4h1v1z"></path></g> <g id="announcement"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 9h-2V5h2v6zm0 4h-2v-2h2v2z"></path></g> <g id="apps"><path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"></path></g> <g id="archive"><path d="M20.54 5.23l-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5L6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"></path></g> <g id="arrow-back"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"></path></g> <g id="arrow-downward"><path d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"></path></g> <g id="arrow-drop-down"><path d="M7 10l5 5 5-5z"></path></g> <g id="arrow-drop-down-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 12l-4-4h8l-4 4z"></path></g> <g id="arrow-drop-up"><path d="M7 14l5-5 5 5z"></path></g> <g id="arrow-forward"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"></path></g> <g id="arrow-upward"><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"></path></g> <g id="aspect-ratio"><path d="M19 12h-2v3h-3v2h5v-5zM7 9h3V7H5v5h2V9zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z"></path></g> <g id="assessment"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"></path></g> <g id="assignment"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm2 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"></path></g> <g id="assignment-ind"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 4c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm6 12H6v-1.4c0-2 4-3.1 6-3.1s6 1.1 6 3.1V19z"></path></g> <g id="assignment-late"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-6 15h-2v-2h2v2zm0-4h-2V8h2v6zm-1-9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"></path></g> <g id="assignment-return"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm4 12h-4v3l-5-5 5-5v3h4v4z"></path></g> <g id="assignment-returned"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 15l-5-5h3V9h4v4h3l-5 5z"></path></g> <g id="assignment-turned-in"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm-2 14l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z"></path></g> <g id="attachment"><path d="M2 12.5C2 9.46 4.46 7 7.5 7H18c2.21 0 4 1.79 4 4s-1.79 4-4 4H9.5C8.12 15 7 13.88 7 12.5S8.12 10 9.5 10H17v2H9.41c-.55 0-.55 1 0 1H18c1.1 0 2-.9 2-2s-.9-2-2-2H7.5C5.57 9 4 10.57 4 12.5S5.57 16 7.5 16H17v2H7.5C4.46 18 2 15.54 2 12.5z"></path></g> <g id="autorenew"><path d="M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"></path></g> <g id="backspace"><path d="M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-3 12.59L17.59 17 14 13.41 10.41 17 9 15.59 12.59 12 9 8.41 10.41 7 14 10.59 17.59 7 19 8.41 15.41 12 19 15.59z"></path></g> <g id="backup"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path></g> <g id="block"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z"></path></g> <g id="book"><path d="M18 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 4h5v8l-2.5-1.5L6 12V4z"></path></g> <g id="bookmark"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"></path></g> <g id="bookmark-border"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z"></path></g> <g id="bug-report"><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"></path></g> <g id="build"><path d="M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z"></path></g> <g id="cached"><path d="M19 8l-4 4h3c0 3.31-2.69 6-6 6-1.01 0-1.97-.25-2.8-.7l-1.46 1.46C8.97 19.54 10.43 20 12 20c4.42 0 8-3.58 8-8h3l-4-4zM6 12c0-3.31 2.69-6 6-6 1.01 0 1.97.25 2.8.7l1.46-1.46C15.03 4.46 13.57 4 12 4c-4.42 0-8 3.58-8 8H1l4 4 4-4H6z"></path></g> <g id="camera-enhance"><path d="M9 3L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2h-3.17L15 3H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-1l1.25-2.75L16 13l-2.75-1.25L12 9l-1.25 2.75L8 13l2.75 1.25z"></path></g> <g id="cancel"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"></path></g> <g id="card-giftcard"><path d="M20 6h-2.18c.11-.31.18-.65.18-1 0-1.66-1.34-3-3-3-1.05 0-1.96.54-2.5 1.35l-.5.67-.5-.68C10.96 2.54 10.05 2 9 2 7.34 2 6 3.34 6 5c0 .35.07.69.18 1H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-5-2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zM9 4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm11 15H4v-2h16v2zm0-5H4V8h5.08L7 10.83 8.62 12 11 8.76l1-1.36 1 1.36L15.38 12 17 10.83 14.92 8H20v6z"></path></g> <g id="card-membership"><path d="M20 2H4c-1.11 0-2 .89-2 2v11c0 1.11.89 2 2 2h4v5l4-2 4 2v-5h4c1.11 0 2-.89 2-2V4c0-1.11-.89-2-2-2zm0 13H4v-2h16v2zm0-5H4V4h16v6z"></path></g> <g id="card-travel"><path d="M20 6h-3V4c0-1.11-.89-2-2-2H9c-1.11 0-2 .89-2 2v2H4c-1.11 0-2 .89-2 2v11c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zM9 4h6v2H9V4zm11 15H4v-2h16v2zm0-5H4V8h3v2h2V8h6v2h2V8h3v6z"></path></g> <g id="change-history"><path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"></path></g> <g id="check"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></g> <g id="check-box"><path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></g> <g id="check-box-outline-blank"><path d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path></g> <g id="check-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></g> <g id="chevron-left"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path></g> <g id="chevron-right"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g> <g id="chrome-reader-mode"><path d="M13 12h7v1.5h-7zm0-2.5h7V11h-7zm0 5h7V16h-7zM21 4H3c-1.1 0-2 .9-2 2v13c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 15h-9V6h9v13z"></path></g> <g id="class"><path d="M18 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 4h5v8l-2.5-1.5L6 12V4z"></path></g> <g id="clear"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></g> <g id="close"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></g> <g id="cloud"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"></path></g> <g id="cloud-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.5 14H8c-1.66 0-3-1.34-3-3s1.34-3 3-3l.14.01C8.58 8.28 10.13 7 12 7c2.21 0 4 1.79 4 4h.5c1.38 0 2.5 1.12 2.5 2.5S17.88 16 16.5 16z"></path></g> <g id="cloud-done"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM10 17l-3.5-3.5 1.41-1.41L10 14.17 15.18 9l1.41 1.41L10 17z"></path></g> <g id="cloud-download"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z"></path></g> <g id="cloud-off"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4c-1.48 0-2.85.43-4.01 1.17l1.46 1.46C10.21 6.23 11.08 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 1.13-.64 2.11-1.56 2.62l1.45 1.45C23.16 18.16 24 16.68 24 15c0-2.64-2.05-4.78-4.65-4.96zM3 5.27l2.75 2.74C2.56 8.15 0 10.77 0 14c0 3.31 2.69 6 6 6h11.73l2 2L21 20.73 4.27 4 3 5.27zM7.73 10l8 8H6c-2.21 0-4-1.79-4-4s1.79-4 4-4h1.73z"></path></g> <g id="cloud-queue"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4s1.79-4 4-4h.71C7.37 7.69 9.48 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3s-1.34 3-3 3z"></path></g> <g id="cloud-upload"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path></g> <g id="code"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"></path></g> <g id="compare-arrows"><path d="M9.01 14H2v2h7.01v3L13 15l-3.99-4v3zm5.98-1v-3H22V8h-7.01V5L11 9l3.99 4z"></path></g> <g id="content-copy"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></g> <g id="content-cut"><path d="M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3z"></path></g> <g id="content-paste"><path d="M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"></path></g> <g id="copyright"><path d="M10.08 10.86c.05-.33.16-.62.3-.87s.34-.46.59-.62c.24-.15.54-.22.91-.23.23.01.44.05.63.13.2.09.38.21.52.36s.25.33.34.53.13.42.14.64h1.79c-.02-.47-.11-.9-.28-1.29s-.4-.73-.7-1.01-.66-.5-1.08-.66-.88-.23-1.39-.23c-.65 0-1.22.11-1.7.34s-.88.53-1.2.92-.56.84-.71 1.36S8 11.29 8 11.87v.27c0 .58.08 1.12.23 1.64s.39.97.71 1.35.72.69 1.2.91 1.05.34 1.7.34c.47 0 .91-.08 1.32-.23s.77-.36 1.08-.63.56-.58.74-.94.29-.74.3-1.15h-1.79c-.01.21-.06.4-.15.58s-.21.33-.36.46-.32.23-.52.3c-.19.07-.39.09-.6.1-.36-.01-.66-.08-.89-.23-.25-.16-.45-.37-.59-.62s-.25-.55-.3-.88-.08-.67-.08-1v-.27c0-.35.03-.68.08-1.01zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g> <g id="create"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></g> <g id="create-new-folder"><path d="M20 6h-8l-2-2H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-1 8h-3v3h-2v-3h-3v-2h3V9h2v3h3v2z"></path></g> <g id="credit-card"><path d="M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z"></path></g> <g id="dashboard"><path d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"></path></g> <g id="date-range"><path d="M9 11H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V9h14v11z"></path></g> <g id="delete"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"></path></g> <g id="delete-forever"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"></path></g> <g id="delete-sweep"><path d="M15 16h4v2h-4zm0-8h7v2h-7zm0 4h6v2h-6zM3 18c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V8H3v10zM14 5h-3l-1-1H6L5 5H2v2h12z"></path></g> <g id="description"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"></path></g> <g id="dns"><path d="M20 13H4c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zM7 19c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM20 3H4c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zM7 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></g> <g id="done"><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"></path></g> <g id="done-all"><path d="M18 7l-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41L6 19l1.41-1.41L1.83 12 .41 13.41z"></path></g> <g id="donut-large"><path d="M11 5.08V2c-5 .5-9 4.81-9 10s4 9.5 9 10v-3.08c-3-.48-6-3.4-6-6.92s3-6.44 6-6.92zM18.97 11H22c-.47-5-4-8.53-9-9v3.08C16 5.51 18.54 8 18.97 11zM13 18.92V22c5-.47 8.53-4 9-9h-3.03c-.43 3-2.97 5.49-5.97 5.92z"></path></g> <g id="donut-small"><path d="M11 9.16V2c-5 .5-9 4.79-9 10s4 9.5 9 10v-7.16c-1-.41-2-1.52-2-2.84s1-2.43 2-2.84zM14.86 11H22c-.48-4.75-4-8.53-9-9v7.16c1 .3 1.52.98 1.86 1.84zM13 14.84V22c5-.47 8.52-4.25 9-9h-7.14c-.34.86-.86 1.54-1.86 1.84z"></path></g> <g id="drafts"><path d="M21.99 8c0-.72-.37-1.35-.94-1.7L12 1 2.95 6.3C2.38 6.65 2 7.28 2 8v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2l-.01-10zM12 13L3.74 7.84 12 3l8.26 4.84L12 13z"></path></g> <g id="eject"><path d="M5 17h14v2H5zm7-12L5.33 15h13.34z"></path></g> <g id="error"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"></path></g> <g id="error-outline"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g> <g id="euro-symbol"><path d="M15 18.5c-2.51 0-4.68-1.42-5.76-3.5H15v-2H8.58c-.05-.33-.08-.66-.08-1s.03-.67.08-1H15V9H9.24C10.32 6.92 12.5 5.5 15 5.5c1.61 0 3.09.59 4.23 1.57L21 5.3C19.41 3.87 17.3 3 15 3c-3.92 0-7.24 2.51-8.48 6H3v2h3.06c-.04.33-.06.66-.06 1 0 .34.02.67.06 1H3v2h3.52c1.24 3.49 4.56 6 8.48 6 2.31 0 4.41-.87 6-2.3l-1.78-1.77c-1.13.98-2.6 1.57-4.22 1.57z"></path></g> <g id="event"><path d="M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z"></path></g> <g id="event-seat"><path d="M4 18v3h3v-3h10v3h3v-6H4zm15-8h3v3h-3zM2 10h3v3H2zm15 3H7V5c0-1.1.9-2 2-2h6c1.1 0 2 .9 2 2v8z"></path></g> <g id="exit-to-app"><path d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path></g> <g id="expand-less"><path d="M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"></path></g> <g id="expand-more"><path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"></path></g> <g id="explore"><path d="M12 10.9c-.61 0-1.1.49-1.1 1.1s.49 1.1 1.1 1.1c.61 0 1.1-.49 1.1-1.1s-.49-1.1-1.1-1.1zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm2.19 12.19L6 18l3.81-8.19L18 6l-3.81 8.19z"></path></g> <g id="extension"><path d="M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11z"></path></g> <g id="face"><path d="M9 11.75c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zm6 0c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8 0-.29.02-.58.05-.86 2.36-1.05 4.23-2.98 5.21-5.37C11.07 8.33 14.05 10 17.42 10c.78 0 1.53-.09 2.25-.26.21.71.33 1.47.33 2.26 0 4.41-3.59 8-8 8z"></path></g> <g id="favorite"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"></path></g> <g id="favorite-border"><path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"></path></g> <g id="feedback"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 12h-2v-2h2v2zm0-4h-2V6h2v4z"></path></g> <g id="file-download"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path></g> <g id="file-upload"><path d="M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"></path></g> <g id="filter-list"><path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"></path></g> <g id="find-in-page"><path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"></path></g> <g id="find-replace"><path d="M11 6c1.38 0 2.63.56 3.54 1.46L12 10h6V4l-2.05 2.05C14.68 4.78 12.93 4 11 4c-3.53 0-6.43 2.61-6.92 6H6.1c.46-2.28 2.48-4 4.9-4zm5.64 9.14c.66-.9 1.12-1.97 1.28-3.14H15.9c-.46 2.28-2.48 4-4.9 4-1.38 0-2.63-.56-3.54-1.46L10 12H4v6l2.05-2.05C7.32 17.22 9.07 18 11 18c1.55 0 2.98-.51 4.14-1.36L20 21.49 21.49 20l-4.85-4.86z"></path></g> <g id="fingerprint"><path d="M17.81 4.47c-.08 0-.16-.02-.23-.06C15.66 3.42 14 3 12.01 3c-1.98 0-3.86.47-5.57 1.41-.24.13-.54.04-.68-.2-.13-.24-.04-.55.2-.68C7.82 2.52 9.86 2 12.01 2c2.13 0 3.99.47 6.03 1.52.25.13.34.43.21.67-.09.18-.26.28-.44.28zM3.5 9.72c-.1 0-.2-.03-.29-.09-.23-.16-.28-.47-.12-.7.99-1.4 2.25-2.5 3.75-3.27C9.98 4.04 14 4.03 17.15 5.65c1.5.77 2.76 1.86 3.75 3.25.16.22.11.54-.12.7-.23.16-.54.11-.7-.12-.9-1.26-2.04-2.25-3.39-2.94-2.87-1.47-6.54-1.47-9.4.01-1.36.7-2.5 1.7-3.4 2.96-.08.14-.23.21-.39.21zm6.25 12.07c-.13 0-.26-.05-.35-.15-.87-.87-1.34-1.43-2.01-2.64-.69-1.23-1.05-2.73-1.05-4.34 0-2.97 2.54-5.39 5.66-5.39s5.66 2.42 5.66 5.39c0 .28-.22.5-.5.5s-.5-.22-.5-.5c0-2.42-2.09-4.39-4.66-4.39-2.57 0-4.66 1.97-4.66 4.39 0 1.44.32 2.77.93 3.85.64 1.15 1.08 1.64 1.85 2.42.19.2.19.51 0 .71-.11.1-.24.15-.37.15zm7.17-1.85c-1.19 0-2.24-.3-3.1-.89-1.49-1.01-2.38-2.65-2.38-4.39 0-.28.22-.5.5-.5s.5.22.5.5c0 1.41.72 2.74 1.94 3.56.71.48 1.54.71 2.54.71.24 0 .64-.03 1.04-.1.27-.05.53.13.58.41.05.27-.13.53-.41.58-.57.11-1.07.12-1.21.12zM14.91 22c-.04 0-.09-.01-.13-.02-1.59-.44-2.63-1.03-3.72-2.1-1.4-1.39-2.17-3.24-2.17-5.22 0-1.62 1.38-2.94 3.08-2.94 1.7 0 3.08 1.32 3.08 2.94 0 1.07.93 1.94 2.08 1.94s2.08-.87 2.08-1.94c0-3.77-3.25-6.83-7.25-6.83-2.84 0-5.44 1.58-6.61 4.03-.39.81-.59 1.76-.59 2.8 0 .78.07 2.01.67 3.61.1.26-.03.55-.29.64-.26.1-.55-.04-.64-.29-.49-1.31-.73-2.61-.73-3.96 0-1.2.23-2.29.68-3.24 1.33-2.79 4.28-4.6 7.51-4.6 4.55 0 8.25 3.51 8.25 7.83 0 1.62-1.38 2.94-3.08 2.94s-3.08-1.32-3.08-2.94c0-1.07-.93-1.94-2.08-1.94s-2.08.87-2.08 1.94c0 1.71.66 3.31 1.87 4.51.95.94 1.86 1.46 3.27 1.85.27.07.42.35.35.61-.05.23-.26.38-.47.38z"></path></g> <g id="first-page"><path d="M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"></path></g> <g id="flag"><path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"></path></g> <g id="flight-land"><path d="M2.5 19h19v2h-19zm7.18-5.73l4.35 1.16 5.31 1.42c.8.21 1.62-.26 1.84-1.06.21-.8-.26-1.62-1.06-1.84l-5.31-1.42-2.76-9.02L10.12 2v8.28L5.15 8.95l-.93-2.32-1.45-.39v5.17l1.6.43 5.31 1.43z"></path></g> <g id="flight-takeoff"><path d="M2.5 19h19v2h-19zm19.57-9.36c-.21-.8-1.04-1.28-1.84-1.06L14.92 10l-6.9-6.43-1.93.51 4.14 7.17-4.97 1.33-1.97-1.54-1.45.39 1.82 3.16.77 1.33 1.6-.43 5.31-1.42 4.35-1.16L21 11.49c.81-.23 1.28-1.05 1.07-1.85z"></path></g> <g id="flip-to-back"><path d="M9 7H7v2h2V7zm0 4H7v2h2v-2zm0-8c-1.11 0-2 .9-2 2h2V3zm4 12h-2v2h2v-2zm6-12v2h2c0-1.1-.9-2-2-2zm-6 0h-2v2h2V3zM9 17v-2H7c0 1.1.89 2 2 2zm10-4h2v-2h-2v2zm0-4h2V7h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zM5 7H3v12c0 1.1.89 2 2 2h12v-2H5V7zm10-2h2V3h-2v2zm0 12h2v-2h-2v2z"></path></g> <g id="flip-to-front"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm2 4v-2H3c0 1.1.89 2 2 2zM3 9h2V7H3v2zm12 12h2v-2h-2v2zm4-18H9c-1.11 0-2 .9-2 2v10c0 1.1.89 2 2 2h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12H9V5h10v10zm-8 6h2v-2h-2v2zm-4 0h2v-2H7v2z"></path></g> <g id="folder"><path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"></path></g> <g id="folder-open"><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"></path></g> <g id="folder-shared"><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-5 3c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm4 8h-8v-1c0-1.33 2.67-2 4-2s4 .67 4 2v1z"></path></g> <g id="font-download"><path d="M9.93 13.5h4.14L12 7.98zM20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-4.05 16.5l-1.14-3H9.17l-1.12 3H5.96l5.11-13h1.86l5.11 13h-2.09z"></path></g> <g id="forward"><path d="M12 8V4l8 8-8 8v-4H4V8z"></path></g> <g id="fullscreen"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"></path></g> <g id="fullscreen-exit"><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"></path></g> <g id="g-translate"><path d="M20 5h-9.12L10 2H4c-1.1 0-2 .9-2 2v13c0 1.1.9 2 2 2h7l1 3h8c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zM7.17 14.59c-2.25 0-4.09-1.83-4.09-4.09s1.83-4.09 4.09-4.09c1.04 0 1.99.37 2.74 1.07l.07.06-1.23 1.18-.06-.05c-.29-.27-.78-.59-1.52-.59-1.31 0-2.38 1.09-2.38 2.42s1.07 2.42 2.38 2.42c1.37 0 1.96-.87 2.12-1.46H7.08V9.91h3.95l.01.07c.04.21.05.4.05.61 0 2.35-1.61 4-3.92 4zm6.03-1.71c.33.6.74 1.18 1.19 1.7l-.54.53-.65-2.23zm.77-.76h-.99l-.31-1.04h3.99s-.34 1.31-1.56 2.74c-.52-.62-.89-1.23-1.13-1.7zM21 20c0 .55-.45 1-1 1h-7l2-2-.81-2.77.92-.92L17.79 18l.73-.73-2.71-2.68c.9-1.03 1.6-2.25 1.92-3.51H19v-1.04h-3.64V9h-1.04v1.04h-1.96L11.18 6H20c.55 0 1 .45 1 1v13z"></path></g> <g id="gavel"><path d="M1 21h12v2H1zM5.245 8.07l2.83-2.827 14.14 14.142-2.828 2.828zM12.317 1l5.657 5.656-2.83 2.83-5.654-5.66zM3.825 9.485l5.657 5.657-2.828 2.828-5.657-5.657z"></path></g> <g id="gesture"><path d="M4.59 6.89c.7-.71 1.4-1.35 1.71-1.22.5.2 0 1.03-.3 1.52-.25.42-2.86 3.89-2.86 6.31 0 1.28.48 2.34 1.34 2.98.75.56 1.74.73 2.64.46 1.07-.31 1.95-1.4 3.06-2.77 1.21-1.49 2.83-3.44 4.08-3.44 1.63 0 1.65 1.01 1.76 1.79-3.78.64-5.38 3.67-5.38 5.37 0 1.7 1.44 3.09 3.21 3.09 1.63 0 4.29-1.33 4.69-6.1H21v-2.5h-2.47c-.15-1.65-1.09-4.2-4.03-4.2-2.25 0-4.18 1.91-4.94 2.84-.58.73-2.06 2.48-2.29 2.72-.25.3-.68.84-1.11.84-.45 0-.72-.83-.36-1.92.35-1.09 1.4-2.86 1.85-3.52.78-1.14 1.3-1.92 1.3-3.28C8.95 3.69 7.31 3 6.44 3 5.12 3 3.97 4 3.72 4.25c-.36.36-.66.66-.88.93l1.75 1.71zm9.29 11.66c-.31 0-.74-.26-.74-.72 0-.6.73-2.2 2.87-2.76-.3 2.69-1.43 3.48-2.13 3.48z"></path></g> <g id="get-app"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path></g> <g id="gif"><path d="M11.5 9H13v6h-1.5zM9 9H6c-.6 0-1 .5-1 1v4c0 .5.4 1 1 1h3c.6 0 1-.5 1-1v-2H8.5v1.5h-2v-3H10V10c0-.5-.4-1-1-1zm10 1.5V9h-4.5v6H16v-2h2v-1.5h-2v-1z"></path></g> <g id="grade"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"></path></g> <g id="group-work"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM8 17.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5zM9.5 8c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5S9.5 9.38 9.5 8zm6.5 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></g> <g id="help"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"></path></g> <g id="help-outline"><path d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"></path></g> <g id="highlight-off"><path d="M14.59 8L12 10.59 9.41 8 8 9.41 10.59 12 8 14.59 9.41 16 12 13.41 14.59 16 16 14.59 13.41 12 16 9.41 14.59 8zM12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g> <g id="history"><path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"></path></g> <g id="home"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"></path></g> <g id="hourglass-empty"><path d="M6 2v6h.01L6 8.01 10 12l-4 4 .01.01H6V22h12v-5.99h-.01L18 16l-4-4 4-3.99-.01-.01H18V2H6zm10 14.5V20H8v-3.5l4-4 4 4zm-4-5l-4-4V4h8v3.5l-4 4z"></path></g> <g id="hourglass-full"><path d="M6 2v6h.01L6 8.01 10 12l-4 4 .01.01H6V22h12v-5.99h-.01L18 16l-4-4 4-3.99-.01-.01H18V2H6z"></path></g> <g id="http"><path d="M4.5 11h-2V9H1v6h1.5v-2.5h2V15H6V9H4.5v2zm2.5-.5h1.5V15H10v-4.5h1.5V9H7v1.5zm5.5 0H14V15h1.5v-4.5H17V9h-4.5v1.5zm9-1.5H18v6h1.5v-2h2c.8 0 1.5-.7 1.5-1.5v-1c0-.8-.7-1.5-1.5-1.5zm0 2.5h-2v-1h2v1z"></path></g> <g id="https"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"></path></g> <g id="important-devices"><path d="M23 11.01L18 11c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-9c0-.55-.45-.99-1-.99zM23 20h-5v-7h5v7zM20 2H2C.89 2 0 2.89 0 4v12c0 1.1.89 2 2 2h7v2H7v2h8v-2h-2v-2h2v-2H2V4h18v5h2V4c0-1.11-.9-2-2-2zm-8.03 7L11 6l-.97 3H7l2.47 1.76-.94 2.91 2.47-1.8 2.47 1.8-.94-2.91L15 9h-3.03z"></path></g> <g id="inbox"><path d="M19 3H4.99c-1.11 0-1.98.89-1.98 2L3 19c0 1.1.88 2 1.99 2H19c1.1 0 2-.9 2-2V5c0-1.11-.9-2-2-2zm0 12h-4c0 1.66-1.35 3-3 3s-3-1.34-3-3H4.99V5H19v10z"></path></g> <g id="indeterminate-check-box"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"></path></g> <g id="info"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"></path></g> <g id="info-outline"><path d="M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 9h2V7h-2v2z"></path></g> <g id="input"><path d="M21 3.01H3c-1.1 0-2 .9-2 2V9h2V4.99h18v14.03H3V15H1v4.01c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98v-14c0-1.11-.9-2-2-2zM11 16l4-4-4-4v3H1v2h10v3z"></path></g> <g id="invert-colors"><path d="M17.66 7.93L12 2.27 6.34 7.93c-3.12 3.12-3.12 8.19 0 11.31C7.9 20.8 9.95 21.58 12 21.58c2.05 0 4.1-.78 5.66-2.34 3.12-3.12 3.12-8.19 0-11.31zM12 19.59c-1.6 0-3.11-.62-4.24-1.76C6.62 16.69 6 15.19 6 13.59s.62-3.11 1.76-4.24L12 5.1v14.49z"></path></g> <g id="label"><path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 1.99 2 1.99L16 19c.67 0 1.27-.33 1.63-.84L22 12l-4.37-6.16z"></path></g> <g id="label-outline"><path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 1.99 2 1.99L16 19c.67 0 1.27-.33 1.63-.84L22 12l-4.37-6.16zM16 17H5V7h11l3.55 5L16 17z"></path></g> <g id="language"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"></path></g> <g id="last-page"><path d="M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"></path></g> <g id="launch"><path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path></g> <g id="lightbulb-outline"><path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z"></path></g> <g id="line-style"><path d="M3 16h5v-2H3v2zm6.5 0h5v-2h-5v2zm6.5 0h5v-2h-5v2zM3 20h2v-2H3v2zm4 0h2v-2H7v2zm4 0h2v-2h-2v2zm4 0h2v-2h-2v2zm4 0h2v-2h-2v2zM3 12h8v-2H3v2zm10 0h8v-2h-8v2zM3 4v4h18V4H3z"></path></g> <g id="line-weight"><path d="M3 17h18v-2H3v2zm0 3h18v-1H3v1zm0-7h18v-3H3v3zm0-9v4h18V4H3z"></path></g> <g id="link"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></g> <g id="list"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"></path></g> <g id="lock"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"></path></g> <g id="lock-open"><path d="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10z"></path></g> <g id="lock-outline"><path d="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM8.9 6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1v2H8.9V6zM18 20H6V10h12v10z"></path></g> <g id="low-priority"><path d="M14 5h8v2h-8zm0 5.5h8v2h-8zm0 5.5h8v2h-8zM2 11.5C2 15.08 4.92 18 8.5 18H9v2l3-3-3-3v2h-.5C6.02 16 4 13.98 4 11.5S6.02 7 8.5 7H12V5H8.5C4.92 5 2 7.92 2 11.5z"></path></g> <g id="loyalty"><path d="M21.41 11.58l-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42zM5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7zm11.77 8.27L13 19.54l-4.27-4.27C8.28 14.81 8 14.19 8 13.5c0-1.38 1.12-2.5 2.5-2.5.69 0 1.32.28 1.77.74l.73.72.73-.73c.45-.45 1.08-.73 1.77-.73 1.38 0 2.5 1.12 2.5 2.5 0 .69-.28 1.32-.73 1.77z"></path></g> <g id="mail"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"></path></g> <g id="markunread"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"></path></g> <g id="markunread-mailbox"><path d="M20 6H10v6H8V4h6V0H6v6H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2z"></path></g> <g id="menu"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path></g> <g id="more-horiz"><path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></g> <g id="more-vert"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></g> <g id="motorcycle"><path d="M19.44 9.03L15.41 5H11v2h3.59l2 2H5c-2.8 0-5 2.2-5 5s2.2 5 5 5c2.46 0 4.45-1.69 4.9-4h1.65l2.77-2.77c-.21.54-.32 1.14-.32 1.77 0 2.8 2.2 5 5 5s5-2.2 5-5c0-2.65-1.97-4.77-4.56-4.97zM7.82 15C7.4 16.15 6.28 17 5 17c-1.63 0-3-1.37-3-3s1.37-3 3-3c1.28 0 2.4.85 2.82 2H5v2h2.82zM19 17c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"></path></g> <g id="move-to-inbox"><path d="M19 3H4.99c-1.11 0-1.98.9-1.98 2L3 19c0 1.1.88 2 1.99 2H19c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12h-4c0 1.66-1.35 3-3 3s-3-1.34-3-3H4.99V5H19v10zm-3-5h-2V7h-4v3H8l4 4 4-4z"></path></g> <g id="next-week"><path d="M20 7h-4V5c0-.55-.22-1.05-.59-1.41C15.05 3.22 14.55 3 14 3h-4c-1.1 0-2 .9-2 2v2H4c-1.1 0-2 .9-2 2v11c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zM10 5h4v2h-4V5zm1 13.5l-1-1 3-3-3-3 1-1 4 4-4 4z"></path></g> <g id="note-add"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z"></path></g> <g id="offline-pin"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm5 16H7v-2h10v2zm-6.7-4L7 10.7l1.4-1.4 1.9 1.9 5.3-5.3L17 7.3 10.3 14z"></path></g> <g id="opacity"><path d="M17.66 8L12 2.35 6.34 8C4.78 9.56 4 11.64 4 13.64s.78 4.11 2.34 5.67 3.61 2.35 5.66 2.35 4.1-.79 5.66-2.35S20 15.64 20 13.64 19.22 9.56 17.66 8zM6 14c.01-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 17.99 12 18 14H6z"></path></g> <g id="open-in-browser"><path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h4v-2H5V8h14v10h-4v2h4c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm-7 6l-4 4h3v6h2v-6h3l-4-4z"></path></g> <g id="open-in-new"><path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path></g> <g id="open-with"><path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"></path></g> <g id="pageview"><path d="M11.5 9C10.12 9 9 10.12 9 11.5s1.12 2.5 2.5 2.5 2.5-1.12 2.5-2.5S12.88 9 11.5 9zM20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-3.21 14.21l-2.91-2.91c-.69.44-1.51.7-2.39.7C9.01 16 7 13.99 7 11.5S9.01 7 11.5 7 16 9.01 16 11.5c0 .88-.26 1.69-.7 2.39l2.91 2.9-1.42 1.42z"></path></g> <g id="pan-tool"><path d="M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z"></path></g> <g id="payment"><path d="M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z"></path></g> <g id="perm-camera-mic"><path d="M20 5h-3.17L15 3H9L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h7v-2.09c-2.83-.48-5-2.94-5-5.91h2c0 2.21 1.79 4 4 4s4-1.79 4-4h2c0 2.97-2.17 5.43-5 5.91V21h7c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-6 8c0 1.1-.9 2-2 2s-2-.9-2-2V9c0-1.1.9-2 2-2s2 .9 2 2v4z"></path></g> <g id="perm-contact-calendar"><path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm6 12H6v-1c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1z"></path></g> <g id="perm-data-setting"><path d="M18.99 11.5c.34 0 .67.03 1 .07L20 0 0 20h11.56c-.04-.33-.07-.66-.07-1 0-4.14 3.36-7.5 7.5-7.5zm3.71 7.99c.02-.16.04-.32.04-.49 0-.17-.01-.33-.04-.49l1.06-.83c.09-.08.12-.21.06-.32l-1-1.73c-.06-.11-.19-.15-.31-.11l-1.24.5c-.26-.2-.54-.37-.85-.49l-.19-1.32c-.01-.12-.12-.21-.24-.21h-2c-.12 0-.23.09-.25.21l-.19 1.32c-.3.13-.59.29-.85.49l-1.24-.5c-.11-.04-.24 0-.31.11l-1 1.73c-.06.11-.04.24.06.32l1.06.83c-.02.16-.03.32-.03.49 0 .17.01.33.03.49l-1.06.83c-.09.08-.12.21-.06.32l1 1.73c.06.11.19.15.31.11l1.24-.5c.26.2.54.37.85.49l.19 1.32c.02.12.12.21.25.21h2c.12 0 .23-.09.25-.21l.19-1.32c.3-.13.59-.29.84-.49l1.25.5c.11.04.24 0 .31-.11l1-1.73c.06-.11.03-.24-.06-.32l-1.07-.83zm-3.71 1.01c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></g> <g id="perm-device-information"><path d="M13 7h-2v2h2V7zm0 4h-2v6h2v-6zm4-9.99L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z"></path></g> <g id="perm-identity"><path d="M12 5.9c1.16 0 2.1.94 2.1 2.1s-.94 2.1-2.1 2.1S9.9 9.16 9.9 8s.94-2.1 2.1-2.1m0 9c2.97 0 6.1 1.46 6.1 2.1v1.1H5.9V17c0-.64 3.13-2.1 6.1-2.1M12 4C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 9c-2.67 0-8 1.34-8 4v3h16v-3c0-2.66-5.33-4-8-4z"></path></g> <g id="perm-media"><path d="M2 6H0v5h.01L0 20c0 1.1.9 2 2 2h18v-2H2V6zm20-2h-8l-2-2H6c-1.1 0-1.99.9-1.99 2L4 16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM7 15l4.5-6 3.5 4.51 2.5-3.01L21 15H7z"></path></g> <g id="perm-phone-msg"><path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.58l2.2-2.21c.28-.27.36-.66.25-1.01C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM12 3v10l3-3h6V3h-9z"></path></g> <g id="perm-scan-wifi"><path d="M12 3C6.95 3 3.15 4.85 0 7.23L12 22 24 7.25C20.85 4.87 17.05 3 12 3zm1 13h-2v-6h2v6zm-2-8V6h2v2h-2z"></path></g> <g id="pets"><circle cx="4.5" cy="9.5" r="2.5"></circle><circle cx="9" cy="5.5" r="2.5"></circle><circle cx="15" cy="5.5" r="2.5"></circle><circle cx="19.5" cy="9.5" r="2.5"></circle><path d="M17.34 14.86c-.87-1.02-1.6-1.89-2.48-2.91-.46-.54-1.05-1.08-1.75-1.32-.11-.04-.22-.07-.33-.09-.25-.04-.52-.04-.78-.04s-.53 0-.79.05c-.11.02-.22.05-.33.09-.7.24-1.28.78-1.75 1.32-.87 1.02-1.6 1.89-2.48 2.91-1.31 1.31-2.92 2.76-2.62 4.79.29 1.02 1.02 2.03 2.33 2.32.73.15 3.06-.44 5.54-.44h.18c2.48 0 4.81.58 5.54.44 1.31-.29 2.04-1.31 2.33-2.32.31-2.04-1.3-3.49-2.61-4.8z"></path></g> <g id="picture-in-picture"><path d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98V5c0-1.1-.9-2-2-2zm0 16.01H3V4.98h18v14.03z"></path></g> <g id="picture-in-picture-alt"><path d="M19 11h-8v6h8v-6zm4 8V4.98C23 3.88 22.1 3 21 3H3c-1.1 0-2 .88-2 1.98V19c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zm-2 .02H3V4.97h18v14.05z"></path></g> <g id="play-for-work"><path d="M11 5v5.59H7.5l4.5 4.5 4.5-4.5H13V5h-2zm-5 9c0 3.31 2.69 6 6 6s6-2.69 6-6h-2c0 2.21-1.79 4-4 4s-4-1.79-4-4H6z"></path></g> <g id="polymer"><path d="M19 4h-4L7.11 16.63 4.5 12 9 4H5L.5 12 5 20h4l7.89-12.63L19.5 12 15 20h4l4.5-8z"></path></g> <g id="power-settings-new"><path d="M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z"></path></g> <g id="pregnant-woman"><path d="M9 4c0-1.11.89-2 2-2s2 .89 2 2-.89 2-2 2-2-.89-2-2zm7 9c-.01-1.34-.83-2.51-2-3 0-1.66-1.34-3-3-3s-3 1.34-3 3v7h2v5h3v-5h3v-4z"></path></g> <g id="print"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"></path></g> <g id="query-builder"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"></path></g> <g id="question-answer"><path d="M21 6h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1zm-4 6V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1z"></path></g> <g id="radio-button-checked"><path d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g> <g id="radio-button-unchecked"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g> <g id="receipt"><path d="M18 17H6v-2h12v2zm0-4H6v-2h12v2zm0-4H6V7h12v2zM3 22l1.5-1.5L6 22l1.5-1.5L9 22l1.5-1.5L12 22l1.5-1.5L15 22l1.5-1.5L18 22l1.5-1.5L21 22V2l-1.5 1.5L18 2l-1.5 1.5L15 2l-1.5 1.5L12 2l-1.5 1.5L9 2 7.5 3.5 6 2 4.5 3.5 3 2v20z"></path></g> <g id="record-voice-over"><circle cx="9" cy="9" r="4"></circle><path d="M9 15c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4zm7.76-9.64l-1.68 1.69c.84 1.18.84 2.71 0 3.89l1.68 1.69c2.02-2.02 2.02-5.07 0-7.27zM20.07 2l-1.63 1.63c2.77 3.02 2.77 7.56 0 10.74L20.07 16c3.9-3.89 3.91-9.95 0-14z"></path></g> <g id="redeem"><path d="M20 6h-2.18c.11-.31.18-.65.18-1 0-1.66-1.34-3-3-3-1.05 0-1.96.54-2.5 1.35l-.5.67-.5-.68C10.96 2.54 10.05 2 9 2 7.34 2 6 3.34 6 5c0 .35.07.69.18 1H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-5-2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zM9 4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm11 15H4v-2h16v2zm0-5H4V8h5.08L7 10.83 8.62 12 11 8.76l1-1.36 1 1.36L15.38 12 17 10.83 14.92 8H20v6z"></path></g> <g id="redo"><path d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"></path></g> <g id="refresh"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"></path></g> <g id="remove"><path d="M19 13H5v-2h14v2z"></path></g> <g id="remove-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11H7v-2h10v2z"></path></g> <g id="remove-circle-outline"><path d="M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g> <g id="remove-shopping-cart"><path d="M22.73 22.73L2.77 2.77 2 2l-.73-.73L0 2.54l4.39 4.39 2.21 4.66-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h7.46l1.38 1.38c-.5.36-.83.95-.83 1.62 0 1.1.89 2 1.99 2 .67 0 1.26-.33 1.62-.84L21.46 24l1.27-1.27zM7.42 15c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h2.36l2 2H7.42zm8.13-2c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H6.54l9.01 9zM7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2z"></path></g> <g id="reorder"><path d="M3 15h18v-2H3v2zm0 4h18v-2H3v2zm0-8h18V9H3v2zm0-6v2h18V5H3z"></path></g> <g id="reply"><path d="M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z"></path></g> <g id="reply-all"><path d="M7 8V5l-7 7 7 7v-3l-4-4 4-4zm6 1V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z"></path></g> <g id="report"><path d="M15.73 3H8.27L3 8.27v7.46L8.27 21h7.46L21 15.73V8.27L15.73 3zM12 17.3c-.72 0-1.3-.58-1.3-1.3 0-.72.58-1.3 1.3-1.3.72 0 1.3.58 1.3 1.3 0 .72-.58 1.3-1.3 1.3zm1-4.3h-2V7h2v6z"></path></g> <g id="report-problem"><path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"></path></g> <g id="restore"><path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"></path></g> <g id="restore-page"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm-2 16c-2.05 0-3.81-1.24-4.58-3h1.71c.63.9 1.68 1.5 2.87 1.5 1.93 0 3.5-1.57 3.5-3.5S13.93 9.5 12 9.5c-1.35 0-2.52.78-3.1 1.9l1.6 1.6h-4V9l1.3 1.3C8.69 8.92 10.23 8 12 8c2.76 0 5 2.24 5 5s-2.24 5-5 5z"></path></g> <g id="room"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></g> <g id="rounded-corner"><path d="M19 19h2v2h-2v-2zm0-2h2v-2h-2v2zM3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm0-4h2V3H3v2zm4 0h2V3H7v2zm8 16h2v-2h-2v2zm-4 0h2v-2h-2v2zm4 0h2v-2h-2v2zm-8 0h2v-2H7v2zm-4 0h2v-2H3v2zM21 8c0-2.76-2.24-5-5-5h-5v2h5c1.65 0 3 1.35 3 3v5h2V8z"></path></g> <g id="rowing"><path d="M8.5 14.5L4 19l1.5 1.5L9 17h2l-2.5-2.5zM15 1c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 20.01L18 24l-2.99-3.01V19.5l-7.1-7.09c-.31.05-.61.07-.91.07v-2.16c1.66.03 3.61-.87 4.67-2.04l1.4-1.55c.19-.21.43-.38.69-.5.29-.14.62-.23.96-.23h.03C15.99 6.01 17 7.02 17 8.26v5.75c0 .84-.35 1.61-.92 2.16l-3.58-3.58v-2.27c-.63.52-1.43 1.02-2.29 1.39L16.5 18H18l3 3.01z"></path></g> <g id="save"><path d="M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z"></path></g> <g id="schedule"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"></path></g> <g id="search"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></g> <g id="select-all"><path d="M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10zm2-8h6v6H9V9z"></path></g> <g id="send"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"></path></g> <g id="settings"><path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"></path></g> <g id="settings-applications"><path d="M12 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm7-7H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-1.75 9c0 .23-.02.46-.05.68l1.48 1.16c.13.11.17.3.08.45l-1.4 2.42c-.09.15-.27.21-.43.15l-1.74-.7c-.36.28-.76.51-1.18.69l-.26 1.85c-.03.17-.18.3-.35.3h-2.8c-.17 0-.32-.13-.35-.29l-.26-1.85c-.43-.18-.82-.41-1.18-.69l-1.74.7c-.16.06-.34 0-.43-.15l-1.4-2.42c-.09-.15-.05-.34.08-.45l1.48-1.16c-.03-.23-.05-.46-.05-.69 0-.23.02-.46.05-.68l-1.48-1.16c-.13-.11-.17-.3-.08-.45l1.4-2.42c.09-.15.27-.21.43-.15l1.74.7c.36-.28.76-.51 1.18-.69l.26-1.85c.03-.17.18-.3.35-.3h2.8c.17 0 .32.13.35.29l.26 1.85c.43.18.82.41 1.18.69l1.74-.7c.16-.06.34 0 .43.15l1.4 2.42c.09.15.05.34-.08.45l-1.48 1.16c.03.23.05.46.05.69z"></path></g> <g id="settings-backup-restore"><path d="M14 12c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2zm-2-9c-4.97 0-9 4.03-9 9H0l4 4 4-4H5c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.51 0-2.91-.49-4.06-1.3l-1.42 1.44C8.04 20.3 9.94 21 12 21c4.97 0 9-4.03 9-9s-4.03-9-9-9z"></path></g> <g id="settings-bluetooth"><path d="M11 24h2v-2h-2v2zm-4 0h2v-2H7v2zm8 0h2v-2h-2v2zm2.71-18.29L12 0h-1v7.59L6.41 3 5 4.41 10.59 10 5 15.59 6.41 17 11 12.41V20h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 3.83l1.88 1.88L13 7.59V3.83zm1.88 10.46L13 16.17v-3.76l1.88 1.88z"></path></g> <g id="settings-brightness"><path d="M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02zM8 16h2.5l1.5 1.5 1.5-1.5H16v-2.5l1.5-1.5-1.5-1.5V8h-2.5L12 6.5 10.5 8H8v2.5L6.5 12 8 13.5V16zm4-7c1.66 0 3 1.34 3 3s-1.34 3-3 3V9z"></path></g> <g id="settings-cell"><path d="M7 24h2v-2H7v2zm4 0h2v-2h-2v2zm4 0h2v-2h-2v2zM16 .01L8 0C6.9 0 6 .9 6 2v16c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V2c0-1.1-.9-1.99-2-1.99zM16 16H8V4h8v12z"></path></g> <g id="settings-ethernet"><path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z"></path></g> <g id="settings-input-antenna"><path d="M12 5c-3.87 0-7 3.13-7 7h2c0-2.76 2.24-5 5-5s5 2.24 5 5h2c0-3.87-3.13-7-7-7zm1 9.29c.88-.39 1.5-1.26 1.5-2.29 0-1.38-1.12-2.5-2.5-2.5S9.5 10.62 9.5 12c0 1.02.62 1.9 1.5 2.29v3.3L7.59 21 9 22.41l3-3 3 3L16.41 21 13 17.59v-3.3zM12 1C5.93 1 1 5.93 1 12h2c0-4.97 4.03-9 9-9s9 4.03 9 9h2c0-6.07-4.93-11-11-11z"></path></g> <g id="settings-input-component"><path d="M5 2c0-.55-.45-1-1-1s-1 .45-1 1v4H1v6h6V6H5V2zm4 14c0 1.3.84 2.4 2 2.82V23h2v-4.18c1.16-.41 2-1.51 2-2.82v-2H9v2zm-8 0c0 1.3.84 2.4 2 2.82V23h2v-4.18C6.16 18.4 7 17.3 7 16v-2H1v2zM21 6V2c0-.55-.45-1-1-1s-1 .45-1 1v4h-2v6h6V6h-2zm-8-4c0-.55-.45-1-1-1s-1 .45-1 1v4H9v6h6V6h-2V2zm4 14c0 1.3.84 2.4 2 2.82V23h2v-4.18c1.16-.41 2-1.51 2-2.82v-2h-6v2z"></path></g> <g id="settings-input-composite"><path d="M5 2c0-.55-.45-1-1-1s-1 .45-1 1v4H1v6h6V6H5V2zm4 14c0 1.3.84 2.4 2 2.82V23h2v-4.18c1.16-.41 2-1.51 2-2.82v-2H9v2zm-8 0c0 1.3.84 2.4 2 2.82V23h2v-4.18C6.16 18.4 7 17.3 7 16v-2H1v2zM21 6V2c0-.55-.45-1-1-1s-1 .45-1 1v4h-2v6h6V6h-2zm-8-4c0-.55-.45-1-1-1s-1 .45-1 1v4H9v6h6V6h-2V2zm4 14c0 1.3.84 2.4 2 2.82V23h2v-4.18c1.16-.41 2-1.51 2-2.82v-2h-6v2z"></path></g> <g id="settings-input-hdmi"><path d="M18 7V4c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v3H5v6l3 6v3h8v-3l3-6V7h-1zM8 4h8v3h-2V5h-1v2h-2V5h-1v2H8V4z"></path></g> <g id="settings-input-svideo"><path d="M8 11.5c0-.83-.67-1.5-1.5-1.5S5 10.67 5 11.5 5.67 13 6.5 13 8 12.33 8 11.5zm7-5c0-.83-.67-1.5-1.5-1.5h-3C9.67 5 9 5.67 9 6.5S9.67 8 10.5 8h3c.83 0 1.5-.67 1.5-1.5zM8.5 15c-.83 0-1.5.67-1.5 1.5S7.67 18 8.5 18s1.5-.67 1.5-1.5S9.33 15 8.5 15zM12 1C5.93 1 1 5.93 1 12s4.93 11 11 11 11-4.93 11-11S18.07 1 12 1zm0 20c-4.96 0-9-4.04-9-9s4.04-9 9-9 9 4.04 9 9-4.04 9-9 9zm5.5-11c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm-2 5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"></path></g> <g id="settings-overscan"><path d="M12.01 5.5L10 8h4l-1.99-2.5zM18 10v4l2.5-1.99L18 10zM6 10l-2.5 2.01L6 14v-4zm8 6h-4l2.01 2.5L14 16zm7-13H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z"></path></g> <g id="settings-phone"><path d="M13 9h-2v2h2V9zm4 0h-2v2h2V9zm3 6.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.58l2.2-2.21c.28-.27.36-.66.25-1.01C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM19 9v2h2V9h-2z"></path></g> <g id="settings-power"><path d="M7 24h2v-2H7v2zm4 0h2v-2h-2v2zm2-22h-2v10h2V2zm3.56 2.44l-1.45 1.45C16.84 6.94 18 8.83 18 11c0 3.31-2.69 6-6 6s-6-2.69-6-6c0-2.17 1.16-4.06 2.88-5.12L7.44 4.44C5.36 5.88 4 8.28 4 11c0 4.42 3.58 8 8 8s8-3.58 8-8c0-2.72-1.36-5.12-3.44-6.56zM15 24h2v-2h-2v2z"></path></g> <g id="settings-remote"><path d="M15 9H9c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V10c0-.55-.45-1-1-1zm-3 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM7.05 6.05l1.41 1.41C9.37 6.56 10.62 6 12 6s2.63.56 3.54 1.46l1.41-1.41C15.68 4.78 13.93 4 12 4s-3.68.78-4.95 2.05zM12 0C8.96 0 6.21 1.23 4.22 3.22l1.41 1.41C7.26 3.01 9.51 2 12 2s4.74 1.01 6.36 2.64l1.41-1.41C17.79 1.23 15.04 0 12 0z"></path></g> <g id="settings-voice"><path d="M7 24h2v-2H7v2zm5-11c1.66 0 2.99-1.34 2.99-3L15 4c0-1.66-1.34-3-3-3S9 2.34 9 4v6c0 1.66 1.34 3 3 3zm-1 11h2v-2h-2v2zm4 0h2v-2h-2v2zm4-14h-1.7c0 3-2.54 5.1-5.3 5.1S6.7 13 6.7 10H5c0 3.41 2.72 6.23 6 6.72V20h2v-3.28c3.28-.49 6-3.31 6-6.72z"></path></g> <g id="shop"><path d="M16 6V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H2v13c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6h-6zm-6-2h4v2h-4V4zM9 18V9l7.5 4L9 18z"></path></g> <g id="shop-two"><path d="M3 9H1v11c0 1.11.89 2 2 2h14c1.11 0 2-.89 2-2H3V9zm15-4V3c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H5v11c0 1.11.89 2 2 2h14c1.11 0 2-.89 2-2V5h-5zm-6-2h4v2h-4V3zm0 12V8l5.5 3-5.5 4z"></path></g> <g id="shopping-basket"><path d="M17.21 9l-4.38-6.56c-.19-.28-.51-.42-.83-.42-.32 0-.64.14-.83.43L6.79 9H2c-.55 0-1 .45-1 1 0 .09.01.18.04.27l2.54 9.27c.23.84 1 1.46 1.92 1.46h13c.92 0 1.69-.62 1.93-1.46l2.54-9.27L23 10c0-.55-.45-1-1-1h-4.79zM9 9l3-4.4L15 9H9zm3 8c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></g> <g id="shopping-cart"><path d="M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z"></path></g> <g id="sort"><path d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"></path></g> <g id="speaker-notes"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 14H6v-2h2v2zm0-3H6V9h2v2zm0-3H6V6h2v2zm7 6h-5v-2h5v2zm3-3h-8V9h8v2zm0-3h-8V6h8v2z"></path></g> <g id="speaker-notes-off"><path d="M10.54 11l-.54-.54L7.54 8 6 6.46 2.38 2.84 1.27 1.73 0 3l2.01 2.01L2 22l4-4h9l5.73 5.73L22 22.46 17.54 18l-7-7zM8 14H6v-2h2v2zm-2-3V9l2 2H6zm14-9H4.08L10 7.92V6h8v2h-7.92l1 1H18v2h-4.92l6.99 6.99C21.14 17.95 22 17.08 22 16V4c0-1.1-.9-2-2-2z"></path></g> <g id="spellcheck"><path d="M12.45 16h2.09L9.43 3H7.57L2.46 16h2.09l1.12-3h5.64l1.14 3zm-6.02-5L8.5 5.48 10.57 11H6.43zm15.16.59l-8.09 8.09L9.83 16l-1.41 1.41 5.09 5.09L23 13l-1.41-1.41z"></path></g> <g id="star"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"></path></g> <g id="star-border"><path d="M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"></path></g> <g id="star-half"><path d="M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4V6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"></path></g> <g id="stars"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm4.24 16L12 15.45 7.77 18l1.12-4.81-3.73-3.23 4.92-.42L12 5l1.92 4.53 4.92.42-3.73 3.23L16.23 18z"></path></g> <g id="store"><path d="M20 4H4v2h16V4zm1 10v-2l-1-5H4l-1 5v2h1v6h10v-6h4v6h2v-6h1zm-9 4H6v-4h6v4z"></path></g> <g id="subdirectory-arrow-left"><path d="M11 9l1.42 1.42L8.83 14H18V4h2v12H8.83l3.59 3.58L11 21l-6-6 6-6z"></path></g> <g id="subdirectory-arrow-right"><path d="M19 15l-6 6-1.42-1.42L15.17 16H4V4h2v10h9.17l-3.59-3.58L13 9l6 6z"></path></g> <g id="subject"><path d="M14 17H4v2h10v-2zm6-8H4v2h16V9zM4 15h16v-2H4v2zM4 5v2h16V5H4z"></path></g> <g id="supervisor-account"><path d="M16.5 12c1.38 0 2.49-1.12 2.49-2.5S17.88 7 16.5 7C15.12 7 14 8.12 14 9.5s1.12 2.5 2.5 2.5zM9 11c1.66 0 2.99-1.34 2.99-3S10.66 5 9 5C7.34 5 6 6.34 6 8s1.34 3 3 3zm7.5 3c-1.83 0-5.5.92-5.5 2.75V19h11v-2.25c0-1.83-3.67-2.75-5.5-2.75zM9 13c-2.33 0-7 1.17-7 3.5V19h7v-2.25c0-.85.33-2.34 2.37-3.47C10.5 13.1 9.66 13 9 13z"></path></g> <g id="swap-horiz"><path d="M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"></path></g> <g id="swap-vert"><path d="M16 17.01V10h-2v7.01h-3L15 21l4-3.99h-3zM9 3L5 6.99h3V14h2V6.99h3L9 3z"></path></g> <g id="swap-vertical-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM6.5 9L10 5.5 13.5 9H11v4H9V9H6.5zm11 6L14 18.5 10.5 15H13v-4h2v4h2.5z"></path></g> <g id="system-update-alt"><path d="M12 16.5l4-4h-3v-9h-2v9H8l4 4zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2z"></path></g> <g id="tab"><path d="M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h10v4h8v10z"></path></g> <g id="tab-unselected"><path d="M1 9h2V7H1v2zm0 4h2v-2H1v2zm0-8h2V3c-1.1 0-2 .9-2 2zm8 16h2v-2H9v2zm-8-4h2v-2H1v2zm2 4v-2H1c0 1.1.9 2 2 2zM21 3h-8v6h10V5c0-1.1-.9-2-2-2zm0 14h2v-2h-2v2zM9 5h2V3H9v2zM5 21h2v-2H5v2zM5 5h2V3H5v2zm16 16c1.1 0 2-.9 2-2h-2v2zm0-8h2v-2h-2v2zm-8 8h2v-2h-2v2zm4 0h2v-2h-2v2z"></path></g> <g id="text-format"><path d="M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98L13.87 11h-3.74L12 5.98z"></path></g> <g id="theaters"><path d="M18 3v2h-2V3H8v2H6V3H4v18h2v-2h2v2h8v-2h2v2h2V3h-2zM8 17H6v-2h2v2zm0-4H6v-2h2v2zm0-4H6V7h2v2zm10 8h-2v-2h2v2zm0-4h-2v-2h2v2zm0-4h-2V7h2v2z"></path></g> <g id="thumb-down"><path d="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v1.91l.01.01L1 14c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm4 0v12h4V3h-4z"></path></g> <g id="thumb-up"><path d="M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-1.91l-.01-.01L23 10z"></path></g> <g id="thumbs-up-down"><path d="M12 6c0-.55-.45-1-1-1H5.82l.66-3.18.02-.23c0-.31-.13-.59-.33-.8L5.38 0 .44 4.94C.17 5.21 0 5.59 0 6v6.5c0 .83.67 1.5 1.5 1.5h6.75c.62 0 1.15-.38 1.38-.91l2.26-5.29c.07-.17.11-.36.11-.55V6zm10.5 4h-6.75c-.62 0-1.15.38-1.38.91l-2.26 5.29c-.07.17-.11.36-.11.55V18c0 .55.45 1 1 1h5.18l-.66 3.18-.02.24c0 .31.13.59.33.8l.79.78 4.94-4.94c.27-.27.44-.65.44-1.06v-6.5c0-.83-.67-1.5-1.5-1.5z"></path></g> <g id="timeline"><path d="M23 8c0 1.1-.9 2-2 2-.18 0-.35-.02-.51-.07l-3.56 3.55c.05.16.07.34.07.52 0 1.1-.9 2-2 2s-2-.9-2-2c0-.18.02-.36.07-.52l-2.55-2.55c-.16.05-.34.07-.52.07s-.36-.02-.52-.07l-4.55 4.56c.05.16.07.33.07.51 0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2c.18 0 .35.02.51.07l4.56-4.55C8.02 9.36 8 9.18 8 9c0-1.1.9-2 2-2s2 .9 2 2c0 .18-.02.36-.07.52l2.55 2.55c.16-.05.34-.07.52-.07s.36.02.52.07l3.55-3.56C19.02 8.35 19 8.18 19 8c0-1.1.9-2 2-2s2 .9 2 2z"></path></g> <g id="toc"><path d="M3 9h14V7H3v2zm0 4h14v-2H3v2zm0 4h14v-2H3v2zm16 0h2v-2h-2v2zm0-10v2h2V7h-2zm0 6h2v-2h-2v2z"></path></g> <g id="today"><path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"></path></g> <g id="toll"><path d="M15 4c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zM3 12c0-2.61 1.67-4.83 4-5.65V4.26C3.55 5.15 1 8.27 1 12s2.55 6.85 6 7.74v-2.09c-2.33-.82-4-3.04-4-5.65z"></path></g> <g id="touch-app"><path d="M9 11.24V7.5C9 6.12 10.12 5 11.5 5S14 6.12 14 7.5v3.74c1.21-.81 2-2.18 2-3.74C16 5.01 13.99 3 11.5 3S7 5.01 7 7.5c0 1.56.79 2.93 2 3.74zm9.84 4.63l-4.54-2.26c-.17-.07-.35-.11-.54-.11H13v-6c0-.83-.67-1.5-1.5-1.5S10 6.67 10 7.5v10.74l-3.43-.72c-.08-.01-.15-.03-.24-.03-.31 0-.59.13-.79.33l-.79.8 4.94 4.94c.27.27.65.44 1.06.44h6.79c.75 0 1.33-.55 1.44-1.28l.75-5.27c.01-.07.02-.14.02-.2 0-.62-.38-1.16-.91-1.38z"></path></g> <g id="track-changes"><path d="M19.07 4.93l-1.41 1.41C19.1 7.79 20 9.79 20 12c0 4.42-3.58 8-8 8s-8-3.58-8-8c0-4.08 3.05-7.44 7-7.93v2.02C8.16 6.57 6 9.03 6 12c0 3.31 2.69 6 6 6s6-2.69 6-6c0-1.66-.67-3.16-1.76-4.24l-1.41 1.41C15.55 9.9 16 10.9 16 12c0 2.21-1.79 4-4 4s-4-1.79-4-4c0-1.86 1.28-3.41 3-3.86v2.14c-.6.35-1 .98-1 1.72 0 1.1.9 2 2 2s2-.9 2-2c0-.74-.4-1.38-1-1.72V2h-1C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10c0-2.76-1.12-5.26-2.93-7.07z"></path></g> <g id="translate"><path d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"></path></g> <g id="trending-down"><path d="M16 18l2.29-2.29-4.88-4.88-4 4L2 7.41 3.41 6l6 6 4-4 6.3 6.29L22 12v6z"></path></g> <g id="trending-flat"><path d="M22 12l-4-4v3H3v2h15v3z"></path></g> <g id="trending-up"><path d="M16 6l2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6z"></path></g> <g id="turned-in"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"></path></g> <g id="turned-in-not"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z"></path></g> <g id="unarchive"><path d="M20.55 5.22l-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.15.55L3.46 5.22C3.17 5.57 3 6.01 3 6.5V19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.49-.17-.93-.45-1.28zM12 9.5l5.5 5.5H14v2h-4v-2H6.5L12 9.5zM5.12 5l.82-1h12l.93 1H5.12z"></path></g> <g id="undo"><path d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"></path></g> <g id="unfold-less"><path d="M7.41 18.59L8.83 20 12 16.83 15.17 20l1.41-1.41L12 14l-4.59 4.59zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10l4.59-4.59z"></path></g> <g id="unfold-more"><path d="M12 5.83L15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9 12 5.83zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15 12 18.17z"></path></g> <g id="update"><path d="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79 2.73 2.71 7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58 3.51-3.47 9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"></path></g> <g id="verified-user"><path d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm-2 16l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z"></path></g> <g id="view-agenda"><path d="M20 13H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h17c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zm0-10H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h17c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"></path></g> <g id="view-array"><path d="M4 18h3V5H4v13zM18 5v13h3V5h-3zM8 18h9V5H8v13z"></path></g> <g id="view-carousel"><path d="M7 19h10V4H7v15zm-5-2h4V6H2v11zM18 6v11h4V6h-4z"></path></g> <g id="view-column"><path d="M10 18h5V5h-5v13zm-6 0h5V5H4v13zM16 5v13h5V5h-5z"></path></g> <g id="view-day"><path d="M2 21h19v-3H2v3zM20 8H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h17c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zM2 3v3h19V3H2z"></path></g> <g id="view-headline"><path d="M4 15h16v-2H4v2zm0 4h16v-2H4v2zm0-8h16V9H4v2zm0-6v2h16V5H4z"></path></g> <g id="view-list"><path d="M4 14h4v-4H4v4zm0 5h4v-4H4v4zM4 9h4V5H4v4zm5 5h12v-4H9v4zm0 5h12v-4H9v4zM9 5v4h12V5H9z"></path></g> <g id="view-module"><path d="M4 11h5V5H4v6zm0 7h5v-6H4v6zm6 0h5v-6h-5v6zm6 0h5v-6h-5v6zm-6-7h5V5h-5v6zm6-6v6h5V5h-5z"></path></g> <g id="view-quilt"><path d="M10 18h5v-6h-5v6zm-6 0h5V5H4v13zm12 0h5v-6h-5v6zM10 5v6h11V5H10z"></path></g> <g id="view-stream"><path d="M4 18h17v-6H4v6zM4 5v6h17V5H4z"></path></g> <g id="view-week"><path d="M6 5H3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm14 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-7 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"></path></g> <g id="visibility"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"></path></g> <g id="visibility-off"><path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"></path></g> <g id="warning"><path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"></path></g> <g id="watch-later"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"></path></g> <g id="weekend"><path d="M21 10c-1.1 0-2 .9-2 2v3H5v-3c0-1.1-.9-2-2-2s-2 .9-2 2v5c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-5c0-1.1-.9-2-2-2zm-3-5H6c-1.1 0-2 .9-2 2v2.15c1.16.41 2 1.51 2 2.82V14h12v-2.03c0-1.3.84-2.4 2-2.82V7c0-1.1-.9-2-2-2z"></path></g> <g id="work"><path d="M20 6h-4V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-6 0h-4V4h4v2z"></path></g> <g id="youtube-searched-for"><path d="M17.01 14h-.8l-.27-.27c.98-1.14 1.57-2.61 1.57-4.23 0-3.59-2.91-6.5-6.5-6.5s-6.5 3-6.5 6.5H2l3.84 4 4.16-4H6.51C6.51 7 8.53 5 11.01 5s4.5 2.01 4.5 4.5c0 2.48-2.02 4.5-4.5 4.5-.65 0-1.26-.14-1.82-.38L7.71 15.1c.97.57 2.09.9 3.3.9 1.61 0 3.08-.59 4.22-1.57l.27.27v.79l5.01 4.99L22 19l-4.99-5z"></path></g> <g id="zoom-in"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"></path></g> <g id="zoom-out"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"></path></g> </defs></svg> </iron-iconset-svg>`;document.head.appendChild(template$k.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ var KEY_IDENTIFIER={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"},KEY_CODE={8:"backspace",9:"tab",13:"enter",27:"esc",33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"del",106:"*"},MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrlKey",alt:"altKey",meta:"metaKey"},KEY_CHAR=/[a-z0-9*]/,IDENT_CHAR=/U\+/,ARROW_KEY=/^arrow/,SPACE_KEY=/^space(bar)?/,ESC_KEY=/^escape$/;function transformKey(e,t){var n="";if(e){var i=e.toLowerCase();" "===i||SPACE_KEY.test(i)?n="space":ESC_KEY.test(i)?n="esc":1==i.length?t&&!KEY_CHAR.test(i)||(n=i):n=ARROW_KEY.test(i)?i.replace("arrow",""):"multiply"==i?"*":i}return n}function transformKeyIdentifier(e){var t="";return e&&(e in KEY_IDENTIFIER?t=KEY_IDENTIFIER[e]:IDENT_CHAR.test(e)?(e=parseInt(e.replace("U+","0x"),16),t=String.fromCharCode(e).toLowerCase()):t=e.toLowerCase()),t}function transformKeyCode(e){var t="";return Number(e)&&(t=e>=65&&e<=90?String.fromCharCode(32+e):e>=112&&e<=123?"f"+(e-112+1):e>=48&&e<=57?String(e-48):e>=96&&e<=105?String(e-96):KEY_CODE[e]),t}function normalizedKeyForEvent(e,t){return e.key?transformKey(e.key,t):e.detail&&e.detail.key?transformKey(e.detail.key,t):transformKeyIdentifier(e.keyIdentifier)||transformKeyCode(e.keyCode)||""}function keyComboMatchesEvent(e,t){return normalizedKeyForEvent(t,e.hasModifiers)===e.key&&(!e.hasModifiers||!!t.shiftKey==!!e.shiftKey&&!!t.ctrlKey==!!e.ctrlKey&&!!t.altKey==!!e.altKey&&!!t.metaKey==!!e.metaKey)}function parseKeyComboString(e){return 1===e.length?{combo:e,key:e,event:"keydown"}:e.split("+").reduce((function(e,t){var n=t.split(":"),i=n[0],r=n[1];return i in MODIFIER_KEYS?(e[MODIFIER_KEYS[i]]=!0,e.hasModifiers=!0):(e.key=i,e.event=r||"keydown"),e}),{combo:e.split(":").shift()})}function parseEventString(e){return e.trim().split(" ").map((function(e){return parseKeyComboString(e)}))}const IronA11yKeysBehavior={properties:{keyEventTarget:{type:Object,value:function(){return this}},stopKeyboardEventPropagation:{type:Boolean,value:!1},_boundKeyHandlers:{type:Array,value:function(){return[]}},_imperativeKeyBindings:{type:Object,value:function(){return{}}}},observers:["_resetKeyEventListeners(keyEventTarget, _boundKeyHandlers)"],keyBindings:{},registered:function(){this._prepKeyBindings()},attached:function(){this._listenKeyEventListeners()},detached:function(){this._unlistenKeyEventListeners()},addOwnKeyBinding:function(e,t){this._imperativeKeyBindings[e]=t,this._prepKeyBindings(),this._resetKeyEventListeners()},removeOwnKeyBindings:function(){this._imperativeKeyBindings={},this._prepKeyBindings(),this._resetKeyEventListeners()},keyboardEventMatchesKeys:function(e,t){for(var n=parseEventString(t),i=0;i<n.length;++i)if(keyComboMatchesEvent(n[i],e))return!0;return!1},_collectKeyBindings:function(){var e=this.behaviors.map((function(e){return e.keyBindings}));return-1===e.indexOf(this.keyBindings)&&e.push(this.keyBindings),e},_prepKeyBindings:function(){for(var e in this._keyBindings={},this._collectKeyBindings().forEach((function(e){for(var t in e)this._addKeyBinding(t,e[t])}),this),this._imperativeKeyBindings)this._addKeyBinding(e,this._imperativeKeyBindings[e]);for(var t in this._keyBindings)this._keyBindings[t].sort((function(e,t){var n=e[0].hasModifiers;return n===t[0].hasModifiers?0:n?-1:1}))},_addKeyBinding:function(e,t){parseEventString(e).forEach((function(e){this._keyBindings[e.event]=this._keyBindings[e.event]||[],this._keyBindings[e.event].push([e,t])}),this)},_resetKeyEventListeners:function(){this._unlistenKeyEventListeners(),this.isAttached&&this._listenKeyEventListeners()},_listenKeyEventListeners:function(){this.keyEventTarget&&Object.keys(this._keyBindings).forEach((function(e){var t=this._onKeyBindingEvent.bind(this,this._keyBindings[e]);this._boundKeyHandlers.push([this.keyEventTarget,e,t]),this.keyEventTarget.addEventListener(e,t)}),this)},_unlistenKeyEventListeners:function(){for(var e;this._boundKeyHandlers.length;)(e=this._boundKeyHandlers.pop())[0].removeEventListener(e[1],e[2])},_onKeyBindingEvent:function(e,t){if(this.stopKeyboardEventPropagation&&t.stopPropagation(),!t.defaultPrevented)for(var n=0;n<e.length;n++){var i=e[n][0],r=e[n][1];if(keyComboMatchesEvent(i,t)&&(this._triggerKeyHandler(i,r,t),t.defaultPrevented))return}},_triggerKeyHandler:function(e,t,n){var i=Object.create(e);i.keyboardEvent=n;var r=new CustomEvent(e.event,{detail:i,cancelable:!0});this[t].call(this,r),r.defaultPrevented&&n.preventDefault()}},IronScrollTargetBehavior={properties:{scrollTarget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},observers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:!0,_scrollTargetChanged:function(e,t){if(this._oldScrollTarget&&(this._toggleScrollListener(!1,this._oldScrollTarget),this._oldScrollTarget=null),t)if("document"===e)this.scrollTarget=this._doc;else if("string"==typeof e){var n=this.domHost;this.scrollTarget=n&&n.$?n.$[e]:dom$1(this.ownerDocument).querySelector("#"+e)}else this._isValidScrollTarget()&&(this._oldScrollTarget=e,this._toggleScrollListener(this._shouldHaveListener,e))},_scrollHandler:function e(){},get _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrollTop(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop:0},get _scrollLeft(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.pageXOffset:this.scrollTarget.scrollLeft:0},set _scrollTop(e){this.scrollTarget===this._doc?window.scrollTo(window.pageXOffset,e):this._isValidScrollTarget()&&(this.scrollTarget.scrollTop=e)},set _scrollLeft(e){this.scrollTarget===this._doc?window.scrollTo(e,window.pageYOffset):this._isValidScrollTarget()&&(this.scrollTarget.scrollLeft=e)},scroll:function(e,t){var n;"object"==typeof e?(n=e.left,t=e.top):n=e,n=n||0,t=t||0,this.scrollTarget===this._doc?window.scrollTo(n,t):this._isValidScrollTarget()&&(this.scrollTarget.scrollLeft=n,this.scrollTarget.scrollTop=t)},get _scrollTargetWidth(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth:0},get _scrollTargetHeight(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget.offsetHeight:0},_isValidScrollTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleScrollListener:function(e,t){var n=t===this._doc?window:t;e?this._boundScrollHandler||(this._boundScrollHandler=this._scrollHandler.bind(this),n.addEventListener("scroll",this._boundScrollHandler)):this._boundScrollHandler&&(n.removeEventListener("scroll",this._boundScrollHandler),this._boundScrollHandler=null)},toggleScrollListener:function(e){this._shouldHaveListener=e,this._toggleScrollListener(e,this.scrollTarget)}}; /** @license Copyright (c) 2016 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ /** @license Copyright (c) 2016 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ var IOS=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/),IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8,DEFAULT_PHYSICAL_COUNT=3,HIDDEN_Y="-10000px",SECRET_TABINDEX=-100;Polymer({_template:html` <style> :host { display: block; } @media only screen and (-webkit-max-device-pixel-ratio: 1) { :host { will-change: transform; } } #items { @apply --iron-list-items-container; position: relative; } :host(:not([grid])) #items > ::slotted(*) { width: 100%; } #items > ::slotted(*) { box-sizing: border-box; margin: 0; position: absolute; top: 0; will-change: transform; } </style> <array-selector id="selector" items="{{items}}" selected="{{selectedItems}}" selected-item="{{selectedItem}}"></array-selector> <div id="items"> <slot></slot> </div> `,is:"iron-list",properties:{items:{type:Array},as:{type:String,value:"item"},indexAs:{type:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_gridChanged"},selectionEnabled:{type:Boolean,value:!1},selectedItem:{type:Object,notify:!0},selectedItems:{type:Object,notify:!0},multiSelection:{type:Boolean,value:!1},scrollOffset:{type:Number,value:0}},observers:["_itemsChanged(items.*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChanged(multiSelection)","_setOverflow(scrollTarget, scrollOffset)"],behaviors:[Templatizer,IronResizableBehavior,IronScrollTargetBehavior,OptionalMutableDataBehavior],_ratio:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalItems:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null,_maxPages:2,_focusedItem:null,_focusedVirtualIndex:-1,_focusedPhysicalIndex:-1,_offscreenFocusedItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,_templateCost:0,_parentModel:!0,get _physicalBottom(){return this._physicalTop+this._physicalSize},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _virtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSize(){return(this.grid?this._physicalRows*this._rowHeight:this._physicalSize)-this._viewportHeight},get _itemsParent(){return dom$1(dom$1(this._userTemplate).parentNode)},get _maxScrollTop(){return this._estScrollHeight-this._viewportHeight+this._scrollOffset},get _maxVirtualStart(){var e=this._convertIndexToCompleteRow(this._virtualCount);return Math.max(0,e-this._physicalCount)},set _virtualStart(e){e=this._clamp(e,0,this._maxVirtualStart),this.grid&&(e-=e%this._itemsPerRow),this._virtualStartVal=e},get _virtualStart(){return this._virtualStartVal||0},set _physicalStart(e){(e%=this._physicalCount)<0&&(e=this._physicalCount+e),this.grid&&(e-=e%this._itemsPerRow),this._physicalStartVal=e},get _physicalStart(){return this._physicalStartVal||0},get _physicalEnd(){return(this._physicalStart+this._physicalCount-1)%this._physicalCount},set _physicalCount(e){this._physicalCountVal=e},get _physicalCount(){return this._physicalCountVal||0},get _optPhysicalSize(){return 0===this._viewportHeight?1/0:this._viewportHeight*this._maxPages},get _isVisible(){return Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){var e=this._firstVisibleIndexVal;if(null==e){var t=this._physicalTop+this._scrollOffset;e=this._iterateItems((function(e,n){return(t+=this._getPhysicalSizeIncrement(e))>this._scrollPosition?this.grid?n-n%this._itemsPerRow:n:this.grid&&this._virtualCount-1===n?n-n%this._itemsPerRow:void 0}))||0,this._firstVisibleIndexVal=e}return e},get lastVisibleIndex(){var e=this._lastVisibleIndexVal;if(null==e){if(this.grid)e=Math.min(this._virtualCount,this.firstVisibleIndex+this._estRowsInView*this._itemsPerRow-1);else{var t=this._physicalTop+this._scrollOffset;this._iterateItems((function(n,i){t<this._scrollBottom&&(e=i),t+=this._getPhysicalSizeIncrement(n)}))}this._lastVisibleIndexVal=e}return e},get _defaultScrollTarget(){return this},get _virtualRowCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estRowsInView(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physicalRows(){return Math.ceil(this._physicalCount/this._itemsPerRow)},get _scrollOffset(){return this._scrollerPaddingTop+this.scrollOffset},ready:function(){this.addEventListener("focus",this._didFocus.bind(this),!0)},attached:function(){this._debounce("_render",this._render,animationFrame),this.listen(this,"iron-resize","_resizeHandler"),this.listen(this,"keydown","_keydownHandler")},detached:function(){this.unlisten(this,"iron-resize","_resizeHandler"),this.unlisten(this,"keydown","_keydownHandler")},_setOverflow:function(e){this.style.webkitOverflowScrolling=e===this?"touch":"",this.style.overflowY=e===this?"auto":"",this._lastVisibleIndexVal=null,this._firstVisibleIndexVal=null,this._debounce("_render",this._render,animationFrame)},updateViewportBoundaries:function(){var e=window.getComputedStyle(this);this._scrollerPaddingTop=this.scrollTarget===this?0:parseInt(e["padding-top"],10),this._isRTL=Boolean("rtl"===e.direction),this._viewportWidth=this.$.items.offsetWidth,this._viewportHeight=this._scrollTargetHeight,this.grid&&this._updateGridMetrics()},_scrollHandler:function(){var e=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop)),t=e-this._scrollPosition,n=t>=0;if(this._scrollPosition=e,this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,Math.abs(t)>this._physicalSize&&this._physicalSize>0){t-=this._scrollOffset;var i=Math.round(t/this._physicalAverage)*this._itemsPerRow;this._virtualStart=this._virtualStart+i,this._physicalStart=this._physicalStart+i,this._physicalTop=Math.min(Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAverage,this._scrollPosition),this._update()}else if(this._physicalCount>0){var r=this._getReusables(n);n?(this._physicalTop=r.physicalTop,this._virtualStart=this._virtualStart+r.indexes.length,this._physicalStart=this._physicalStart+r.indexes.length):(this._virtualStart=this._virtualStart-r.indexes.length,this._physicalStart=this._physicalStart-r.indexes.length),this._update(r.indexes,n?null:r.indexes),this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,0),microTask)}},_getReusables:function(e){var t,n,i,r=[],o=this._hiddenContentSize*this._ratio,a=this._virtualStart,s=this._virtualEnd,l=this._physicalCount,c=this._physicalTop+this._scrollOffset,h=this._scrollPosition,u=this._scrollBottom;for(e?(t=this._physicalStart,n=h-c):(t=this._physicalEnd,n=this._physicalBottom+this._scrollOffset-u);n-=i=this._getPhysicalSizeIncrement(t),!(r.length>=l||n<=o);)if(e){if(s+r.length+1>=this._virtualCount)break;if(c+i>=h-this._scrollOffset)break;r.push(t),c+=i,t=(t+1)%l}else{if(a-r.length<=0)break;if(c+this._physicalSize-i<=u)break;r.push(t),c-=i,t=0===t?l-1:t-1}return{indexes:r,physicalTop:c-this._scrollOffset}},_update:function(e,t){if(!(e&&0===e.length||0===this._physicalCount)){if(this._manageFocus(),this._assignModels(e),this._updateMetrics(e),t)for(;t.length;){var n=t.pop();this._physicalTop-=this._getPhysicalSizeIncrement(n)}this._positionItems(),this._updateScrollerSize()}},_createPool:function(e){var t,n;this._ensureTemplatized();var i=new Array(e);for(t=0;t<e;t++)n=this.stamp(null),i[t]=n.root.querySelector("*"),this._itemsParent.appendChild(n.root);return i},_isClientFull:function(){return 0!=this._scrollBottom&&this._physicalBottom-1>=this._scrollBottom&&this._physicalTop<=this._scrollPosition},_increasePoolIfNeeded:function(e){var t=this._clamp(this._physicalCount+e,DEFAULT_PHYSICAL_COUNT,this._virtualCount-this._virtualStart);if(t=this._convertIndexToCompleteRow(t),this.grid){var n=t%this._itemsPerRow;n&&t-n<=this._physicalCount&&(t+=this._itemsPerRow),t-=n}var i=t-this._physicalCount,r=Math.round(.5*this._physicalCount);if(!(i<0)){if(i>0){var o=window.performance.now();[].push.apply(this._physicalItems,this._createPool(i));for(var a=0;a<i;a++)this._physicalSizes.push(0);this._physicalCount=this._physicalCount+i,this._physicalStart>this._physicalEnd&&this._isIndexRendered(this._focusedVirtualIndex)&&this._getPhysicalIndex(this._focusedVirtualIndex)<this._physicalEnd&&(this._physicalStart=this._physicalStart+i),this._update(),this._templateCost=(window.performance.now()-o)/i,r=Math.round(.5*this._physicalCount)}this._virtualEnd>=this._virtualCount-1||0===r||(this._isClientFull()?this._physicalSize<this._optPhysicalSize&&this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,this._clamp(Math.round(50/this._templateCost),1,r)),idlePeriod):this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,r),microTask))}},_render:function(){if(this.isAttached&&this._isVisible)if(0!==this._physicalCount){var e=this._getReusables(!0);this._physicalTop=e.physicalTop,this._virtualStart=this._virtualStart+e.indexes.length,this._physicalStart=this._physicalStart+e.indexes.length,this._update(e.indexes),this._update(),this._increasePoolIfNeeded(0)}else this._virtualCount>0&&(this.updateViewportBoundaries(),this._increasePoolIfNeeded(DEFAULT_PHYSICAL_COUNT))},_ensureTemplatized:function(){if(!this.ctor){this._userTemplate=this.queryEffectiveChildren("template"),this._userTemplate||console.warn("iron-list requires a template to be provided in light-dom");var e={__key__:!0};e[this.as]=!0,e[this.indexAs]=!0,e[this.selectedAs]=!0,e.tabIndex=!0,this._instanceProps=e,this.templatize(this._userTemplate,this.mutableData)}},_gridChanged:function(e,t){void 0!==t&&(this.notifyResize(),flush(),e&&this._updateGridMetrics())},_itemsChanged:function(e){if("items"===e.path)this._virtualStart=0,this._physicalTop=0,this._virtualCount=this.items?this.items.length:0,this._physicalIndexForKey={},this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,this._physicalCount=this._physicalCount||0,this._physicalItems=this._physicalItems||[],this._physicalSizes=this._physicalSizes||[],this._physicalStart=0,this._scrollTop>this._scrollOffset&&this._resetScrollPosition(0),this._removeFocusedItem(),this._debounce("_render",this._render,animationFrame);else if("items.splices"===e.path){if(this._adjustVirtualIndex(e.value.indexSplices),this._virtualCount=this.items?this.items.length:0,e.value.indexSplices.some((function(e){return e.addedCount>0||e.removed.length>0}))){var t=this._getActiveElement();this.contains(t)&&t.blur()}var n=e.value.indexSplices.some((function(e){return e.index+e.addedCount>=this._virtualStart&&e.index<=this._virtualEnd}),this);this._isClientFull()&&!n||this._debounce("_render",this._render,animationFrame)}else"items.length"!==e.path&&this._forwardItemPath(e.path,e.value)},_forwardItemPath:function(e,t){var n,i,r,o=(e=e.slice(6)).indexOf(".");-1===o&&(o=e.length);var a=this.modelForElement(this._offscreenFocusedItem),s=parseInt(e.substring(0,o),10);(n=this._isIndexRendered(s))?(i=this._getPhysicalIndex(s),r=this.modelForElement(this._physicalItems[i])):a&&(r=a),r&&r[this.indexAs]===s&&(e=e.substring(o+1),r._setPendingPropertyOrPath(e=this.as+(e?"."+e:""),t,!1,!0),r._flushProperties&&r._flushProperties(),n&&(this._updateMetrics([i]),this._positionItems(),this._updateScrollerSize()))},_adjustVirtualIndex:function(e){e.forEach((function(e){if(e.removed.forEach(this._removeItem,this),e.index<this._virtualStart){var t=Math.max(e.addedCount-e.removed.length,e.index-this._virtualStart);this._virtualStart=this._virtualStart+t,this._focusedVirtualIndex>=0&&(this._focusedVirtualIndex=this._focusedVirtualIndex+t)}}),this)},_removeItem:function(e){this.$.selector.deselect(e),this._focusedItem&&this.modelForElement(this._focusedItem)[this.as]===e&&this._removeFocusedItem()},_iterateItems:function(e,t){var n,i,r,o;if(2===arguments.length&&t){for(o=0;o<t.length;o++)if(i=this._computeVidx(n=t[o]),null!=(r=e.call(this,n,i)))return r}else{for(n=this._physicalStart,i=this._virtualStart;n<this._physicalCount;n++,i++)if(null!=(r=e.call(this,n,i)))return r;for(n=0;n<this._physicalStart;n++,i++)if(null!=(r=e.call(this,n,i)))return r}},_computeVidx:function(e){return e>=this._physicalStart?this._virtualStart+(e-this._physicalStart):this._virtualStart+(this._physicalCount-this._physicalStart)+e},_assignModels:function(e){this._iterateItems((function(e,t){var n=this._physicalItems[e],i=this.items&&this.items[t];if(null!=i){var r=this.modelForElement(n);r.__key__=null,this._forwardProperty(r,this.as,i),this._forwardProperty(r,this.selectedAs,this.$.selector.isSelected(i)),this._forwardProperty(r,this.indexAs,t),this._forwardProperty(r,"tabIndex",this._focusedVirtualIndex===t?0:-1),this._physicalIndexForKey[r.__key__]=e,r._flushProperties&&r._flushProperties(!0),n.removeAttribute("hidden")}else n.setAttribute("hidden","")}),e)},_updateMetrics:function(e){flush();var t=0,n=0,i=this._physicalAverageCount,r=this._physicalAverage;this._iterateItems((function(e,i){n+=this._physicalSizes[e],this._physicalSizes[e]=this._physicalItems[e].offsetHeight,t+=this._physicalSizes[e],this._physicalAverageCount+=this._physicalSizes[e]?1:0}),e),this.grid?(this._updateGridMetrics(),this._physicalSize=Math.ceil(this._physicalCount/this._itemsPerRow)*this._rowHeight):(n=1===this._itemsPerRow?n:Math.ceil(this._physicalCount/this._itemsPerRow)*this._rowHeight,this._physicalSize=this._physicalSize+t-n,this._itemsPerRow=1),this._physicalAverageCount!==i&&(this._physicalAverage=Math.round((r*i+t)/this._physicalAverageCount))},_updateGridMetrics:function(){this._itemWidth=this._physicalCount>0?this._physicalItems[0].getBoundingClientRect().width:200,this._rowHeight=this._physicalCount>0?this._physicalItems[0].offsetHeight:200,this._itemsPerRow=this._itemWidth?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRow},_positionItems:function(){this._adjustScrollPosition();var e=this._physicalTop;if(this.grid){var t=(this._viewportWidth-this._itemsPerRow*this._itemWidth)/2;this._iterateItems((function(n,i){var r=Math.floor(i%this._itemsPerRow*this._itemWidth+t);this._isRTL&&(r*=-1),this.translate3d(r+"px",e+"px",0,this._physicalItems[n]),this._shouldRenderNextRow(i)&&(e+=this._rowHeight)}))}else{const t=[];this._iterateItems((function(n,i){const r=this._physicalItems[n];this.translate3d(0,e+"px",0,r),e+=this._physicalSizes[n];const o=r.id;o&&t.push(o)})),t.length&&this.setAttribute("aria-owns",t.join(" "))}},_getPhysicalSizeIncrement:function(e){return this.grid?this._computeVidx(e)%this._itemsPerRow!=this._itemsPerRow-1?0:this._rowHeight:this._physicalSizes[e]},_shouldRenderNextRow:function(e){return e%this._itemsPerRow==this._itemsPerRow-1},_adjustScrollPosition:function(){var e=0===this._virtualStart?this._physicalTop:Math.min(this._scrollPosition+this._physicalTop,0);if(0!==e){this._physicalTop=this._physicalTop-e;var t=this._scrollPosition;!IOS_TOUCH_SCROLLING&&t>0&&this._resetScrollPosition(t-e)}},_resetScrollPosition:function(e){this.scrollTarget&&e>=0&&(this._scrollTop=e,this._scrollPosition=this._scrollTop)},_updateScrollerSize:function(e){this._estScrollHeight=this.grid?this._virtualRowCount*this._rowHeight:this._physicalBottom+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._physicalAverage,((e=(e=(e=e||0===this._scrollHeight)||this._scrollPosition>=this._estScrollHeight-this._physicalSize)||this.grid&&this.$.items.style.height<this._estScrollHeight)||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._viewportHeight)&&(this.$.items.style.height=this._estScrollHeight+"px",this._scrollHeight=this._estScrollHeight)},scrollToItem:function(e){return this.scrollToIndex(this.items.indexOf(e))},scrollToIndex:function(e){if(!("number"!=typeof e||e<0||e>this.items.length-1)&&(flush(),0!==this._physicalCount)){e=this._clamp(e,0,this._virtualCount-1),(!this._isIndexRendered(e)||e>=this._maxVirtualStart)&&(this._virtualStart=this.grid?e-2*this._itemsPerRow:e-1),this._manageFocus(),this._assignModels(),this._updateMetrics(),this._physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAverage;for(var t=this._physicalStart,n=this._virtualStart,i=0,r=this._hiddenContentSize;n<e&&i<=r;)i+=this._getPhysicalSizeIncrement(t),t=(t+1)%this._physicalCount,n++;this._updateScrollerSize(!0),this._positionItems(),this._resetScrollPosition(this._physicalTop+this._scrollOffset+i),this._increasePoolIfNeeded(0),this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null}},_resetAverage:function(){this._physicalAverage=0,this._physicalAverageCount=0},_resizeHandler:function(){this._debounce("_render",(function(){this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,this._isVisible?(this.updateViewportBoundaries(),this.toggleScrollListener(!0),this._resetAverage(),this._render()):this.toggleScrollListener(!1)}),animationFrame)},selectItem:function(e){return this.selectIndex(this.items.indexOf(e))},selectIndex:function(e){if(!(e<0||e>=this._virtualCount)){if(!this.multiSelection&&this.selectedItem&&this.clearSelection(),this._isIndexRendered(e)){var t=this.modelForElement(this._physicalItems[this._getPhysicalIndex(e)]);t&&(t[this.selectedAs]=!0),this.updateSizeForIndex(e)}this.$.selector.selectIndex(e)}},deselectItem:function(e){return this.deselectIndex(this.items.indexOf(e))},deselectIndex:function(e){e<0||e>=this._virtualCount||(this._isIndexRendered(e)&&(this.modelForElement(this._physicalItems[this._getPhysicalIndex(e)])[this.selectedAs]=!1,this.updateSizeForIndex(e)),this.$.selector.deselectIndex(e))},toggleSelectionForItem:function(e){return this.toggleSelectionForIndex(this.items.indexOf(e))},toggleSelectionForIndex:function(e){(this.$.selector.isIndexSelected?this.$.selector.isIndexSelected(e):this.$.selector.isSelected(this.items[e]))?this.deselectIndex(e):this.selectIndex(e)},clearSelection:function(){this._iterateItems((function(e,t){this.modelForElement(this._physicalItems[e])[this.selectedAs]=!1})),this.$.selector.clearSelection()},_selectionEnabledChanged:function(e){(e?this.listen:this.unlisten).call(this,this,"tap","_selectionHandler")},_selectionHandler:function(e){var t=this.modelForElement(e.target);if(t){var n,i,r=dom$1(e).path[0],o=this._getActiveElement(),a=this._physicalItems[this._getPhysicalIndex(t[this.indexAs])];"input"!==r.localName&&"button"!==r.localName&&"select"!==r.localName&&(n=t.tabIndex,t.tabIndex=SECRET_TABINDEX,i=o?o.tabIndex:-1,t.tabIndex=n,o&&a!==o&&a.contains(o)&&i!==SECRET_TABINDEX||this.toggleSelectionForItem(t[this.as]))}},_multiSelectionChanged:function(e){this.clearSelection(),this.$.selector.multi=e},updateSizeForItem:function(e){return this.updateSizeForIndex(this.items.indexOf(e))},updateSizeForIndex:function(e){return this._isIndexRendered(e)?(this._updateMetrics([this._getPhysicalIndex(e)]),this._positionItems(),null):null},_manageFocus:function(){var e=this._focusedVirtualIndex;e>=0&&e<this._virtualCount?this._isIndexRendered(e)?this._restoreFocusedItem():this._createFocusBackfillItem():this._virtualCount>0&&this._physicalCount>0&&(this._focusedPhysicalIndex=this._physicalStart,this._focusedVirtualIndex=this._virtualStart,this._focusedItem=this._physicalItems[this._physicalStart])},_convertIndexToCompleteRow:function(e){return this._itemsPerRow=this._itemsPerRow||1,this.grid?Math.ceil(e/this._itemsPerRow)*this._itemsPerRow:e},_isIndexRendered:function(e){return e>=this._virtualStart&&e<=this._virtualEnd},_isIndexVisible:function(e){return e>=this.firstVisibleIndex&&e<=this.lastVisibleIndex},_getPhysicalIndex:function(e){return(this._physicalStart+(e-this._virtualStart))%this._physicalCount},focusItem:function(e){this._focusPhysicalItem(e)},_focusPhysicalItem:function(e){if(!(e<0||e>=this._virtualCount)){this._restoreFocusedItem(),this._isIndexRendered(e)||this.scrollToIndex(e);var t,n=this._physicalItems[this._getPhysicalIndex(e)],i=this.modelForElement(n);i.tabIndex=SECRET_TABINDEX,n.tabIndex===SECRET_TABINDEX&&(t=n),t||(t=dom$1(n).querySelector('[tabindex="'+SECRET_TABINDEX+'"]')),i.tabIndex=0,this._focusedVirtualIndex=e,t&&t.focus()}},_removeFocusedItem:function(){this._offscreenFocusedItem&&this._itemsParent.removeChild(this._offscreenFocusedItem),this._offscreenFocusedItem=null,this._focusBackfillItem=null,this._focusedItem=null,this._focusedVirtualIndex=-1,this._focusedPhysicalIndex=-1},_createFocusBackfillItem:function(){var e=this._focusedPhysicalIndex;if(!(this._offscreenFocusedItem||this._focusedVirtualIndex<0)){if(!this._focusBackfillItem){var t=this.stamp(null);this._focusBackfillItem=t.root.querySelector("*"),this._itemsParent.appendChild(t.root)}this._offscreenFocusedItem=this._physicalItems[e],this.modelForElement(this._offscreenFocusedItem).tabIndex=0,this._physicalItems[e]=this._focusBackfillItem,this._focusedPhysicalIndex=e,this.translate3d(0,HIDDEN_Y,0,this._offscreenFocusedItem)}},_restoreFocusedItem:function(){if(this._offscreenFocusedItem&&!(this._focusedVirtualIndex<0)){this._assignModels();var e=this._focusedPhysicalIndex=this._getPhysicalIndex(this._focusedVirtualIndex),t=this._physicalItems[e];if(t){var n=this.modelForElement(t),i=this.modelForElement(this._offscreenFocusedItem);n[this.as]===i[this.as]?(this._focusBackfillItem=t,n.tabIndex=-1,this._physicalItems[e]=this._offscreenFocusedItem,this.translate3d(0,HIDDEN_Y,0,this._focusBackfillItem)):(this._removeFocusedItem(),this._focusBackfillItem=null),this._offscreenFocusedItem=null}}},_didFocus:function(e){var t=this.modelForElement(e.target),n=this.modelForElement(this._focusedItem),i=null!==this._offscreenFocusedItem,r=this._focusedVirtualIndex;t&&(n===t?this._isIndexVisible(r)||this.scrollToIndex(r):(this._restoreFocusedItem(),n&&(n.tabIndex=-1),t.tabIndex=0,this._focusedVirtualIndex=r=t[this.indexAs],this._focusedPhysicalIndex=this._getPhysicalIndex(r),this._focusedItem=this._physicalItems[this._focusedPhysicalIndex],i&&!this._offscreenFocusedItem&&this._update()))},_keydownHandler:function(e){switch(e.keyCode){case 40:this._focusedVirtualIndex<this._virtualCount-1&&e.preventDefault(),this._focusPhysicalItem(this._focusedVirtualIndex+(this.grid?this._itemsPerRow:1));break;case 39:this.grid&&this._focusPhysicalItem(this._focusedVirtualIndex+(this._isRTL?-1:1));break;case 38:this._focusedVirtualIndex>0&&e.preventDefault(),this._focusPhysicalItem(this._focusedVirtualIndex-(this.grid?this._itemsPerRow:1));break;case 37:this.grid&&this._focusPhysicalItem(this._focusedVirtualIndex+(this._isRTL?1:-1));break;case 13:this._focusPhysicalItem(this._focusedVirtualIndex),this.selectionEnabled&&this._selectionHandler(e)}},_clamp:function(e,t,n){return Math.min(n,Math.max(t,e))},_debounce:function(e,t,n){this._debouncers=this._debouncers||{},this._debouncers[e]=Debouncer.debounce(this._debouncers[e],n,t.bind(this)),enqueueDebouncer(this._debouncers[e])},_forwardProperty:function(e,t,n){e._setPendingProperty(t,n)},_forwardHostPropV2:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(n){n&&this.modelForElement(n).forwardHostProp(e,t)}),this)},_notifyInstancePropV2:function(e,t,n){if(matches$1(this.as,t)){var i=e[this.indexAs];t==this.as&&(this.items[i]=n),this.notifyPath(translate(this.as,"items."+i,t),n)}},_getStampedChildren:function(){return this._physicalItems},_forwardInstancePath:function(e,t,n){0===t.indexOf(this.as+".")&&this.notifyPath("items."+e.__key__+"."+t.slice(this.as.length+1),n)},_forwardParentPath:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(n){n&&this.modelForElement(n).notifyPath(e,t)}),this)},_forwardParentProp:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(n){n&&(this.modelForElement(n)[e]=t)}),this)},_getActiveElement:function(){var e=this._itemsParent.node.domHost;return dom$1(e?e.root:document).activeElement}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ class IronSelection{constructor(e){this.selection=[],this.selectCallback=e}get(){return this.multi?this.selection.slice():this.selection[0]}clear(e){this.selection.slice().forEach((function(t){(!e||e.indexOf(t)<0)&&this.setItemSelected(t,!1)}),this)}isSelected(e){return this.selection.indexOf(e)>=0}setItemSelected(e,t){if(null!=e&&t!==this.isSelected(e)){if(t)this.selection.push(e);else{var n=this.selection.indexOf(e);n>=0&&this.selection.splice(n,1)}this.selectCallback&&this.selectCallback(e,t)}}select(e){this.multi?this.toggle(e):this.get()!==e&&(this.setItemSelected(this.get(),!1),this.setItemSelected(e,!0))}toggle(e){this.setItemSelected(e,!this.isSelected(e))}} /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const IronSelectableBehavior={properties:{attrForSelected:{type:String,value:null},selected:{type:String,notify:!0},selectedItem:{type:Object,readOnly:!0,notify:!0},activateEvent:{type:String,value:"tap",observer:"_activateEventChanged"},selectable:String,selectedClass:{type:String,value:"iron-selected"},selectedAttribute:{type:String,value:null},fallbackSelection:{type:String,value:null},items:{type:Array,readOnly:!0,notify:!0,value:function(){return[]}},_excludedLocalNames:{type:Object,value:function(){return{template:1,"dom-bind":1,"dom-if":1,"dom-repeat":1}}}},observers:["_updateAttrForSelected(attrForSelected)","_updateSelected(selected)","_checkFallback(fallbackSelection)"],created:function(){this._bindFilterItem=this._filterItem.bind(this),this._selection=new IronSelection(this._applySelection.bind(this))},attached:function(){this._observer=this._observeItems(this),this._addListener(this.activateEvent)},detached:function(){this._observer&&dom$1(this).unobserveNodes(this._observer),this._removeListener(this.activateEvent)},indexOf:function(e){return this.items?this.items.indexOf(e):-1},select:function(e){this.selected=e},selectPrevious:function(){var e=this.items.length,t=e-1;void 0!==this.selected&&(t=(Number(this._valueToIndex(this.selected))-1+e)%e),this.selected=this._indexToValue(t)},selectNext:function(){var e=0;void 0!==this.selected&&(e=(Number(this._valueToIndex(this.selected))+1)%this.items.length),this.selected=this._indexToValue(e)},selectIndex:function(e){this.select(this._indexToValue(e))},forceSynchronousItemUpdate:function(){this._observer&&"function"==typeof this._observer.flush?this._observer.flush():this._updateItems()},get _shouldUpdateSelection(){return null!=this.selected},_checkFallback:function(){this._updateSelected()},_addListener:function(e){this.listen(this,e,"_activateHandler")},_removeListener:function(e){this.unlisten(this,e,"_activateHandler")},_activateEventChanged:function(e,t){this._removeListener(t),this._addListener(e)},_updateItems:function(){var e=dom$1(this).queryDistributedElements(this.selectable||"*");e=Array.prototype.filter.call(e,this._bindFilterItem),this._setItems(e)},_updateAttrForSelected:function(){this.selectedItem&&(this.selected=this._valueForItem(this.selectedItem))},_updateSelected:function(){this._selectSelected(this.selected)},_selectSelected:function(e){if(this.items){var t=this._valueToItem(this.selected);t?this._selection.select(t):this._selection.clear(),this.fallbackSelection&&this.items.length&&void 0===this._selection.get()&&(this.selected=this.fallbackSelection)}},_filterItem:function(e){return!this._excludedLocalNames[e.localName]},_valueToItem:function(e){return null==e?null:this.items[this._valueToIndex(e)]},_valueToIndex:function(e){if(!this.attrForSelected)return Number(e);for(var t,n=0;t=this.items[n];n++)if(this._valueForItem(t)==e)return n},_indexToValue:function(e){if(!this.attrForSelected)return e;var t=this.items[e];return t?this._valueForItem(t):void 0},_valueForItem:function(e){if(!e)return null;if(!this.attrForSelected){var t=this.indexOf(e);return-1===t?null:t}var n=e[dashToCamelCase(this.attrForSelected)];return null!=n?n:e.getAttribute(this.attrForSelected)},_applySelection:function(e,t){this.selectedClass&&this.toggleClass(this.selectedClass,t,e),this.selectedAttribute&&this.toggleAttribute(this.selectedAttribute,t,e),this._selectionChange(),this.fire("iron-"+(t?"select":"deselect"),{item:e})},_selectionChange:function(){this._setSelectedItem(this._selection.get())},_observeItems:function(e){return dom$1(e).observeNodes((function(e){this._updateItems(),this._updateSelected(),this.fire("iron-items-changed",e,{bubbles:!1,cancelable:!1})}))},_activateHandler:function(e){for(var t=e.target,n=this.items;t&&t!=this;){var i=n.indexOf(t);if(i>=0){var r=this._indexToValue(i);return void this._itemActivate(r,t)}t=t.parentNode}},_itemActivate:function(e,t){this.fire("iron-activate",{selected:e,item:t},{cancelable:!0}).defaultPrevented||this.select(e)}}; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */Polymer({_template:html` <style> :host { display: block; } :host > ::slotted(:not(slot):not(.iron-selected)) { display: none !important; } </style> <slot></slot> `,is:"iron-pages",behaviors:[IronResizableBehavior,IronSelectableBehavior],properties:{activateEvent:{type:String,value:null}},observers:["_selectedPageChanged(selected)"],_selectedPageChanged:function(e,t){this.async(this.notifyResize)}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$j=html` <custom-style> <style is="custom-style"> html { --shadow-transition: { transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1); }; --shadow-none: { box-shadow: none; }; /* from http://codepen.io/shyndman/pen/c5394ddf2e8b2a5c9185904b57421cdb */ --shadow-elevation-2dp: { box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2); }; --shadow-elevation-3dp: { box-shadow: 0 3px 4px 0 rgba(0, 0, 0, 0.14), 0 1px 8px 0 rgba(0, 0, 0, 0.12), 0 3px 3px -2px rgba(0, 0, 0, 0.4); }; --shadow-elevation-4dp: { box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.4); }; --shadow-elevation-6dp: { box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.4); }; --shadow-elevation-8dp: { box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.4); }; --shadow-elevation-12dp: { box-shadow: 0 12px 16px 1px rgba(0, 0, 0, 0.14), 0 4px 22px 3px rgba(0, 0, 0, 0.12), 0 6px 7px -4px rgba(0, 0, 0, 0.4); }; --shadow-elevation-16dp: { box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.4); }; --shadow-elevation-24dp: { box-shadow: 0 24px 38px 3px rgba(0, 0, 0, 0.14), 0 9px 46px 8px rgba(0, 0, 0, 0.12), 0 11px 15px -7px rgba(0, 0, 0, 0.4); }; } </style> </custom-style>`;template$j.setAttribute("style","display: none;"),document.head.appendChild(template$j.content); /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$i=html` <dom-module id="paper-material-styles"> <template> <style> html { --paper-material: { display: block; position: relative; }; --paper-material-elevation-1: { @apply --shadow-elevation-2dp; }; --paper-material-elevation-2: { @apply --shadow-elevation-4dp; }; --paper-material-elevation-3: { @apply --shadow-elevation-6dp; }; --paper-material-elevation-4: { @apply --shadow-elevation-8dp; }; --paper-material-elevation-5: { @apply --shadow-elevation-16dp; }; } .paper-material { @apply --paper-material; } .paper-material[elevation="1"] { @apply --paper-material-elevation-1; } .paper-material[elevation="2"] { @apply --paper-material-elevation-2; } .paper-material[elevation="3"] { @apply --paper-material-elevation-3; } .paper-material[elevation="4"] { @apply --paper-material-elevation-4; } .paper-material[elevation="5"] { @apply --paper-material-elevation-5; } /* Duplicate the styles because of https://github.com/webcomponents/shadycss/issues/193 */ :host { --paper-material: { display: block; position: relative; }; --paper-material-elevation-1: { @apply --shadow-elevation-2dp; }; --paper-material-elevation-2: { @apply --shadow-elevation-4dp; }; --paper-material-elevation-3: { @apply --shadow-elevation-6dp; }; --paper-material-elevation-4: { @apply --shadow-elevation-8dp; }; --paper-material-elevation-5: { @apply --shadow-elevation-16dp; }; } :host(.paper-material) { @apply --paper-material; } :host(.paper-material[elevation="1"]) { @apply --paper-material-elevation-1; } :host(.paper-material[elevation="2"]) { @apply --paper-material-elevation-2; } :host(.paper-material[elevation="3"]) { @apply --paper-material-elevation-3; } :host(.paper-material[elevation="4"]) { @apply --paper-material-elevation-4; } :host(.paper-material[elevation="5"]) { @apply --paper-material-elevation-5; } </style> </template> </dom-module>`;template$i.setAttribute("style","display: none;"),document.head.appendChild(template$i.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const IronControlState={properties:{focused:{type:Boolean,value:!1,notify:!0,readOnly:!0,reflectToAttribute:!0},disabled:{type:Boolean,value:!1,notify:!0,observer:"_disabledChanged",reflectToAttribute:!0},_oldTabIndex:{type:String},_boundFocusBlurHandler:{type:Function,value:function(){return this._focusBlurHandler.bind(this)}}},observers:["_changedControlState(focused, disabled)"],ready:function(){this.addEventListener("focus",this._boundFocusBlurHandler,!0),this.addEventListener("blur",this._boundFocusBlurHandler,!0)},_focusBlurHandler:function(e){this._setFocused("focus"===e.type)},_disabledChanged:function(e,t){this.setAttribute("aria-disabled",e?"true":"false"),this.style.pointerEvents=e?"none":"",e?(this._oldTabIndex=this.getAttribute("tabindex"),this._setFocused(!1),this.tabIndex=-1,this.blur()):void 0!==this._oldTabIndex&&(null===this._oldTabIndex?this.removeAttribute("tabindex"):this.setAttribute("tabindex",this._oldTabIndex))},_changedControlState:function(){this._controlStateChanged&&this._controlStateChanged()}},IronButtonStateImpl={properties:{pressed:{type:Boolean,readOnly:!0,value:!1,reflectToAttribute:!0,observer:"_pressedChanged"},toggles:{type:Boolean,value:!1,reflectToAttribute:!0},active:{type:Boolean,value:!1,notify:!0,reflectToAttribute:!0},pointerDown:{type:Boolean,readOnly:!0,value:!1},receivedFocusFromKeyboard:{type:Boolean,readOnly:!0},ariaActiveAttribute:{type:String,value:"aria-pressed",observer:"_ariaActiveAttributeChanged"}},listeners:{down:"_downHandler",up:"_upHandler",tap:"_tapHandler"},observers:["_focusChanged(focused)","_activeChanged(active, ariaActiveAttribute)"],keyBindings:{"enter:keydown":"_asyncClick","space:keydown":"_spaceKeyDownHandler","space:keyup":"_spaceKeyUpHandler"},_mouseEventRe:/^mouse/,_tapHandler:function(){this.toggles?this._userActivate(!this.active):this.active=!1},_focusChanged:function(e){this._detectKeyboardFocus(e),e||this._setPressed(!1)},_detectKeyboardFocus:function(e){this._setReceivedFocusFromKeyboard(!this.pointerDown&&e)},_userActivate:function(e){this.active!==e&&(this.active=e,this.fire("change"))},_downHandler:function(e){this._setPointerDown(!0),this._setPressed(!0),this._setReceivedFocusFromKeyboard(!1)},_upHandler:function(){this._setPointerDown(!1),this._setPressed(!1)},_spaceKeyDownHandler:function(e){var t=e.detail.keyboardEvent,n=dom$1(t).localTarget;this.isLightDescendant(n)||(t.preventDefault(),t.stopImmediatePropagation(),this._setPressed(!0))},_spaceKeyUpHandler:function(e){var t=dom$1(e.detail.keyboardEvent).localTarget;this.isLightDescendant(t)||(this.pressed&&this._asyncClick(),this._setPressed(!1))},_asyncClick:function(){this.async((function(){this.click()}),1)},_pressedChanged:function(e){this._changedButtonState()},_ariaActiveAttributeChanged:function(e,t){t&&t!=e&&this.hasAttribute(t)&&this.removeAttribute(t)},_activeChanged:function(e,t){this.toggles?this.setAttribute(this.ariaActiveAttribute,e?"true":"false"):this.removeAttribute(this.ariaActiveAttribute),this._changedButtonState()},_controlStateChanged:function(){this.disabled?this._setPressed(!1):this._changedButtonState()},_changedButtonState:function(){this._buttonStateChanged&&this._buttonStateChanged()}},IronButtonState=[IronA11yKeysBehavior,IronButtonStateImpl]; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ /** @license Copyright (c) 2014 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ var Utility={distance:function(e,t,n,i){var r=e-n,o=t-i;return Math.sqrt(r*r+o*o)},now:window.performance&&window.performance.now?window.performance.now.bind(window.performance):Date.now};function ElementMetrics(e){this.element=e,this.width=this.boundingRect.width,this.height=this.boundingRect.height,this.size=Math.max(this.width,this.height)}function Ripple(e){this.element=e,this.color=window.getComputedStyle(e).color,this.wave=document.createElement("div"),this.waveContainer=document.createElement("div"),this.wave.style.backgroundColor=this.color,this.wave.classList.add("wave"),this.waveContainer.classList.add("wave-container"),dom$1(this.waveContainer).appendChild(this.wave),this.resetInteractionState()}ElementMetrics.prototype={get boundingRect(){return this.element.getBoundingClientRect()},furthestCornerDistanceFrom:function(e,t){var n=Utility.distance(e,t,0,0),i=Utility.distance(e,t,this.width,0),r=Utility.distance(e,t,0,this.height),o=Utility.distance(e,t,this.width,this.height);return Math.max(n,i,r,o)}},Ripple.MAX_RADIUS=300,Ripple.prototype={get recenters(){return this.element.recenters},get center(){return this.element.center},get mouseDownElapsed(){var e;return this.mouseDownStart?(e=Utility.now()-this.mouseDownStart,this.mouseUpStart&&(e-=this.mouseUpElapsed),e):0},get mouseUpElapsed(){return this.mouseUpStart?Utility.now()-this.mouseUpStart:0},get mouseDownElapsedSeconds(){return this.mouseDownElapsed/1e3},get mouseUpElapsedSeconds(){return this.mouseUpElapsed/1e3},get mouseInteractionSeconds(){return this.mouseDownElapsedSeconds+this.mouseUpElapsedSeconds},get initialOpacity(){return this.element.initialOpacity},get opacityDecayVelocity(){return this.element.opacityDecayVelocity},get radius(){var e=1.1*Math.min(Math.sqrt(this.containerMetrics.width*this.containerMetrics.width+this.containerMetrics.height*this.containerMetrics.height),Ripple.MAX_RADIUS)+5,t=e*(1-Math.pow(80,-this.mouseInteractionSeconds/(1.1-e/Ripple.MAX_RADIUS*.2)));return Math.abs(t)},get opacity(){return this.mouseUpStart?Math.max(0,this.initialOpacity-this.mouseUpElapsedSeconds*this.opacityDecayVelocity):this.initialOpacity},get outerOpacity(){return Math.max(0,Math.min(.3*this.mouseUpElapsedSeconds,this.opacity))},get isOpacityFullyDecayed(){return this.opacity<.01&&this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get isRestingAtMaxRadius(){return this.opacity>=this.initialOpacity&&this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get isAnimationComplete(){return this.mouseUpStart?this.isOpacityFullyDecayed:this.isRestingAtMaxRadius},get translationFraction(){return Math.min(1,this.radius/this.containerMetrics.size*2/Math.sqrt(2))},get xNow(){return this.xEnd?this.xStart+this.translationFraction*(this.xEnd-this.xStart):this.xStart},get yNow(){return this.yEnd?this.yStart+this.translationFraction*(this.yEnd-this.yStart):this.yStart},get isMouseDown(){return this.mouseDownStart&&!this.mouseUpStart},resetInteractionState:function(){this.maxRadius=0,this.mouseDownStart=0,this.mouseUpStart=0,this.xStart=0,this.yStart=0,this.xEnd=0,this.yEnd=0,this.slideDistance=0,this.containerMetrics=new ElementMetrics(this.element)},draw:function(){var e,t,n;this.wave.style.opacity=this.opacity,e=this.radius/(this.containerMetrics.size/2),this.waveContainer.style.webkitTransform="translate("+(t=this.xNow-this.containerMetrics.width/2)+"px, "+(n=this.yNow-this.containerMetrics.height/2)+"px)",this.waveContainer.style.transform="translate3d("+t+"px, "+n+"px, 0)",this.wave.style.webkitTransform="scale("+e+","+e+")",this.wave.style.transform="scale3d("+e+","+e+",1)"},downAction:function(e){var t=this.containerMetrics.width/2,n=this.containerMetrics.height/2;this.resetInteractionState(),this.mouseDownStart=Utility.now(),this.center?(this.xStart=t,this.yStart=n,this.slideDistance=Utility.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)):(this.xStart=e?e.detail.x-this.containerMetrics.boundingRect.left:this.containerMetrics.width/2,this.yStart=e?e.detail.y-this.containerMetrics.boundingRect.top:this.containerMetrics.height/2),this.recenters&&(this.xEnd=t,this.yEnd=n,this.slideDistance=Utility.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)),this.maxRadius=this.containerMetrics.furthestCornerDistanceFrom(this.xStart,this.yStart),this.waveContainer.style.top=(this.containerMetrics.height-this.containerMetrics.size)/2+"px",this.waveContainer.style.left=(this.containerMetrics.width-this.containerMetrics.size)/2+"px",this.waveContainer.style.width=this.containerMetrics.size+"px",this.waveContainer.style.height=this.containerMetrics.size+"px"},upAction:function(e){this.isMouseDown&&(this.mouseUpStart=Utility.now())},remove:function(){dom$1(dom$1(this.waveContainer).parentNode).removeChild(this.waveContainer)}},Polymer({_template:html` <style> :host { display: block; position: absolute; border-radius: inherit; overflow: hidden; top: 0; left: 0; right: 0; bottom: 0; /* See PolymerElements/paper-behaviors/issues/34. On non-Chrome browsers, * creating a node (with a position:absolute) in the middle of an event * handler "interrupts" that event handler (which happens when the * ripple is created on demand) */ pointer-events: none; } :host([animating]) { /* This resolves a rendering issue in Chrome (as of 40) where the ripple is not properly clipped by its parent (which may have rounded corners). See: http://jsbin.com/temexa/4 Note: We only apply this style conditionally. Otherwise, the browser will create a new compositing layer for every ripple element on the page, and that would be bad. */ -webkit-transform: translate(0, 0); transform: translate3d(0, 0, 0); } #background, #waves, .wave-container, .wave { pointer-events: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; } #background, .wave { opacity: 0; } #waves, .wave { overflow: hidden; } .wave-container, .wave { border-radius: 50%; } :host(.circle) #background, :host(.circle) #waves { border-radius: 50%; } :host(.circle) .wave-container { overflow: hidden; } </style> <div id="background"></div> <div id="waves"></div> `,is:"paper-ripple",behaviors:[IronA11yKeysBehavior],properties:{initialOpacity:{type:Number,value:.25},opacityDecayVelocity:{type:Number,value:.8},recenters:{type:Boolean,value:!1},center:{type:Boolean,value:!1},ripples:{type:Array,value:function(){return[]}},animating:{type:Boolean,readOnly:!0,reflectToAttribute:!0,value:!1},holdDown:{type:Boolean,value:!1,observer:"_holdDownChanged"},noink:{type:Boolean,value:!1},_animating:{type:Boolean},_boundAnimate:{type:Function,value:function(){return this.animate.bind(this)}}},get target(){return this.keyEventTarget},keyBindings:{"enter:keydown":"_onEnterKeydown","space:keydown":"_onSpaceKeydown","space:keyup":"_onSpaceKeyup"},attached:function(){this.keyEventTarget=11==dom$1(this).parentNode.nodeType?dom$1(this).getOwnerRoot().host:dom$1(this).parentNode;var e=this.keyEventTarget;this.listen(e,"up","uiUpAction"),this.listen(e,"down","uiDownAction")},detached:function(){this.unlisten(this.keyEventTarget,"up","uiUpAction"),this.unlisten(this.keyEventTarget,"down","uiDownAction"),this.keyEventTarget=null},get shouldKeepAnimating(){for(var e=0;e<this.ripples.length;++e)if(!this.ripples[e].isAnimationComplete)return!0;return!1},simulatedRipple:function(){this.downAction(null),this.async((function(){this.upAction()}),1)},uiDownAction:function(e){this.noink||this.downAction(e)},downAction:function(e){this.holdDown&&this.ripples.length>0||(this.addRipple().downAction(e),this._animating||(this._animating=!0,this.animate()))},uiUpAction:function(e){this.noink||this.upAction(e)},upAction:function(e){this.holdDown||(this.ripples.forEach((function(t){t.upAction(e)})),this._animating=!0,this.animate())},onAnimationComplete:function(){this._animating=!1,this.$.background.style.backgroundColor="",this.fire("transitionend")},addRipple:function(){var e=new Ripple(this);return dom$1(this.$.waves).appendChild(e.waveContainer),this.$.background.style.backgroundColor=e.color,this.ripples.push(e),this._setAnimating(!0),e},removeRipple:function(e){var t=this.ripples.indexOf(e);t<0||(this.ripples.splice(t,1),e.remove(),this.ripples.length||this._setAnimating(!1))},animate:function(){if(this._animating){var e,t;for(e=0;e<this.ripples.length;++e)(t=this.ripples[e]).draw(),this.$.background.style.opacity=t.outerOpacity,t.isOpacityFullyDecayed&&!t.isRestingAtMaxRadius&&this.removeRipple(t);this.shouldKeepAnimating||0!==this.ripples.length?window.requestAnimationFrame(this._boundAnimate):this.onAnimationComplete()}},animateRipple:function(){return this.animate()},_onEnterKeydown:function(){this.uiDownAction(),this.async(this.uiUpAction,1)},_onSpaceKeydown:function(){this.uiDownAction()},_onSpaceKeyup:function(){this.uiUpAction()},_holdDownChanged:function(e,t){void 0!==t&&(e?this.downAction():this.upAction())}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const PaperRippleBehavior={properties:{noink:{type:Boolean,observer:"_noinkChanged"},_rippleContainer:{type:Object}},_buttonStateChanged:function(){this.focused&&this.ensureRipple()},_downHandler:function(e){IronButtonStateImpl._downHandler.call(this,e),this.pressed&&this.ensureRipple(e)},ensureRipple:function(e){if(!this.hasRipple()){this._ripple=this._createRipple(),this._ripple.noink=this.noink;var t=this._rippleContainer||this.root;if(t&&dom$1(t).appendChild(this._ripple),e){var n=dom$1(this._rippleContainer||this),i=dom$1(e).rootTarget;n.deepContains(i)&&this._ripple.uiDownAction(e)}}},getRipple:function(){return this.ensureRipple(),this._ripple},hasRipple:function(){return Boolean(this._ripple)},_createRipple:function(){return document.createElement("paper-ripple")},_noinkChanged:function(e){this.hasRipple()&&(this._ripple.noink=e)}},PaperButtonBehaviorImpl={properties:{elevation:{type:Number,reflectToAttribute:!0,readOnly:!0}},observers:["_calculateElevation(focused, disabled, active, pressed, receivedFocusFromKeyboard)","_computeKeyboardClass(receivedFocusFromKeyboard)"],hostAttributes:{role:"button",tabindex:"0",animated:!0},_calculateElevation:function(){var e=1;this.disabled?e=0:this.active||this.pressed?e=4:this.receivedFocusFromKeyboard&&(e=3),this._setElevation(e)},_computeKeyboardClass:function(e){this.toggleClass("keyboard-focus",e)},_spaceKeyDownHandler:function(e){IronButtonStateImpl._spaceKeyDownHandler.call(this,e),this.hasRipple()&&this.getRipple().ripples.length<1&&this._ripple.uiDownAction()},_spaceKeyUpHandler:function(e){IronButtonStateImpl._spaceKeyUpHandler.call(this,e),this.hasRipple()&&this._ripple.uiUpAction()}},PaperButtonBehavior=[IronButtonState,IronControlState,PaperRippleBehavior,PaperButtonBehaviorImpl],template$h=html` <style include="paper-material-styles"> /* Need to specify the same specificity as the styles imported from paper-material. */ :host { @apply --layout-inline; @apply --layout-center-center; position: relative; box-sizing: border-box; min-width: 5.14em; margin: 0 0.29em; background: transparent; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-tap-highlight-color: transparent; font: inherit; text-transform: uppercase; outline-width: 0; border-radius: 3px; -moz-user-select: none; -ms-user-select: none; -webkit-user-select: none; user-select: none; cursor: pointer; z-index: 0; padding: 0.7em 0.57em; @apply --paper-font-common-base; @apply --paper-button; } :host([elevation="1"]) { @apply --paper-material-elevation-1; } :host([elevation="2"]) { @apply --paper-material-elevation-2; } :host([elevation="3"]) { @apply --paper-material-elevation-3; } :host([elevation="4"]) { @apply --paper-material-elevation-4; } :host([elevation="5"]) { @apply --paper-material-elevation-5; } :host([hidden]) { display: none !important; } :host([raised].keyboard-focus) { font-weight: bold; @apply --paper-button-raised-keyboard-focus; } :host(:not([raised]).keyboard-focus) { font-weight: bold; @apply --paper-button-flat-keyboard-focus; } :host([disabled]) { background: none; color: #a8a8a8; cursor: auto; pointer-events: none; @apply --paper-button-disabled; } :host([disabled][raised]) { background: #eaeaea; } :host([animated]) { @apply --shadow-transition; } paper-ripple { color: var(--paper-button-ink-color); } </style> <slot></slot>`; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */template$h.setAttribute("strip-whitespace",""),Polymer({_template:template$h,is:"paper-button",behaviors:[PaperButtonBehavior],properties:{raised:{type:Boolean,reflectToAttribute:!0,value:!1,observer:"_calculateElevation"}},_calculateElevation:function(){this.raised?PaperButtonBehaviorImpl._calculateElevation.apply(this):this._setElevation(0)}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$g=html` <custom-style> <style is="custom-style"> html { /* Material Design color palette for Google products */ --google-red-100: #f4c7c3; --google-red-300: #e67c73; --google-red-500: #db4437; --google-red-700: #c53929; --google-blue-100: #c6dafc; --google-blue-300: #7baaf7; --google-blue-500: #4285f4; --google-blue-700: #3367d6; --google-green-100: #b7e1cd; --google-green-300: #57bb8a; --google-green-500: #0f9d58; --google-green-700: #0b8043; --google-yellow-100: #fce8b2; --google-yellow-300: #f7cb4d; --google-yellow-500: #f4b400; --google-yellow-700: #f09300; --google-grey-100: #f5f5f5; --google-grey-300: #e0e0e0; --google-grey-500: #9e9e9e; --google-grey-700: #616161; /* Material Design color palette from online spec document */ --paper-red-50: #ffebee; --paper-red-100: #ffcdd2; --paper-red-200: #ef9a9a; --paper-red-300: #e57373; --paper-red-400: #ef5350; --paper-red-500: #f44336; --paper-red-600: #e53935; --paper-red-700: #d32f2f; --paper-red-800: #c62828; --paper-red-900: #b71c1c; --paper-red-a100: #ff8a80; --paper-red-a200: #ff5252; --paper-red-a400: #ff1744; --paper-red-a700: #d50000; --paper-pink-50: #fce4ec; --paper-pink-100: #f8bbd0; --paper-pink-200: #f48fb1; --paper-pink-300: #f06292; --paper-pink-400: #ec407a; --paper-pink-500: #e91e63; --paper-pink-600: #d81b60; --paper-pink-700: #c2185b; --paper-pink-800: #ad1457; --paper-pink-900: #880e4f; --paper-pink-a100: #ff80ab; --paper-pink-a200: #ff4081; --paper-pink-a400: #f50057; --paper-pink-a700: #c51162; --paper-purple-50: #f3e5f5; --paper-purple-100: #e1bee7; --paper-purple-200: #ce93d8; --paper-purple-300: #ba68c8; --paper-purple-400: #ab47bc; --paper-purple-500: #9c27b0; --paper-purple-600: #8e24aa; --paper-purple-700: #7b1fa2; --paper-purple-800: #6a1b9a; --paper-purple-900: #4a148c; --paper-purple-a100: #ea80fc; --paper-purple-a200: #e040fb; --paper-purple-a400: #d500f9; --paper-purple-a700: #aa00ff; --paper-deep-purple-50: #ede7f6; --paper-deep-purple-100: #d1c4e9; --paper-deep-purple-200: #b39ddb; --paper-deep-purple-300: #9575cd; --paper-deep-purple-400: #7e57c2; --paper-deep-purple-500: #673ab7; --paper-deep-purple-600: #5e35b1; --paper-deep-purple-700: #512da8; --paper-deep-purple-800: #4527a0; --paper-deep-purple-900: #311b92; --paper-deep-purple-a100: #b388ff; --paper-deep-purple-a200: #7c4dff; --paper-deep-purple-a400: #651fff; --paper-deep-purple-a700: #6200ea; --paper-indigo-50: #e8eaf6; --paper-indigo-100: #c5cae9; --paper-indigo-200: #9fa8da; --paper-indigo-300: #7986cb; --paper-indigo-400: #5c6bc0; --paper-indigo-500: #3f51b5; --paper-indigo-600: #3949ab; --paper-indigo-700: #303f9f; --paper-indigo-800: #283593; --paper-indigo-900: #1a237e; --paper-indigo-a100: #8c9eff; --paper-indigo-a200: #536dfe; --paper-indigo-a400: #3d5afe; --paper-indigo-a700: #304ffe; --paper-blue-50: #e3f2fd; --paper-blue-100: #bbdefb; --paper-blue-200: #90caf9; --paper-blue-300: #64b5f6; --paper-blue-400: #42a5f5; --paper-blue-500: #2196f3; --paper-blue-600: #1e88e5; --paper-blue-700: #1976d2; --paper-blue-800: #1565c0; --paper-blue-900: #0d47a1; --paper-blue-a100: #82b1ff; --paper-blue-a200: #448aff; --paper-blue-a400: #2979ff; --paper-blue-a700: #2962ff; --paper-light-blue-50: #e1f5fe; --paper-light-blue-100: #b3e5fc; --paper-light-blue-200: #81d4fa; --paper-light-blue-300: #4fc3f7; --paper-light-blue-400: #29b6f6; --paper-light-blue-500: #03a9f4; --paper-light-blue-600: #039be5; --paper-light-blue-700: #0288d1; --paper-light-blue-800: #0277bd; --paper-light-blue-900: #01579b; --paper-light-blue-a100: #80d8ff; --paper-light-blue-a200: #40c4ff; --paper-light-blue-a400: #00b0ff; --paper-light-blue-a700: #0091ea; --paper-cyan-50: #e0f7fa; --paper-cyan-100: #b2ebf2; --paper-cyan-200: #80deea; --paper-cyan-300: #4dd0e1; --paper-cyan-400: #26c6da; --paper-cyan-500: #00bcd4; --paper-cyan-600: #00acc1; --paper-cyan-700: #0097a7; --paper-cyan-800: #00838f; --paper-cyan-900: #006064; --paper-cyan-a100: #84ffff; --paper-cyan-a200: #18ffff; --paper-cyan-a400: #00e5ff; --paper-cyan-a700: #00b8d4; --paper-teal-50: #e0f2f1; --paper-teal-100: #b2dfdb; --paper-teal-200: #80cbc4; --paper-teal-300: #4db6ac; --paper-teal-400: #26a69a; --paper-teal-500: #009688; --paper-teal-600: #00897b; --paper-teal-700: #00796b; --paper-teal-800: #00695c; --paper-teal-900: #004d40; --paper-teal-a100: #a7ffeb; --paper-teal-a200: #64ffda; --paper-teal-a400: #1de9b6; --paper-teal-a700: #00bfa5; --paper-green-50: #e8f5e9; --paper-green-100: #c8e6c9; --paper-green-200: #a5d6a7; --paper-green-300: #81c784; --paper-green-400: #66bb6a; --paper-green-500: #4caf50; --paper-green-600: #43a047; --paper-green-700: #388e3c; --paper-green-800: #2e7d32; --paper-green-900: #1b5e20; --paper-green-a100: #b9f6ca; --paper-green-a200: #69f0ae; --paper-green-a400: #00e676; --paper-green-a700: #00c853; --paper-light-green-50: #f1f8e9; --paper-light-green-100: #dcedc8; --paper-light-green-200: #c5e1a5; --paper-light-green-300: #aed581; --paper-light-green-400: #9ccc65; --paper-light-green-500: #8bc34a; --paper-light-green-600: #7cb342; --paper-light-green-700: #689f38; --paper-light-green-800: #558b2f; --paper-light-green-900: #33691e; --paper-light-green-a100: #ccff90; --paper-light-green-a200: #b2ff59; --paper-light-green-a400: #76ff03; --paper-light-green-a700: #64dd17; --paper-lime-50: #f9fbe7; --paper-lime-100: #f0f4c3; --paper-lime-200: #e6ee9c; --paper-lime-300: #dce775; --paper-lime-400: #d4e157; --paper-lime-500: #cddc39; --paper-lime-600: #c0ca33; --paper-lime-700: #afb42b; --paper-lime-800: #9e9d24; --paper-lime-900: #827717; --paper-lime-a100: #f4ff81; --paper-lime-a200: #eeff41; --paper-lime-a400: #c6ff00; --paper-lime-a700: #aeea00; --paper-yellow-50: #fffde7; --paper-yellow-100: #fff9c4; --paper-yellow-200: #fff59d; --paper-yellow-300: #fff176; --paper-yellow-400: #ffee58; --paper-yellow-500: #ffeb3b; --paper-yellow-600: #fdd835; --paper-yellow-700: #fbc02d; --paper-yellow-800: #f9a825; --paper-yellow-900: #f57f17; --paper-yellow-a100: #ffff8d; --paper-yellow-a200: #ffff00; --paper-yellow-a400: #ffea00; --paper-yellow-a700: #ffd600; --paper-amber-50: #fff8e1; --paper-amber-100: #ffecb3; --paper-amber-200: #ffe082; --paper-amber-300: #ffd54f; --paper-amber-400: #ffca28; --paper-amber-500: #ffc107; --paper-amber-600: #ffb300; --paper-amber-700: #ffa000; --paper-amber-800: #ff8f00; --paper-amber-900: #ff6f00; --paper-amber-a100: #ffe57f; --paper-amber-a200: #ffd740; --paper-amber-a400: #ffc400; --paper-amber-a700: #ffab00; --paper-orange-50: #fff3e0; --paper-orange-100: #ffe0b2; --paper-orange-200: #ffcc80; --paper-orange-300: #ffb74d; --paper-orange-400: #ffa726; --paper-orange-500: #ff9800; --paper-orange-600: #fb8c00; --paper-orange-700: #f57c00; --paper-orange-800: #ef6c00; --paper-orange-900: #e65100; --paper-orange-a100: #ffd180; --paper-orange-a200: #ffab40; --paper-orange-a400: #ff9100; --paper-orange-a700: #ff6500; --paper-deep-orange-50: #fbe9e7; --paper-deep-orange-100: #ffccbc; --paper-deep-orange-200: #ffab91; --paper-deep-orange-300: #ff8a65; --paper-deep-orange-400: #ff7043; --paper-deep-orange-500: #ff5722; --paper-deep-orange-600: #f4511e; --paper-deep-orange-700: #e64a19; --paper-deep-orange-800: #d84315; --paper-deep-orange-900: #bf360c; --paper-deep-orange-a100: #ff9e80; --paper-deep-orange-a200: #ff6e40; --paper-deep-orange-a400: #ff3d00; --paper-deep-orange-a700: #dd2c00; --paper-brown-50: #efebe9; --paper-brown-100: #d7ccc8; --paper-brown-200: #bcaaa4; --paper-brown-300: #a1887f; --paper-brown-400: #8d6e63; --paper-brown-500: #795548; --paper-brown-600: #6d4c41; --paper-brown-700: #5d4037; --paper-brown-800: #4e342e; --paper-brown-900: #3e2723; --paper-grey-50: #fafafa; --paper-grey-100: #f5f5f5; --paper-grey-200: #eeeeee; --paper-grey-300: #e0e0e0; --paper-grey-400: #bdbdbd; --paper-grey-500: #9e9e9e; --paper-grey-600: #757575; --paper-grey-700: #616161; --paper-grey-800: #424242; --paper-grey-900: #212121; --paper-blue-grey-50: #eceff1; --paper-blue-grey-100: #cfd8dc; --paper-blue-grey-200: #b0bec5; --paper-blue-grey-300: #90a4ae; --paper-blue-grey-400: #78909c; --paper-blue-grey-500: #607d8b; --paper-blue-grey-600: #546e7a; --paper-blue-grey-700: #455a64; --paper-blue-grey-800: #37474f; --paper-blue-grey-900: #263238; /* opacity for dark text on a light background */ --dark-divider-opacity: 0.12; --dark-disabled-opacity: 0.38; /* or hint text or icon */ --dark-secondary-opacity: 0.54; --dark-primary-opacity: 0.87; /* opacity for light text on a dark background */ --light-divider-opacity: 0.12; --light-disabled-opacity: 0.3; /* or hint text or icon */ --light-secondary-opacity: 0.7; --light-primary-opacity: 1.0; } </style> </custom-style> `;template$g.setAttribute("style","display: none;"),document.head.appendChild(template$g.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$f=html` <custom-style> <style is="custom-style"> html { /* * You can use these generic variables in your elements for easy theming. * For example, if all your elements use \`--primary-text-color\` as its main * color, then switching from a light to a dark theme is just a matter of * changing the value of \`--primary-text-color\` in your application. */ --primary-text-color: var(--light-theme-text-color); --primary-background-color: var(--light-theme-background-color); --secondary-text-color: var(--light-theme-secondary-color); --disabled-text-color: var(--light-theme-disabled-color); --divider-color: var(--light-theme-divider-color); --error-color: var(--paper-deep-orange-a700); /* * Primary and accent colors. Also see color.js for more colors. */ --primary-color: var(--paper-indigo-500); --light-primary-color: var(--paper-indigo-100); --dark-primary-color: var(--paper-indigo-700); --accent-color: var(--paper-pink-a200); --light-accent-color: var(--paper-pink-a100); --dark-accent-color: var(--paper-pink-a400); /* * Material Design Light background theme */ --light-theme-background-color: #ffffff; --light-theme-base-color: #000000; --light-theme-text-color: var(--paper-grey-900); --light-theme-secondary-color: #737373; /* for secondary text and icons */ --light-theme-disabled-color: #9b9b9b; /* disabled/hint text */ --light-theme-divider-color: #dbdbdb; /* * Material Design Dark background theme */ --dark-theme-background-color: var(--paper-grey-900); --dark-theme-base-color: #ffffff; --dark-theme-text-color: #ffffff; --dark-theme-secondary-color: #bcbcbc; /* for secondary text and icons */ --dark-theme-disabled-color: #646464; /* disabled/hint text */ --dark-theme-divider-color: #3c3c3c; /* * Deprecated values because of their confusing names. */ --text-primary-color: var(--dark-theme-text-color); --default-primary-color: var(--primary-color); } </style> </custom-style>`;template$f.setAttribute("style","display: none;"),document.head.appendChild(template$f.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const IronFormElementBehavior={properties:{name:{type:String},value:{notify:!0,type:String},required:{type:Boolean,value:!1}},attached:function(){},detached:function(){}}; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */let IronValidatableBehaviorMeta=null;const IronValidatableBehavior={properties:{validator:{type:String},invalid:{notify:!0,reflectToAttribute:!0,type:Boolean,value:!1,observer:"_invalidChanged"}},registered:function(){IronValidatableBehaviorMeta=new IronMeta({type:"validator"})},_invalidChanged:function(){this.invalid?this.setAttribute("aria-invalid","true"):this.removeAttribute("aria-invalid")},get _validator(){return IronValidatableBehaviorMeta&&IronValidatableBehaviorMeta.byKey(this.validator)},hasValidator:function(){return null!=this._validator},validate:function(e){return this.invalid=void 0===e&&void 0!==this.value?!this._getValidity(this.value):!this._getValidity(e),!this.invalid},_getValidity:function(e){return!this.hasValidator()||this._validator.validate(e)}},IronCheckedElementBehaviorImpl={properties:{checked:{type:Boolean,value:!1,reflectToAttribute:!0,notify:!0,observer:"_checkedChanged"},toggles:{type:Boolean,value:!0,reflectToAttribute:!0},value:{type:String,value:"on",observer:"_valueChanged"}},observers:["_requiredChanged(required)"],created:function(){this._hasIronCheckedElementBehavior=!0},_getValidity:function(e){return this.disabled||!this.required||this.checked},_requiredChanged:function(){this.required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required")},_checkedChanged:function(){this.active=this.checked,this.fire("iron-change")},_valueChanged:function(){null==this.value&&(this.value="on")}},IronCheckedElementBehavior=[IronFormElementBehavior,IronValidatableBehavior,IronCheckedElementBehaviorImpl],PaperInkyFocusBehaviorImpl={observers:["_focusedChanged(receivedFocusFromKeyboard)"],_focusedChanged:function(e){e&&this.ensureRipple(),this.hasRipple()&&(this._ripple.holdDown=e)},_createRipple:function(){var e=PaperRippleBehavior._createRipple();return e.id="ink",e.setAttribute("center",""),e.classList.add("circle"),e}},PaperInkyFocusBehavior=[IronButtonState,IronControlState,PaperRippleBehavior,PaperInkyFocusBehaviorImpl],PaperCheckedElementBehaviorImpl={_checkedChanged:function(){IronCheckedElementBehaviorImpl._checkedChanged.call(this),this.hasRipple()&&(this.checked?this._ripple.setAttribute("checked",""):this._ripple.removeAttribute("checked"))},_buttonStateChanged:function(){PaperRippleBehavior._buttonStateChanged.call(this),this.disabled||this.isAttached&&(this.checked=this.active)}},PaperCheckedElementBehavior=[PaperInkyFocusBehavior,IronCheckedElementBehavior,PaperCheckedElementBehaviorImpl],template$e=html`<style> :host { display: inline-block; white-space: nowrap; cursor: pointer; --calculated-paper-checkbox-size: var(--paper-checkbox-size, 18px); /* -1px is a sentinel for the default and is replaced in \`attached\`. */ --calculated-paper-checkbox-ink-size: var(--paper-checkbox-ink-size, -1px); @apply --paper-font-common-base; line-height: 0; -webkit-tap-highlight-color: transparent; } :host([hidden]) { display: none !important; } :host(:focus) { outline: none; } .hidden { display: none; } #checkboxContainer { display: inline-block; position: relative; width: var(--calculated-paper-checkbox-size); height: var(--calculated-paper-checkbox-size); min-width: var(--calculated-paper-checkbox-size); margin: var(--paper-checkbox-margin, initial); vertical-align: var(--paper-checkbox-vertical-align, middle); background-color: var(--paper-checkbox-unchecked-background-color, transparent); } #ink { position: absolute; /* Center the ripple in the checkbox by negative offsetting it by * (inkWidth - rippleWidth) / 2 */ top: calc(0px - (var(--calculated-paper-checkbox-ink-size) - var(--calculated-paper-checkbox-size)) / 2); left: calc(0px - (var(--calculated-paper-checkbox-ink-size) - var(--calculated-paper-checkbox-size)) / 2); width: var(--calculated-paper-checkbox-ink-size); height: var(--calculated-paper-checkbox-ink-size); color: var(--paper-checkbox-unchecked-ink-color, var(--primary-text-color)); opacity: 0.6; pointer-events: none; } #ink:dir(rtl) { right: calc(0px - (var(--calculated-paper-checkbox-ink-size) - var(--calculated-paper-checkbox-size)) / 2); left: auto; } #ink[checked] { color: var(--paper-checkbox-checked-ink-color, var(--primary-color)); } #checkbox { position: relative; box-sizing: border-box; height: 100%; border: solid 2px; border-color: var(--paper-checkbox-unchecked-color, var(--primary-text-color)); border-radius: 2px; pointer-events: none; -webkit-transition: background-color 140ms, border-color 140ms; transition: background-color 140ms, border-color 140ms; -webkit-transition-duration: var(--paper-checkbox-animation-duration, 140ms); transition-duration: var(--paper-checkbox-animation-duration, 140ms); } /* checkbox checked animations */ #checkbox.checked #checkmark { -webkit-animation: checkmark-expand 140ms ease-out forwards; animation: checkmark-expand 140ms ease-out forwards; -webkit-animation-duration: var(--paper-checkbox-animation-duration, 140ms); animation-duration: var(--paper-checkbox-animation-duration, 140ms); } @-webkit-keyframes checkmark-expand { 0% { -webkit-transform: scale(0, 0) rotate(45deg); } 100% { -webkit-transform: scale(1, 1) rotate(45deg); } } @keyframes checkmark-expand { 0% { transform: scale(0, 0) rotate(45deg); } 100% { transform: scale(1, 1) rotate(45deg); } } #checkbox.checked { background-color: var(--paper-checkbox-checked-color, var(--primary-color)); border-color: var(--paper-checkbox-checked-color, var(--primary-color)); } #checkmark { position: absolute; width: 36%; height: 70%; border-style: solid; border-top: none; border-left: none; border-right-width: calc(2/15 * var(--calculated-paper-checkbox-size)); border-bottom-width: calc(2/15 * var(--calculated-paper-checkbox-size)); border-color: var(--paper-checkbox-checkmark-color, white); -webkit-transform-origin: 97% 86%; transform-origin: 97% 86%; box-sizing: content-box; /* protect against page-level box-sizing */ } #checkmark:dir(rtl) { -webkit-transform-origin: 50% 14%; transform-origin: 50% 14%; } /* label */ #checkboxLabel { position: relative; display: inline-block; vertical-align: middle; padding-left: var(--paper-checkbox-label-spacing, 8px); white-space: normal; line-height: normal; color: var(--paper-checkbox-label-color, var(--primary-text-color)); @apply --paper-checkbox-label; } :host([checked]) #checkboxLabel { color: var(--paper-checkbox-label-checked-color, var(--paper-checkbox-label-color, var(--primary-text-color))); @apply --paper-checkbox-label-checked; } #checkboxLabel:dir(rtl) { padding-right: var(--paper-checkbox-label-spacing, 8px); padding-left: 0; } #checkboxLabel[hidden] { display: none; } /* disabled state */ :host([disabled]) #checkbox { opacity: 0.5; border-color: var(--paper-checkbox-unchecked-color, var(--primary-text-color)); } :host([disabled][checked]) #checkbox { background-color: var(--paper-checkbox-unchecked-color, var(--primary-text-color)); opacity: 0.5; } :host([disabled]) #checkboxLabel { opacity: 0.65; } /* invalid state */ #checkbox.invalid:not(.checked) { border-color: var(--paper-checkbox-error-color, var(--error-color)); } </style> <div id="checkboxContainer"> <div id="checkbox" class$="[[_computeCheckboxClass(checked, invalid)]]"> <div id="checkmark" class$="[[_computeCheckmarkClass(checked)]]"></div> </div> </div> <div id="checkboxLabel"><slot></slot></div>`; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ let verticalScrollbarMaxWidthBugOffset;template$e.setAttribute("strip-whitespace",""),Polymer({_template:template$e,is:"paper-checkbox",behaviors:[PaperCheckedElementBehavior],hostAttributes:{role:"checkbox","aria-checked":!1,tabindex:0},properties:{ariaActiveAttribute:{type:String,value:"aria-checked"}},attached:function(){afterNextRender(this,(function(){if("-1px"===this.getComputedStyleValue("--calculated-paper-checkbox-ink-size").trim()){var e=this.getComputedStyleValue("--calculated-paper-checkbox-size").trim(),t="px",n=e.match(/[A-Za-z]+$/);null!==n&&(t=n[0]);var i=parseFloat(e),r=8/3*i;"px"===t&&(r=Math.floor(r))%2!=i%2&&r++,this.updateStyles({"--paper-checkbox-ink-size":r+t})}}))},_computeCheckboxClass:function(e,t){var n="";return e&&(n+="checked "),t&&(n+="invalid"),n},_computeCheckmarkClass:function(e){return e?"":"hidden"},_createRipple:function(){return this._rippleContainer=this.$.checkboxContainer,PaperInkyFocusBehaviorImpl._createRipple.call(this)}});const getVerticalScrollbarMaxWidthBugOffset=()=>{if(void 0!==verticalScrollbarMaxWidthBugOffset)return verticalScrollbarMaxWidthBugOffset;const e=document.createElement("div");Object.assign(e.style,{overflow:"auto",position:"fixed",left:"0px",top:"0px",maxWidth:"100px",maxHeight:"100px"});const t=document.createElement("div");return t.style.width="200px",t.style.height="200px",e.appendChild(t),document.body.appendChild(e),verticalScrollbarMaxWidthBugOffset=Math.abs(e.offsetWidth-100)>1?e.offsetWidth-e.clientWidth:0,document.body.removeChild(e),verticalScrollbarMaxWidthBugOffset},IronFitBehavior={properties:{sizingTarget:{type:Object,value:function(){return this}},fitInto:{type:Object,value:window},noOverlap:{type:Boolean},positionTarget:{type:Element},horizontalAlign:{type:String},verticalAlign:{type:String},dynamicAlign:{type:Boolean},horizontalOffset:{type:Number,value:0,notify:!0},verticalOffset:{type:Number,value:0,notify:!0},autoFitOnAttach:{type:Boolean,value:!1},expandSizingTargetForScrollbars:{type:Boolean,value:!1},_fitInfo:{type:Object}},get _fitWidth(){return this.fitInto===window?this.fitInto.innerWidth:this.fitInto.getBoundingClientRect().width},get _fitHeight(){return this.fitInto===window?this.fitInto.innerHeight:this.fitInto.getBoundingClientRect().height},get _fitLeft(){return this.fitInto===window?0:this.fitInto.getBoundingClientRect().left},get _fitTop(){return this.fitInto===window?0:this.fitInto.getBoundingClientRect().top},get _defaultPositionTarget(){var e=dom$1(this).parentNode;return e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(e=e.host),e},get _localeHorizontalAlign(){if(this._isRTL){if("right"===this.horizontalAlign)return"left";if("left"===this.horizontalAlign)return"right"}return this.horizontalAlign},get __shouldPosition(){return(this.horizontalAlign||this.verticalAlign)&&this.positionTarget},get _isRTL(){return void 0===this._memoizedIsRTL&&(this._memoizedIsRTL="rtl"==window.getComputedStyle(this).direction),this._memoizedIsRTL},attached:function(){this.positionTarget=this.positionTarget||this._defaultPositionTarget,this.autoFitOnAttach&&("none"===window.getComputedStyle(this).display?setTimeout(function(){this.fit()}.bind(this)):(window.ShadyDOM&&ShadyDOM.flush(),this.fit()))},detached:function(){this.__deferredFit&&(clearTimeout(this.__deferredFit),this.__deferredFit=null)},fit:function(){this.position(),this.constrain(),this.center()},_discoverInfo:function(){if(!this._fitInfo){var e=window.getComputedStyle(this),t=window.getComputedStyle(this.sizingTarget);this._fitInfo={inlineStyle:{top:this.style.top||"",left:this.style.left||"",position:this.style.position||""},sizerInlineStyle:{maxWidth:this.sizingTarget.style.maxWidth||"",maxHeight:this.sizingTarget.style.maxHeight||"",boxSizing:this.sizingTarget.style.boxSizing||""},positionedBy:{vertically:"auto"!==e.top?"top":"auto"!==e.bottom?"bottom":null,horizontally:"auto"!==e.left?"left":"auto"!==e.right?"right":null},sizedBy:{height:"none"!==t.maxHeight,width:"none"!==t.maxWidth,minWidth:parseInt(t.minWidth,10)||0,minHeight:parseInt(t.minHeight,10)||0},margin:{top:parseInt(e.marginTop,10)||0,right:parseInt(e.marginRight,10)||0,bottom:parseInt(e.marginBottom,10)||0,left:parseInt(e.marginLeft,10)||0}}}},resetFit:function(){var e=this._fitInfo||{};for(var t in e.sizerInlineStyle)this.sizingTarget.style[t]=e.sizerInlineStyle[t];for(var t in e.inlineStyle)this.style[t]=e.inlineStyle[t];this._fitInfo=null},refit:function(){var e=this.sizingTarget.scrollLeft,t=this.sizingTarget.scrollTop;this.resetFit(),this.fit(),this.sizingTarget.scrollLeft=e,this.sizingTarget.scrollTop=t},position:function(){if(!this.__shouldPosition)return;this._discoverInfo(),window.ShadyDOM&&window.ShadyDOM.flush(),this.style.position="fixed",this.sizingTarget.style.boxSizing="border-box",this.style.left="0px",this.style.top="0px";var e=this.getBoundingClientRect(),t=this.__getNormalizedRect(this.positionTarget),n=this.__getNormalizedRect(this.fitInto);let i,r,o,a;this.expandSizingTargetForScrollbars&&(i=this.sizingTarget.offsetWidth,r=this.sizingTarget.offsetHeight,o=this.sizingTarget.clientWidth,a=this.sizingTarget.clientHeight);var s=this._fitInfo.margin,l=this.__getPosition(this._localeHorizontalAlign,this.verticalAlign,{width:e.width+s.left+s.right,height:e.height+s.top+s.bottom},e,t,n),c=l.left+s.left,h=l.top+s.top,u=Math.min(n.right-s.right,c+e.width),d=Math.min(n.bottom-s.bottom,h+e.height);c=Math.max(n.left+s.left,Math.min(c,u-this._fitInfo.sizedBy.minWidth)),h=Math.max(n.top+s.top,Math.min(h,d-this._fitInfo.sizedBy.minHeight));const p=Math.max(u-c,this._fitInfo.sizedBy.minWidth),m=Math.max(d-h,this._fitInfo.sizedBy.minHeight);this.sizingTarget.style.maxWidth=p+"px",this.sizingTarget.style.maxHeight=m+"px";const f=c-e.left,g=h-e.top;if(this.style.left=`${f}px`,this.style.top=`${g}px`,this.expandSizingTargetForScrollbars){const e=this.sizingTarget.offsetHeight,t=e-this.sizingTarget.clientHeight-(r-a);if(t>0){const i=Math.min(n.height-s.top-s.bottom,m+t);this.sizingTarget.style.maxHeight=`${i}px`;const r=this.sizingTarget.offsetHeight,o=r-e;let a;"top"===l.verticalAlign?a=g:"middle"===l.verticalAlign?a=g-o/2:"bottom"===l.verticalAlign&&(a=g-o),a=Math.max(n.top+s.top,Math.min(a,n.bottom-s.bottom-r)),this.style.top=`${a}px`}const c=this.sizingTarget.offsetWidth,h=c-this.sizingTarget.clientWidth-(i-o);if(h>0){const e=getVerticalScrollbarMaxWidthBugOffset(),t=Math.min(n.width-s.left-s.right,p+h-e);this.sizingTarget.style.maxWidth=`${t}px`;const i=this.sizingTarget.offsetWidth+e,r=i-c;let o;"left"===l.horizontalAlign?o=f:"center"===l.horizontalAlign?o=f-r/2:"right"===l.horizontalAlign&&(o=f-r),o=Math.max(n.left+s.left,Math.min(o,n.right-s.right-i)),this.style.left=`${o}px`}}},constrain:function(){if(!this.__shouldPosition){this._discoverInfo();var e=this._fitInfo;e.positionedBy.vertically||(this.style.position="fixed",this.style.top="0px"),e.positionedBy.horizontally||(this.style.position="fixed",this.style.left="0px"),this.sizingTarget.style.boxSizing="border-box";var t=this.getBoundingClientRect();e.sizedBy.height||this.__sizeDimension(t,e.positionedBy.vertically,"top","bottom","Height"),e.sizedBy.width||this.__sizeDimension(t,e.positionedBy.horizontally,"left","right","Width")}},_sizeDimension:function(e,t,n,i,r){this.__sizeDimension(e,t,n,i,r)},__sizeDimension:function(e,t,n,i,r){var o=this._fitInfo,a=this.__getNormalizedRect(this.fitInto),s="Width"===r?a.width:a.height,l=t===i,c="offset"+r;this.sizingTarget.style["max"+r]=s-o.margin[l?n:i]-(l?s-e[i]:e[n])-(this[c]-this.sizingTarget[c])+"px"},center:function(){if(!this.__shouldPosition){this._discoverInfo();var e=this._fitInfo.positionedBy;if(!e.vertically||!e.horizontally){this.style.position="fixed",e.vertically||(this.style.top="0px"),e.horizontally||(this.style.left="0px");var t=this.getBoundingClientRect(),n=this.__getNormalizedRect(this.fitInto);e.vertically||(this.style.top=n.top-t.top+(n.height-t.height)/2+"px"),e.horizontally||(this.style.left=n.left-t.left+(n.width-t.width)/2+"px")}}},__getNormalizedRect:function(e){return e===document.documentElement||e===window?{top:0,left:0,width:window.innerWidth,height:window.innerHeight,right:window.innerWidth,bottom:window.innerHeight}:e.getBoundingClientRect()},__getOffscreenArea:function(e,t,n){var i=Math.min(0,e.top)+Math.min(0,n.bottom-(e.top+t.height)),r=Math.min(0,e.left)+Math.min(0,n.right-(e.left+t.width));return Math.abs(i)*t.width+Math.abs(r)*t.height},__getPosition:function(e,t,n,i,r,o){var a,s=[{verticalAlign:"top",horizontalAlign:"left",top:r.top+this.verticalOffset,left:r.left+this.horizontalOffset},{verticalAlign:"top",horizontalAlign:"right",top:r.top+this.verticalOffset,left:r.right-n.width-this.horizontalOffset},{verticalAlign:"bottom",horizontalAlign:"left",top:r.bottom-n.height-this.verticalOffset,left:r.left+this.horizontalOffset},{verticalAlign:"bottom",horizontalAlign:"right",top:r.bottom-n.height-this.verticalOffset,left:r.right-n.width-this.horizontalOffset}];if(this.noOverlap){for(var l=0,c=s.length;l<c;l++){var h={};for(var u in s[l])h[u]=s[l][u];s.push(h)}s[0].top=s[1].top+=r.height,s[2].top=s[3].top-=r.height,s[4].left=s[6].left+=r.width,s[5].left=s[7].left-=r.width}for(t="auto"===t?null:t,(e="auto"===e?null:e)&&"center"!==e||(s.push({verticalAlign:"top",horizontalAlign:"center",top:r.top+this.verticalOffset+(this.noOverlap?r.height:0),left:r.left-i.width/2+r.width/2+this.horizontalOffset}),s.push({verticalAlign:"bottom",horizontalAlign:"center",top:r.bottom-n.height-this.verticalOffset-(this.noOverlap?r.height:0),left:r.left-i.width/2+r.width/2+this.horizontalOffset})),t&&"middle"!==t||(s.push({verticalAlign:"middle",horizontalAlign:"left",top:r.top-i.height/2+r.height/2+this.verticalOffset,left:r.left+this.horizontalOffset+(this.noOverlap?r.width:0)}),s.push({verticalAlign:"middle",horizontalAlign:"right",top:r.top-i.height/2+r.height/2+this.verticalOffset,left:r.right-n.width-this.horizontalOffset-(this.noOverlap?r.width:0)})),"middle"===t&&"center"===e&&s.push({verticalAlign:"middle",horizontalAlign:"center",top:r.top-i.height/2+r.height/2+this.verticalOffset,left:r.left-i.width/2+r.width/2+this.horizontalOffset}),l=0;l<s.length;l++){var d=s[l],p=d.verticalAlign===t,m=d.horizontalAlign===e;if(!this.dynamicAlign&&!this.noOverlap&&p&&m){a=d;break}var f=(!t||p)&&(!e||m);if(this.dynamicAlign||f){if(d.offscreenArea=this.__getOffscreenArea(d,n,o),0===d.offscreenArea&&f){a=d;break}var g=d.offscreenArea-(a=a||d).offscreenArea;(g<0||0===g&&(p||m))&&(a=d)}}return a}}; /** @license Copyright (c) 2016 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ var p$1=Element.prototype,matches=p$1.matches||p$1.matchesSelector||p$1.mozMatchesSelector||p$1.msMatchesSelector||p$1.oMatchesSelector||p$1.webkitMatchesSelector;class IronFocusablesHelperClass{getTabbableNodes(e){var t=[];return this._collectTabbableNodes(e,t)?this._sortByTabIndex(t):t}isFocusable(e){return matches.call(e,"input, select, textarea, button, object")?matches.call(e,":not([disabled])"):matches.call(e,"a[href], area[href], iframe, [tabindex], [contentEditable]")}isTabbable(e){return this.isFocusable(e)&&matches.call(e,':not([tabindex="-1"])')&&this._isVisible(e)}_normalizedTabIndex(e){if(this.isFocusable(e)){var t=e.getAttribute("tabindex")||0;return Number(t)}return-1}_collectTabbableNodes(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return!1;var n=e;if(!this._isVisible(n))return!1;var i,r=this._normalizedTabIndex(n),o=r>0;r>=0&&t.push(n),i="content"===n.localName||"slot"===n.localName?dom$1(n).getDistributedNodes():dom$1(n.root||n).children;for(var a=0;a<i.length;a++)o=this._collectTabbableNodes(i[a],t)||o;return o}_isVisible(e){var t=e.style;return"hidden"!==t.visibility&&"none"!==t.display&&"hidden"!==(t=window.getComputedStyle(e)).visibility&&"none"!==t.display}_sortByTabIndex(e){var t=e.length;if(t<2)return e;var n=Math.ceil(t/2),i=this._sortByTabIndex(e.slice(0,n)),r=this._sortByTabIndex(e.slice(n));return this._mergeSortByTabIndex(i,r)}_mergeSortByTabIndex(e,t){for(var n=[];e.length>0&&t.length>0;)this._hasLowerTabOrder(e[0],t[0])?n.push(t.shift()):n.push(e.shift());return n.concat(e,t)}_hasLowerTabOrder(e,t){var n=Math.max(e.tabIndex,0),i=Math.max(t.tabIndex,0);return 0===n||0===i?i>n:n>i}}const IronFocusablesHelper=new IronFocusablesHelperClass; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */Polymer({_template:html` <style> :host { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--iron-overlay-backdrop-background-color, #000); opacity: 0; transition: opacity 0.2s; pointer-events: none; @apply --iron-overlay-backdrop; } :host(.opened) { opacity: var(--iron-overlay-backdrop-opacity, 0.6); pointer-events: auto; @apply --iron-overlay-backdrop-opened; } </style> <slot></slot> `,is:"iron-overlay-backdrop",properties:{opened:{reflectToAttribute:!0,type:Boolean,value:!1,observer:"_openedChanged"}},listeners:{transitionend:"_onTransitionend"},created:function(){this.__openedRaf=null},attached:function(){this.opened&&this._openedChanged(this.opened)},prepare:function(){this.opened&&!this.parentNode&&dom$1(document.body).appendChild(this)},open:function(){this.opened=!0},close:function(){this.opened=!1},complete:function(){this.opened||this.parentNode!==document.body||dom$1(this.parentNode).removeChild(this)},_onTransitionend:function(e){e&&e.target===this&&this.complete()},_openedChanged:function(e){if(e)this.prepare();else{var t=window.getComputedStyle(this);"0s"!==t.transitionDuration&&0!=t.opacity||this.complete()}this.isAttached&&(this.__openedRaf&&(window.cancelAnimationFrame(this.__openedRaf),this.__openedRaf=null),this.scrollTop=this.scrollTop,this.__openedRaf=window.requestAnimationFrame(function(){this.__openedRaf=null,this.toggleClass("opened",this.opened)}.bind(this)))}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ class IronOverlayManagerClass{constructor(){this._overlays=[],this._minimumZ=101,this._backdropElement=null,addListener(document.documentElement,"tap",(function(){})),document.addEventListener("tap",this._onCaptureClick.bind(this),!0),document.addEventListener("focus",this._onCaptureFocus.bind(this),!0),document.addEventListener("keydown",this._onCaptureKeyDown.bind(this),!0)}get backdropElement(){return this._backdropElement||(this._backdropElement=document.createElement("iron-overlay-backdrop")),this._backdropElement}get deepActiveElement(){var e=document.activeElement;for(e&&e instanceof Element!=0||(e=document.body);e.root&&dom$1(e.root).activeElement;)e=dom$1(e.root).activeElement;return e}_bringOverlayAtIndexToFront(e){var t=this._overlays[e];if(t){var n=this._overlays.length-1,i=this._overlays[n];if(i&&this._shouldBeBehindOverlay(t,i)&&n--,!(e>=n)){var r=Math.max(this.currentOverlayZ(),this._minimumZ);for(this._getZ(t)<=r&&this._applyOverlayZ(t,r);e<n;)this._overlays[e]=this._overlays[e+1],e++;this._overlays[n]=t}}}addOrRemoveOverlay(e){e.opened?this.addOverlay(e):this.removeOverlay(e)}addOverlay(e){var t=this._overlays.indexOf(e);if(t>=0)return this._bringOverlayAtIndexToFront(t),void this.trackBackdrop();var n=this._overlays.length,i=this._overlays[n-1],r=Math.max(this._getZ(i),this._minimumZ),o=this._getZ(e);i&&this._shouldBeBehindOverlay(e,i)&&(this._applyOverlayZ(i,r),n--,r=Math.max(this._getZ(this._overlays[n-1]),this._minimumZ)),o<=r&&this._applyOverlayZ(e,r),this._overlays.splice(n,0,e),this.trackBackdrop()}removeOverlay(e){var t=this._overlays.indexOf(e);-1!==t&&(this._overlays.splice(t,1),this.trackBackdrop())}currentOverlay(){return this._overlays[this._overlays.length-1]}currentOverlayZ(){return this._getZ(this.currentOverlay())}ensureMinimumZ(e){this._minimumZ=Math.max(this._minimumZ,e)}focusOverlay(){var e=this.currentOverlay();e&&e._applyFocus()}trackBackdrop(){var e=this._overlayWithBackdrop();(e||this._backdropElement)&&(this.backdropElement.style.zIndex=this._getZ(e)-1,this.backdropElement.opened=!!e,this.backdropElement.prepare())}getBackdrops(){for(var e=[],t=0;t<this._overlays.length;t++)this._overlays[t].withBackdrop&&e.push(this._overlays[t]);return e}backdropZ(){return this._getZ(this._overlayWithBackdrop())-1}_overlayWithBackdrop(){for(var e=this._overlays.length-1;e>=0;e--)if(this._overlays[e].withBackdrop)return this._overlays[e]}_getZ(e){var t=this._minimumZ;if(e){var n=Number(e.style.zIndex||window.getComputedStyle(e).zIndex);n==n&&(t=n)}return t}_setZ(e,t){e.style.zIndex=t}_applyOverlayZ(e,t){this._setZ(e,t+2)}_overlayInPath(e){e=e||[];for(var t=0;t<e.length;t++)if(e[t]._manager===this)return e[t]}_onCaptureClick(e){var t=this._overlays.length-1;if(-1!==t)for(var n,i=dom$1(e).path;(n=this._overlays[t])&&this._overlayInPath(i)!==n&&(n._onCaptureClick(e),n.allowClickThrough);)t--}_onCaptureFocus(e){var t=this.currentOverlay();t&&t._onCaptureFocus(e)}_onCaptureKeyDown(e){var t=this.currentOverlay();t&&(IronA11yKeysBehavior.keyboardEventMatchesKeys(e,"esc")?t._onCaptureEsc(e):IronA11yKeysBehavior.keyboardEventMatchesKeys(e,"tab")&&t._onCaptureTab(e))}_shouldBeBehindOverlay(e,t){return!e.alwaysOnTop&&t.alwaysOnTop}}const IronOverlayManager=new IronOverlayManagerClass; /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */var lastTouchPosition={pageX:0,pageY:0},lastRootTarget=null,lastScrollableNodes=[],scrollEvents=["wheel","mousewheel","DOMMouseScroll","touchstart","touchmove"],_boundScrollHandler,currentLockingElement;function pushScrollLock(e){_lockingElements.indexOf(e)>=0||(0===_lockingElements.length&&_lockScrollInteractions(),_lockingElements.push(e),currentLockingElement=_lockingElements[_lockingElements.length-1])}function removeScrollLock(e){var t=_lockingElements.indexOf(e);-1!==t&&(_lockingElements.splice(t,1),currentLockingElement=_lockingElements[_lockingElements.length-1],0===_lockingElements.length&&_unlockScrollInteractions())}const _lockingElements=[];function _scrollInteractionHandler(e){if(e.cancelable&&_shouldPreventScrolling(e)&&e.preventDefault(),e.targetTouches){var t=e.targetTouches[0];lastTouchPosition.pageX=t.pageX,lastTouchPosition.pageY=t.pageY}}function _lockScrollInteractions(){_boundScrollHandler=_boundScrollHandler||_scrollInteractionHandler.bind(void 0);for(var e=0,t=scrollEvents.length;e<t;e++)document.addEventListener(scrollEvents[e],_boundScrollHandler,{capture:!0,passive:!1})}function _unlockScrollInteractions(){for(var e=0,t=scrollEvents.length;e<t;e++)document.removeEventListener(scrollEvents[e],_boundScrollHandler,{capture:!0,passive:!1})}function _shouldPreventScrolling(e){var t=dom$1(e).rootTarget;if("touchmove"!==e.type&&lastRootTarget!==t&&(lastRootTarget=t,lastScrollableNodes=_getScrollableNodes(dom$1(e).path)),!lastScrollableNodes.length)return!0;if("touchstart"===e.type)return!1;var n=_getScrollInfo(e);return!_getScrollingNode(lastScrollableNodes,n.deltaX,n.deltaY)}function _getScrollableNodes(e){for(var t=[],n=e.indexOf(currentLockingElement),i=0;i<=n;i++)if(e[i].nodeType===Node.ELEMENT_NODE){var r=e[i],o=r.style;"scroll"!==o.overflow&&"auto"!==o.overflow&&(o=window.getComputedStyle(r)),"scroll"!==o.overflow&&"auto"!==o.overflow||t.push(r)}return t}function _getScrollingNode(e,t,n){if(t||n)for(var i=Math.abs(n)>=Math.abs(t),r=0;r<e.length;r++){var o=e[r];if(i?n<0?o.scrollTop>0:o.scrollTop<o.scrollHeight-o.clientHeight:t<0?o.scrollLeft>0:o.scrollLeft<o.scrollWidth-o.clientWidth)return o}}function _getScrollInfo(e){var t={deltaX:e.deltaX,deltaY:e.deltaY};if("deltaX"in e);else if("wheelDeltaX"in e&&"wheelDeltaY"in e)t.deltaX=-e.wheelDeltaX,t.deltaY=-e.wheelDeltaY;else if("wheelDelta"in e)t.deltaX=0,t.deltaY=-e.wheelDelta;else if("axis"in e)t.deltaX=1===e.axis?e.detail:0,t.deltaY=2===e.axis?e.detail:0;else if(e.targetTouches){var n=e.targetTouches[0];t.deltaX=lastTouchPosition.pageX-n.pageX,t.deltaY=lastTouchPosition.pageY-n.pageY}return t} /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const IronOverlayBehaviorImpl={properties:{opened:{observer:"_openedChanged",type:Boolean,value:!1,notify:!0},canceled:{observer:"_canceledChanged",readOnly:!0,type:Boolean,value:!1},withBackdrop:{observer:"_withBackdropChanged",type:Boolean},noAutoFocus:{type:Boolean,value:!1},noCancelOnEscKey:{type:Boolean,value:!1},noCancelOnOutsideClick:{type:Boolean,value:!1},closingReason:{type:Object},restoreFocusOnClose:{type:Boolean,value:!1},allowClickThrough:{type:Boolean},alwaysOnTop:{type:Boolean},scrollAction:{type:String},_manager:{type:Object,value:IronOverlayManager},_focusedChild:{type:Object}},listeners:{"iron-resize":"_onIronResize"},observers:["__updateScrollObservers(isAttached, opened, scrollAction)"],get backdropElement(){return this._manager.backdropElement},get _focusNode(){return this._focusedChild||dom$1(this).querySelector("[autofocus]")||this},get _focusableNodes(){return IronFocusablesHelper.getTabbableNodes(this)},ready:function(){this.__isAnimating=!1,this.__shouldRemoveTabIndex=!1,this.__firstFocusableNode=this.__lastFocusableNode=null,this.__rafs={},this.__restoreFocusNode=null,this.__scrollTop=this.__scrollLeft=null,this.__onCaptureScroll=this.__onCaptureScroll.bind(this),this.__rootNodes=null,this._ensureSetup()},attached:function(){this.opened&&this._openedChanged(this.opened),this._observer=dom$1(this).observeNodes(this._onNodesChange)},detached:function(){for(var e in this._observer&&dom$1(this).unobserveNodes(this._observer),this._observer=null,this.__rafs)null!==this.__rafs[e]&&cancelAnimationFrame(this.__rafs[e]);this.__rafs={},this._manager.removeOverlay(this),this.__isAnimating&&(this.opened?this._finishRenderOpened():(this._applyFocus(),this._finishRenderClosed()))},toggle:function(){this._setCanceled(!1),this.opened=!this.opened},open:function(){this._setCanceled(!1),this.opened=!0},close:function(){this._setCanceled(!1),this.opened=!1},cancel:function(e){this.fire("iron-overlay-canceled",e,{cancelable:!0}).defaultPrevented||(this._setCanceled(!0),this.opened=!1)},invalidateTabbables:function(){this.__firstFocusableNode=this.__lastFocusableNode=null},_ensureSetup:function(){this._overlaySetup||(this._overlaySetup=!0,this.style.outline="none",this.style.display="none")},_openedChanged:function(e){e?this.removeAttribute("aria-hidden"):this.setAttribute("aria-hidden","true"),this.isAttached&&(this.__isAnimating=!0,this.__deraf("__openedChanged",this.__openedChanged))},_canceledChanged:function(){this.closingReason=this.closingReason||{},this.closingReason.canceled=this.canceled},_withBackdropChanged:function(){this.withBackdrop&&!this.hasAttribute("tabindex")?(this.setAttribute("tabindex","-1"),this.__shouldRemoveTabIndex=!0):this.__shouldRemoveTabIndex&&(this.removeAttribute("tabindex"),this.__shouldRemoveTabIndex=!1),this.opened&&this.isAttached&&this._manager.trackBackdrop()},_prepareRenderOpened:function(){this.__restoreFocusNode=this._manager.deepActiveElement,this._preparePositioning(),this.refit(),this._finishPositioning(),this.noAutoFocus&&document.activeElement===this._focusNode&&(this._focusNode.blur(),this.__restoreFocusNode.focus())},_renderOpened:function(){this._finishRenderOpened()},_renderClosed:function(){this._finishRenderClosed()},_finishRenderOpened:function(){this.notifyResize(),this.__isAnimating=!1,this.fire("iron-overlay-opened")},_finishRenderClosed:function(){this.style.display="none",this.style.zIndex="",this.notifyResize(),this.__isAnimating=!1,this.fire("iron-overlay-closed",this.closingReason)},_preparePositioning:function(){this.style.transition=this.style.webkitTransition="none",this.style.transform=this.style.webkitTransform="none",this.style.display=""},_finishPositioning:function(){this.style.display="none",this.scrollTop=this.scrollTop,this.style.transition=this.style.webkitTransition="",this.style.transform=this.style.webkitTransform="",this.style.display="",this.scrollTop=this.scrollTop},_applyFocus:function(){if(this.opened)this.noAutoFocus||this._focusNode.focus();else{if(this.restoreFocusOnClose&&this.__restoreFocusNode){var e=this._manager.deepActiveElement;(e===document.body||composedContains(this,e))&&this.__restoreFocusNode.focus()}this.__restoreFocusNode=null,this._focusNode.blur(),this._focusedChild=null}},_onCaptureClick:function(e){this.noCancelOnOutsideClick||this.cancel(e)},_onCaptureFocus:function(e){if(this.withBackdrop){var t=dom$1(e).path;-1===t.indexOf(this)?(e.stopPropagation(),this._applyFocus()):this._focusedChild=t[0]}},_onCaptureEsc:function(e){this.noCancelOnEscKey||this.cancel(e)},_onCaptureTab:function(e){if(this.withBackdrop){this.__ensureFirstLastFocusables();var t=e.shiftKey,n=t?this.__firstFocusableNode:this.__lastFocusableNode,i=t?this.__lastFocusableNode:this.__firstFocusableNode,r=!1;if(n===i)r=!0;else{var o=this._manager.deepActiveElement;r=o===n||o===this}r&&(e.preventDefault(),this._focusedChild=i,this._applyFocus())}},_onIronResize:function(){this.opened&&!this.__isAnimating&&this.__deraf("refit",this.refit)},_onNodesChange:function(){this.opened&&!this.__isAnimating&&(this.invalidateTabbables(),this.notifyResize())},__ensureFirstLastFocusables:function(){var e=this._focusableNodes;this.__firstFocusableNode=e[0],this.__lastFocusableNode=e[e.length-1]},__openedChanged:function(){this.opened?(this._prepareRenderOpened(),this._manager.addOverlay(this),this._applyFocus(),this._renderOpened()):(this._manager.removeOverlay(this),this._applyFocus(),this._renderClosed())},__deraf:function(e,t){var n=this.__rafs;null!==n[e]&&cancelAnimationFrame(n[e]),n[e]=requestAnimationFrame(function i(){n[e]=null,t.call(this)}.bind(this))},__updateScrollObservers:function(e,t,n){e&&t&&this.__isValidScrollAction(n)?("lock"===n&&(this.__saveScrollPosition(),pushScrollLock(this)),this.__addScrollListeners()):(removeScrollLock(this),this.__removeScrollListeners())},__addScrollListeners:function(){if(!this.__rootNodes){if(this.__rootNodes=[],useShadow)for(var e=this;e;)e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host&&this.__rootNodes.push(e),e=e.host||e.assignedSlot||e.parentNode;this.__rootNodes.push(document)}this.__rootNodes.forEach((function(e){e.addEventListener("scroll",this.__onCaptureScroll,{capture:!0,passive:!0})}),this)},__removeScrollListeners:function(){this.__rootNodes&&this.__rootNodes.forEach((function(e){e.removeEventListener("scroll",this.__onCaptureScroll,{capture:!0,passive:!0})}),this),this.isAttached||(this.__rootNodes=null)},__isValidScrollAction:function(e){return"lock"===e||"refit"===e||"cancel"===e},__onCaptureScroll:function(e){if(!(this.__isAnimating||dom$1(e).path.indexOf(this)>=0))switch(this.scrollAction){case"lock":this.__restoreScrollPosition();break;case"refit":this.__deraf("refit",this.refit);break;case"cancel":this.cancel(e)}},__saveScrollPosition:function(){document.scrollingElement?(this.__scrollTop=document.scrollingElement.scrollTop,this.__scrollLeft=document.scrollingElement.scrollLeft):(this.__scrollTop=Math.max(document.documentElement.scrollTop,document.body.scrollTop),this.__scrollLeft=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft))},__restoreScrollPosition:function(){document.scrollingElement?(document.scrollingElement.scrollTop=this.__scrollTop,document.scrollingElement.scrollLeft=this.__scrollLeft):(document.documentElement.scrollTop=document.body.scrollTop=this.__scrollTop,document.documentElement.scrollLeft=document.body.scrollLeft=this.__scrollLeft)}},composedParent=e=>e.assignedSlot||e.parentNode||e.host,composedContains=(e,t)=>{for(let n=t;n;n=composedParent(n))if(n===e)return!0;return!1},IronOverlayBehavior=[IronFitBehavior,IronResizableBehavior,IronOverlayBehaviorImpl],PaperDialogBehaviorImpl={hostAttributes:{role:"dialog",tabindex:"-1"},properties:{modal:{type:Boolean,value:!1},__readied:{type:Boolean,value:!1}},observers:["_modalChanged(modal, __readied)"],listeners:{tap:"_onDialogClick"},ready:function(){this.__prevNoCancelOnOutsideClick=this.noCancelOnOutsideClick,this.__prevNoCancelOnEscKey=this.noCancelOnEscKey,this.__prevWithBackdrop=this.withBackdrop,this.__readied=!0},_modalChanged:function(e,t){t&&(e?(this.__prevNoCancelOnOutsideClick=this.noCancelOnOutsideClick,this.__prevNoCancelOnEscKey=this.noCancelOnEscKey,this.__prevWithBackdrop=this.withBackdrop,this.noCancelOnOutsideClick=!0,this.noCancelOnEscKey=!0,this.withBackdrop=!0):(this.noCancelOnOutsideClick=this.noCancelOnOutsideClick&&this.__prevNoCancelOnOutsideClick,this.noCancelOnEscKey=this.noCancelOnEscKey&&this.__prevNoCancelOnEscKey,this.withBackdrop=this.withBackdrop&&this.__prevWithBackdrop))},_updateClosingReasonConfirmed:function(e){this.closingReason=this.closingReason||{},this.closingReason.confirmed=e},_onDialogClick:function(e){for(var t=dom$1(e).path,n=0,i=t.indexOf(this);n<i;n++){var r=t[n];if(r.hasAttribute&&(r.hasAttribute("dialog-dismiss")||r.hasAttribute("dialog-confirm"))){this._updateClosingReasonConfirmed(r.hasAttribute("dialog-confirm")),this.close(),e.stopPropagation();break}}}},PaperDialogBehavior=[IronOverlayBehavior,PaperDialogBehaviorImpl]; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ if( /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { display: block; @apply --layout-relative; } :host(.is-scrolled:not(:first-child))::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: var(--divider-color); } :host(.can-scroll:not(.scrolled-to-bottom):not(:last-child))::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px; background: var(--divider-color); } .scrollable { padding: 0 24px; @apply --layout-scroll; @apply --paper-dialog-scrollable; } .fit { @apply --layout-fit; } </style> <div id="scrollable" class="scrollable" on-scroll="updateScrollState"> <slot></slot> </div> `,is:"paper-dialog-scrollable",properties:{dialogElement:{type:Object}},get scrollTarget(){return this.$.scrollable},ready:function(){this._ensureTarget(),this.classList.add("no-padding")},attached:function(){this._ensureTarget(),requestAnimationFrame(this.updateScrollState.bind(this))},updateScrollState:function(){this.toggleClass("is-scrolled",this.scrollTarget.scrollTop>0),this.toggleClass("can-scroll",this.scrollTarget.offsetHeight<this.scrollTarget.scrollHeight),this.toggleClass("scrolled-to-bottom",this.scrollTarget.scrollTop+this.scrollTarget.offsetHeight>=this.scrollTarget.scrollHeight)},_ensureTarget:function(){this.dialogElement=this.dialogElement||this.parentElement,this.dialogElement&&this.dialogElement.behaviors&&this.dialogElement.behaviors.indexOf(PaperDialogBehaviorImpl)>=0?(this.dialogElement.sizingTarget=this.scrollTarget,this.scrollTarget.classList.remove("fit")):this.dialogElement&&this.scrollTarget.classList.add("fit")}}),!window.polymerSkipLoadingFontRoboto){const e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.crossOrigin="anonymous",e.href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,700|Roboto:400,300,300italic,400italic,500,500italic,700,700italic",document.head.appendChild(e)} /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */const template$d=html`<custom-style> <style is="custom-style"> html { /* Shared Styles */ --paper-font-common-base: { font-family: 'Roboto', 'Noto', sans-serif; -webkit-font-smoothing: antialiased; }; --paper-font-common-code: { font-family: 'Roboto Mono', 'Consolas', 'Menlo', monospace; -webkit-font-smoothing: antialiased; }; --paper-font-common-expensive-kerning: { text-rendering: optimizeLegibility; }; --paper-font-common-nowrap: { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }; /* Material Font Styles */ --paper-font-display4: { @apply --paper-font-common-base; @apply --paper-font-common-nowrap; font-size: 112px; font-weight: 300; letter-spacing: -.044em; line-height: 120px; }; --paper-font-display3: { @apply --paper-font-common-base; @apply --paper-font-common-nowrap; font-size: 56px; font-weight: 400; letter-spacing: -.026em; line-height: 60px; }; --paper-font-display2: { @apply --paper-font-common-base; font-size: 45px; font-weight: 400; letter-spacing: -.018em; line-height: 48px; }; --paper-font-display1: { @apply --paper-font-common-base; font-size: 34px; font-weight: 400; letter-spacing: -.01em; line-height: 40px; }; --paper-font-headline: { @apply --paper-font-common-base; font-size: 24px; font-weight: 400; letter-spacing: -.012em; line-height: 32px; }; --paper-font-title: { @apply --paper-font-common-base; @apply --paper-font-common-nowrap; font-size: 20px; font-weight: 500; line-height: 28px; }; --paper-font-subhead: { @apply --paper-font-common-base; font-size: 16px; font-weight: 400; line-height: 24px; }; --paper-font-body2: { @apply --paper-font-common-base; font-size: 14px; font-weight: 500; line-height: 24px; }; --paper-font-body1: { @apply --paper-font-common-base; font-size: 14px; font-weight: 400; line-height: 20px; }; --paper-font-caption: { @apply --paper-font-common-base; @apply --paper-font-common-nowrap; font-size: 12px; font-weight: 400; letter-spacing: 0.011em; line-height: 20px; }; --paper-font-menu: { @apply --paper-font-common-base; @apply --paper-font-common-nowrap; font-size: 13px; font-weight: 500; line-height: 24px; }; --paper-font-button: { @apply --paper-font-common-base; @apply --paper-font-common-nowrap; font-size: 14px; font-weight: 500; letter-spacing: 0.018em; line-height: 24px; text-transform: uppercase; }; --paper-font-code2: { @apply --paper-font-common-code; font-size: 14px; font-weight: 700; line-height: 20px; }; --paper-font-code1: { @apply --paper-font-common-code; font-size: 14px; font-weight: 500; line-height: 20px; }; } </style> </custom-style>`;template$d.setAttribute("style","display: none;"),document.head.appendChild(template$d.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const $_documentContainer$4=document.createElement("template");$_documentContainer$4.setAttribute("style","display: none;"),$_documentContainer$4.innerHTML='<dom-module id="paper-dialog-shared-styles">\n <template>\n <style>\n :host {\n display: block;\n margin: 24px 40px;\n\n background: var(--paper-dialog-background-color, var(--primary-background-color));\n color: var(--paper-dialog-color, var(--primary-text-color));\n\n @apply --paper-font-body1;\n @apply --shadow-elevation-16dp;\n @apply --paper-dialog;\n }\n\n :host > ::slotted(*) {\n margin-top: 20px;\n padding: 0 24px;\n }\n\n :host > ::slotted(.no-padding) {\n padding: 0;\n }\n\n \n :host > ::slotted(*:first-child) {\n margin-top: 24px;\n }\n\n :host > ::slotted(*:last-child) {\n margin-bottom: 24px;\n }\n\n /* In 1.x, this selector was `:host > ::content h2`. In 2.x <slot> allows\n to select direct children only, which increases the weight of this\n selector, so we have to re-define first-child/last-child margins below. */\n :host > ::slotted(h2) {\n position: relative;\n margin: 0;\n\n @apply --paper-font-title;\n @apply --paper-dialog-title;\n }\n\n /* Apply mixin again, in case it sets margin-top. */\n :host > ::slotted(h2:first-child) {\n margin-top: 24px;\n @apply --paper-dialog-title;\n }\n\n /* Apply mixin again, in case it sets margin-bottom. */\n :host > ::slotted(h2:last-child) {\n margin-bottom: 24px;\n @apply --paper-dialog-title;\n }\n\n :host > ::slotted(.paper-dialog-buttons),\n :host > ::slotted(.buttons) {\n position: relative;\n padding: 8px 8px 8px 24px;\n margin: 0;\n\n color: var(--paper-dialog-button-color, var(--primary-color));\n\n @apply --layout-horizontal;\n @apply --layout-end-justified;\n }\n </style>\n </template>\n</dom-module>',document.head.appendChild($_documentContainer$4.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const NeonAnimatableBehavior={properties:{animationConfig:{type:Object},entryAnimation:{observer:"_entryAnimationChanged",type:String},exitAnimation:{observer:"_exitAnimationChanged",type:String}},_entryAnimationChanged:function(){this.animationConfig=this.animationConfig||{},this.animationConfig.entry=[{name:this.entryAnimation,node:this}]},_exitAnimationChanged:function(){this.animationConfig=this.animationConfig||{},this.animationConfig.exit=[{name:this.exitAnimation,node:this}]},_copyProperties:function(e,t){for(var n in t)e[n]=t[n]},_cloneConfig:function(e){var t={isClone:!0};return this._copyProperties(t,e),t},_getAnimationConfigRecursive:function(e,t,n){var i;if(this.animationConfig)if(this.animationConfig.value&&"function"==typeof this.animationConfig.value)this._warn(this._logf("playAnimation","Please put 'animationConfig' inside of your components 'properties' object instead of outside of it."));else if(i=e?this.animationConfig[e]:this.animationConfig,Array.isArray(i)||(i=[i]),i)for(var r,o=0;r=i[o];o++)if(r.animatable)r.animatable._getAnimationConfigRecursive(r.type||e,t,n);else if(r.id){var a=t[r.id];a?(a.isClone||(t[r.id]=this._cloneConfig(a),a=t[r.id]),this._copyProperties(a,r)):t[r.id]=r}else n.push(r)},getAnimationConfig:function(e){var t={},n=[];for(var i in this._getAnimationConfigRecursive(e,t,n),t)n.push(t[i]);return n}},NeonAnimationRunnerBehaviorImpl={_configureAnimations:function(e){var t=[],n=[];if(e.length>0)for(let t,i=0;t=e[i];i++){let e=document.createElement(t.name);if(e.isNeonAnimation){let i=null;e.configure||(e.configure=function(e){return null}),i=e.configure(t),n.push({result:i,config:t,neonAnimation:e})}else console.warn(this.is+":",t.name,"not found!")}for(var i=0;i<n.length;i++){let e=n[i].result,r=n[i].config,o=n[i].neonAnimation;try{"function"!=typeof e.cancel&&(e=document.timeline.play(e))}catch(t){e=null,console.warn("Couldnt play","(",r.name,").",t)}e&&t.push({neonAnimation:o,config:r,animation:e})}return t},_shouldComplete:function(e){for(var t=!0,n=0;n<e.length;n++)if("finished"!=e[n].animation.playState){t=!1;break}return t},_complete:function(e){for(var t=0;t<e.length;t++)e[t].neonAnimation.complete(e[t].config);for(t=0;t<e.length;t++)e[t].animation.cancel()},playAnimation:function(e,t){var n=this.getAnimationConfig(e);if(n){this._active=this._active||{},this._active[e]&&(this._complete(this._active[e]),delete this._active[e]);var i=this._configureAnimations(n);if(0!=i.length){this._active[e]=i;for(var r=0;r<i.length;r++)i[r].animation.onfinish=function(){this._shouldComplete(i)&&(this._complete(i),delete this._active[e],this.fire("neon-animation-finish",t,{bubbles:!1}))}.bind(this)}else this.fire("neon-animation-finish",t,{bubbles:!1})}},cancelAnimation:function(){for(var e in this._active){var t=this._active[e];for(var n in t)t[n].animation.cancel()}this._active={}}},NeonAnimationRunnerBehavior=[NeonAnimatableBehavior,NeonAnimationRunnerBehaviorImpl]; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style include="paper-dialog-shared-styles"></style> <slot></slot> `,is:"paper-dialog",behaviors:[PaperDialogBehavior,NeonAnimationRunnerBehavior],listeners:{"neon-animation-finish":"_onNeonAnimationFinish"},_renderOpened:function(){this.cancelAnimation(),this.playAnimation("entry")},_renderClosed:function(){this.cancelAnimation(),this.playAnimation("exit")},_onNeonAnimationFinish:function(){this.opened?this._finishRenderOpened():this._finishRenderClosed()}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const IronA11yAnnouncer=Polymer({_template:html` <style> :host { display: inline-block; position: fixed; clip: rect(0px,0px,0px,0px); } </style> <div aria-live$="[[mode]]">[[_text]]</div> `,is:"iron-a11y-announcer",properties:{mode:{type:String,value:"polite"},timeout:{type:Number,value:150},_text:{type:String,value:""}},created:function(){IronA11yAnnouncer.instance||(IronA11yAnnouncer.instance=this),document.addEventListener("iron-announce",this._onIronAnnounce.bind(this))},announce:function(e){this._text="",this.async((function(){this._text=e}),this.timeout)},_onIronAnnounce:function(e){e.detail&&e.detail.text&&this.announce(e.detail.text)}});IronA11yAnnouncer.instance=null,IronA11yAnnouncer.requestAvailability=function(){IronA11yAnnouncer.instance||(IronA11yAnnouncer.instance=document.createElement("iron-a11y-announcer")),document.body?document.body.appendChild(IronA11yAnnouncer.instance):document.addEventListener("load",(function(){document.body.appendChild(IronA11yAnnouncer.instance)}))}, /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { display: inline-block; } </style> <slot id="content"></slot> `,is:"iron-input",behaviors:[IronValidatableBehavior],properties:{bindValue:{type:String,value:""},value:{type:String,computed:"_computeValue(bindValue)"},allowedPattern:{type:String},autoValidate:{type:Boolean,value:!1},_inputElement:Object},observers:["_bindValueChanged(bindValue, _inputElement)"],listeners:{input:"_onInput",keypress:"_onKeypress"},created:function(){IronA11yAnnouncer.requestAvailability(),this._previousValidInput="",this._patternAlreadyChecked=!1},attached:function(){this._observer=dom$1(this).observeNodes(function(e){this._initSlottedInput()}.bind(this))},detached:function(){this._observer&&(dom$1(this).unobserveNodes(this._observer),this._observer=null)},get inputElement(){return this._inputElement},_initSlottedInput:function(){this._inputElement=this.getEffectiveChildren()[0],this.inputElement&&this.inputElement.value&&(this.bindValue=this.inputElement.value),this.fire("iron-input-ready")},get _patternRegExp(){var e;if(this.allowedPattern)e=new RegExp(this.allowedPattern);else switch(this.inputElement.type){case"number":e=/[0-9.,e-]/}return e},_bindValueChanged:function(e,t){t&&(void 0===e?t.value=null:e!==t.value&&(this.inputElement.value=e),this.autoValidate&&this.validate(),this.fire("bind-value-changed",{value:e}))},_onInput:function(){this.allowedPattern&&!this._patternAlreadyChecked&&(this._checkPatternValidity()||(this._announceInvalidCharacter("Invalid string of characters not entered."),this.inputElement.value=this._previousValidInput)),this.bindValue=this._previousValidInput=this.inputElement.value,this._patternAlreadyChecked=!1},_isPrintable:function(e){return!(8==e.keyCode||9==e.keyCode||13==e.keyCode||27==e.keyCode||0==e.charCode&&(19==e.keyCode||20==e.keyCode||45==e.keyCode||46==e.keyCode||144==e.keyCode||145==e.keyCode||e.keyCode>32&&e.keyCode<41||e.keyCode>111&&e.keyCode<124))},_onKeypress:function(e){if(this.allowedPattern||"number"===this.inputElement.type){var t=this._patternRegExp;if(t&&!(e.metaKey||e.ctrlKey||e.altKey)){this._patternAlreadyChecked=!0;var n=String.fromCharCode(e.charCode);this._isPrintable(e)&&!t.test(n)&&(e.preventDefault(),this._announceInvalidCharacter("Invalid character "+n+" not entered."))}}},_checkPatternValidity:function(){var e=this._patternRegExp;if(!e)return!0;for(var t=0;t<this.inputElement.value.length;t++)if(!e.test(this.inputElement.value[t]))return!1;return!0},validate:function(){if(!this.inputElement)return this.invalid=!1,!0;var e=this.inputElement.checkValidity();return e&&(this.required&&""===this.bindValue?e=!1:this.hasValidator()&&(e=IronValidatableBehavior.validate.call(this,this.bindValue))),this.invalid=!e,this.fire("iron-input-validate"),e},_announceInvalidCharacter:function(e){this.fire("iron-announce",{text:e})},_computeValue:function(e){return e}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const PaperInputAddonBehavior={attached:function(){this.fire("addon-attached")},update:function(e){}}; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */Polymer({_template:html` <style> :host { display: inline-block; float: right; @apply --paper-font-caption; @apply --paper-input-char-counter; } :host([hidden]) { display: none !important; } :host(:dir(rtl)) { float: left; } </style> <span>[[_charCounterStr]]</span> `,is:"paper-input-char-counter",behaviors:[PaperInputAddonBehavior],properties:{_charCounterStr:{type:String,value:"0"}},update:function(e){if(e.inputElement){e.value=e.value||"";var t=e.value.toString().length.toString();e.inputElement.hasAttribute("maxlength")&&(t+="/"+e.inputElement.getAttribute("maxlength")),this._charCounterStr=t}}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$c=html` <custom-style> <style is="custom-style"> html { --paper-input-container-shared-input-style: { position: relative; /* to make a stacking context */ outline: none; box-shadow: none; padding: 0; margin: 0; width: 100%; max-width: 100%; background: transparent; border: none; color: var(--paper-input-container-input-color, var(--primary-text-color)); -webkit-appearance: none; text-align: inherit; vertical-align: var(--paper-input-container-input-align, bottom); @apply --paper-font-subhead; }; } </style> </custom-style> `;template$c.setAttribute("style","display: none;"),document.head.appendChild(template$c.content),Polymer({_template:html` <style> :host { display: block; padding: 8px 0; @apply --paper-input-container; } :host([inline]) { display: inline-block; } :host([disabled]) { pointer-events: none; opacity: 0.33; @apply --paper-input-container-disabled; } :host([hidden]) { display: none !important; } [hidden] { display: none !important; } .floated-label-placeholder { @apply --paper-font-caption; } .underline { height: 2px; position: relative; } .focused-line { @apply --layout-fit; border-bottom: 2px solid var(--paper-input-container-focus-color, var(--primary-color)); -webkit-transform-origin: center center; transform-origin: center center; -webkit-transform: scale3d(0,1,1); transform: scale3d(0,1,1); @apply --paper-input-container-underline-focus; } .underline.is-highlighted .focused-line { -webkit-transform: none; transform: none; -webkit-transition: -webkit-transform 0.25s; transition: transform 0.25s; @apply --paper-transition-easing; } .underline.is-invalid .focused-line { border-color: var(--paper-input-container-invalid-color, var(--error-color)); -webkit-transform: none; transform: none; -webkit-transition: -webkit-transform 0.25s; transition: transform 0.25s; @apply --paper-transition-easing; } .unfocused-line { @apply --layout-fit; border-bottom: 1px solid var(--paper-input-container-color, var(--secondary-text-color)); @apply --paper-input-container-underline; } :host([disabled]) .unfocused-line { border-bottom: 1px dashed; border-color: var(--paper-input-container-color, var(--secondary-text-color)); @apply --paper-input-container-underline-disabled; } .input-wrapper { @apply --layout-horizontal; @apply --layout-center; position: relative; } .input-content { @apply --layout-flex-auto; @apply --layout-relative; max-width: 100%; } .input-content ::slotted(label), .input-content ::slotted(.paper-input-label) { position: absolute; top: 0; left: 0; width: 100%; font: inherit; color: var(--paper-input-container-color, var(--secondary-text-color)); -webkit-transition: -webkit-transform 0.25s, width 0.25s; transition: transform 0.25s, width 0.25s; -webkit-transform-origin: left top; transform-origin: left top; /* Fix for safari not focusing 0-height date/time inputs with -webkit-apperance: none; */ min-height: 1px; @apply --paper-font-common-nowrap; @apply --paper-font-subhead; @apply --paper-input-container-label; @apply --paper-transition-easing; } .input-content ::slotted(label):before, .input-content ::slotted(.paper-input-label):before { @apply --paper-input-container-label-before; } .input-content ::slotted(label):after, .input-content ::slotted(.paper-input-label):after { @apply --paper-input-container-label-after; } .input-content.label-is-floating ::slotted(label), .input-content.label-is-floating ::slotted(.paper-input-label) { -webkit-transform: translateY(-75%) scale(0.75); transform: translateY(-75%) scale(0.75); /* Since we scale to 75/100 of the size, we actually have 100/75 of the original space now available */ width: 133%; @apply --paper-input-container-label-floating; } :host(:dir(rtl)) .input-content.label-is-floating ::slotted(label), :host(:dir(rtl)) .input-content.label-is-floating ::slotted(.paper-input-label) { right: 0; left: auto; -webkit-transform-origin: right top; transform-origin: right top; } .input-content.label-is-highlighted ::slotted(label), .input-content.label-is-highlighted ::slotted(.paper-input-label) { color: var(--paper-input-container-focus-color, var(--primary-color)); @apply --paper-input-container-label-focus; } .input-content.is-invalid ::slotted(label), .input-content.is-invalid ::slotted(.paper-input-label) { color: var(--paper-input-container-invalid-color, var(--error-color)); } .input-content.label-is-hidden ::slotted(label), .input-content.label-is-hidden ::slotted(.paper-input-label) { visibility: hidden; } .input-content ::slotted(input), .input-content ::slotted(iron-input), .input-content ::slotted(textarea), .input-content ::slotted(iron-autogrow-textarea), .input-content ::slotted(.paper-input-input) { @apply --paper-input-container-shared-input-style; /* The apply shim doesn't apply the nested color custom property, so we have to re-apply it here. */ color: var(--paper-input-container-input-color, var(--primary-text-color)); @apply --paper-input-container-input; } .input-content ::slotted(input)::-webkit-outer-spin-button, .input-content ::slotted(input)::-webkit-inner-spin-button { @apply --paper-input-container-input-webkit-spinner; } .input-content.focused ::slotted(input), .input-content.focused ::slotted(iron-input), .input-content.focused ::slotted(textarea), .input-content.focused ::slotted(iron-autogrow-textarea), .input-content.focused ::slotted(.paper-input-input) { @apply --paper-input-container-input-focus; } .input-content.is-invalid ::slotted(input), .input-content.is-invalid ::slotted(iron-input), .input-content.is-invalid ::slotted(textarea), .input-content.is-invalid ::slotted(iron-autogrow-textarea), .input-content.is-invalid ::slotted(.paper-input-input) { @apply --paper-input-container-input-invalid; } .prefix ::slotted(*) { display: inline-block; @apply --paper-font-subhead; @apply --layout-flex-none; @apply --paper-input-prefix; } .suffix ::slotted(*) { display: inline-block; @apply --paper-font-subhead; @apply --layout-flex-none; @apply --paper-input-suffix; } /* Firefox sets a min-width on the input, which can cause layout issues */ .input-content ::slotted(input) { min-width: 0; } .input-content ::slotted(textarea) { resize: none; } .add-on-content { position: relative; } .add-on-content.is-invalid ::slotted(*) { color: var(--paper-input-container-invalid-color, var(--error-color)); } .add-on-content.is-highlighted ::slotted(*) { color: var(--paper-input-container-focus-color, var(--primary-color)); } </style> <div class="floated-label-placeholder" aria-hidden="true" hidden="[[noLabelFloat]]"> </div> <div class="input-wrapper"> <span class="prefix"><slot name="prefix"></slot></span> <div class$="[[_computeInputContentClass(noLabelFloat,alwaysFloatLabel,focused,invalid,_inputHasContent)]]" id="labelAndInputContainer"> <slot name="label"></slot> <slot name="input"></slot> </div> <span class="suffix"><slot name="suffix"></slot></span> </div> <div class$="[[_computeUnderlineClass(focused,invalid)]]"> <div class="unfocused-line"></div> <div class="focused-line"></div> </div> <div class$="[[_computeAddOnContentClass(focused,invalid)]]"> <slot name="add-on"></slot> </div> `,is:"paper-input-container",properties:{noLabelFloat:{type:Boolean,value:!1},alwaysFloatLabel:{type:Boolean,value:!1},attrForValue:{type:String,value:"bind-value"},autoValidate:{type:Boolean,value:!1},invalid:{observer:"_invalidChanged",type:Boolean,value:!1},focused:{readOnly:!0,type:Boolean,value:!1,notify:!0},_addons:{type:Array},_inputHasContent:{type:Boolean,value:!1},_inputSelector:{type:String,value:"input,iron-input,textarea,.paper-input-input"},_boundOnFocus:{type:Function,value:function(){return this._onFocus.bind(this)}},_boundOnBlur:{type:Function,value:function(){return this._onBlur.bind(this)}},_boundOnInput:{type:Function,value:function(){return this._onInput.bind(this)}},_boundValueChanged:{type:Function,value:function(){return this._onValueChanged.bind(this)}}},listeners:{"addon-attached":"_onAddonAttached","iron-input-validate":"_onIronInputValidate"},get _valueChangedEvent(){return this.attrForValue+"-changed"},get _propertyForValue(){return dashToCamelCase(this.attrForValue)},get _inputElement(){return dom$1(this).querySelector(this._inputSelector)},get _inputElementValue(){return this._inputElement[this._propertyForValue]||this._inputElement.value},ready:function(){this.__isFirstValueUpdate=!0,this._addons||(this._addons=[]),this.addEventListener("focus",this._boundOnFocus,!0),this.addEventListener("blur",this._boundOnBlur,!0)},attached:function(){this.attrForValue?this._inputElement.addEventListener(this._valueChangedEvent,this._boundValueChanged):this.addEventListener("input",this._onInput),this._inputElementValue&&""!=this._inputElementValue?this._handleValueAndAutoValidate(this._inputElement):this._handleValue(this._inputElement)},_onAddonAttached:function(e){this._addons||(this._addons=[]);var t=e.target;-1===this._addons.indexOf(t)&&(this._addons.push(t),this.isAttached&&this._handleValue(this._inputElement))},_onFocus:function(){this._setFocused(!0)},_onBlur:function(){this._setFocused(!1),this._handleValueAndAutoValidate(this._inputElement)},_onInput:function(e){this._handleValueAndAutoValidate(e.target)},_onValueChanged:function(e){var t=e.target;this.__isFirstValueUpdate&&(this.__isFirstValueUpdate=!1,void 0===t.value||""===t.value)||this._handleValueAndAutoValidate(e.target)},_handleValue:function(e){var t=this._inputElementValue;this._inputHasContent=!(!t&&0!==t&&("number"!==e.type||e.checkValidity())),this.updateAddons({inputElement:e,value:t,invalid:this.invalid})},_handleValueAndAutoValidate:function(e){var t;this.autoValidate&&e&&(t=e.validate?e.validate(this._inputElementValue):e.checkValidity(),this.invalid=!t),this._handleValue(e)},_onIronInputValidate:function(e){this.invalid=this._inputElement.invalid},_invalidChanged:function(){this._addons&&this.updateAddons({invalid:this.invalid})},updateAddons:function(e){for(var t,n=0;t=this._addons[n];n++)t.update(e)},_computeInputContentClass:function(e,t,n,i,r){var o="input-content";if(e)r&&(o+=" label-is-hidden"),i&&(o+=" is-invalid");else{var a=this.querySelector("label");t||r?(o+=" label-is-floating",this.$.labelAndInputContainer.style.position="static",i?o+=" is-invalid":n&&(o+=" label-is-highlighted")):(a&&(this.$.labelAndInputContainer.style.position="relative"),i&&(o+=" is-invalid"))}return n&&(o+=" focused"),o},_computeUnderlineClass:function(e,t){var n="underline";return t?n+=" is-invalid":e&&(n+=" is-highlighted"),n},_computeAddOnContentClass:function(e,t){var n="add-on-content";return t?n+=" is-invalid":e&&(n+=" is-highlighted"),n}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { display: inline-block; visibility: hidden; color: var(--paper-input-container-invalid-color, var(--error-color)); @apply --paper-font-caption; @apply --paper-input-error; position: absolute; left:0; right:0; } :host([invalid]) { visibility: visible; } #a11yWrapper { visibility: hidden; } :host([invalid]) #a11yWrapper { visibility: visible; } </style> <!-- If the paper-input-error element is directly referenced by an \`aria-describedby\` attribute, such as when used as a paper-input add-on, then applying \`visibility: hidden;\` to the paper-input-error element itself does not hide the error. For more information, see: https://www.w3.org/TR/accname-1.1/#mapping_additional_nd_description --> <div id="a11yWrapper"> <slot></slot> </div> `,is:"paper-input-error",behaviors:[PaperInputAddonBehavior],properties:{invalid:{readOnly:!0,reflectToAttribute:!0,type:Boolean}},update:function(e){this._setInvalid(e.invalid)}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const PaperInputHelper={NextLabelID:1,NextAddonID:1,NextInputID:1},PaperInputBehaviorImpl={properties:{label:{type:String},value:{notify:!0,type:String},disabled:{type:Boolean,value:!1},invalid:{type:Boolean,value:!1,notify:!0},allowedPattern:{type:String},type:{type:String},list:{type:String},pattern:{type:String},required:{type:Boolean,value:!1},errorMessage:{type:String},charCounter:{type:Boolean,value:!1},noLabelFloat:{type:Boolean,value:!1},alwaysFloatLabel:{type:Boolean,value:!1},autoValidate:{type:Boolean,value:!1},validator:{type:String},autocomplete:{type:String,value:"off"},autofocus:{type:Boolean,observer:"_autofocusChanged"},inputmode:{type:String},minlength:{type:Number},maxlength:{type:Number},min:{type:String},max:{type:String},step:{type:String},name:{type:String},placeholder:{type:String,value:""},readonly:{type:Boolean,value:!1},size:{type:Number},autocapitalize:{type:String,value:"none"},autocorrect:{type:String,value:"off"},autosave:{type:String},results:{type:Number},accept:{type:String},multiple:{type:Boolean},_ariaDescribedBy:{type:String,value:""},_ariaLabelledBy:{type:String,value:""},_inputId:{type:String,value:""}},listeners:{"addon-attached":"_onAddonAttached"},keyBindings:{"shift+tab:keydown":"_onShiftTabDown"},hostAttributes:{tabindex:0},get inputElement(){return this.$||(this.$={}),this.$.input||(this._generateInputId(),this.$.input=this.$$("#"+this._inputId)),this.$.input},get _focusableElement(){return this.inputElement},created:function(){this._typesThatHaveText=["date","datetime","datetime-local","month","time","week","file"]},attached:function(){this._updateAriaLabelledBy(),!PolymerElement&&this.inputElement&&-1!==this._typesThatHaveText.indexOf(this.inputElement.type)&&(this.alwaysFloatLabel=!0)},_appendStringWithSpace:function(e,t){return e?e+" "+t:t},_onAddonAttached:function(e){var t=dom$1(e).rootTarget;if(t.id)this._ariaDescribedBy=this._appendStringWithSpace(this._ariaDescribedBy,t.id);else{var n="paper-input-add-on-"+PaperInputHelper.NextAddonID++;t.id=n,this._ariaDescribedBy=this._appendStringWithSpace(this._ariaDescribedBy,n)}},validate:function(){return this.inputElement.validate()},_focusBlurHandler:function(e){IronControlState._focusBlurHandler.call(this,e),this.focused&&!this._shiftTabPressed&&this._focusableElement&&this._focusableElement.focus()},_onShiftTabDown:function(e){var t=this.getAttribute("tabindex");this._shiftTabPressed=!0,this.setAttribute("tabindex","-1"),this.async((function(){this.setAttribute("tabindex",t),this._shiftTabPressed=!1}),1)},_handleAutoValidate:function(){this.autoValidate&&this.validate()},updateValueAndPreserveCaret:function(e){try{var t=this.inputElement.selectionStart;this.value=e,this.inputElement.selectionStart=t,this.inputElement.selectionEnd=t}catch(t){this.value=e}},_computeAlwaysFloatLabel:function(e,t){return t||e},_updateAriaLabelledBy:function(){var e,t=dom$1(this.root).querySelector("label");t?(t.id?e=t.id:(e="paper-input-label-"+PaperInputHelper.NextLabelID++,t.id=e),this._ariaLabelledBy=e):this._ariaLabelledBy=""},_generateInputId:function(){this._inputId&&""!==this._inputId||(this._inputId="input-"+PaperInputHelper.NextInputID++)},_onChange:function(e){this.shadowRoot&&this.fire(e.type,{sourceEvent:e},{node:this,bubbles:e.bubbles,cancelable:e.cancelable})},_autofocusChanged:function(){if(this.autofocus&&this._focusableElement){var e=document.activeElement;e instanceof HTMLElement&&e!==document.body&&e!==document.documentElement||this._focusableElement.focus()}}},PaperInputBehavior=[IronControlState,IronA11yKeysBehavior,PaperInputBehaviorImpl]; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({is:"paper-input",_template:html` <style> :host { display: block; } :host([focused]) { outline: none; } :host([hidden]) { display: none !important; } input { /* Firefox sets a min-width on the input, which can cause layout issues */ min-width: 0; } /* In 1.x, the <input> is distributed to paper-input-container, which styles it. In 2.x the <iron-input> is distributed to paper-input-container, which styles it, but in order for this to work correctly, we need to reset some of the native input's properties to inherit (from the iron-input) */ iron-input > input { @apply --paper-input-container-shared-input-style; font-family: inherit; font-weight: inherit; font-size: inherit; letter-spacing: inherit; word-spacing: inherit; line-height: inherit; text-shadow: inherit; color: inherit; cursor: inherit; } input:disabled { @apply --paper-input-container-input-disabled; } input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { @apply --paper-input-container-input-webkit-spinner; } input::-webkit-clear-button { @apply --paper-input-container-input-webkit-clear; } input::-webkit-calendar-picker-indicator { @apply --paper-input-container-input-webkit-calendar-picker-indicator; } input::-webkit-input-placeholder { color: var(--paper-input-container-color, var(--secondary-text-color)); } input:-moz-placeholder { color: var(--paper-input-container-color, var(--secondary-text-color)); } input::-moz-placeholder { color: var(--paper-input-container-color, var(--secondary-text-color)); } input::-ms-clear { @apply --paper-input-container-ms-clear; } input::-ms-reveal { @apply --paper-input-container-ms-reveal; } input:-ms-input-placeholder { color: var(--paper-input-container-color, var(--secondary-text-color)); } label { pointer-events: none; } </style> <paper-input-container id="container" no-label-float="[[noLabelFloat]]" always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]" auto-validate$="[[autoValidate]]" disabled$="[[disabled]]" invalid="[[invalid]]"> <slot name="prefix" slot="prefix"></slot> <label hidden$="[[!label]]" aria-hidden="true" for$="[[_inputId]]" slot="label">[[label]]</label> <!-- Need to bind maxlength so that the paper-input-char-counter works correctly --> <iron-input bind-value="{{value}}" slot="input" class="input-element" id$="[[_inputId]]" maxlength$="[[maxlength]]" allowed-pattern="[[allowedPattern]]" invalid="{{invalid}}" validator="[[validator]]"> <input aria-labelledby$="[[_ariaLabelledBy]]" aria-describedby$="[[_ariaDescribedBy]]" disabled$="[[disabled]]" title$="[[title]]" type$="[[type]]" pattern$="[[pattern]]" required$="[[required]]" autocomplete$="[[autocomplete]]" autofocus$="[[autofocus]]" inputmode$="[[inputmode]]" minlength$="[[minlength]]" maxlength$="[[maxlength]]" min$="[[min]]" max$="[[max]]" step$="[[step]]" name$="[[name]]" placeholder$="[[placeholder]]" readonly$="[[readonly]]" list$="[[list]]" size$="[[size]]" autocapitalize$="[[autocapitalize]]" autocorrect$="[[autocorrect]]" on-change="_onChange" tabindex$="[[tabIndex]]" autosave$="[[autosave]]" results$="[[results]]" accept$="[[accept]]" multiple$="[[multiple]]" role$="[[inputRole]]" aria-haspopup$="[[inputAriaHaspopup]]"> </iron-input> <slot name="suffix" slot="suffix"></slot> <template is="dom-if" if="[[errorMessage]]"> <paper-input-error aria-live="assertive" slot="add-on">[[errorMessage]]</paper-input-error> </template> <template is="dom-if" if="[[charCounter]]"> <paper-input-char-counter slot="add-on"></paper-input-char-counter> </template> </paper-input-container> `,behaviors:[PaperInputBehavior,IronFormElementBehavior],properties:{value:{type:String},inputRole:{type:String,value:void 0},inputAriaHaspopup:{type:String,value:void 0}},get _focusableElement(){return this.inputElement._inputElement},listeners:{"iron-input-ready":"_onIronInputReady"},_onIronInputReady:function(){this.$.nativeInput||(this.$.nativeInput=this.$$("input")),this.inputElement&&-1!==this._typesThatHaveText.indexOf(this.$.nativeInput.type)&&(this.alwaysFloatLabel=!0),this.inputElement.bindValue&&this.$.container._handleValueAndAutoValidate(this.inputElement)}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { position: fixed; } #contentWrapper ::slotted(*) { overflow: auto; } #contentWrapper.animating ::slotted(*) { overflow: hidden; pointer-events: none; } </style> <div id="contentWrapper"> <slot id="content" name="dropdown-content"></slot> </div> `,is:"iron-dropdown",behaviors:[IronControlState,IronA11yKeysBehavior,IronOverlayBehavior,NeonAnimationRunnerBehavior],properties:{horizontalAlign:{type:String,value:"left",reflectToAttribute:!0},verticalAlign:{type:String,value:"top",reflectToAttribute:!0},openAnimationConfig:{type:Object},closeAnimationConfig:{type:Object},focusTarget:{type:Object},noAnimations:{type:Boolean,value:!1},allowOutsideScroll:{type:Boolean,value:!1,observer:"_allowOutsideScrollChanged"}},listeners:{"neon-animation-finish":"_onNeonAnimationFinish"},observers:["_updateOverlayPosition(positionTarget, verticalAlign, horizontalAlign, verticalOffset, horizontalOffset)"],get containedElement(){for(var e=dom$1(this.$.content).getDistributedNodes(),t=0,n=e.length;t<n;t++)if(e[t].nodeType===Node.ELEMENT_NODE)return e[t]},ready:function(){this.scrollAction||(this.scrollAction=this.allowOutsideScroll?"refit":"lock"),this._readied=!0},attached:function(){this.sizingTarget&&this.sizingTarget!==this||(this.sizingTarget=this.containedElement||this)},detached:function(){this.cancelAnimation()},_openedChanged:function(){this.opened&&this.disabled?this.cancel():(this.cancelAnimation(),this._updateAnimationConfig(),IronOverlayBehaviorImpl._openedChanged.apply(this,arguments))},_renderOpened:function(){!this.noAnimations&&this.animationConfig.open?(this.$.contentWrapper.classList.add("animating"),this.playAnimation("open")):IronOverlayBehaviorImpl._renderOpened.apply(this,arguments)},_renderClosed:function(){!this.noAnimations&&this.animationConfig.close?(this.$.contentWrapper.classList.add("animating"),this.playAnimation("close")):IronOverlayBehaviorImpl._renderClosed.apply(this,arguments)},_onNeonAnimationFinish:function(){this.$.contentWrapper.classList.remove("animating"),this.opened?this._finishRenderOpened():this._finishRenderClosed()},_updateAnimationConfig:function(){for(var e=this.containedElement,t=[].concat(this.openAnimationConfig||[]).concat(this.closeAnimationConfig||[]),n=0;n<t.length;n++)t[n].node=e;this.animationConfig={open:this.openAnimationConfig,close:this.closeAnimationConfig}},_updateOverlayPosition:function(){this.isAttached&&this.notifyResize()},_allowOutsideScrollChanged:function(e){this._readied&&(e?this.scrollAction&&"lock"!==this.scrollAction||(this.scrollAction="refit"):this.scrollAction="lock")},_applyFocus:function(){var e=this.focusTarget||this.containedElement;e&&this.opened&&!this.noAutoFocus?e.focus():IronOverlayBehaviorImpl._applyFocus.apply(this,arguments)}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const NeonAnimationBehavior={properties:{animationTiming:{type:Object,value:function(){return{duration:500,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"both"}}}},isNeonAnimation:!0,created:function(){document.body.animate||console.warn("No web animations detected. This element will not function without a web animations polyfill.")},timingFromConfig:function(e){if(e.timing)for(var t in e.timing)this.animationTiming[t]=e.timing[t];return this.animationTiming},setPrefixedProperty:function(e,t,n){for(var i,r={transform:["webkitTransform"],transformOrigin:["mozTransformOrigin","webkitTransformOrigin"]}[t],o=0;i=r[o];o++)e.style[i]=n;e.style[t]=n},complete:function(e){}}; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */Polymer({is:"fade-in-animation",behaviors:[NeonAnimationBehavior],configure:function(e){return this._effect=new KeyframeEffect(e.node,[{opacity:"0"},{opacity:"1"}],this.timingFromConfig(e)),this._effect}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({is:"fade-out-animation",behaviors:[NeonAnimationBehavior],configure:function(e){return this._effect=new KeyframeEffect(e.node,[{opacity:"1"},{opacity:"0"}],this.timingFromConfig(e)),this._effect}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({is:"paper-menu-grow-height-animation",_template:null,behaviors:[NeonAnimationBehavior],configure:function(e){var t=e.node,n=t.getBoundingClientRect().height;return this._effect=new KeyframeEffect(t,[{height:n/2+"px"},{height:n+"px"}],this.timingFromConfig(e)),this._effect}}),Polymer({is:"paper-menu-grow-width-animation",_template:null,behaviors:[NeonAnimationBehavior],configure:function(e){var t=e.node,n=t.getBoundingClientRect().width;return this._effect=new KeyframeEffect(t,[{width:n/2+"px"},{width:n+"px"}],this.timingFromConfig(e)),this._effect}}),Polymer({is:"paper-menu-shrink-width-animation",_template:null,behaviors:[NeonAnimationBehavior],configure:function(e){var t=e.node,n=t.getBoundingClientRect().width;return this._effect=new KeyframeEffect(t,[{width:n+"px"},{width:n-n/20+"px"}],this.timingFromConfig(e)),this._effect}}),Polymer({is:"paper-menu-shrink-height-animation",_template:null,behaviors:[NeonAnimationBehavior],configure:function(e){var t=e.node,n=t.getBoundingClientRect().height;return this.setPrefixedProperty(t,"transformOrigin","0 0"),this._effect=new KeyframeEffect(t,[{height:n+"px",transform:"translateY(0)"},{height:n/2+"px",transform:"translateY(-20px)"}],this.timingFromConfig(e)),this._effect}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ var config={ANIMATION_CUBIC_BEZIER:"cubic-bezier(.3,.95,.5,1)",MAX_ANIMATION_TIME_MS:400};const PaperMenuButton=Polymer({_template:html` <style> :host { display: inline-block; position: relative; padding: 8px; outline: none; @apply --paper-menu-button; } :host([disabled]) { cursor: auto; color: var(--disabled-text-color); @apply --paper-menu-button-disabled; } iron-dropdown { @apply --paper-menu-button-dropdown; } .dropdown-content { @apply --shadow-elevation-2dp; position: relative; border-radius: 2px; background-color: var(--paper-menu-button-dropdown-background, var(--primary-background-color)); @apply --paper-menu-button-content; } :host([vertical-align="top"]) .dropdown-content { margin-bottom: 20px; margin-top: -10px; top: 10px; } :host([vertical-align="bottom"]) .dropdown-content { bottom: 10px; margin-bottom: -10px; margin-top: 20px; } #trigger { cursor: pointer; } </style> <div id="trigger" on-tap="toggle"> <slot name="dropdown-trigger"></slot> </div> <iron-dropdown id="dropdown" opened="{{opened}}" horizontal-align="[[horizontalAlign]]" vertical-align="[[verticalAlign]]" dynamic-align="[[dynamicAlign]]" horizontal-offset="[[horizontalOffset]]" vertical-offset="[[verticalOffset]]" no-overlap="[[noOverlap]]" open-animation-config="[[openAnimationConfig]]" close-animation-config="[[closeAnimationConfig]]" no-animations="[[noAnimations]]" focus-target="[[_dropdownContent]]" allow-outside-scroll="[[allowOutsideScroll]]" restore-focus-on-close="[[restoreFocusOnClose]]" on-iron-overlay-canceled="__onIronOverlayCanceled" expand-sizing-target-for-scrollbars="[[expandSizingTargetForScrollbars]]"> <div slot="dropdown-content" class="dropdown-content"> <slot id="content" name="dropdown-content"></slot> </div> </iron-dropdown> `,is:"paper-menu-button",behaviors:[IronA11yKeysBehavior,IronControlState],properties:{opened:{type:Boolean,value:!1,notify:!0,observer:"_openedChanged"},horizontalAlign:{type:String,value:"left",reflectToAttribute:!0},verticalAlign:{type:String,value:"top",reflectToAttribute:!0},dynamicAlign:{type:Boolean},horizontalOffset:{type:Number,value:0,notify:!0},verticalOffset:{type:Number,value:0,notify:!0},noOverlap:{type:Boolean},noAnimations:{type:Boolean,value:!1},ignoreSelect:{type:Boolean,value:!1},closeOnActivate:{type:Boolean,value:!1},openAnimationConfig:{type:Object,value:function(){return[{name:"fade-in-animation",timing:{delay:100,duration:200}},{name:"paper-menu-grow-width-animation",timing:{delay:100,duration:150,easing:config.ANIMATION_CUBIC_BEZIER}},{name:"paper-menu-grow-height-animation",timing:{delay:100,duration:275,easing:config.ANIMATION_CUBIC_BEZIER}}]}},closeAnimationConfig:{type:Object,value:function(){return[{name:"fade-out-animation",timing:{duration:150}},{name:"paper-menu-shrink-width-animation",timing:{delay:100,duration:50,easing:config.ANIMATION_CUBIC_BEZIER}},{name:"paper-menu-shrink-height-animation",timing:{duration:200,easing:"ease-in"}}]}},allowOutsideScroll:{type:Boolean,value:!1},restoreFocusOnClose:{type:Boolean,value:!0},expandSizingTargetForScrollbars:{type:Boolean,value:!1},_dropdownContent:{type:Object}},hostAttributes:{role:"group","aria-haspopup":"true"},listeners:{"iron-activate":"_onIronActivate","iron-select":"_onIronSelect"},get contentElement(){for(var e=dom$1(this.$.content).getDistributedNodes(),t=0,n=e.length;t<n;t++)if(e[t].nodeType===Node.ELEMENT_NODE)return e[t]},toggle:function(){this.opened?this.close():this.open()},open:function(){this.disabled||this.$.dropdown.open()},close:function(){this.$.dropdown.close()},_onIronSelect:function(e){this.ignoreSelect||this.close()},_onIronActivate:function(e){this.closeOnActivate&&this.close()},_openedChanged:function(e,t){e?(this._dropdownContent=this.contentElement,this.fire("paper-dropdown-open")):null!=t&&this.fire("paper-dropdown-close")},_disabledChanged:function(e){IronControlState._disabledChanged.apply(this,arguments),e&&this.opened&&this.close()},__onIronOverlayCanceled:function(e){var t=this.$.trigger;dom$1(e.detail).path.indexOf(t)>-1&&e.preventDefault()}});Object.keys(config).forEach((function(e){PaperMenuButton[e]=config[e]})); /** @license Copyright (c) 2016 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const $_documentContainer$3=document.createElement("template");$_documentContainer$3.setAttribute("style","display: none;"),$_documentContainer$3.innerHTML='<iron-iconset-svg name="paper-dropdown-menu" size="24">\n<svg><defs>\n<g id="arrow-drop-down"><path d="M7 10l5 5 5-5z"></path></g>\n</defs></svg>\n</iron-iconset-svg>',document.head.appendChild($_documentContainer$3.content); /** @license Copyright (c) 2016 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const $_documentContainer$2=document.createElement("template");$_documentContainer$2.setAttribute("style","display: none;"),$_documentContainer$2.innerHTML='<dom-module id="paper-dropdown-menu-shared-styles">\n <template>\n <style>\n :host {\n display: inline-block;\n position: relative;\n text-align: left;\n\n /* NOTE(cdata): Both values are needed, since some phones require the\n * value to be `transparent`.\n */\n -webkit-tap-highlight-color: rgba(0,0,0,0);\n -webkit-tap-highlight-color: transparent;\n\n --paper-input-container-input: {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n max-width: 100%;\n box-sizing: border-box;\n cursor: pointer;\n };\n\n @apply --paper-dropdown-menu;\n }\n\n /* paper-dropdown-menu and paper-dropdown-menu-light both delegate focus\n * to other internal elements which manage focus styling. */\n :host(:focus) {\n outline: none;\n }\n\n :host(:dir(rtl)) {\n text-align: right;\n\n @apply(--paper-dropdown-menu);\n }\n\n :host([disabled]) {\n @apply --paper-dropdown-menu-disabled;\n }\n\n :host([noink]) paper-ripple {\n display: none;\n }\n\n :host([no-label-float]) paper-ripple {\n top: 8px;\n }\n\n paper-ripple {\n top: 12px;\n left: 0px;\n bottom: 8px;\n right: 0px;\n\n @apply --paper-dropdown-menu-ripple;\n }\n\n paper-menu-button {\n display: block;\n padding: 0;\n\n @apply --paper-dropdown-menu-button;\n }\n\n paper-input {\n @apply --paper-dropdown-menu-input;\n }\n\n iron-icon {\n color: var(--disabled-text-color);\n\n @apply --paper-dropdown-menu-icon;\n }\n </style>\n </template>\n</dom-module>',document.head.appendChild($_documentContainer$2.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const LegacyPolymerElementBase=LegacyElementMixin(HTMLElement);Polymer({_template:html` <style include="paper-dropdown-menu-shared-styles"></style> <paper-menu-button id="menuButton" vertical-align="[[verticalAlign]]" horizontal-align="[[horizontalAlign]]" dynamic-align="[[dynamicAlign]]" vertical-offset="[[_computeMenuVerticalOffset(noLabelFloat, verticalOffset)]]" disabled="[[disabled]]" no-animations="[[noAnimations]]" on-iron-select="_onIronSelect" on-iron-deselect="_onIronDeselect" opened="{{opened}}" close-on-activate allow-outside-scroll="[[allowOutsideScroll]]" restore-focus-on-close="[[restoreFocusOnClose]]" expand-sizing-target-for-scrollbars="[[expandSizingTargetForScrollbars]]"> <!-- support hybrid mode: user might be using paper-menu-button 1.x which distributes via <content> --> <div class="dropdown-trigger" slot="dropdown-trigger"> <paper-ripple></paper-ripple> <!-- paper-input has type="text" for a11y, do not remove --> <paper-input id="input" type="text" invalid="[[invalid]]" readonly disabled="[[disabled]]" value="[[value]]" placeholder="[[placeholder]]" error-message="[[errorMessage]]" always-float-label="[[alwaysFloatLabel]]" no-label-float="[[noLabelFloat]]" label="[[label]]" input-role="button" input-aria-haspopup="listbox" autocomplete="off"> <!-- support hybrid mode: user might be using paper-input 1.x which distributes via <content> --> <iron-icon icon="paper-dropdown-menu:arrow-drop-down" suffix slot="suffix"></iron-icon> </paper-input> </div> <slot id="content" name="dropdown-content" slot="dropdown-content"></slot> </paper-menu-button> `,is:"paper-dropdown-menu",behaviors:[IronButtonState,IronControlState,IronFormElementBehavior,IronValidatableBehavior],properties:{selectedItemLabel:{type:String,notify:!0,readOnly:!0},selectedItem:{type:Object,notify:!0,readOnly:!0},value:{type:String,notify:!0},label:{type:String},placeholder:{type:String},errorMessage:{type:String},opened:{type:Boolean,notify:!0,value:!1,observer:"_openedChanged"},allowOutsideScroll:{type:Boolean,value:!1},noLabelFloat:{type:Boolean,value:!1,reflectToAttribute:!0},alwaysFloatLabel:{type:Boolean,value:!1},noAnimations:{type:Boolean,value:!1},horizontalAlign:{type:String,value:"right"},verticalAlign:{type:String,value:"top"},verticalOffset:Number,dynamicAlign:{type:Boolean},restoreFocusOnClose:{type:Boolean,value:!0},expandSizingTargetForScrollbars:{type:Boolean,value:!1}},listeners:{tap:"_onTap"},keyBindings:{"up down":"open",esc:"close"},observers:["_selectedItemChanged(selectedItem)"],_attachDom(e){const t=wrap(this);return t.attachShadow({mode:"open",delegatesFocus:!0,shadyUpgradeFragment:e}),t.shadowRoot.appendChild(e),LegacyPolymerElementBase.prototype._attachDom.call(this,e)},focus(){this.$.input._focusableElement.focus()},attached:function(){var e=this.contentElement;e&&e.selectedItem&&this._setSelectedItem(e.selectedItem)},get contentElement(){for(var e=dom$1(this.$.content).getDistributedNodes(),t=0,n=e.length;t<n;t++)if(e[t].nodeType===Node.ELEMENT_NODE)return e[t]},open:function(){this.$.menuButton.open()},close:function(){this.$.menuButton.close()},_onIronSelect:function(e){this._setSelectedItem(e.detail.item)},_onIronDeselect:function(e){this._setSelectedItem(null)},_onTap:function(e){findOriginalTarget(e)===this&&this.open()},_selectedItemChanged:function(e){var t;t=e?e.label||e.getAttribute("label")||e.textContent.trim():"",this.value=t,this._setSelectedItemLabel(t)},_computeMenuVerticalOffset:function(e,t){return t||(e?-4:8)},_getValidity:function(e){return this.disabled||!this.required||this.required&&!!this.value},_openedChanged:function(){var e=this.contentElement;e&&e.setAttribute("aria-expanded",this.opened?"true":"false")}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ var SHADOW_WHEN_SCROLLING=1,SHADOW_ALWAYS=2,MODE_CONFIGS={outerScroll:{scroll:!0},shadowMode:{standard:SHADOW_ALWAYS,waterfall:SHADOW_WHEN_SCROLLING,"waterfall-tall":SHADOW_WHEN_SCROLLING},tallMode:{"waterfall-tall":!0}};Polymer({_template:html` <style> :host { @apply --layout-vertical; position: relative; height: 100%; @apply --paper-header-panel; } #mainContainer { @apply --layout-flex; position: relative; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; } #mainPanel { @apply --layout-vertical; @apply --layout-flex; position: relative; min-height: 0; @apply --paper-header-panel-body; } #mainContainer { @apply --paper-header-panel-container; } /* * mode: scroll */ :host([mode=scroll]) #mainContainer { @apply --paper-header-panel-scroll-container; overflow: visible; } :host([mode=scroll]) { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; } /* * mode: cover */ :host([mode=cover]) #mainContainer { @apply --paper-header-panel-cover-container; position: absolute; top: 0; right: 0; bottom: 0; left: 0; } :host([mode=cover]) #mainPanel { position: static; } /* * mode: standard */ :host([mode=standard]) #mainContainer { @apply --paper-header-panel-standard-container; } /* * mode: seamed */ :host([mode=seamed]) #mainContainer { @apply --paper-header-panel-seamed-container; } /* * mode: waterfall */ :host([mode=waterfall]) #mainContainer { @apply --paper-header-panel-waterfall-container; } /* * mode: waterfall-tall */ :host([mode=waterfall-tall]) #mainContainer { @apply --paper-header-panel-waterfall-tall-container; } #dropShadow { transition: opacity 0.5s; height: 6px; box-shadow: inset 0px 5px 6px -3px rgba(0, 0, 0, 0.4); @apply --paper-header-panel-shadow; position: absolute; top: 0; left: 0; right: 0; opacity: 0; pointer-events: none; } #dropShadow.has-shadow { opacity: 1; } #mainContainer > ::slotted(.fit) { @apply --layout-fit; } </style> <slot id="headerSlot" name="header"></slot> <div id="mainPanel"> <div id="mainContainer" class\$="[[_computeMainContainerClass(mode)]]"> <slot></slot> </div> <div id="dropShadow"></div> </div> `,is:"paper-header-panel",properties:{mode:{type:String,value:"standard",observer:"_modeChanged",reflectToAttribute:!0},shadow:{type:Boolean,value:!1},tallClass:{type:String,value:"tall"},atTop:{type:Boolean,value:!0,notify:!0,readOnly:!0,reflectToAttribute:!0}},observers:["_computeDropShadowHidden(atTop, mode, shadow)"],attached:function(){this._addListener(),this._keepScrollingState()},detached:function(){this._removeListener()},ready:function(){this.scrollHandler=this._scroll.bind(this),console.warn(this.is,"is deprecated. Please use app-layout instead!")},get header(){return dom$1(this.$.headerSlot).getDistributedNodes()[0]},get scroller(){return this._getScrollerForMode(this.mode)},get visibleShadow(){return this.$.dropShadow.classList.contains("has-shadow")},_computeDropShadowHidden:function(e,t,n){var i=MODE_CONFIGS.shadowMode[t];this.toggleClass("has-shadow",!!this.shadow||i===SHADOW_ALWAYS||i===SHADOW_WHEN_SCROLLING&&!e,this.$.dropShadow)},_computeMainContainerClass:function(e){var t={};return t.flex="cover"!==e,Object.keys(t).filter((function(e){return t[e]})).join(" ")},_addListener:function(){this.scroller.addEventListener("scroll",this.scrollHandler)},_removeListener:function(){this.scroller.removeEventListener("scroll",this.scrollHandler)},_modeChanged:function(e,t){var n=MODE_CONFIGS,i=this.header;i&&(n.tallMode[t]&&!n.tallMode[e]?(i.classList.remove(this.tallClass),this.async((function(){i.classList.remove("animate")}),200)):this.toggleClass("animate",n.tallMode[e],i)),this._keepScrollingState()},_keepScrollingState:function(){var e=this.scroller,t=this.header;this._setAtTop(0===e.scrollTop),t&&this.tallClass&&MODE_CONFIGS.tallMode[this.mode]&&this.toggleClass(this.tallClass,this.atTop||t.classList.contains(this.tallClass)&&e.scrollHeight<this.offsetHeight,t)},_scroll:function(){this._keepScrollingState(),this.fire("content-scroll",{target:this.scroller},{bubbles:!1})},_getScrollerForMode:function(e){return MODE_CONFIGS.outerScroll[e]?this:this.$.mainContainer}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({is:"paper-icon-button",_template:html` <style> :host { display: inline-block; position: relative; padding: 8px; outline: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; cursor: pointer; z-index: 0; line-height: 1; width: 40px; height: 40px; /* NOTE: Both values are needed, since some phones require the value to be \`transparent\`. */ -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-tap-highlight-color: transparent; /* Because of polymer/2558, this style has lower specificity than * */ box-sizing: border-box !important; @apply --paper-icon-button; } :host #ink { color: var(--paper-icon-button-ink-color, var(--primary-text-color)); opacity: 0.6; } :host([disabled]) { color: var(--paper-icon-button-disabled-text, var(--disabled-text-color)); pointer-events: none; cursor: auto; @apply --paper-icon-button-disabled; } :host([hidden]) { display: none !important; } :host(:hover) { @apply --paper-icon-button-hover; } iron-icon { --iron-icon-width: 100%; --iron-icon-height: 100%; } </style> <iron-icon id="icon" src="[[src]]" icon="[[icon]]" alt$="[[alt]]"></iron-icon> `,hostAttributes:{role:"button",tabindex:"0"},behaviors:[PaperInkyFocusBehavior],registered:function(){this._template.setAttribute("strip-whitespace","")},properties:{src:{type:String},icon:{type:String},alt:{type:String,observer:"_altChanged"}},_altChanged:function(e,t){var n=this.getAttribute("aria-label");n&&t!=n||this.setAttribute("aria-label",e)}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { display: inline-block; position: relative; width: 400px; border: 1px solid; padding: 2px; -moz-appearance: textarea; -webkit-appearance: textarea; overflow: hidden; } .mirror-text { visibility: hidden; word-wrap: break-word; @apply --iron-autogrow-textarea; } .fit { @apply --layout-fit; } textarea { position: relative; outline: none; border: none; resize: none; background: inherit; color: inherit; /* see comments in template */ width: 100%; height: 100%; font-size: inherit; font-family: inherit; line-height: inherit; text-align: inherit; @apply --iron-autogrow-textarea; } textarea::-webkit-input-placeholder { @apply --iron-autogrow-textarea-placeholder; } textarea:-moz-placeholder { @apply --iron-autogrow-textarea-placeholder; } textarea::-moz-placeholder { @apply --iron-autogrow-textarea-placeholder; } textarea:-ms-input-placeholder { @apply --iron-autogrow-textarea-placeholder; } </style> <!-- the mirror sizes the input/textarea so it grows with typing --> <!-- use   instead of to allow this element to be used in XHTML --> <div id="mirror" class="mirror-text" aria-hidden="true"> </div> <!-- size the input/textarea with a div, because the textarea has intrinsic size in ff --> <div class="textarea-container fit"> <textarea id="textarea" name$="[[name]]" aria-label$="[[label]]" autocomplete$="[[autocomplete]]" autofocus$="[[autofocus]]" autocapitalize$="[[autocapitalize]]" inputmode$="[[inputmode]]" placeholder$="[[placeholder]]" readonly$="[[readonly]]" required$="[[required]]" disabled$="[[disabled]]" rows$="[[rows]]" minlength$="[[minlength]]" maxlength$="[[maxlength]]"></textarea> </div> `,is:"iron-autogrow-textarea",behaviors:[IronValidatableBehavior,IronControlState],properties:{value:{observer:"_valueChanged",type:String,notify:!0},bindValue:{observer:"_bindValueChanged",type:String,notify:!0},rows:{type:Number,value:1,observer:"_updateCached"},maxRows:{type:Number,value:0,observer:"_updateCached"},autocomplete:{type:String,value:"off"},autofocus:{type:Boolean,value:!1},autocapitalize:{type:String,value:"none"},inputmode:{type:String},placeholder:{type:String},readonly:{type:String},required:{type:Boolean},minlength:{type:Number},maxlength:{type:Number},label:{type:String}},listeners:{input:"_onInput"},get textarea(){return this.$.textarea},get selectionStart(){return this.$.textarea.selectionStart},get selectionEnd(){return this.$.textarea.selectionEnd},set selectionStart(e){this.$.textarea.selectionStart=e},set selectionEnd(e){this.$.textarea.selectionEnd=e},attached:function(){navigator.userAgent.match(/iP(?:[oa]d|hone)/)&&!navigator.userAgent.match(/OS 1[3456789]/)&&(this.$.textarea.style.marginLeft="-3px")},validate:function(){var e=this.$.textarea.validity.valid;return e&&(this.required&&""===this.value?e=!1:this.hasValidator()&&(e=IronValidatableBehavior.validate.call(this,this.value))),this.invalid=!e,this.fire("iron-input-validate"),e},_bindValueChanged:function(e){this.value=e},_valueChanged:function(e){var t=this.textarea;t&&(t.value!==e&&(t.value=e||0===e?e:""),this.bindValue=e,this.$.mirror.innerHTML=this._valueForMirror(),this.fire("bind-value-changed",{value:this.bindValue}))},_onInput:function(e){var t=dom$1(e).path;this.value=t?t[0].value:e.target.value},_constrain:function(e){var t;for(e=e||[""],t=this.maxRows>0&&e.length>this.maxRows?e.slice(0,this.maxRows):e.slice(0);this.rows>0&&t.length<this.rows;)t.push("");return t.join("<br/>")+" "},_valueForMirror:function(){var e=this.textarea;if(e)return this.tokens=e&&e.value?e.value.replace(/&/gm,"&").replace(/"/gm,""").replace(/'/gm,"'").replace(/</gm,"<").replace(/>/gm,">").split("\n"):[""],this._constrain(this.tokens)},_updateCached:function(){this.$.mirror.innerHTML=this._constrain(this.tokens)}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { display: block; } :host([hidden]) { display: none !important; } label { pointer-events: none; } </style> <paper-input-container no-label-float$="[[noLabelFloat]]" always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]" auto-validate$="[[autoValidate]]" disabled$="[[disabled]]" invalid="[[invalid]]"> <label hidden$="[[!label]]" aria-hidden="true" for$="[[_inputId]]" slot="label">[[label]]</label> <iron-autogrow-textarea class="paper-input-input" slot="input" id$="[[_inputId]]" aria-labelledby$="[[_ariaLabelledBy]]" aria-describedby$="[[_ariaDescribedBy]]" bind-value="{{value}}" invalid="{{invalid}}" validator$="[[validator]]" disabled$="[[disabled]]" autocomplete$="[[autocomplete]]" autofocus$="[[autofocus]]" inputmode$="[[inputmode]]" name$="[[name]]" placeholder$="[[placeholder]]" readonly$="[[readonly]]" required$="[[required]]" minlength$="[[minlength]]" maxlength$="[[maxlength]]" autocapitalize$="[[autocapitalize]]" rows$="[[rows]]" max-rows$="[[maxRows]]" on-change="_onChange"></iron-autogrow-textarea> <template is="dom-if" if="[[errorMessage]]"> <paper-input-error aria-live="assertive" slot="add-on">[[errorMessage]]</paper-input-error> </template> <template is="dom-if" if="[[charCounter]]"> <paper-input-char-counter slot="add-on"></paper-input-char-counter> </template> </paper-input-container> `,is:"paper-textarea",behaviors:[PaperInputBehavior,IronFormElementBehavior],properties:{_ariaLabelledBy:{observer:"_ariaLabelledByChanged",type:String},_ariaDescribedBy:{observer:"_ariaDescribedByChanged",type:String},value:{type:String},rows:{type:Number,value:1},maxRows:{type:Number,value:0}},get selectionStart(){return this.$.input.textarea.selectionStart},set selectionStart(e){this.$.input.textarea.selectionStart=e},get selectionEnd(){return this.$.input.textarea.selectionEnd},set selectionEnd(e){this.$.input.textarea.selectionEnd=e},_ariaLabelledByChanged:function(e){this._focusableElement.setAttribute("aria-labelledby",e)},_ariaDescribedByChanged:function(e){this._focusableElement.setAttribute("aria-describedby",e)},get _focusableElement(){return this.inputElement.textarea}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const $_documentContainer$1=document.createElement("template");$_documentContainer$1.setAttribute("style","display: none;"),$_documentContainer$1.innerHTML="<dom-module id=\"paper-item-shared-styles\">\n <template>\n <style>\n :host, .paper-item {\n display: block;\n position: relative;\n min-height: var(--paper-item-min-height, 48px);\n padding: 0px 16px;\n }\n\n .paper-item {\n @apply --paper-font-subhead;\n border:none;\n outline: none;\n background: white;\n width: 100%;\n text-align: left;\n }\n\n :host([hidden]), .paper-item[hidden] {\n display: none !important;\n }\n\n :host(.iron-selected), .paper-item.iron-selected {\n font-weight: var(--paper-item-selected-weight, bold);\n\n @apply --paper-item-selected;\n }\n\n :host([disabled]), .paper-item[disabled] {\n color: var(--paper-item-disabled-color, var(--disabled-text-color));\n\n @apply --paper-item-disabled;\n }\n\n :host(:focus), .paper-item:focus {\n position: relative;\n outline: 0;\n\n @apply --paper-item-focused;\n }\n\n :host(:focus):before, .paper-item:focus:before {\n @apply --layout-fit;\n\n background: currentColor;\n content: '';\n opacity: var(--dark-divider-opacity);\n pointer-events: none;\n\n @apply --paper-item-focused-before;\n }\n </style>\n </template>\n</dom-module>",document.head.appendChild($_documentContainer$1.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const PaperItemBehaviorImpl={hostAttributes:{role:"option",tabindex:"0"}},PaperItemBehavior=[IronButtonState,IronControlState,PaperItemBehaviorImpl]; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style include="paper-item-shared-styles"> :host { @apply --layout-horizontal; @apply --layout-center; @apply --paper-font-subhead; @apply --paper-item; } </style> <slot></slot> `,is:"paper-item",behaviors:[PaperItemBehavior]}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { overflow: hidden; /* needed for text-overflow: ellipsis to work on ff */ @apply --layout-vertical; @apply --layout-center-justified; @apply --layout-flex; } :host([two-line]) { min-height: var(--paper-item-body-two-line-min-height, 72px); } :host([three-line]) { min-height: var(--paper-item-body-three-line-min-height, 88px); } :host > ::slotted(*) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } :host > ::slotted([secondary]) { @apply --paper-font-body1; color: var(--paper-item-body-secondary-color, var(--secondary-text-color)); @apply --paper-item-body-secondary; } </style> <slot></slot> `,is:"paper-item-body"}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style include="paper-item-shared-styles"></style> <style> :host { @apply --layout-horizontal; @apply --layout-center; @apply --paper-font-subhead; @apply --paper-item; @apply --paper-icon-item; } .content-icon { @apply --layout-horizontal; @apply --layout-center; width: var(--paper-item-icon-width, 56px); @apply --paper-item-icon; } </style> <div id="contentIcon" class="content-icon"> <slot name="item-icon"></slot> </div> <slot></slot> `,is:"paper-icon-item",behaviors:[PaperItemBehavior]}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const IronMultiSelectableBehaviorImpl={properties:{multi:{type:Boolean,value:!1,observer:"multiChanged"},selectedValues:{type:Array,notify:!0,value:function(){return[]}},selectedItems:{type:Array,readOnly:!0,notify:!0,value:function(){return[]}}},observers:["_updateSelected(selectedValues.splices)"],select:function(e){this.multi?this._toggleSelected(e):this.selected=e},multiChanged:function(e){this._selection.multi=e,this._updateSelected()},get _shouldUpdateSelection(){return null!=this.selected||null!=this.selectedValues&&this.selectedValues.length},_updateAttrForSelected:function(){this.multi?this.selectedItems&&this.selectedItems.length>0&&(this.selectedValues=this.selectedItems.map((function(e){return this._indexToValue(this.indexOf(e))}),this).filter((function(e){return null!=e}),this)):IronSelectableBehavior._updateAttrForSelected.apply(this)},_updateSelected:function(){this.multi?this._selectMulti(this.selectedValues):this._selectSelected(this.selected)},_selectMulti:function(e){var t=(this._valuesToItems(e=e||[])||[]).filter((function(e){return null!=e}));this._selection.clear(t);for(var n=0;n<t.length;n++)this._selection.setItemSelected(t[n],!0);this.fallbackSelection&&!this._selection.get().length&&this._valueToItem(this.fallbackSelection)&&this.select(this.fallbackSelection)},_selectionChange:function(){var e=this._selection.get();this.multi?(this._setSelectedItems(e),this._setSelectedItem(e.length?e[0]:null)):null!=e?(this._setSelectedItems([e]),this._setSelectedItem(e)):(this._setSelectedItems([]),this._setSelectedItem(null))},_toggleSelected:function(e){var t=this.selectedValues.indexOf(e);t<0?this.push("selectedValues",e):this.splice("selectedValues",t,1)},_valuesToItems:function(e){return null==e?null:e.map((function(e){return this._valueToItem(e)}),this)}},IronMultiSelectableBehavior=[IronSelectableBehavior,IronMultiSelectableBehaviorImpl],IronMenuBehaviorImpl={properties:{focusedItem:{observer:"_focusedItemChanged",readOnly:!0,type:Object},attrForItemTitle:{type:String},disabled:{type:Boolean,value:!1,observer:"_disabledChanged"}},_MODIFIER_KEYS:["Alt","AltGraph","CapsLock","Control","Fn","FnLock","Hyper","Meta","NumLock","OS","ScrollLock","Shift","Super","Symbol","SymbolLock"],_SEARCH_RESET_TIMEOUT_MS:1e3,_previousTabIndex:0,hostAttributes:{role:"menu"},observers:["_updateMultiselectable(multi)"],listeners:{focus:"_onFocus",keydown:"_onKeydown","iron-items-changed":"_onIronItemsChanged"},keyBindings:{up:"_onUpKey",down:"_onDownKey",esc:"_onEscKey","shift+tab:keydown":"_onShiftTabDown"},attached:function(){this._resetTabindices()},select:function(e){this._defaultFocusAsync&&(this.cancelAsync(this._defaultFocusAsync),this._defaultFocusAsync=null);var t=this._valueToItem(e);t&&t.hasAttribute("disabled")||(this._setFocusedItem(t),IronMultiSelectableBehaviorImpl.select.apply(this,arguments))},_resetTabindices:function(){var e=this.multi?this.selectedItems&&this.selectedItems[0]:this.selectedItem;this.items.forEach((function(t){t.setAttribute("tabindex",t===e?"0":"-1"),t.setAttribute("aria-selected",this._selection.isSelected(t))}),this)},_updateMultiselectable:function(e){e?this.setAttribute("aria-multiselectable","true"):this.removeAttribute("aria-multiselectable")},_focusWithKeyboardEvent:function(e){if(-1===this._MODIFIER_KEYS.indexOf(e.key)){this.cancelDebouncer("_clearSearchText");for(var t,n=this._searchText||"",i=(n+=(e.key&&1==e.key.length?e.key:String.fromCharCode(e.keyCode)).toLocaleLowerCase()).length,r=0;t=this.items[r];r++)if(!t.hasAttribute("disabled")){var o=this.attrForItemTitle||"textContent",a=(t[o]||t.getAttribute(o)||"").trim();if(!(a.length<i)&&a.slice(0,i).toLocaleLowerCase()==n){this._setFocusedItem(t);break}}this._searchText=n,this.debounce("_clearSearchText",this._clearSearchText,this._SEARCH_RESET_TIMEOUT_MS)}},_clearSearchText:function(){this._searchText=""},_focusPrevious:function(){for(var e=this.items.length,t=Number(this.indexOf(this.focusedItem)),n=1;n<e+1;n++){var i=this.items[(t-n+e)%e];if(!i.hasAttribute("disabled")){var r=dom$1(i).getOwnerRoot()||document;if(this._setFocusedItem(i),dom$1(r).activeElement==i)return}}},_focusNext:function(){for(var e=this.items.length,t=Number(this.indexOf(this.focusedItem)),n=1;n<e+1;n++){var i=this.items[(t+n)%e];if(!i.hasAttribute("disabled")){var r=dom$1(i).getOwnerRoot()||document;if(this._setFocusedItem(i),dom$1(r).activeElement==i)return}}},_applySelection:function(e,t){e.setAttribute("aria-selected",t?"true":"false"),IronSelectableBehavior._applySelection.apply(this,arguments)},_focusedItemChanged:function(e,t){t&&t.setAttribute("tabindex","-1"),!e||e.hasAttribute("disabled")||this.disabled||(e.setAttribute("tabindex","0"),e.focus())},_onIronItemsChanged:function(e){e.detail.addedNodes.length&&this._resetTabindices()},_onShiftTabDown:function(e){var t=this.getAttribute("tabindex");IronMenuBehaviorImpl._shiftTabPressed=!0,this._setFocusedItem(null),this.setAttribute("tabindex","-1"),this.async((function(){this.setAttribute("tabindex",t),IronMenuBehaviorImpl._shiftTabPressed=!1}),1)},_onFocus:function(e){if(!IronMenuBehaviorImpl._shiftTabPressed){var t=dom$1(e).rootTarget;(t===this||void 0===t.tabIndex||this.isLightDescendant(t))&&(this._defaultFocusAsync=this.async((function(){var e=this.multi?this.selectedItems&&this.selectedItems[0]:this.selectedItem;this._setFocusedItem(null),e?this._setFocusedItem(e):this.items[0]&&this._focusNext()})))}},_onUpKey:function(e){this._focusPrevious(),e.detail.keyboardEvent.preventDefault()},_onDownKey:function(e){this._focusNext(),e.detail.keyboardEvent.preventDefault()},_onEscKey:function(e){var t=this.focusedItem;t&&t.blur()},_onKeydown:function(e){this.keyboardEventMatchesKeys(e,"up down esc")||this._focusWithKeyboardEvent(e),e.stopPropagation()},_activateHandler:function(e){IronSelectableBehavior._activateHandler.call(this,e),e.stopPropagation()},_disabledChanged:function(e){e?(this._previousTabIndex=this.hasAttribute("tabindex")?this.tabIndex:0,this.removeAttribute("tabindex")):this.hasAttribute("tabindex")||this.setAttribute("tabindex",this._previousTabIndex)},_shiftTabPressed:!1},IronMenuBehavior=[IronMultiSelectableBehavior,IronA11yKeysBehavior,IronMenuBehaviorImpl]; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { display: block; padding: 8px 0; background: var(--paper-listbox-background-color, var(--primary-background-color)); color: var(--paper-listbox-color, var(--primary-text-color)); @apply --paper-listbox; } </style> <slot></slot> `,is:"paper-listbox",behaviors:[IronMenuBehavior],hostAttributes:{role:"listbox"}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$b=html` <dom-module id="paper-material-shared-styles"> <template> <style> :host { display: block; position: relative; } :host([elevation="1"]) { @apply --shadow-elevation-2dp; } :host([elevation="2"]) { @apply --shadow-elevation-4dp; } :host([elevation="3"]) { @apply --shadow-elevation-6dp; } :host([elevation="4"]) { @apply --shadow-elevation-8dp; } :host([elevation="5"]) { @apply --shadow-elevation-16dp; } </style> </template> </dom-module> `;template$b.setAttribute("style","display: none;"),document.body.appendChild(template$b.content), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style include="paper-material-shared-styles"></style> <style> :host([animated]) { @apply --shadow-transition; } :host { @apply --paper-material; } </style> <slot></slot> `,is:"paper-material",properties:{elevation:{type:Number,reflectToAttribute:!0,value:1},animated:{type:Boolean,reflectToAttribute:!0,value:!1}}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const IronRangeBehavior={properties:{value:{type:Number,value:0,notify:!0,reflectToAttribute:!0},min:{type:Number,value:0,notify:!0},max:{type:Number,value:100,notify:!0},step:{type:Number,value:1,notify:!0},ratio:{type:Number,value:0,readOnly:!0,notify:!0}},observers:["_update(value, min, max, step)"],_calcRatio:function(e){return(this._clampValue(e)-this.min)/(this.max-this.min)},_clampValue:function(e){return Math.min(this.max,Math.max(this.min,this._calcStep(e)))},_calcStep:function(e){if(e=parseFloat(e),!this.step)return e;var t=Math.round((e-this.min)/this.step);return this.step<1?t/(1/this.step)+this.min:t*this.step+this.min},_validateValue:function(){var e=this._clampValue(this.value);return this.value=this.oldValue=isNaN(e)?this.oldValue:e,this.value!==e},_update:function(){this._validateValue(),this._setRatio(100*this._calcRatio(this.value))}}; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */Polymer({_template:html` <style> :host { display: block; width: 200px; position: relative; overflow: hidden; } :host([hidden]), [hidden] { display: none !important; } #progressContainer { @apply --paper-progress-container; position: relative; } #progressContainer, /* the stripe for the indeterminate animation*/ .indeterminate::after { height: var(--paper-progress-height, 4px); } #primaryProgress, #secondaryProgress, .indeterminate::after { @apply --layout-fit; } #progressContainer, .indeterminate::after { background: var(--paper-progress-container-color, var(--google-grey-300)); } :host(.transiting) #primaryProgress, :host(.transiting) #secondaryProgress { -webkit-transition-property: -webkit-transform; transition-property: transform; /* Duration */ -webkit-transition-duration: var(--paper-progress-transition-duration, 0.08s); transition-duration: var(--paper-progress-transition-duration, 0.08s); /* Timing function */ -webkit-transition-timing-function: var(--paper-progress-transition-timing-function, ease); transition-timing-function: var(--paper-progress-transition-timing-function, ease); /* Delay */ -webkit-transition-delay: var(--paper-progress-transition-delay, 0s); transition-delay: var(--paper-progress-transition-delay, 0s); } #primaryProgress, #secondaryProgress { @apply --layout-fit; -webkit-transform-origin: left center; transform-origin: left center; -webkit-transform: scaleX(0); transform: scaleX(0); will-change: transform; } #primaryProgress { background: var(--paper-progress-active-color, var(--google-green-500)); } #secondaryProgress { background: var(--paper-progress-secondary-color, var(--google-green-100)); } :host([disabled]) #primaryProgress { background: var(--paper-progress-disabled-active-color, var(--google-grey-500)); } :host([disabled]) #secondaryProgress { background: var(--paper-progress-disabled-secondary-color, var(--google-grey-300)); } :host(:not([disabled])) #primaryProgress.indeterminate { -webkit-transform-origin: right center; transform-origin: right center; -webkit-animation: indeterminate-bar var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite; animation: indeterminate-bar var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite; } :host(:not([disabled])) #primaryProgress.indeterminate::after { content: ""; -webkit-transform-origin: center center; transform-origin: center center; -webkit-animation: indeterminate-splitter var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite; animation: indeterminate-splitter var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite; } @-webkit-keyframes indeterminate-bar { 0% { -webkit-transform: scaleX(1) translateX(-100%); } 50% { -webkit-transform: scaleX(1) translateX(0%); } 75% { -webkit-transform: scaleX(1) translateX(0%); -webkit-animation-timing-function: cubic-bezier(.28,.62,.37,.91); } 100% { -webkit-transform: scaleX(0) translateX(0%); } } @-webkit-keyframes indeterminate-splitter { 0% { -webkit-transform: scaleX(.75) translateX(-125%); } 30% { -webkit-transform: scaleX(.75) translateX(-125%); -webkit-animation-timing-function: cubic-bezier(.42,0,.6,.8); } 90% { -webkit-transform: scaleX(.75) translateX(125%); } 100% { -webkit-transform: scaleX(.75) translateX(125%); } } @keyframes indeterminate-bar { 0% { transform: scaleX(1) translateX(-100%); } 50% { transform: scaleX(1) translateX(0%); } 75% { transform: scaleX(1) translateX(0%); animation-timing-function: cubic-bezier(.28,.62,.37,.91); } 100% { transform: scaleX(0) translateX(0%); } } @keyframes indeterminate-splitter { 0% { transform: scaleX(.75) translateX(-125%); } 30% { transform: scaleX(.75) translateX(-125%); animation-timing-function: cubic-bezier(.42,0,.6,.8); } 90% { transform: scaleX(.75) translateX(125%); } 100% { transform: scaleX(.75) translateX(125%); } } </style> <div id="progressContainer"> <div id="secondaryProgress" hidden\$="[[_hideSecondaryProgress(secondaryRatio)]]"></div> <div id="primaryProgress"></div> </div> `,is:"paper-progress",behaviors:[IronRangeBehavior],properties:{secondaryProgress:{type:Number,value:0},secondaryRatio:{type:Number,value:0,readOnly:!0},indeterminate:{type:Boolean,value:!1,observer:"_toggleIndeterminate"},disabled:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_disabledChanged"}},observers:["_progressChanged(secondaryProgress, value, min, max, indeterminate)"],hostAttributes:{role:"progressbar"},_toggleIndeterminate:function(e){this.toggleClass("indeterminate",e,this.$.primaryProgress)},_transformProgress:function(e,t){e.style.transform=e.style.webkitTransform="scaleX("+t/100+")"},_mainRatioChanged:function(e){this._transformProgress(this.$.primaryProgress,e)},_progressChanged:function(e,t,n,i,r){e=this._clampValue(e),t=this._clampValue(t);var o=100*this._calcRatio(e),a=100*this._calcRatio(t);this._setSecondaryRatio(o),this._transformProgress(this.$.secondaryProgress,o),this._transformProgress(this.$.primaryProgress,a),this.secondaryProgress=e,r?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",t),this.setAttribute("aria-valuemin",n),this.setAttribute("aria-valuemax",i)},_disabledChanged:function(e){this.setAttribute("aria-disabled",e?"true":"false")},_hideSecondaryProgress:function(e){return 0===e}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$a=html` <style> :host { display: inline-block; line-height: 0; white-space: nowrap; cursor: pointer; @apply --paper-font-common-base; --calculated-paper-radio-button-size: var(--paper-radio-button-size, 16px); /* -1px is a sentinel for the default and is replace in \`attached\`. */ --calculated-paper-radio-button-ink-size: var(--paper-radio-button-ink-size, -1px); } :host(:focus) { outline: none; } #radioContainer { @apply --layout-inline; @apply --layout-center-center; position: relative; width: var(--calculated-paper-radio-button-size); height: var(--calculated-paper-radio-button-size); vertical-align: middle; @apply --paper-radio-button-radio-container; } #ink { position: absolute; top: 50%; left: 50%; right: auto; width: var(--calculated-paper-radio-button-ink-size); height: var(--calculated-paper-radio-button-ink-size); color: var(--paper-radio-button-unchecked-ink-color, var(--primary-text-color)); opacity: 0.6; pointer-events: none; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } #ink[checked] { color: var(--paper-radio-button-checked-ink-color, var(--primary-color)); } #offRadio, #onRadio { position: absolute; box-sizing: border-box; top: 0; left: 0; width: 100%; height: 100%; border-radius: 50%; } #offRadio { border: 2px solid var(--paper-radio-button-unchecked-color, var(--primary-text-color)); background-color: var(--paper-radio-button-unchecked-background-color, transparent); transition: border-color 0.28s; } #onRadio { background-color: var(--paper-radio-button-checked-color, var(--primary-color)); -webkit-transform: scale(0); transform: scale(0); transition: -webkit-transform ease 0.28s; transition: transform ease 0.28s; will-change: transform; } :host([checked]) #offRadio { border-color: var(--paper-radio-button-checked-color, var(--primary-color)); } :host([checked]) #onRadio { -webkit-transform: scale(0.5); transform: scale(0.5); } #radioLabel { line-height: normal; position: relative; display: inline-block; vertical-align: middle; margin-left: var(--paper-radio-button-label-spacing, 10px); white-space: normal; color: var(--paper-radio-button-label-color, var(--primary-text-color)); @apply --paper-radio-button-label; } :host([checked]) #radioLabel { @apply --paper-radio-button-label-checked; } #radioLabel:dir(rtl) { margin-left: 0; margin-right: var(--paper-radio-button-label-spacing, 10px); } #radioLabel[hidden] { display: none; } /* disabled state */ :host([disabled]) #offRadio { border-color: var(--paper-radio-button-unchecked-color, var(--primary-text-color)); opacity: 0.5; } :host([disabled][checked]) #onRadio { background-color: var(--paper-radio-button-unchecked-color, var(--primary-text-color)); opacity: 0.5; } :host([disabled]) #radioLabel { /* slightly darker than the button, so that it's readable */ opacity: 0.65; } </style> <div id="radioContainer"> <div id="offRadio"></div> <div id="onRadio"></div> </div> <div id="radioLabel"><slot></slot></div>`;template$a.setAttribute("strip-whitespace",""),Polymer({_template:template$a,is:"paper-radio-button",behaviors:[PaperCheckedElementBehavior],hostAttributes:{role:"radio","aria-checked":!1,tabindex:0},properties:{ariaActiveAttribute:{type:String,value:"aria-checked"}},ready:function(){this._rippleContainer=this.$.radioContainer},attached:function(){afterNextRender(this,(function(){if("-1px"===this.getComputedStyleValue("--calculated-paper-radio-button-ink-size").trim()){var e=parseFloat(this.getComputedStyleValue("--calculated-paper-radio-button-size").trim()),t=Math.floor(3*e);t%2!=e%2&&t++,this.updateStyles({"--paper-radio-button-ink-size":t+"px"})}}))}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const IronMenubarBehaviorImpl={hostAttributes:{role:"menubar"},keyBindings:{left:"_onLeftKey",right:"_onRightKey"},_onUpKey:function(e){this.focusedItem.click(),e.detail.keyboardEvent.preventDefault()},_onDownKey:function(e){this.focusedItem.click(),e.detail.keyboardEvent.preventDefault()},get _isRTL(){return"rtl"===window.getComputedStyle(this).direction},_onLeftKey:function(e){this._isRTL?this._focusNext():this._focusPrevious(),e.detail.keyboardEvent.preventDefault()},_onRightKey:function(e){this._isRTL?this._focusPrevious():this._focusNext(),e.detail.keyboardEvent.preventDefault()},_onKeydown:function(e){this.keyboardEventMatchesKeys(e,"up down left right esc")||this._focusWithKeyboardEvent(e)}},IronMenubarBehavior=[IronMenuBehavior,IronMenubarBehaviorImpl]; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { display: inline-block; } :host ::slotted(*) { padding: var(--paper-radio-group-item-padding, 12px); } </style> <slot></slot> `,is:"paper-radio-group",behaviors:[IronMenubarBehavior],hostAttributes:{role:"radiogroup"},properties:{attrForSelected:{type:String,value:"name"},selectedAttribute:{type:String,value:"checked"},selectable:{type:String,value:"paper-radio-button"},allowEmptySelection:{type:Boolean,value:!1}},select:function(e){var t=this._valueToItem(e);if(!t||!t.hasAttribute("disabled")){if(this.selected){var n=this._valueToItem(this.selected);if(this.selected==e){if(!this.allowEmptySelection)return void(n&&(n.checked=!0));e=""}n&&(n.checked=!1)}IronSelectableBehavior.select.apply(this,[e]),this.fire("paper-radio-group-changed")}},_activateFocusedItem:function(){this._itemActivate(this._valueForItem(this.focusedItem),this.focusedItem)},_onUpKey:function(e){this._focusPrevious(),e.preventDefault(),this._activateFocusedItem()},_onDownKey:function(e){this._focusNext(),e.preventDefault(),this._activateFocusedItem()},_onLeftKey:function(e){IronMenubarBehaviorImpl._onLeftKey.apply(this,arguments),this._activateFocusedItem()},_onRightKey:function(e){IronMenubarBehaviorImpl._onRightKey.apply(this,arguments),this._activateFocusedItem()}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$9=html` <style> :host { @apply --layout; @apply --layout-justified; @apply --layout-center; width: 200px; cursor: default; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); --paper-progress-active-color: var(--paper-slider-active-color, var(--google-blue-700)); --paper-progress-secondary-color: var(--paper-slider-secondary-color, var(--google-blue-300)); --paper-progress-disabled-active-color: var(--paper-slider-disabled-active-color, var(--paper-grey-400)); --paper-progress-disabled-secondary-color: var(--paper-slider-disabled-secondary-color, var(--paper-grey-400)); --calculated-paper-slider-height: var(--paper-slider-height, 2px); } /* focus shows the ripple */ :host(:focus) { outline: none; } /** * NOTE(keanulee): Though :host-context is not universally supported, some pages * still rely on paper-slider being flipped when dir="rtl" is set on body. For full * compatibility, dir="rtl" must be explicitly set on paper-slider. */ :dir(rtl) #sliderContainer { -webkit-transform: scaleX(-1); transform: scaleX(-1); } /** * NOTE(keanulee): This is separate from the rule above because :host-context may * not be recognized. */ :host([dir="rtl"]) #sliderContainer { -webkit-transform: scaleX(-1); transform: scaleX(-1); } /** * NOTE(keanulee): Needed to override the :host-context rule (where supported) * to support LTR sliders in RTL pages. */ :host([dir="ltr"]) #sliderContainer { -webkit-transform: scaleX(1); transform: scaleX(1); } #sliderContainer { position: relative; width: 100%; height: calc(30px + var(--calculated-paper-slider-height)); margin-left: calc(15px + var(--calculated-paper-slider-height)/2); margin-right: calc(15px + var(--calculated-paper-slider-height)/2); } #sliderContainer:focus { outline: 0; } #sliderContainer.editable { margin-top: 12px; margin-bottom: 12px; } .bar-container { position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow: hidden; } .ring > .bar-container { left: calc(5px + var(--calculated-paper-slider-height)/2); transition: left 0.18s ease; } .ring.expand.dragging > .bar-container { transition: none; } .ring.expand:not(.pin) > .bar-container { left: calc(8px + var(--calculated-paper-slider-height)/2); } #sliderBar { padding: 15px 0; width: 100%; background-color: var(--paper-slider-bar-color, transparent); --paper-progress-container-color: var(--paper-slider-container-color, var(--paper-grey-400)); --paper-progress-height: var(--calculated-paper-slider-height); } .slider-markers { position: absolute; /* slider-knob is 30px + the slider-height so that the markers should start at a offset of 15px*/ top: 15px; height: var(--calculated-paper-slider-height); left: 0; right: -1px; box-sizing: border-box; pointer-events: none; @apply --layout-horizontal; } .slider-marker { @apply --layout-flex; } .slider-markers::after, .slider-marker::after { content: ""; display: block; margin-left: -1px; width: 2px; height: var(--calculated-paper-slider-height); border-radius: 50%; background-color: var(--paper-slider-markers-color, #000); } .slider-knob { position: absolute; left: 0; top: 0; margin-left: calc(-15px - var(--calculated-paper-slider-height)/2); width: calc(30px + var(--calculated-paper-slider-height)); height: calc(30px + var(--calculated-paper-slider-height)); } .transiting > .slider-knob { transition: left 0.08s ease; } .slider-knob:focus { outline: none; } .slider-knob.dragging { transition: none; } .snaps > .slider-knob.dragging { transition: -webkit-transform 0.08s ease; transition: transform 0.08s ease; } .slider-knob-inner { margin: 10px; width: calc(100% - 20px); height: calc(100% - 20px); background-color: var(--paper-slider-knob-color, var(--google-blue-700)); border: 2px solid var(--paper-slider-knob-color, var(--google-blue-700)); border-radius: 50%; -moz-box-sizing: border-box; box-sizing: border-box; transition-property: -webkit-transform, background-color, border; transition-property: transform, background-color, border; transition-duration: 0.18s; transition-timing-function: ease; } .expand:not(.pin) > .slider-knob > .slider-knob-inner { -webkit-transform: scale(1.5); transform: scale(1.5); } .ring > .slider-knob > .slider-knob-inner { background-color: var(--paper-slider-knob-start-color, transparent); border: 2px solid var(--paper-slider-knob-start-border-color, var(--paper-grey-400)); } .slider-knob-inner::before { background-color: var(--paper-slider-pin-color, var(--google-blue-700)); } .pin > .slider-knob > .slider-knob-inner::before { content: ""; position: absolute; top: 0; left: 50%; margin-left: -13px; width: 26px; height: 26px; border-radius: 50% 50% 50% 0; -webkit-transform: rotate(-45deg) scale(0) translate(0); transform: rotate(-45deg) scale(0) translate(0); } .slider-knob-inner::before, .slider-knob-inner::after { transition: -webkit-transform .18s ease, background-color .18s ease; transition: transform .18s ease, background-color .18s ease; } .pin.ring > .slider-knob > .slider-knob-inner::before { background-color: var(--paper-slider-pin-start-color, var(--paper-grey-400)); } .pin.expand > .slider-knob > .slider-knob-inner::before { -webkit-transform: rotate(-45deg) scale(1) translate(17px, -17px); transform: rotate(-45deg) scale(1) translate(17px, -17px); } .pin > .slider-knob > .slider-knob-inner::after { content: attr(value); position: absolute; top: 0; left: 50%; margin-left: -16px; width: 32px; height: 26px; text-align: center; color: var(--paper-slider-font-color, #fff); font-size: 10px; -webkit-transform: scale(0) translate(0); transform: scale(0) translate(0); } .pin.expand > .slider-knob > .slider-knob-inner::after { -webkit-transform: scale(1) translate(0, -17px); transform: scale(1) translate(0, -17px); } /* paper-input */ .slider-input { width: 50px; overflow: hidden; --paper-input-container-input: { text-align: center; @apply --paper-slider-input-container-input; }; @apply --paper-slider-input; } /* disabled state */ #sliderContainer.disabled { pointer-events: none; } .disabled > .slider-knob > .slider-knob-inner { background-color: var(--paper-slider-disabled-knob-color, var(--paper-grey-400)); border: 2px solid var(--paper-slider-disabled-knob-color, var(--paper-grey-400)); -webkit-transform: scale3d(0.75, 0.75, 1); transform: scale3d(0.75, 0.75, 1); } .disabled.ring > .slider-knob > .slider-knob-inner { background-color: var(--paper-slider-knob-start-color, transparent); border: 2px solid var(--paper-slider-knob-start-border-color, var(--paper-grey-400)); } paper-ripple { color: var(--paper-slider-knob-color, var(--google-blue-700)); } </style> <div id="sliderContainer" class\$="[[_getClassNames(disabled, pin, snaps, immediateValue, min, expand, dragging, transiting, editable)]]"> <div class="bar-container"> <paper-progress disabled\$="[[disabled]]" id="sliderBar" aria-hidden="true" min="[[min]]" max="[[max]]" step="[[step]]" value="[[immediateValue]]" secondary-progress="[[secondaryProgress]]" on-down="_bardown" on-up="_resetKnob" on-track="_bartrack" on-tap="_barclick"> </paper-progress> </div> <template is="dom-if" if="[[snaps]]"> <div class="slider-markers"> <template is="dom-repeat" items="[[markers]]"> <div class="slider-marker"></div> </template> </div> </template> <div id="sliderKnob" class="slider-knob" on-down="_knobdown" on-up="_resetKnob" on-track="_onTrack" on-transitionend="_knobTransitionEnd"> <div class="slider-knob-inner" value\$="[[immediateValue]]"></div> </div> </div> <template is="dom-if" if="[[editable]]"> <paper-input id="input" type="number" step="[[step]]" min="[[min]]" max="[[max]]" class="slider-input" disabled\$="[[disabled]]" value="[[immediateValue]]" on-change="_changeValue" on-keydown="_inputKeyDown" no-label-float> </paper-input> </template> `;template$9.setAttribute("strip-whitespace",""),Polymer({_template:template$9,is:"paper-slider",behaviors:[IronA11yKeysBehavior,IronFormElementBehavior,PaperInkyFocusBehavior,IronRangeBehavior],properties:{value:{type:Number,value:0},snaps:{type:Boolean,value:!1,notify:!0},pin:{type:Boolean,value:!1,notify:!0},secondaryProgress:{type:Number,value:0,notify:!0,observer:"_secondaryProgressChanged"},editable:{type:Boolean,value:!1},immediateValue:{type:Number,value:0,readOnly:!0,notify:!0},maxMarkers:{type:Number,value:0,notify:!0},expand:{type:Boolean,value:!1,readOnly:!0},ignoreBarTouch:{type:Boolean,value:!1},dragging:{type:Boolean,value:!1,readOnly:!0,notify:!0},transiting:{type:Boolean,value:!1,readOnly:!0},markers:{type:Array,readOnly:!0,value:function(){return[]}}},observers:["_updateKnob(value, min, max, snaps, step)","_valueChanged(value)","_immediateValueChanged(immediateValue)","_updateMarkers(maxMarkers, min, max, snaps)"],hostAttributes:{role:"slider",tabindex:0},keyBindings:{left:"_leftKey",right:"_rightKey","down pagedown home":"_decrementKey","up pageup end":"_incrementKey"},ready:function(){this.ignoreBarTouch&&setTouchAction(this.$.sliderBar,"auto")},increment:function(){this.value=this._clampValue(this.value+this.step)},decrement:function(){this.value=this._clampValue(this.value-this.step)},_updateKnob:function(e,t,n,i,r){this.setAttribute("aria-valuemin",t),this.setAttribute("aria-valuemax",n),this.setAttribute("aria-valuenow",e),this._positionKnob(100*this._calcRatio(e))},_valueChanged:function(){this.fire("value-change",{composed:!0})},_immediateValueChanged:function(){this.dragging?this.fire("immediate-value-change",{composed:!0}):this.value=this.immediateValue},_secondaryProgressChanged:function(){this.secondaryProgress=this._clampValue(this.secondaryProgress)},_expandKnob:function(){this._setExpand(!0)},_resetKnob:function(){this.cancelDebouncer("expandKnob"),this._setExpand(!1)},_positionKnob:function(e){this._setImmediateValue(this._calcStep(this._calcKnobPosition(e))),this._setRatio(100*this._calcRatio(this.immediateValue)),this.$.sliderKnob.style.left=this.ratio+"%",this.dragging&&(this._knobstartx=this.ratio*this._w/100,this.translate3d(0,0,0,this.$.sliderKnob))},_calcKnobPosition:function(e){return(this.max-this.min)*e/100+this.min},_onTrack:function(e){switch(e.stopPropagation(),e.detail.state){case"start":this._trackStart(e);break;case"track":this._trackX(e);break;case"end":this._trackEnd()}},_trackStart:function(e){this._setTransiting(!1),this._w=this.$.sliderBar.offsetWidth,this._x=this.ratio*this._w/100,this._startx=this._x,this._knobstartx=this._startx,this._minx=-this._startx,this._maxx=this._w-this._startx,this.$.sliderKnob.classList.add("dragging"),this._setDragging(!0)},_trackX:function(e){this.dragging||this._trackStart(e);var t=Math.min(this._maxx,Math.max(this._minx,e.detail.dx*(this._isRTL?-1:1)));this._x=this._startx+t;var n=this._calcStep(this._calcKnobPosition(this._x/this._w*100));this._setImmediateValue(n);var i=this._calcRatio(this.immediateValue)*this._w-this._knobstartx;this.translate3d(i+"px",0,0,this.$.sliderKnob)},_trackEnd:function(){var e=this.$.sliderKnob.style;this.$.sliderKnob.classList.remove("dragging"),this._setDragging(!1),this._resetKnob(),this.value=this.immediateValue,e.transform=e.webkitTransform="",this.fire("change",{composed:!0})},_knobdown:function(e){this._expandKnob(),e.preventDefault(),this.focus()},_bartrack:function(e){this._allowBarEvent(e)&&this._onTrack(e)},_barclick:function(e){this._w=this.$.sliderBar.offsetWidth;var t=this.$.sliderBar.getBoundingClientRect(),n=(e.detail.x-t.left)/this._w*100;this._isRTL&&(n=100-n);var i=this.ratio;this._setTransiting(!0),this._positionKnob(n),i===this.ratio&&this._setTransiting(!1),this.async((function(){this.fire("change",{composed:!0})})),e.preventDefault(),this.focus()},_bardown:function(e){this._allowBarEvent(e)&&(this.debounce("expandKnob",this._expandKnob,60),this._barclick(e))},_knobTransitionEnd:function(e){e.target===this.$.sliderKnob&&this._setTransiting(!1)},_updateMarkers:function(e,t,n,i){i||this._setMarkers([]);var r=Math.round((n-t)/this.step);r>e&&(r=e),(r<0||!isFinite(r))&&(r=0),this._setMarkers(new Array(r))},_mergeClasses:function(e){return Object.keys(e).filter((function(t){return e[t]})).join(" ")},_getClassNames:function(){return this._mergeClasses({disabled:this.disabled,pin:this.pin,snaps:this.snaps,ring:this.immediateValue<=this.min,expand:this.expand,dragging:this.dragging,transiting:this.transiting,editable:this.editable})},_allowBarEvent:function(e){return!this.ignoreBarTouch||e.detail.sourceEvent instanceof MouseEvent},get _isRTL(){return void 0===this.__isRTL&&(this.__isRTL="rtl"===window.getComputedStyle(this).direction),this.__isRTL},_leftKey:function(e){this._isRTL?this._incrementKey(e):this._decrementKey(e)},_rightKey:function(e){this._isRTL?this._decrementKey(e):this._incrementKey(e)},_incrementKey:function(e){this.disabled||("end"===e.detail.key?this.value=this.max:this.increment(),this.fire("change"),e.preventDefault())},_decrementKey:function(e){this.disabled||("home"===e.detail.key?this.value=this.min:this.decrement(),this.fire("change"),e.preventDefault())},_changeValue:function(e){this.value=e.target.value,this.fire("change",{composed:!0})},_inputKeyDown:function(e){e.stopPropagation()},_createRipple:function(){return this._rippleContainer=this.$.sliderKnob,PaperInkyFocusBehaviorImpl._createRipple.call(this)},_focusedChanged:function(e){e&&this.ensureRipple(),this.hasRipple()&&(this._ripple.style.display=e?"":"none",this._ripple.holdDown=e)}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const $_documentContainer=document.createElement("template");$_documentContainer.setAttribute("style","display: none;"),$_documentContainer.innerHTML="<dom-module id=\"paper-spinner-styles\">\n <template>\n <style>\n /*\n /**************************/\n /* STYLES FOR THE SPINNER */\n /**************************/\n\n /*\n * Constants:\n * ARCSIZE = 270 degrees (amount of circle the arc takes up)\n * ARCTIME = 1333ms (time it takes to expand and contract arc)\n * ARCSTARTROT = 216 degrees (how much the start location of the arc\n * should rotate each time, 216 gives us a\n * 5 pointed star shape (it's 360/5 * 3).\n * For a 7 pointed star, we might do\n * 360/7 * 3 = 154.286)\n * SHRINK_TIME = 400ms\n */\n\n :host {\n display: inline-block;\n position: relative;\n width: 28px;\n height: 28px;\n\n /* 360 * ARCTIME / (ARCSTARTROT + (360-ARCSIZE)) */\n --paper-spinner-container-rotation-duration: 1568ms;\n\n /* ARCTIME */\n --paper-spinner-expand-contract-duration: 1333ms;\n\n /* 4 * ARCTIME */\n --paper-spinner-full-cycle-duration: 5332ms;\n\n /* SHRINK_TIME */\n --paper-spinner-cooldown-duration: 400ms;\n }\n\n #spinnerContainer {\n width: 100%;\n height: 100%;\n\n /* The spinner does not have any contents that would have to be\n * flipped if the direction changes. Always use ltr so that the\n * style works out correctly in both cases. */\n direction: ltr;\n }\n\n #spinnerContainer.active {\n -webkit-animation: container-rotate var(--paper-spinner-container-rotation-duration) linear infinite;\n animation: container-rotate var(--paper-spinner-container-rotation-duration) linear infinite;\n }\n\n @-webkit-keyframes container-rotate {\n to { -webkit-transform: rotate(360deg) }\n }\n\n @keyframes container-rotate {\n to { transform: rotate(360deg) }\n }\n\n .spinner-layer {\n position: absolute;\n width: 100%;\n height: 100%;\n opacity: 0;\n white-space: nowrap;\n color: var(--paper-spinner-color, var(--google-blue-500));\n }\n\n .layer-1 {\n color: var(--paper-spinner-layer-1-color, var(--google-blue-500));\n }\n\n .layer-2 {\n color: var(--paper-spinner-layer-2-color, var(--google-red-500));\n }\n\n .layer-3 {\n color: var(--paper-spinner-layer-3-color, var(--google-yellow-500));\n }\n\n .layer-4 {\n color: var(--paper-spinner-layer-4-color, var(--google-green-500));\n }\n\n /**\n * IMPORTANT NOTE ABOUT CSS ANIMATION PROPERTIES (keanulee):\n *\n * iOS Safari (tested on iOS 8.1) does not handle animation-delay very well - it doesn't\n * guarantee that the animation will start _exactly_ after that value. So we avoid using\n * animation-delay and instead set custom keyframes for each color (as layer-2undant as it\n * seems).\n */\n .active .spinner-layer {\n -webkit-animation-name: fill-unfill-rotate;\n -webkit-animation-duration: var(--paper-spinner-full-cycle-duration);\n -webkit-animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);\n -webkit-animation-iteration-count: infinite;\n animation-name: fill-unfill-rotate;\n animation-duration: var(--paper-spinner-full-cycle-duration);\n animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);\n animation-iteration-count: infinite;\n opacity: 1;\n }\n\n .active .spinner-layer.layer-1 {\n -webkit-animation-name: fill-unfill-rotate, layer-1-fade-in-out;\n animation-name: fill-unfill-rotate, layer-1-fade-in-out;\n }\n\n .active .spinner-layer.layer-2 {\n -webkit-animation-name: fill-unfill-rotate, layer-2-fade-in-out;\n animation-name: fill-unfill-rotate, layer-2-fade-in-out;\n }\n\n .active .spinner-layer.layer-3 {\n -webkit-animation-name: fill-unfill-rotate, layer-3-fade-in-out;\n animation-name: fill-unfill-rotate, layer-3-fade-in-out;\n }\n\n .active .spinner-layer.layer-4 {\n -webkit-animation-name: fill-unfill-rotate, layer-4-fade-in-out;\n animation-name: fill-unfill-rotate, layer-4-fade-in-out;\n }\n\n @-webkit-keyframes fill-unfill-rotate {\n 12.5% { -webkit-transform: rotate(135deg) } /* 0.5 * ARCSIZE */\n 25% { -webkit-transform: rotate(270deg) } /* 1 * ARCSIZE */\n 37.5% { -webkit-transform: rotate(405deg) } /* 1.5 * ARCSIZE */\n 50% { -webkit-transform: rotate(540deg) } /* 2 * ARCSIZE */\n 62.5% { -webkit-transform: rotate(675deg) } /* 2.5 * ARCSIZE */\n 75% { -webkit-transform: rotate(810deg) } /* 3 * ARCSIZE */\n 87.5% { -webkit-transform: rotate(945deg) } /* 3.5 * ARCSIZE */\n to { -webkit-transform: rotate(1080deg) } /* 4 * ARCSIZE */\n }\n\n @keyframes fill-unfill-rotate {\n 12.5% { transform: rotate(135deg) } /* 0.5 * ARCSIZE */\n 25% { transform: rotate(270deg) } /* 1 * ARCSIZE */\n 37.5% { transform: rotate(405deg) } /* 1.5 * ARCSIZE */\n 50% { transform: rotate(540deg) } /* 2 * ARCSIZE */\n 62.5% { transform: rotate(675deg) } /* 2.5 * ARCSIZE */\n 75% { transform: rotate(810deg) } /* 3 * ARCSIZE */\n 87.5% { transform: rotate(945deg) } /* 3.5 * ARCSIZE */\n to { transform: rotate(1080deg) } /* 4 * ARCSIZE */\n }\n\n @-webkit-keyframes layer-1-fade-in-out {\n 0% { opacity: 1 }\n 25% { opacity: 1 }\n 26% { opacity: 0 }\n 89% { opacity: 0 }\n 90% { opacity: 1 }\n to { opacity: 1 }\n }\n\n @keyframes layer-1-fade-in-out {\n 0% { opacity: 1 }\n 25% { opacity: 1 }\n 26% { opacity: 0 }\n 89% { opacity: 0 }\n 90% { opacity: 1 }\n to { opacity: 1 }\n }\n\n @-webkit-keyframes layer-2-fade-in-out {\n 0% { opacity: 0 }\n 15% { opacity: 0 }\n 25% { opacity: 1 }\n 50% { opacity: 1 }\n 51% { opacity: 0 }\n to { opacity: 0 }\n }\n\n @keyframes layer-2-fade-in-out {\n 0% { opacity: 0 }\n 15% { opacity: 0 }\n 25% { opacity: 1 }\n 50% { opacity: 1 }\n 51% { opacity: 0 }\n to { opacity: 0 }\n }\n\n @-webkit-keyframes layer-3-fade-in-out {\n 0% { opacity: 0 }\n 40% { opacity: 0 }\n 50% { opacity: 1 }\n 75% { opacity: 1 }\n 76% { opacity: 0 }\n to { opacity: 0 }\n }\n\n @keyframes layer-3-fade-in-out {\n 0% { opacity: 0 }\n 40% { opacity: 0 }\n 50% { opacity: 1 }\n 75% { opacity: 1 }\n 76% { opacity: 0 }\n to { opacity: 0 }\n }\n\n @-webkit-keyframes layer-4-fade-in-out {\n 0% { opacity: 0 }\n 65% { opacity: 0 }\n 75% { opacity: 1 }\n 90% { opacity: 1 }\n to { opacity: 0 }\n }\n\n @keyframes layer-4-fade-in-out {\n 0% { opacity: 0 }\n 65% { opacity: 0 }\n 75% { opacity: 1 }\n 90% { opacity: 1 }\n to { opacity: 0 }\n }\n\n .circle-clipper {\n display: inline-block;\n position: relative;\n width: 50%;\n height: 100%;\n overflow: hidden;\n }\n\n /**\n * Patch the gap that appear between the two adjacent div.circle-clipper while the\n * spinner is rotating (appears on Chrome 50, Safari 9.1.1, and Edge).\n */\n .spinner-layer::after {\n content: '';\n left: 45%;\n width: 10%;\n border-top-style: solid;\n }\n\n .spinner-layer::after,\n .circle-clipper .circle {\n box-sizing: border-box;\n position: absolute;\n top: 0;\n border-width: var(--paper-spinner-stroke-width, 3px);\n border-radius: 50%;\n }\n\n .circle-clipper .circle {\n bottom: 0;\n width: 200%;\n border-style: solid;\n border-bottom-color: transparent !important;\n }\n\n .circle-clipper.left .circle {\n left: 0;\n border-right-color: transparent !important;\n -webkit-transform: rotate(129deg);\n transform: rotate(129deg);\n }\n\n .circle-clipper.right .circle {\n left: -100%;\n border-left-color: transparent !important;\n -webkit-transform: rotate(-129deg);\n transform: rotate(-129deg);\n }\n\n .active .gap-patch::after,\n .active .circle-clipper .circle {\n -webkit-animation-duration: var(--paper-spinner-expand-contract-duration);\n -webkit-animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);\n -webkit-animation-iteration-count: infinite;\n animation-duration: var(--paper-spinner-expand-contract-duration);\n animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);\n animation-iteration-count: infinite;\n }\n\n .active .circle-clipper.left .circle {\n -webkit-animation-name: left-spin;\n animation-name: left-spin;\n }\n\n .active .circle-clipper.right .circle {\n -webkit-animation-name: right-spin;\n animation-name: right-spin;\n }\n\n @-webkit-keyframes left-spin {\n 0% { -webkit-transform: rotate(130deg) }\n 50% { -webkit-transform: rotate(-5deg) }\n to { -webkit-transform: rotate(130deg) }\n }\n\n @keyframes left-spin {\n 0% { transform: rotate(130deg) }\n 50% { transform: rotate(-5deg) }\n to { transform: rotate(130deg) }\n }\n\n @-webkit-keyframes right-spin {\n 0% { -webkit-transform: rotate(-130deg) }\n 50% { -webkit-transform: rotate(5deg) }\n to { -webkit-transform: rotate(-130deg) }\n }\n\n @keyframes right-spin {\n 0% { transform: rotate(-130deg) }\n 50% { transform: rotate(5deg) }\n to { transform: rotate(-130deg) }\n }\n\n #spinnerContainer.cooldown {\n -webkit-animation: container-rotate var(--paper-spinner-container-rotation-duration) linear infinite, fade-out var(--paper-spinner-cooldown-duration) cubic-bezier(0.4, 0.0, 0.2, 1);\n animation: container-rotate var(--paper-spinner-container-rotation-duration) linear infinite, fade-out var(--paper-spinner-cooldown-duration) cubic-bezier(0.4, 0.0, 0.2, 1);\n }\n\n @-webkit-keyframes fade-out {\n 0% { opacity: 1 }\n to { opacity: 0 }\n }\n\n @keyframes fade-out {\n 0% { opacity: 1 }\n to { opacity: 0 }\n }\n </style>\n </template>\n</dom-module>",document.head.appendChild($_documentContainer.content); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const PaperSpinnerBehavior={properties:{active:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"__activeChanged"},alt:{type:String,value:"loading",observer:"__altChanged"},__coolingDown:{type:Boolean,value:!1}},__computeContainerClasses:function(e,t){return[e||t?"active":"",t?"cooldown":""].join(" ")},__activeChanged:function(e,t){this.__setAriaHidden(!e),this.__coolingDown=!e&&t},__altChanged:function(e){"loading"===e?this.alt=this.getAttribute("aria-label")||e:(this.__setAriaHidden(""===e),this.setAttribute("aria-label",e))},__setAriaHidden:function(e){var t="aria-hidden";e?this.setAttribute(t,"true"):this.removeAttribute(t)},__reset:function(){this.active=!1,this.__coolingDown=!1}},template$8=html` <style include="paper-spinner-styles"></style> <div id="spinnerContainer" class-name="[[__computeContainerClasses(active, __coolingDown)]]" on-animationend="__reset" on-webkit-animation-end="__reset"> <div class="spinner-layer"> <div class="circle-clipper left"> <div class="circle"></div> </div> <div class="circle-clipper right"> <div class="circle"></div> </div> </div> </div> `; /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */template$8.setAttribute("strip-whitespace",""),Polymer({_template:template$8,is:"paper-spinner-lite",behaviors:[PaperSpinnerBehavior]}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$7=html` <style include="paper-spinner-styles"></style> <div id="spinnerContainer" class-name="[[__computeContainerClasses(active, __coolingDown)]]" on-animationend="__reset" on-webkit-animation-end="__reset"> <div class="spinner-layer layer-1"> <div class="circle-clipper left"> <div class="circle"></div> </div> <div class="circle-clipper right"> <div class="circle"></div> </div> </div> <div class="spinner-layer layer-2"> <div class="circle-clipper left"> <div class="circle"></div> </div> <div class="circle-clipper right"> <div class="circle"></div> </div> </div> <div class="spinner-layer layer-3"> <div class="circle-clipper left"> <div class="circle"></div> </div> <div class="circle-clipper right"> <div class="circle"></div> </div> </div> <div class="spinner-layer layer-4"> <div class="circle-clipper left"> <div class="circle"></div> </div> <div class="circle-clipper right"> <div class="circle"></div> </div> </div> </div> `;template$7.setAttribute("strip-whitespace",""),Polymer({_template:template$7,is:"paper-spinner",behaviors:[PaperSpinnerBehavior]}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$6=html`<iron-iconset-svg name="paper-tabs" size="24"> <svg><defs> <g id="chevron-left"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path></g> <g id="chevron-right"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g> </defs></svg> </iron-iconset-svg>`;document.head.appendChild(template$6.content), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { @apply --layout-inline; @apply --layout-center; @apply --layout-center-justified; @apply --layout-flex-auto; position: relative; padding: 0 12px; overflow: hidden; cursor: pointer; vertical-align: middle; @apply --paper-font-common-base; @apply --paper-tab; } :host(:focus) { outline: none; } :host([link]) { padding: 0; } .tab-content { height: 100%; transform: translateZ(0); -webkit-transform: translateZ(0); transition: opacity 0.1s cubic-bezier(0.4, 0.0, 1, 1); @apply --layout-horizontal; @apply --layout-center-center; @apply --layout-flex-auto; @apply --paper-tab-content; } :host(:not(.iron-selected)) > .tab-content { opacity: 0.8; @apply --paper-tab-content-unselected; } :host(:focus) .tab-content { opacity: 1; font-weight: 700; @apply --paper-tab-content-focused; } paper-ripple { color: var(--paper-tab-ink, var(--paper-yellow-a100)); } .tab-content > ::slotted(a) { @apply --layout-flex-auto; height: 100%; } </style> <div class="tab-content"> <slot></slot> </div> `,is:"paper-tab",behaviors:[IronControlState,IronButtonState,PaperRippleBehavior],properties:{link:{type:Boolean,value:!1,reflectToAttribute:!0}},hostAttributes:{role:"tab"},listeners:{down:"_updateNoink",tap:"_onTap"},attached:function(){this._updateNoink()},get _parentNoink(){var e=dom$1(this).parentNode;return!!e&&!!e.noink},_updateNoink:function(){this.noink=!!this.noink||!!this._parentNoink},_onTap:function(e){if(this.link){var t=this.queryEffectiveChildren("a");if(!t)return;if(e.target===t)return;t.click()}}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { @apply --layout; @apply --layout-center; height: 48px; font-size: 14px; font-weight: 500; overflow: hidden; -moz-user-select: none; -ms-user-select: none; -webkit-user-select: none; user-select: none; /* NOTE: Both values are needed, since some phones require the value to be \`transparent\`. */ -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-tap-highlight-color: transparent; @apply --paper-tabs; } :host(:dir(rtl)) { @apply --layout-horizontal-reverse; } #tabsContainer { position: relative; height: 100%; white-space: nowrap; overflow: hidden; @apply --layout-flex-auto; @apply --paper-tabs-container; } #tabsContent { height: 100%; -moz-flex-basis: auto; -ms-flex-basis: auto; flex-basis: auto; @apply --paper-tabs-content; } #tabsContent.scrollable { position: absolute; white-space: nowrap; } #tabsContent:not(.scrollable), #tabsContent.scrollable.fit-container { @apply --layout-horizontal; } #tabsContent.scrollable.fit-container { min-width: 100%; } #tabsContent.scrollable.fit-container > ::slotted(*) { /* IE - prevent tabs from compressing when they should scroll. */ -ms-flex: 1 0 auto; -webkit-flex: 1 0 auto; flex: 1 0 auto; } .hidden { display: none; } .not-visible { opacity: 0; cursor: default; } paper-icon-button { width: 48px; height: 48px; padding: 12px; margin: 0 4px; } #selectionBar { position: absolute; height: 0; bottom: 0; left: 0; right: 0; border-bottom: 2px solid var(--paper-tabs-selection-bar-color, var(--paper-yellow-a100)); -webkit-transform: scale(0); transform: scale(0); -webkit-transform-origin: left center; transform-origin: left center; transition: -webkit-transform; transition: transform; @apply --paper-tabs-selection-bar; } #selectionBar.align-bottom { top: 0; bottom: auto; } #selectionBar.expand { transition-duration: 0.15s; transition-timing-function: cubic-bezier(0.4, 0.0, 1, 1); } #selectionBar.contract { transition-duration: 0.18s; transition-timing-function: cubic-bezier(0.0, 0.0, 0.2, 1); } #tabsContent > ::slotted(:not(#selectionBar)) { height: 100%; } </style> <paper-icon-button icon="paper-tabs:chevron-left" class$="[[_computeScrollButtonClass(_leftHidden, scrollable, hideScrollButtons)]]" on-up="_onScrollButtonUp" on-down="_onLeftScrollButtonDown" tabindex="-1"></paper-icon-button> <div id="tabsContainer" on-track="_scroll" on-down="_down"> <div id="tabsContent" class$="[[_computeTabsContentClass(scrollable, fitContainer)]]"> <div id="selectionBar" class$="[[_computeSelectionBarClass(noBar, alignBottom)]]" on-transitionend="_onBarTransitionEnd"></div> <slot></slot> </div> </div> <paper-icon-button icon="paper-tabs:chevron-right" class$="[[_computeScrollButtonClass(_rightHidden, scrollable, hideScrollButtons)]]" on-up="_onScrollButtonUp" on-down="_onRightScrollButtonDown" tabindex="-1"></paper-icon-button> `,is:"paper-tabs",behaviors:[IronResizableBehavior,IronMenubarBehavior],properties:{noink:{type:Boolean,value:!1,observer:"_noinkChanged"},noBar:{type:Boolean,value:!1},noSlide:{type:Boolean,value:!1},scrollable:{type:Boolean,value:!1},fitContainer:{type:Boolean,value:!1},disableDrag:{type:Boolean,value:!1},hideScrollButtons:{type:Boolean,value:!1},alignBottom:{type:Boolean,value:!1},selectable:{type:String,value:"paper-tab"},autoselect:{type:Boolean,value:!1},autoselectDelay:{type:Number,value:0},_step:{type:Number,value:10},_holdDelay:{type:Number,value:1},_leftHidden:{type:Boolean,value:!1},_rightHidden:{type:Boolean,value:!1},_previousTab:{type:Object}},hostAttributes:{role:"tablist"},listeners:{"iron-resize":"_onTabSizingChanged","iron-items-changed":"_onTabSizingChanged","iron-select":"_onIronSelect","iron-deselect":"_onIronDeselect"},keyBindings:{"left:keyup right:keyup":"_onArrowKeyup"},created:function(){this._holdJob=null,this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0,this._bindDelayedActivationHandler=this._delayedActivationHandler.bind(this),this.addEventListener("blur",this._onBlurCapture.bind(this),!0)},ready:function(){this.setScrollDirection("y",this.$.tabsContainer)},detached:function(){this._cancelPendingActivation()},_noinkChanged:function(e){dom$1(this).querySelectorAll("paper-tab").forEach(e?this._setNoinkAttribute:this._removeNoinkAttribute)},_setNoinkAttribute:function(e){e.setAttribute("noink","")},_removeNoinkAttribute:function(e){e.removeAttribute("noink")},_computeScrollButtonClass:function(e,t,n){return!t||n?"hidden":e?"not-visible":""},_computeTabsContentClass:function(e,t){return e?"scrollable"+(t?" fit-container":""):" fit-container"},_computeSelectionBarClass:function(e,t){return e?"hidden":t?"align-bottom":""},_onTabSizingChanged:function(){this.debounce("_onTabSizingChanged",(function(){this._scroll(),this._tabChanged(this.selectedItem)}),10)},_onIronSelect:function(e){this._tabChanged(e.detail.item,this._previousTab),this._previousTab=e.detail.item,this.cancelDebouncer("tab-changed")},_onIronDeselect:function(e){this.debounce("tab-changed",(function(){this._tabChanged(null,this._previousTab),this._previousTab=null}),1)},_activateHandler:function(){this._cancelPendingActivation(),IronMenuBehaviorImpl._activateHandler.apply(this,arguments)},_scheduleActivation:function(e,t){this._pendingActivationItem=e,this._pendingActivationTimeout=this.async(this._bindDelayedActivationHandler,t)},_delayedActivationHandler:function(){var e=this._pendingActivationItem;this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0,e.fire(this.activateEvent,null,{bubbles:!0,cancelable:!0})},_cancelPendingActivation:function(){void 0!==this._pendingActivationTimeout&&(this.cancelAsync(this._pendingActivationTimeout),this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0)},_onArrowKeyup:function(e){this.autoselect&&this._scheduleActivation(this.focusedItem,this.autoselectDelay)},_onBlurCapture:function(e){e.target===this._pendingActivationItem&&this._cancelPendingActivation()},get _tabContainerScrollSize(){return Math.max(0,this.$.tabsContainer.scrollWidth-this.$.tabsContainer.offsetWidth)},_scroll:function(e,t){this.scrollable&&this._affectScroll(t&&-t.ddx||0)},_down:function(e){this.async((function(){this._defaultFocusAsync&&(this.cancelAsync(this._defaultFocusAsync),this._defaultFocusAsync=null)}),1)},_affectScroll:function(e){this.$.tabsContainer.scrollLeft+=e;var t=this.$.tabsContainer.scrollLeft;this._leftHidden=0===t,this._rightHidden=t===this._tabContainerScrollSize},_onLeftScrollButtonDown:function(){this._scrollToLeft(),this._holdJob=setInterval(this._scrollToLeft.bind(this),this._holdDelay)},_onRightScrollButtonDown:function(){this._scrollToRight(),this._holdJob=setInterval(this._scrollToRight.bind(this),this._holdDelay)},_onScrollButtonUp:function(){clearInterval(this._holdJob),this._holdJob=null},_scrollToLeft:function(){this._affectScroll(-this._step)},_scrollToRight:function(){this._affectScroll(this._step)},_tabChanged:function(e,t){if(!e)return this.$.selectionBar.classList.remove("expand"),this.$.selectionBar.classList.remove("contract"),void this._positionBar(0,0);var n=this.$.tabsContent.getBoundingClientRect(),i=n.width,r=e.getBoundingClientRect(),o=r.left-n.left;if(this._pos={width:this._calcPercent(r.width,i),left:this._calcPercent(o,i)},this.noSlide||null==t)return this.$.selectionBar.classList.remove("expand"),this.$.selectionBar.classList.remove("contract"),void this._positionBar(this._pos.width,this._pos.left);var a=t.getBoundingClientRect(),s=this.items.indexOf(t),l=this.items.indexOf(e);this.$.selectionBar.classList.add("expand");var c=s<l;this._isRTL&&(c=!c),c?this._positionBar(this._calcPercent(r.left+r.width-a.left,i)-5,this._left):this._positionBar(this._calcPercent(a.left+a.width-r.left,i)-5,this._calcPercent(o,i)+5),this.scrollable&&this._scrollToSelectedIfNeeded(r.width,o)},_scrollToSelectedIfNeeded:function(e,t){var n=t-this.$.tabsContainer.scrollLeft;(n<0||(n+=e-this.$.tabsContainer.offsetWidth)>0)&&(this.$.tabsContainer.scrollLeft+=n)},_calcPercent:function(e,t){return 100*e/t},_positionBar:function(e,t){t=t||0,this._width=e=e||0,this._left=t,this.transform("translateX("+t+"%) scaleX("+e/100+")",this.$.selectionBar)},_onBarTransitionEnd:function(e){var t=this.$.selectionBar.classList;t.contains("expand")?(t.remove("expand"),t.add("contract"),this._positionBar(this._pos.width,this._pos.left)):t.contains("contract")&&t.remove("contract")}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ var currentToast=null;Polymer({_template:html` <style> :host { display: block; position: fixed; background-color: var(--paper-toast-background-color, #323232); color: var(--paper-toast-color, #f1f1f1); min-height: 48px; min-width: 288px; padding: 16px 24px; box-sizing: border-box; box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26); border-radius: 2px; margin: 12px; font-size: 14px; cursor: default; -webkit-transition: -webkit-transform 0.3s, opacity 0.3s; transition: transform 0.3s, opacity 0.3s; opacity: 0; -webkit-transform: translateY(100px); transform: translateY(100px); @apply --paper-font-common-base; } :host(.capsule) { border-radius: 24px; } :host(.fit-bottom) { width: 100%; min-width: 0; border-radius: 0; margin: 0; } :host(.paper-toast-open) { opacity: 1; -webkit-transform: translateY(0px); transform: translateY(0px); } </style> <span id="label">{{text}}</span> <slot></slot> `,is:"paper-toast",behaviors:[IronOverlayBehavior],properties:{fitInto:{type:Object,value:window,observer:"_onFitIntoChanged"},horizontalAlign:{type:String,value:"left"},verticalAlign:{type:String,value:"bottom"},duration:{type:Number,value:3e3},text:{type:String,value:""},noCancelOnOutsideClick:{type:Boolean,value:!0},noAutoFocus:{type:Boolean,value:!0}},listeners:{transitionend:"__onTransitionEnd"},get visible(){return Base._warn("`visible` is deprecated, use `opened` instead"),this.opened},get _canAutoClose(){return this.duration>0&&this.duration!==1/0},created:function(){this._autoClose=null,IronA11yAnnouncer.requestAvailability()},show:function(e){for(var t in"string"==typeof e&&(e={text:e}),e)0===t.indexOf("_")?Base._warn('The property "'+t+'" is private and was not set.'):t in this?this[t]=e[t]:Base._warn('The property "'+t+'" is not valid.');this.open()},hide:function(){this.close()},__onTransitionEnd:function(e){e&&e.target===this&&"opacity"===e.propertyName&&(this.opened?this._finishRenderOpened():this._finishRenderClosed())},_openedChanged:function(){null!==this._autoClose&&(this.cancelAsync(this._autoClose),this._autoClose=null),this.opened?(currentToast&¤tToast!==this&¤tToast.close(),currentToast=this,this.fire("iron-announce",{text:this.text}),this._canAutoClose&&(this._autoClose=this.async(this.close,this.duration))):currentToast===this&&(currentToast=null),IronOverlayBehaviorImpl._openedChanged.apply(this,arguments)},_renderOpened:function(){this.classList.add("paper-toast-open")},_renderClosed:function(){this.classList.remove("paper-toast-open")},_onFitIntoChanged:function(e){this.positionTarget=e}}); /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const template$5=html` <style> :host { display: inline-block; @apply --layout-horizontal; @apply --layout-center; @apply --paper-font-common-base; } :host([disabled]) { pointer-events: none; } :host(:focus) { outline:none; } .toggle-bar { position: absolute; height: 100%; width: 100%; border-radius: 8px; pointer-events: none; opacity: 0.4; transition: background-color linear .08s; background-color: var(--paper-toggle-button-unchecked-bar-color, #000000); @apply --paper-toggle-button-unchecked-bar; } .toggle-button { position: absolute; top: -3px; left: 0; height: 20px; width: 20px; border-radius: 50%; box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6); transition: -webkit-transform linear .08s, background-color linear .08s; transition: transform linear .08s, background-color linear .08s; will-change: transform; background-color: var(--paper-toggle-button-unchecked-button-color, var(--paper-grey-50)); @apply --paper-toggle-button-unchecked-button; } .toggle-button.dragging { -webkit-transition: none; transition: none; } :host([checked]:not([disabled])) .toggle-bar { opacity: 0.5; background-color: var(--paper-toggle-button-checked-bar-color, var(--primary-color)); @apply --paper-toggle-button-checked-bar; } :host([disabled]) .toggle-bar { background-color: #000; opacity: 0.12; } :host([checked]) .toggle-button { -webkit-transform: translate(16px, 0); transform: translate(16px, 0); } :host([checked]:not([disabled])) .toggle-button { background-color: var(--paper-toggle-button-checked-button-color, var(--primary-color)); @apply --paper-toggle-button-checked-button; } :host([disabled]) .toggle-button { background-color: #bdbdbd; opacity: 1; } .toggle-ink { position: absolute; top: -14px; left: -14px; right: auto; bottom: auto; width: 48px; height: 48px; opacity: 0.5; pointer-events: none; color: var(--paper-toggle-button-unchecked-ink-color, var(--primary-text-color)); @apply --paper-toggle-button-unchecked-ink; } :host([checked]) .toggle-ink { color: var(--paper-toggle-button-checked-ink-color, var(--primary-color)); @apply --paper-toggle-button-checked-ink; } .toggle-container { display: inline-block; position: relative; width: 36px; height: 14px; /* The toggle button has an absolute position of -3px; The extra 1px /* accounts for the toggle button shadow box. */ margin: 4px 1px; } .toggle-label { position: relative; display: inline-block; vertical-align: middle; padding-left: var(--paper-toggle-button-label-spacing, 8px); pointer-events: none; color: var(--paper-toggle-button-label-color, var(--primary-text-color)); } /* invalid state */ :host([invalid]) .toggle-bar { background-color: var(--paper-toggle-button-invalid-bar-color, var(--error-color)); } :host([invalid]) .toggle-button { background-color: var(--paper-toggle-button-invalid-button-color, var(--error-color)); } :host([invalid]) .toggle-ink { color: var(--paper-toggle-button-invalid-ink-color, var(--error-color)); } </style> <div class="toggle-container"> <div id="toggleBar" class="toggle-bar"></div> <div id="toggleButton" class="toggle-button"></div> </div> <div class="toggle-label"><slot></slot></div> `;template$5.setAttribute("strip-whitespace",""),Polymer({_template:template$5,is:"paper-toggle-button",behaviors:[PaperCheckedElementBehavior],hostAttributes:{role:"button","aria-pressed":"false",tabindex:0},properties:{},listeners:{track:"_ontrack"},attached:function(){afterNextRender(this,(function(){setTouchAction(this,"pan-y")}))},_ontrack:function(e){var t=e.detail;"start"===t.state?this._trackStart(t):"track"===t.state?this._trackMove(t):"end"===t.state&&this._trackEnd(t)},_trackStart:function(e){this._width=this.$.toggleBar.offsetWidth/2,this._trackChecked=this.checked,this.$.toggleButton.classList.add("dragging")},_trackMove:function(e){var t=e.dx;this._x=Math.min(this._width,Math.max(0,this._trackChecked?this._width+t:t)),this.translate3d(this._x+"px",0,0,this.$.toggleButton),this._userActivate(this._x>this._width/2)},_trackEnd:function(e){this.$.toggleButton.classList.remove("dragging"),this.transform("",this.$.toggleButton)},_createRipple:function(){this._rippleContainer=this.$.toggleButton;var e=PaperRippleBehavior._createRipple();return e.id="ink",e.setAttribute("recenters",""),e.classList.add("circle","toggle-ink"),e}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { --calculated-paper-toolbar-height: var(--paper-toolbar-height, 64px); --calculated-paper-toolbar-sm-height: var(--paper-toolbar-sm-height, 56px); display: block; position: relative; box-sizing: border-box; -moz-box-sizing: border-box; height: var(--calculated-paper-toolbar-height); background: var(--paper-toolbar-background, var(--primary-color)); color: var(--paper-toolbar-color, var(--dark-theme-text-color)); @apply --paper-toolbar; } :host(.animate) { transition: var(--paper-toolbar-transition, height 0.18s ease-in); } :host(.medium-tall) { height: calc(var(--calculated-paper-toolbar-height) * 2); @apply --paper-toolbar-medium; } :host(.tall) { height: calc(var(--calculated-paper-toolbar-height) * 3); @apply --paper-toolbar-tall; } .toolbar-tools { position: relative; height: var(--calculated-paper-toolbar-height); padding: 0 16px; pointer-events: none; @apply --layout-horizontal; @apply --layout-center; @apply --paper-toolbar-content; } /* * TODO: Where should media query breakpoints live so they can be shared between elements? */ @media (max-width: 600px) { :host { height: var(--calculated-paper-toolbar-sm-height); } :host(.medium-tall) { height: calc(var(--calculated-paper-toolbar-sm-height) * 2); } :host(.tall) { height: calc(var(--calculated-paper-toolbar-sm-height) * 3); } .toolbar-tools { height: var(--calculated-paper-toolbar-sm-height); } } #topBar { position: relative; } /* middle bar */ #middleBar { position: absolute; top: 0; right: 0; left: 0; } :host(.tall) #middleBar, :host(.medium-tall) #middleBar { -webkit-transform: translateY(100%); transform: translateY(100%); } /* bottom bar */ #bottomBar { position: absolute; right: 0; bottom: 0; left: 0; } /* * make elements (e.g. buttons) respond to mouse/touch events * * \`.toolbar-tools\` disables touch events so multiple toolbars can stack and not * absorb events. All children must have pointer events re-enabled to work as * expected. */ .toolbar-tools > ::slotted(*:not([disabled])) { pointer-events: auto; } .toolbar-tools > ::slotted(.title) { @apply --paper-font-common-base; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 20px; font-weight: 400; line-height: 1; pointer-events: none; @apply --layout-flex; } .toolbar-tools > ::slotted(.title) { margin-left: 56px; } .toolbar-tools > ::slotted(paper-icon-button + .title) { margin-left: 0; } /** * The --paper-toolbar-title mixin is applied here instead of above to * fix the issue with margin-left being ignored due to css ordering. */ .toolbar-tools > ::slotted(.title) { @apply --paper-toolbar-title; } .toolbar-tools > ::slotted(paper-icon-button[icon=menu]) { margin-right: 24px; } .toolbar-tools > ::slotted(.fit) { position: absolute; top: auto; right: 0; bottom: 0; left: 0; width: auto; margin: 0; } /* TODO(noms): Until we have a better solution for classes that don't use * /deep/ create our own. */ .start-justified { @apply --layout-start-justified; } .center-justified { @apply --layout-center-justified; } .end-justified { @apply --layout-end-justified; } .around-justified { @apply --layout-around-justified; } .justified { @apply --layout-justified; } </style> <div id="topBar" class\$="toolbar-tools [[_computeBarExtraClasses(justify)]]"> <slot name="top"></slot> </div> <div id="middleBar" class\$="toolbar-tools [[_computeBarExtraClasses(middleJustify)]]"> <slot name="middle"></slot> </div> <div id="bottomBar" class\$="toolbar-tools [[_computeBarExtraClasses(bottomJustify)]]"> <slot name="bottom"></slot> </div> `,is:"paper-toolbar",hostAttributes:{role:"toolbar"},properties:{bottomJustify:{type:String,value:""},justify:{type:String,value:""},middleJustify:{type:String,value:""}},ready:function(){console.warn(this.is,"is deprecated. Please use app-layout instead!")},attached:function(){this._observer=this._observe(this),this._updateAriaLabelledBy()},detached:function(){this._observer&&this._observer.disconnect()},_observe:function(e){var t=new MutationObserver(function(){this._updateAriaLabelledBy()}.bind(this));return t.observe(e,{childList:!0,subtree:!0}),t},_updateAriaLabelledBy:function(){flush();for(var e,t=[],n=Array.prototype.slice.call(dom$1(this.root).querySelectorAll("slot")).concat(Array.prototype.slice.call(dom$1(this.root).querySelectorAll("content"))),i=0;e=n[i];i++)for(var r,o=dom$1(e).getDistributedNodes(),a=0;r=o[a];a++)if(r.classList&&r.classList.contains("title"))if(r.id)t.push(r.id);else{var s="paper-toolbar-label-"+Math.floor(1e4*Math.random());r.id=s,t.push(s)}t.length>0&&this.setAttribute("aria-labelledby",t.join(" "))},_computeBarExtraClasses:function(e){return e?e+("justified"===e?"":"-justified"):""}}), /** @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ Polymer({_template:html` <style> :host { display: block; position: absolute; outline: none; z-index: 1002; -moz-user-select: none; -ms-user-select: none; -webkit-user-select: none; user-select: none; cursor: default; } #tooltip { display: block; outline: none; @apply --paper-font-common-base; font-size: 10px; line-height: 1; background-color: var(--paper-tooltip-background, #616161); color: var(--paper-tooltip-text-color, white); padding: 8px; border-radius: 2px; @apply --paper-tooltip; } @keyframes keyFrameScaleUp { 0% { transform: scale(0.0); } 100% { transform: scale(1.0); } } @keyframes keyFrameScaleDown { 0% { transform: scale(1.0); } 100% { transform: scale(0.0); } } @keyframes keyFrameFadeInOpacity { 0% { opacity: 0; } 100% { opacity: var(--paper-tooltip-opacity, 0.9); } } @keyframes keyFrameFadeOutOpacity { 0% { opacity: var(--paper-tooltip-opacity, 0.9); } 100% { opacity: 0; } } @keyframes keyFrameSlideDownIn { 0% { transform: translateY(-2000px); opacity: 0; } 10% { opacity: 0.2; } 100% { transform: translateY(0); opacity: var(--paper-tooltip-opacity, 0.9); } } @keyframes keyFrameSlideDownOut { 0% { transform: translateY(0); opacity: var(--paper-tooltip-opacity, 0.9); } 10% { opacity: 0.2; } 100% { transform: translateY(-2000px); opacity: 0; } } .fade-in-animation { opacity: 0; animation-delay: var(--paper-tooltip-delay-in, 500ms); animation-name: keyFrameFadeInOpacity; animation-iteration-count: 1; animation-timing-function: ease-in; animation-duration: var(--paper-tooltip-duration-in, 500ms); animation-fill-mode: forwards; @apply --paper-tooltip-animation; } .fade-out-animation { opacity: var(--paper-tooltip-opacity, 0.9); animation-delay: var(--paper-tooltip-delay-out, 0ms); animation-name: keyFrameFadeOutOpacity; animation-iteration-count: 1; animation-timing-function: ease-in; animation-duration: var(--paper-tooltip-duration-out, 500ms); animation-fill-mode: forwards; @apply --paper-tooltip-animation; } .scale-up-animation { transform: scale(0); opacity: var(--paper-tooltip-opacity, 0.9); animation-delay: var(--paper-tooltip-delay-in, 500ms); animation-name: keyFrameScaleUp; animation-iteration-count: 1; animation-timing-function: ease-in; animation-duration: var(--paper-tooltip-duration-in, 500ms); animation-fill-mode: forwards; @apply --paper-tooltip-animation; } .scale-down-animation { transform: scale(1); opacity: var(--paper-tooltip-opacity, 0.9); animation-delay: var(--paper-tooltip-delay-out, 500ms); animation-name: keyFrameScaleDown; animation-iteration-count: 1; animation-timing-function: ease-in; animation-duration: var(--paper-tooltip-duration-out, 500ms); animation-fill-mode: forwards; @apply --paper-tooltip-animation; } .slide-down-animation { transform: translateY(-2000px); opacity: 0; animation-delay: var(--paper-tooltip-delay-out, 500ms); animation-name: keyFrameSlideDownIn; animation-iteration-count: 1; animation-timing-function: cubic-bezier(0.0, 0.0, 0.2, 1); animation-duration: var(--paper-tooltip-duration-out, 500ms); animation-fill-mode: forwards; @apply --paper-tooltip-animation; } .slide-down-animation-out { transform: translateY(0); opacity: var(--paper-tooltip-opacity, 0.9); animation-delay: var(--paper-tooltip-delay-out, 500ms); animation-name: keyFrameSlideDownOut; animation-iteration-count: 1; animation-timing-function: cubic-bezier(0.4, 0.0, 1, 1); animation-duration: var(--paper-tooltip-duration-out, 500ms); animation-fill-mode: forwards; @apply --paper-tooltip-animation; } .cancel-animation { animation-delay: -30s !important; } /* Thanks IE 10. */ .hidden { display: none !important; } </style> <div id="tooltip" class="hidden"> <slot></slot> </div> `,is:"paper-tooltip",hostAttributes:{role:"tooltip",tabindex:-1},properties:{for:{type:String,observer:"_findTarget"},manualMode:{type:Boolean,value:!1,observer:"_manualModeChanged"},position:{type:String,value:"bottom"},fitToVisibleBounds:{type:Boolean,value:!1},offset:{type:Number,value:14},marginTop:{type:Number,value:14},animationDelay:{type:Number,value:500,observer:"_delayChange"},animationEntry:{type:String,value:""},animationExit:{type:String,value:""},animationConfig:{type:Object,value:function(){return{entry:[{name:"fade-in-animation",node:this,timing:{delay:0}}],exit:[{name:"fade-out-animation",node:this}]}}},_showing:{type:Boolean,value:!1}},listeners:{webkitAnimationEnd:"_onAnimationEnd"},get target(){var e=dom$1(this).parentNode,t=dom$1(this).getOwnerRoot();return this.for?dom$1(t).querySelector("#"+this.for):e.nodeType==Node.DOCUMENT_FRAGMENT_NODE?t.host:e},attached:function(){this._findTarget()},detached:function(){this.manualMode||this._removeListeners()},playAnimation:function(e){"entry"===e?this.show():"exit"===e&&this.hide()},cancelAnimation:function(){this.$.tooltip.classList.add("cancel-animation")},show:function(){if(!this._showing){if(""===dom$1(this).textContent.trim()){for(var e=!0,t=dom$1(this).getEffectiveChildNodes(),n=0;n<t.length;n++)if(""!==t[n].textContent.trim()){e=!1;break}if(e)return}this._showing=!0,this.$.tooltip.classList.remove("hidden"),this.$.tooltip.classList.remove("cancel-animation"),this.$.tooltip.classList.remove(this._getAnimationType("exit")),this.updatePosition(),this._animationPlaying=!0,this.$.tooltip.classList.add(this._getAnimationType("entry"))}},hide:function(){if(this._showing){if(this._animationPlaying)return this._showing=!1,void this._cancelAnimation();this._onAnimationFinish(),this._showing=!1,this._animationPlaying=!0}},updatePosition:function(){if(this._target&&this.offsetParent){var e=this.offset;14!=this.marginTop&&14==this.offset&&(e=this.marginTop);var t,n,i=this.offsetParent.getBoundingClientRect(),r=this._target.getBoundingClientRect(),o=this.getBoundingClientRect(),a=(r.width-o.width)/2,s=(r.height-o.height)/2,l=r.left-i.left,c=r.top-i.top;switch(this.position){case"top":t=l+a,n=c-o.height-e;break;case"bottom":t=l+a,n=c+r.height+e;break;case"left":t=l-o.width-e,n=c+s;break;case"right":t=l+r.width+e,n=c+s}this.fitToVisibleBounds?(i.left+t+o.width>window.innerWidth?(this.style.right="0px",this.style.left="auto"):(this.style.left=Math.max(0,t)+"px",this.style.right="auto"),i.top+n+o.height>window.innerHeight?(this.style.bottom=i.height-c+e+"px",this.style.top="auto"):(this.style.top=Math.max(-i.top,n)+"px",this.style.bottom="auto")):(this.style.left=t+"px",this.style.top=n+"px")}},_addListeners:function(){this._target&&(this.listen(this._target,"mouseenter","show"),this.listen(this._target,"focus","show"),this.listen(this._target,"mouseleave","hide"),this.listen(this._target,"blur","hide"),this.listen(this._target,"tap","hide")),this.listen(this.$.tooltip,"animationend","_onAnimationEnd"),this.listen(this,"mouseenter","hide")},_findTarget:function(){this.manualMode||this._removeListeners(),this._target=this.target,this.manualMode||this._addListeners()},_delayChange:function(e){500!==e&&this.updateStyles({"--paper-tooltip-delay-in":e+"ms"})},_manualModeChanged:function(){this.manualMode?this._removeListeners():this._addListeners()},_cancelAnimation:function(){this.$.tooltip.classList.remove(this._getAnimationType("entry")),this.$.tooltip.classList.remove(this._getAnimationType("exit")),this.$.tooltip.classList.remove("cancel-animation"),this.$.tooltip.classList.add("hidden")},_onAnimationFinish:function(){this._showing&&(this.$.tooltip.classList.remove(this._getAnimationType("entry")),this.$.tooltip.classList.remove("cancel-animation"),this.$.tooltip.classList.add(this._getAnimationType("exit")))},_onAnimationEnd:function(){this._animationPlaying=!1,this._showing||(this.$.tooltip.classList.remove(this._getAnimationType("exit")),this.$.tooltip.classList.add("hidden"))},_getAnimationType:function(e){if("entry"===e&&""!==this.animationEntry)return this.animationEntry;if("exit"===e&&""!==this.animationExit)return this.animationExit;if(this.animationConfig[e]&&"string"==typeof this.animationConfig[e][0].name){if(this.animationConfig[e][0].timing&&this.animationConfig[e][0].timing.delay&&0!==this.animationConfig[e][0].timing.delay){var t=this.animationConfig[e][0].timing.delay;"entry"===e?this.updateStyles({"--paper-tooltip-delay-in":t+"ms"}):"exit"===e&&this.updateStyles({"--paper-tooltip-delay-out":t+"ms"})}return this.animationConfig[e][0].name}},_removeListeners:function(){this._target&&(this.unlisten(this._target,"mouseenter","show"),this.unlisten(this._target,"focus","show"),this.unlisten(this._target,"mouseleave","hide"),this.unlisten(this._target,"blur","hide"),this.unlisten(this._target,"tap","hide")),this.unlisten(this.$.tooltip,"animationend","_onAnimationEnd"),this.unlisten(this,"mouseenter","hide")}});class AnalyticsLogger{constructor(e,t){if("undefined"==typeof ga||null==ga)return this.eventLogging=!1,void(this.pageViewLogging=!1);this.eventLogging=t,this.pageViewLogging=e}logPageView(e){this.pageViewLogging&&ga("send",{hitType:"pageview",page:`/v/${e}`})}logProjectionChanged(e){this.eventLogging&&ga("send",{hitType:"event",eventCategory:"Projection",eventAction:"click",eventLabel:e})}logWebGLDisabled(){this.eventLogging&&ga("send",{hitType:"event",eventCategory:"Error",eventAction:"PageLoad",eventLabel:"WebGL_disabled"})}}const template$4=html` <style include="vz-projector-styles"></style> <style> :host { display: flex; width: 100%; height: 100%; } #container { display: flex; width: 100%; height: 100%; overflow: hidden; } .hidden { display: none !important; } /* Main */ #main { position: relative; flex-grow: 2; } #main .stage { position: relative; flex-grow: 2; } #scatter { position: absolute; top: 0; left: 0; right: 0; bottom: 0; } #selector { display: none; height: 100%; position: absolute; width: 100%; } #left-pane { display: flex; flex-direction: column; justify-content: space-between; min-width: 312px; width: 312px; border-right: 1px solid rgba(0, 0, 0, 0.1); background: #fafafa; } #right-pane { border-left: 1px solid rgba(0, 0, 0, 0.1); background: #fafafa; display: flex; height: 100%; min-width: 300px; width: 300px; } .file-name { margin-right: 5px; } .control input[type='text']:focus { outline: none; border-bottom: 1px solid rgba(0, 0, 0, 1); } .control { display: inline-block; width: 45%; vertical-align: top; margin-right: 10px; overflow-x: hidden; } .control.last { margin-right: 0; } #notification-dialog { width: 400px; padding-bottom: 20px; } #notification-dialog paper-button { background: none; text-transform: uppercase; } #notification-dialog .progress { --paper-spinner-color: #880e4f; --paper-spinner-stroke-width: 2px; } #notify-msgs { text-align: center; display: block; } .notify-msg { font-weight: 500; margin: 0; padding: 0; } .notify-msg.error { text-align: left; } .brush .extent { stroke: #fff; fill-opacity: 0.125; shape-rendering: crispEdges; } .origin text { font-size: 12px; font-weight: 500; } .origin line { stroke: black; stroke-opacity: 0.2; } /* Ink Framework */ /* - Buttons */ .ink-button, ::shadow .ink-button { border: none; border-radius: 2px; font-size: 13px; padding: 10px; min-width: 100px; flex-shrink: 0; background: #e3e3e3; } .status-bar-panel { display: flex; align-items: center; } .status-bar-entry { border-left: 1px solid rgba(0, 0, 0, 0.5); margin-left: 5px; padding-left: 5px; } /* - Menubar */ .ink-panel-menubar { align-items: center; position: relative; height: 60px; border-bottom: solid 1px #eee; padding: 0 24px; display: flex; } .ink-panel-menubar .ink-fabs { position: absolute; right: 12px; top: 40px; z-index: 1; } #bookmark-panel { bottom: 0; position: absolute; width: 300px; } #bookmark-panel-container { bottom: 60px; position: absolute; } .ink-fab { margin-left: 8px; border: 1px solid rgba(0, 0, 0, 0.02); background: white; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); } #metadata-card { position: absolute; right: 5px; top: 25px; } #help-3d-icon { position: absolute; top: 20px; left: 20px; } #help3dDialog .main { margin: 0; padding: 20px; } #help3dDialog h3 { margin-top: 20px; margin-bottom: 5px; } #help3dDialog h3:first-child { margin-top: 0; } #data-panel { border-top: 1px solid rgba(0, 0, 0, 0.1); overflow-y: auto; } #toast { display: flex; align-items: center; --paper-toast-color: #eeff41; } </style> <paper-dialog id="notification-dialog" modal> <h2 id="notification-title"></h2> <paper-dialog-scrollable> <div id="notify-msgs"></div> </paper-dialog-scrollable> <div style="text-align: center;"> <paper-spinner-lite active class="progress"></paper-spinner-lite> </div> <div class="buttons"> <paper-button class="close-button" dialog-confirm autofocus >Close</paper-button > </div> </paper-dialog> <div id="container"> <div id="left-pane" class="ink-panel"> <vz-projector-data-panel id="data-panel"></vz-projector-data-panel> <vz-projector-projections-panel id="projections-panel" ></vz-projector-projections-panel> </div> <div id="main" class="ink-panel"> <div class="ink-panel-menubar"> <paper-icon-button id="selectMode" alt="Bounding box selection" toggles icon="image:photo-size-select-small" ></paper-icon-button> <paper-tooltip for="selectMode" position="bottom" animation-delay="0" fit-to-visible-bounds >Bounding box selection</paper-tooltip > <paper-icon-button id="editMode" alt="Edit current selection" toggles icon="image:exposure" ></paper-icon-button> <paper-tooltip for="editMode" position="bottom" animation-delay="0" fit-to-visible-bounds >Edit current selection</paper-tooltip > <paper-icon-button id="nightDayMode" alt="Enable/disable night mode" toggles icon="image:brightness-2" ></paper-icon-button> <paper-tooltip for="nightDayMode" position="bottom" animation-delay="0" fit-to-visible-bounds >Enable/disable night mode</paper-tooltip > <paper-icon-button id="labels3DMode" alt="Enable/disable 3D labels mode" toggles icon="font-download" ></paper-icon-button> <paper-tooltip for="labels3DMode" position="bottom" animation-delay="0" fit-to-visible-bounds >Enable/disable 3D labels mode</paper-tooltip > <div class="status-bar-panel"> <div class="status-bar-entry"> Points: <span class="numDataPoints">Loading...</span> </div> <div class="status-bar-entry"> Dimension: <span class="dim">Loading...</span> </div> <div id="status-bar" class="status-bar-entry" style="display: none;" ></div> </div> <div class="ink-fabs"> <paper-icon-button id="reset-zoom" class="ink-fab" alt="Reset zoom to fit all points" icon="home" ></paper-icon-button> <paper-tooltip for="reset-zoom" position="left" animation-delay="0" >Reset zoom to fit all points</paper-tooltip > </div> </div> <div class="stage"> <div id="scatter"> <svg id="selector"></svg> </div> <vz-projector-metadata-card id="metadata-card" ></vz-projector-metadata-card> <paper-icon-button raised onclick="help3dDialog.open()" icon="help-outline" id="help-3d-icon" ></paper-icon-button> <paper-tooltip animation-delay="0" for="help-3d-icon" >Help with interaction controls.</paper-tooltip > <paper-dialog id="help3dDialog" with-backdrop> <div class="main" dialog-confirm autofocus> <h3>3D controls</h3> <b>Rotate</b> Mouse left click.<br /> <b>Pan</b> Mouse right click.<br /> <b>Zoom</b> Mouse wheel.<br /> Holding <b>ctrl</b> reverses the mouse clicks. <h3>2D controls</h3> <b>Pan</b> Mouse left click.<br /> <b>Zoom</b> Mouse wheel. <div class="dismiss-dialog-note">Click anywhere to dismiss.</div> </div> </paper-dialog> </div> </div> <div id="right-pane" class="ink-panel"> <div class="ink-panel-content active"> <vz-projector-inspector-panel id="inspector-panel" ></vz-projector-inspector-panel> </div> <div id="bookmark-panel-container"> <vz-projector-bookmark-panel id="bookmark-panel" ></vz-projector-bookmark-panel> </div> </div> </div> <paper-toast id="toast" always-on-top></paper-toast> </template> `;var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return commonjsRequire(e,null==t?n.path:t)}},n.exports),n.exports}function getAugmentedNamespace(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})})),t}function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var numeric1_2_6=createCommonjsModule((function(module,exports){var numeric=exports;void 0!==commonjsGlobal&&(commonjsGlobal.numeric=numeric),numeric.version="1.2.6",numeric.bench=function e(t,n){var i,r,o;for(void 0===n&&(n=15),r=.5,i=new Date;;){for(o=r*=2;o>3;o-=4)t(),t(),t(),t();for(;o>0;)t(),o--;if(new Date-i>n)break}for(o=r;o>3;o-=4)t(),t(),t(),t();for(;o>0;)t(),o--;return 1e3*(3*r-1)/(new Date-i)},numeric._myIndexOf=function e(t){var n,i=this.length;for(n=0;n<i;++n)if(this[n]===t)return n;return-1},numeric.myIndexOf=Array.prototype.indexOf?Array.prototype.indexOf:numeric._myIndexOf,numeric.Function=Function,numeric.precision=4,numeric.largeArray=50,numeric.prettyPrint=function e(t){function n(e){if(0===e)return"0";if(isNaN(e))return"NaN";if(e<0)return"-"+n(-e);if(isFinite(e)){var t=Math.floor(Math.log(e)/Math.log(10)),i=e/Math.pow(10,t),r=i.toPrecision(numeric.precision);return 10===parseFloat(r)&&(t++,r=(i=1).toPrecision(numeric.precision)),parseFloat(r).toString()+"e"+t.toString()}return"Infinity"}var i=[];return(function e(t){var r;if(void 0===t)return i.push(Array(numeric.precision+8).join(" ")),!1;if("string"==typeof t)return i.push('"'+t+'"'),!1;if("boolean"==typeof t)return i.push(t.toString()),!1;if("number"==typeof t){var o=n(t),a=t.toPrecision(numeric.precision),s=parseFloat(t.toString()).toString(),l=[o,a,s,parseFloat(a).toString(),parseFloat(s).toString()];for(r=1;r<l.length;r++)l[r].length<o.length&&(o=l[r]);return i.push(Array(numeric.precision+8-o.length).join(" ")+o),!1}if(null===t)return i.push("null"),!1;if("function"==typeof t){i.push(t.toString());var c=!1;for(r in t)t.hasOwnProperty(r)&&(i.push(c?",\n":"\n{"),c=!0,i.push(r),i.push(": \n"),e(t[r]));return c&&i.push("}\n"),!0}if(t instanceof Array){if(t.length>numeric.largeArray)return i.push("...Large Array..."),!0;for(c=!1,i.push("["),r=0;r<t.length;r++)r>0&&(i.push(","),c&&i.push("\n ")),c=e(t[r]);return i.push("]"),!0}for(r in i.push("{"),c=!1,t)t.hasOwnProperty(r)&&(c&&i.push(",\n"),c=!0,i.push(r),i.push(": \n"),e(t[r]));return i.push("}"),!0})(t),i.join("")},numeric.parseDate=function e(t){return(function e(t){if("string"==typeof t)return Date.parse(t.replace(/-/g,"/"));if(!(t instanceof Array))throw new Error("parseDate: parameter must be arrays of strings");var n,i=[];for(n=0;n<t.length;n++)i[n]=e(t[n]);return i})(t)},numeric.parseFloat=function e(t){return(function e(t){if("string"==typeof t)return parseFloat(t);if(!(t instanceof Array))throw new Error("parseFloat: parameter must be arrays of strings");var n,i=[];for(n=0;n<t.length;n++)i[n]=e(t[n]);return i})(t)},numeric.parseCSV=function e(t){var n,i,r,o=t.split("\n"),a=[],s=/(([^'",]*)|('[^']*')|("[^"]*")),/g,l=/^\s*(([+-]?[0-9]+(\.[0-9]*)?(e[+-]?[0-9]+)?)|([+-]?[0-9]*(\.[0-9]+)?(e[+-]?[0-9]+)?))\s*$/,c=0;for(i=0;i<o.length;i++){var h,u=(o[i]+",").match(s);if(u.length>0){for(a[c]=[],n=0;n<u.length;n++)h=(r=u[n]).substr(0,r.length-1),a[c][n]=l.test(h)?parseFloat(h):h;c++}}return a},numeric.toCSV=function e(t){var n,i,r,o,a;for(r=numeric.dim(t)[0],a=[],n=0;n<r;n++){for(o=[],i=0;i<r;i++)o[i]=t[n][i].toString();a[n]=o.join(", ")}return a.join("\n")+"\n"},numeric.getURL=function e(t){var n=new XMLHttpRequest;return n.open("GET",t,!1),n.send(),n},numeric.imageURL=function e(t){function n(e,t,n){void 0===t&&(t=0),void 0===n&&(n=e.length);var i,r=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],o=-1;for(i=t;i<n;i++)o=o>>>8^r[255&(o^e[i])];return-1^o}var i,r,o,a,s,l,c,h,u,d,p=t[0].length,m=t[0][0].length,f=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,m>>24&255,m>>16&255,m>>8&255,255&m,p>>24&255,p>>16&255,p>>8&255,255&p,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(d=n(f,12,29),f[29]=d>>24&255,f[30]=d>>16&255,f[31]=d>>8&255,f[32]=255&d,i=1,r=0,c=0;c<p;c++){for(f.push(c<p-1?0:1),l=3*m+1+(0===c)>>8&255,f.push(s=3*m+1+(0===c)&255),f.push(l),f.push(255&~s),f.push(255&~l),0===c&&f.push(0),h=0;h<m;h++)for(o=0;o<3;o++)r=(r+(i=(i+(s=(s=t[o][c][h])>255?255:s<0?0:Math.round(s)))%65521))%65521,f.push(s);f.push(0)}return f.push((u=(r<<16)+i)>>24&255),f.push(u>>16&255),f.push(u>>8&255),f.push(255&u),f[33]=(a=f.length-41)>>24&255,f[34]=a>>16&255,f[35]=a>>8&255,f[36]=255&a,d=n(f,37),f.push(d>>24&255),f.push(d>>16&255),f.push(d>>8&255),f.push(255&d),f.push(0),f.push(0),f.push(0),f.push(0),f.push(73),f.push(69),f.push(78),f.push(68),f.push(174),f.push(66),f.push(96),f.push(130),"data:image/png;base64,"+(function g(e){var t,n,i,r,o,a,s,l=e.length,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h="";for(t=0;t<l;t+=3)o=((3&(n=e[t]))<<4)+((i=e[t+1])>>4),a=((15&i)<<2)+((r=e[t+2])>>6),s=63&r,t+1>=l?a=s=64:t+2>=l&&(s=64),h+=c.charAt(n>>2)+c.charAt(o)+c.charAt(a)+c.charAt(s);return h})(f)},numeric._dim=function e(t){for(var n=[];"object"==typeof t;)n.push(t.length),t=t[0];return n},numeric.dim=function e(t){var n;return"object"==typeof t?"object"==typeof(n=t[0])?"object"==typeof n[0]?numeric._dim(t):[t.length,n.length]:[t.length]:[]},numeric.mapreduce=function e(t,n){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+n+';\nif(typeof x === "number") { var xi = x; '+t+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) {\n accum = arguments.callee(x[i],accum,_s,_k+1);\n } return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n xi = x[i];\n '+t+";\n xi = x[i-1];\n "+t+";\n}\nif(i === 0) {\n xi = x[i];\n "+t+"\n}\nreturn accum;")},numeric.mapreduce2=function e(t,n){return Function("x","var n = x.length;\nvar i,xi;\n"+n+";\nfor(i=n-1;i!==-1;--i) { \n xi = x[i];\n "+t+";\n}\nreturn accum;")},numeric.same=function e(t,n){var i,r;if(!(t instanceof Array&&n instanceof Array))return!1;if((r=t.length)!==n.length)return!1;for(i=0;i<r;i++)if(t[i]!==n[i]){if("object"!=typeof t[i])return!1;if(!e(t[i],n[i]))return!1}return!0},numeric.rep=function e(t,n,i){void 0===i&&(i=0);var r,o=t[i],a=Array(o);if(i===t.length-1){for(r=o-2;r>=0;r-=2)a[r+1]=n,a[r]=n;return-1===r&&(a[0]=n),a}for(r=o-1;r>=0;r--)a[r]=numeric.rep(t,n,i+1);return a},numeric.dotMMsmall=function e(t,n){var i,r,o,a,s,l,c,h,u,d,p;for(a=t.length,s=n.length,l=n[0].length,c=Array(a),i=a-1;i>=0;i--){for(h=Array(l),u=t[i],o=l-1;o>=0;o--){for(d=u[s-1]*n[s-1][o],r=s-2;r>=1;r-=2)d+=u[r]*n[r][o]+u[p=r-1]*n[p][o];0===r&&(d+=u[0]*n[0][o]),h[o]=d}c[i]=h}return c},numeric._getCol=function e(t,n,i){var r;for(r=t.length-1;r>0;--r)i[r]=t[r][n],i[--r]=t[r][n];0===r&&(i[0]=t[0][n])},numeric.dotMMbig=function e(t,n){var i,r,o=numeric._getCol,a=n.length,s=Array(a),l=t.length,c=n[0].length,h=new Array(l),u=numeric.dotVV;for(--a,i=--l;-1!==i;--i)h[i]=Array(c);for(i=--c;-1!==i;--i)for(o(n,i,s),r=l;-1!==r;--r)h[r][i]=u(t[r],s);return h},numeric.dotMV=function e(t,n){var i,r=t.length,o=Array(r),a=numeric.dotVV;for(i=r-1;i>=0;i--)o[i]=a(t[i],n);return o},numeric.dotVM=function e(t,n){var i,r,o,a,s,l,c;for(o=t.length,a=n[0].length,s=Array(a),r=a-1;r>=0;r--){for(l=t[o-1]*n[o-1][r],i=o-2;i>=1;i-=2)l+=t[i]*n[i][r]+t[c=i-1]*n[c][r];0===i&&(l+=t[0]*n[0][r]),s[r]=l}return s},numeric.dotVV=function e(t,n){var i,r,o=t.length,a=t[o-1]*n[o-1];for(i=o-2;i>=1;i-=2)a+=t[i]*n[i]+t[r=i-1]*n[r];return 0===i&&(a+=t[0]*n[0]),a},numeric.dot=function e(t,n){var i=numeric.dim;switch(1e3*i(t).length+i(n).length){case 2002:return n.length<10?numeric.dotMMsmall(t,n):numeric.dotMMbig(t,n);case 2001:return numeric.dotMV(t,n);case 1002:return numeric.dotVM(t,n);case 1001:return numeric.dotVV(t,n);case 1e3:return numeric.mulVS(t,n);case 1:return numeric.mulSV(t,n);case 0:return t*n;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function e(t){var n,i,r,o,a=t.length,s=Array(a);for(n=a-1;n>=0;n--){for(o=Array(a),i=n+2,r=a-1;r>=i;r-=2)o[r]=0,o[r-1]=0;for(r>n&&(o[r]=0),o[n]=t[n],r=n-1;r>=1;r-=2)o[r]=0,o[r-1]=0;0===r&&(o[0]=0),s[n]=o}return s},numeric.getDiag=function(e){var t,n=Math.min(e.length,e[0].length),i=Array(n);for(t=n-1;t>=1;--t)i[t]=e[t][t],i[--t]=e[t][t];return 0===t&&(i[0]=e[0][0]),i},numeric.identity=function e(t){return numeric.diag(numeric.rep([t],1))},numeric.pointwise=function e(t,n,i){void 0===i&&(i="");var r,o,a=[],s=/\[i\]$/,l="",c=!1;for(r=0;r<t.length;r++)s.test(t[r])?l=o=t[r].substring(0,t[r].length-3):o=t[r],"ret"===o&&(c=!0),a.push(o);return a[t.length]="_s",a[t.length+1]="_k",a[t.length+2]='if(typeof _s === "undefined") _s = numeric.dim('+l+');\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i'+(c?"":", ret = Array(_n)")+";\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) ret[i] = arguments.callee("+t.join(",")+",_s,_k+1);\n return ret;\n}\n"+i+"\nfor(i=_n-1;i!==-1;--i) {\n "+n+"\n}\nreturn ret;",Function.apply(null,a)},numeric.pointwise2=function e(t,n,i){void 0===i&&(i="");var r,o,a=[],s=/\[i\]$/,l="",c=!1;for(r=0;r<t.length;r++)s.test(t[r])?l=o=t[r].substring(0,t[r].length-3):o=t[r],"ret"===o&&(c=!0),a.push(o);return a[t.length]="var _n = "+l+".length;\nvar i"+(c?"":", ret = Array(_n)")+";\n"+i+"\nfor(i=_n-1;i!==-1;--i) {\n"+n+"\n}\nreturn ret;",Function.apply(null,a)},numeric._biforeach=function e(t,n,i,r,o){var a;if(r!==i.length-1)for(a=i[r]-1;a>=0;a--)e("object"==typeof t?t[a]:t,"object"==typeof n?n[a]:n,i,r+1,o);else o(t,n)},numeric._biforeach2=function e(t,n,i,r,o){if(r===i.length-1)return o(t,n);var a,s=i[r],l=Array(s);for(a=s-1;a>=0;--a)l[a]=e("object"==typeof t?t[a]:t,"object"==typeof n?n[a]:n,i,r+1,o);return l},numeric._foreach=function e(t,n,i,r){var o;if(i!==n.length-1)for(o=n[i]-1;o>=0;o--)e(t[o],n,i+1,r);else r(t)},numeric._foreach2=function e(t,n,i,r){if(i===n.length-1)return r(t);var o,a=n[i],s=Array(a);for(o=a-1;o>=0;o--)s[o]=e(t[o],n,i+1,r);return s},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},(function(){var e,t;for(e=0;e<numeric.mathfuns2.length;++e)numeric.ops2[t=numeric.mathfuns2[e]]=t;for(e in numeric.ops2)if(numeric.ops2.hasOwnProperty(e)){t=numeric.ops2[e];var n,i,r="";-1!==numeric.myIndexOf.call(numeric.mathfuns2,e)?(r="var "+t+" = Math."+t+";\n",n=function(e,n,i){return e+" = "+t+"("+n+","+i+")"},i=function(e,n){return e+" = "+t+"("+e+","+n+")"}):(n=function(e,n,i){return e+" = "+n+" "+t+" "+i},i=numeric.opseq.hasOwnProperty(e+"eq")?function(e,n){return e+" "+t+"= "+n}:function(e,n){return e+" = "+e+" "+t+" "+n}),numeric[e+"VV"]=numeric.pointwise2(["x[i]","y[i]"],n("ret[i]","x[i]","y[i]"),r),numeric[e+"SV"]=numeric.pointwise2(["x","y[i]"],n("ret[i]","x","y[i]"),r),numeric[e+"VS"]=numeric.pointwise2(["x[i]","y"],n("ret[i]","x[i]","y"),r),numeric[e]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar VV = numeric."+e+"VV, VS = numeric."+e+"VS, SV = numeric."+e+'SV;\nvar dim = numeric.dim;\nfor(i=1;i!==n;++i) { \n y = arguments[i];\n if(typeof x === "object") {\n if(typeof y === "object") x = numeric._biforeach2(x,y,dim(x),0,VV);\n else x = numeric._biforeach2(x,y,dim(x),0,VS);\n } else if(typeof y === "object") x = numeric._biforeach2(x,y,dim(y),0,SV);\n else '+i("x","y")+"\n}\nreturn x;\n"),numeric[t]=numeric[e],numeric[e+"eqV"]=numeric.pointwise2(["ret[i]","x[i]"],i("ret[i]","x[i]"),r),numeric[e+"eqS"]=numeric.pointwise2(["ret[i]","x"],i("ret[i]","x"),r),numeric[e+"eq"]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar V = numeric."+e+"eqV, S = numeric."+e+'eqS\nvar s = numeric.dim(x);\nfor(i=1;i!==n;++i) { \n y = arguments[i];\n if(typeof y === "object") numeric._biforeach(x,y,s,0,V);\n else numeric._biforeach(x,y,s,0,S);\n}\nreturn x;\n')}for(e=0;e<numeric.mathfuns2.length;++e)delete numeric.ops2[t=numeric.mathfuns2[e]];for(e=0;e<numeric.mathfuns.length;++e)numeric.ops1[t=numeric.mathfuns[e]]=t;for(e in numeric.ops1)numeric.ops1.hasOwnProperty(e)&&(r="",t=numeric.ops1[e],-1!==numeric.myIndexOf.call(numeric.mathfuns,e)&&Math.hasOwnProperty(t)&&(r="var "+t+" = Math."+t+";\n"),numeric[e+"eqV"]=numeric.pointwise2(["ret[i]"],"ret[i] = "+t+"(ret[i]);",r),numeric[e+"eq"]=Function("x",'if(typeof x !== "object") return '+t+"x\nvar i;\nvar V = numeric."+e+"eqV;\nvar s = numeric.dim(x);\nnumeric._foreach(x,s,0,V);\nreturn x;\n"),numeric[e+"V"]=numeric.pointwise2(["x[i]"],"ret[i] = "+t+"(x[i]);",r),numeric[e]=Function("x",'if(typeof x !== "object") return '+t+"(x)\nvar i;\nvar V = numeric."+e+"V;\nvar s = numeric.dim(x);\nreturn numeric._foreach2(x,s,0,V);\n"));for(e=0;e<numeric.mathfuns.length;++e)delete numeric.ops1[t=numeric.mathfuns[e]];for(e in numeric.mapreducers)numeric.mapreducers.hasOwnProperty(e)&&(numeric[e+"V"]=numeric.mapreduce2((t=numeric.mapreducers[e])[0],t[1]),numeric[e]=Function("x","s","k",t[1]+'if(typeof x !== "object") { xi = x;\n'+t[0]+';\n return accum;\n}if(typeof s === "undefined") s = numeric.dim(x);\nif(typeof k === "undefined") k = 0;\nif(k === s.length-1) return numeric.'+e+"V(x);\nvar xi;\nvar n = x.length, i;\nfor(i=n-1;i!==-1;--i) {\n xi = arguments.callee(x[i]);\n"+t[0]+";\n}\nreturn accum;\n"))})(),numeric.truncVV=numeric.pointwise(["x[i]","y[i]"],"ret[i] = round(x[i]/y[i])*y[i];","var round = Math.round;"),numeric.truncVS=numeric.pointwise(["x[i]","y"],"ret[i] = round(x[i]/y)*y;","var round = Math.round;"),numeric.truncSV=numeric.pointwise(["x","y[i]"],"ret[i] = round(x/y[i])*y[i];","var round = Math.round;"),numeric.trunc=function e(t,n){return"object"==typeof t?"object"==typeof n?numeric.truncVV(t,n):numeric.truncVS(t,n):"object"==typeof n?numeric.truncSV(t,n):Math.round(t/n)*n},numeric.inv=function e(t){var n,i,r,o,a,s,l,c=numeric.dim(t),h=Math.abs,u=c[0],d=c[1],p=numeric.clone(t),m=numeric.identity(u);for(s=0;s<d;++s){var f=-1,g=-1;for(a=s;a!==u;++a)(l=h(p[a][s]))>g&&(f=a,g=l);for(i=p[f],p[f]=p[s],p[s]=i,o=m[f],m[f]=m[s],m[s]=o,t=i[s],l=s;l!==d;++l)i[l]/=t;for(l=d-1;-1!==l;--l)o[l]/=t;for(a=u-1;-1!==a;--a)if(a!==s){for(r=m[a],t=(n=p[a])[s],l=s+1;l!==d;++l)n[l]-=i[l]*t;for(l=d-1;l>0;--l)r[l]-=o[l]*t,r[--l]-=o[l]*t;0===l&&(r[0]-=o[0]*t)}}return m},numeric.det=function e(t){var n=numeric.dim(t);if(2!==n.length||n[0]!==n[1])throw new Error("numeric: det() only works on square matrices");var i,r,o,a,s,l,c,h,u=n[0],d=1,p=numeric.clone(t);for(r=0;r<u-1;r++){for(o=r,i=r+1;i<u;i++)Math.abs(p[i][r])>Math.abs(p[o][r])&&(o=i);for(o!==r&&(c=p[o],p[o]=p[r],p[r]=c,d*=-1),a=p[r],i=r+1;i<u;i++){for(l=(s=p[i])[r]/a[r],o=r+1;o<u-1;o+=2)h=o+1,s[o]-=a[o]*l,s[h]-=a[h]*l;o!==u&&(s[o]-=a[o]*l)}if(0===a[r])return 0;d*=a[r]}return d*p[r][r]},numeric.transpose=function e(t){var n,i,r,o,a,s=t.length,l=t[0].length,c=Array(l);for(i=0;i<l;i++)c[i]=Array(s);for(n=s-1;n>=1;n-=2){for(o=t[n],r=t[n-1],i=l-1;i>=1;--i)(a=c[i])[n]=o[i],a[n-1]=r[i],(a=c[--i])[n]=o[i],a[n-1]=r[i];0===i&&((a=c[0])[n]=o[0],a[n-1]=r[0])}if(0===n){for(r=t[0],i=l-1;i>=1;--i)c[i][0]=r[i],c[--i][0]=r[i];0===i&&(c[0][0]=r[0])}return c},numeric.negtranspose=function e(t){var n,i,r,o,a,s=t.length,l=t[0].length,c=Array(l);for(i=0;i<l;i++)c[i]=Array(s);for(n=s-1;n>=1;n-=2){for(o=t[n],r=t[n-1],i=l-1;i>=1;--i)(a=c[i])[n]=-o[i],a[n-1]=-r[i],(a=c[--i])[n]=-o[i],a[n-1]=-r[i];0===i&&((a=c[0])[n]=-o[0],a[n-1]=-r[0])}if(0===n){for(r=t[0],i=l-1;i>=1;--i)c[i][0]=-r[i],c[--i][0]=-r[i];0===i&&(c[0][0]=-r[0])}return c},numeric._random=function e(t,n){var i,r,o=t[n],a=Array(o);if(n===t.length-1){for(r=Math.random,i=o-1;i>=1;i-=2)a[i]=r(),a[i-1]=r();return 0===i&&(a[0]=r()),a}for(i=o-1;i>=0;i--)a[i]=e(t,n+1);return a},numeric.random=function e(t){return numeric._random(t,0)},numeric.norm2=function e(t){return Math.sqrt(numeric.norm2Squared(t))},numeric.linspace=function e(t,n,i){if(void 0===i&&(i=Math.max(Math.round(n-t)+1,1)),i<2)return 1===i?[t]:[];var r,o=Array(i);for(r=--i;r>=0;r--)o[r]=(r*n+(i-r)*t)/i;return o},numeric.getBlock=function e(t,n,i){var r=numeric.dim(t);return(function e(t,o){var a,s=n[o],l=i[o]-s,c=Array(l);if(o===r.length-1){for(a=l;a>=0;a--)c[a]=t[a+s];return c}for(a=l;a>=0;a--)c[a]=e(t[a+s],o+1);return c})(t,0)},numeric.setBlock=function e(t,n,i,r){var o=numeric.dim(t);return(function e(t,r,a){var s,l=n[a],c=i[a]-l;if(a===o.length-1)for(s=c;s>=0;s--)t[s+l]=r[s];for(s=c;s>=0;s--)e(t[s+l],r[s],a+1)})(t,r,0),t},numeric.getRange=function e(t,n,i){var r,o,a,s,l=n.length,c=i.length,h=Array(l);for(r=l-1;-1!==r;--r)for(h[r]=Array(c),a=h[r],s=t[n[r]],o=c-1;-1!==o;--o)a[o]=s[i[o]];return h},numeric.blockMatrix=function e(t){var n=numeric.dim(t);if(n.length<4)return numeric.blockMatrix([t]);var i,r,o,a,s,l=n[0],c=n[1];for(i=0,r=0,o=0;o<l;++o)i+=t[o][0].length;for(a=0;a<c;++a)r+=t[0][a][0].length;var h=Array(i);for(o=0;o<i;++o)h[o]=Array(r);var u,d,p,m,f,g=0;for(o=0;o<l;++o){for(u=r,a=c-1;-1!==a;--a)for(u-=(s=t[o][a])[0].length,p=s.length-1;-1!==p;--p)for(d=h[g+p],m=(f=s[p]).length-1;-1!==m;--m)d[u+m]=f[m];g+=t[o][0].length}return h},numeric.tensor=function e(t,n){if("number"==typeof t||"number"==typeof n)return numeric.mul(t,n);var i=numeric.dim(t),r=numeric.dim(n);if(1!==i.length||1!==r.length)throw new Error("numeric: tensor product is only defined for vectors");var o,a,s,l,c=i[0],h=r[0],u=Array(c);for(a=c-1;a>=0;a--){for(o=Array(h),l=t[a],s=h-1;s>=3;--s)o[s]=l*n[s],o[--s]=l*n[s],o[--s]=l*n[s],o[--s]=l*n[s];for(;s>=0;)o[s]=l*n[s],--s;u[a]=o}return u},numeric.T=function e(t,n){this.x=t,this.y=n},numeric.t=function e(t,n){return new numeric.T(t,n)},numeric.Tbinop=function e(t,n,i,r,o){var a;if("string"!=typeof o)for(a in o="",numeric)numeric.hasOwnProperty(a)&&(t.indexOf(a)>=0||n.indexOf(a)>=0||i.indexOf(a)>=0||r.indexOf(a)>=0)&&a.length>1&&(o+="var "+a+" = numeric."+a+";\n");return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+o+"\nif(x.y) { if(y.y) { return new numeric.T("+r+");\n }\n return new numeric.T("+i+");\n}\nif(y.y) {\n return new numeric.T("+n+");\n}\nreturn new numeric.T("+t+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function e(){var t=numeric.mul,n=numeric.div;if(this.y){var i=numeric.add(t(this.x,this.x),t(this.y,this.y));return new numeric.T(n(this.x,i),n(numeric.neg(this.y),i))}return new T(n(1,this.x))},numeric.T.prototype.div=function e(t){if(t instanceof numeric.T||(t=new numeric.T(t)),t.y)return this.mul(t.reciprocal());var e=numeric.div;return this.y?new numeric.T(e(this.x,t.x),e(this.y,t.x)):new numeric.T(e(this.x,t.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function e(){var t=numeric.transpose,n=this.x,i=this.y;return i?new numeric.T(t(n),t(i)):new numeric.T(t(n))},numeric.T.prototype.transjugate=function e(){var t=numeric.transpose,n=this.x,i=this.y;return i?new numeric.T(t(n),numeric.negtranspose(i)):new numeric.T(t(n))},numeric.Tunop=function e(t,n,i){return"string"!=typeof i&&(i=""),Function("var x = this;\n"+i+"\nif(x.y) { "+n+";\n}\n"+t+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function e(){var t=this;if(void 0===t.y)return new numeric.T(numeric.inv(t.x));var n,i,r,o,a,s,l,c,h,u,d,p,m,f,g,v,y,b,_=t.x.length,x=numeric.identity(_),w=numeric.rep([_,_],0),S=numeric.clone(t.x),C=numeric.clone(t.y);for(h=0;h<_;h++){for(p=(f=S[h][h])*f+(g=C[h][h])*g,d=h,u=h+1;u<_;u++)(m=(f=S[u][h])*f+(g=C[u][h])*g)>p&&(d=u,p=m);for(d!==h&&(b=S[h],S[h]=S[d],S[d]=b,b=C[h],C[h]=C[d],C[d]=b,b=x[h],x[h]=x[d],x[d]=b,b=w[h],w[h]=w[d],w[d]=b),a=x[h],s=w[h],f=(n=S[h])[h],g=(i=C[h])[h],u=h+1;u<_;u++)n[u]=((v=n[u])*f+(y=i[u])*g)/p,i[u]=(y*f-v*g)/p;for(u=0;u<_;u++)a[u]=((v=a[u])*f+(y=s[u])*g)/p,s[u]=(y*f-v*g)/p;for(u=h+1;u<_;u++){for(l=x[u],c=w[u],f=(r=S[u])[h],g=(o=C[u])[h],d=h+1;d<_;d++)r[d]-=(v=n[d])*f-(y=i[d])*g,o[d]-=y*f+v*g;for(d=0;d<_;d++)l[d]-=(v=a[d])*f-(y=s[d])*g,c[d]-=y*f+v*g}}for(h=_-1;h>0;h--)for(a=x[h],s=w[h],u=h-1;u>=0;u--)for(l=x[u],c=w[u],f=S[u][h],g=C[u][h],d=_-1;d>=0;d--)l[d]-=f*(v=a[d])-g*(y=s[d]),c[d]-=f*y+g*v;return new numeric.T(x,w)},numeric.T.prototype.get=function e(t){var n,i=this.x,r=this.y,o=0,a=t.length;if(r){for(;o<a;)i=i[n=t[o]],r=r[n],o++;return new numeric.T(i,r)}for(;o<a;)i=i[n=t[o]],o++;return new numeric.T(i)},numeric.T.prototype.set=function e(t,n){var i,r=this.x,o=this.y,a=0,s=t.length,l=n.x,c=n.y;if(0===s)return c?this.y=c:o&&(this.y=void 0),this.x=r,this;if(c){for(o||(o=numeric.rep(numeric.dim(r),0),this.y=o);a<s-1;)r=r[i=t[a]],o=o[i],a++;return r[i=t[a]]=l,o[i]=c,this}if(o){for(;a<s-1;)r=r[i=t[a]],o=o[i],a++;return r[i=t[a]]=l,o[i]=l instanceof Array?numeric.rep(numeric.dim(l),0):0,this}for(;a<s-1;)r=r[i=t[a]],a++;return r[i=t[a]]=l,this},numeric.T.prototype.getRows=function e(t,n){var i,r,o=n-t+1,a=Array(o),s=this.x,l=this.y;for(i=t;i<=n;i++)a[i-t]=s[i];if(l){for(r=Array(o),i=t;i<=n;i++)r[i-t]=l[i];return new numeric.T(a,r)}return new numeric.T(a)},numeric.T.prototype.setRows=function e(t,n,i){var r,o=this.x,a=this.y,s=i.x,l=i.y;for(r=t;r<=n;r++)o[r]=s[r-t];if(l)for(a||(a=numeric.rep(numeric.dim(o),0),this.y=a),r=t;r<=n;r++)a[r]=l[r-t];else if(a)for(r=t;r<=n;r++)a[r]=numeric.rep([s[r-t].length],0);return this},numeric.T.prototype.getRow=function e(t){var n=this.x,i=this.y;return i?new numeric.T(n[t],i[t]):new numeric.T(n[t])},numeric.T.prototype.setRow=function e(t,n){var i=this.x,r=this.y,o=n.x,a=n.y;return i[t]=o,a?(r||(r=numeric.rep(numeric.dim(i),0),this.y=r),r[t]=a):r&&(r=numeric.rep([o.length],0)),this},numeric.T.prototype.getBlock=function e(t,n){var i=this.x,r=this.y,o=numeric.getBlock;return r?new numeric.T(o(i,t,n),o(r,t,n)):new numeric.T(o(i,t,n))},numeric.T.prototype.setBlock=function e(t,n,i){i instanceof numeric.T||(i=new numeric.T(i));var r=this.x,o=this.y,a=numeric.setBlock,s=i.x,l=i.y;if(l)return o||(this.y=numeric.rep(numeric.dim(this),0),o=this.y),a(r,t,n,s),a(o,t,n,l),this;a(r,t,n,s),o&&a(o,t,n,numeric.rep(numeric.dim(s),0))},numeric.T.rep=function e(t,n){var i=numeric.T;n instanceof i||(n=new i(n));var r=n.x,o=n.y,a=numeric.rep;return o?new i(a(t,r),a(t,o)):new i(a(t,r))},numeric.T.diag=function e(t){t instanceof numeric.T||(t=new numeric.T(t));var n=t.x,i=t.y,e=numeric.diag;return i?new numeric.T(e(n),e(i)):new numeric.T(e(n))},numeric.T.eig=function e(){if(this.y)throw new Error("eig: not implemented for complex matrices.");return numeric.eig(this.x)},numeric.T.identity=function e(t){return new numeric.T(numeric.identity(t))},numeric.T.prototype.getDiag=function e(){var t=numeric,n=this.x,i=this.y;return i?new t.T(t.getDiag(n),t.getDiag(i)):new t.T(t.getDiag(n))},numeric.house=function e(t){var n=numeric.clone(t),i=(t[0]>=0?1:-1)*numeric.norm2(t);n[0]+=i;var r=numeric.norm2(n);if(0===r)throw new Error("eig: internal error");return numeric.div(n,r)},numeric.toUpperHessenberg=function e(t){var n=numeric.dim(t);if(2!==n.length||n[0]!==n[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var i,r,o,a,s,l,c,h,u,d,p=n[0],m=numeric.clone(t),f=numeric.identity(p);for(r=0;r<p-2;r++){for(a=Array(p-r-1),i=r+1;i<p;i++)a[i-r-1]=m[i][r];if(numeric.norm2(a)>0){for(s=numeric.house(a),l=numeric.getBlock(m,[r+1,r],[p-1,p-1]),c=numeric.tensor(s,numeric.dot(s,l)),i=r+1;i<p;i++)for(h=m[i],u=c[i-r-1],o=r;o<p;o++)h[o]-=2*u[o-r];for(l=numeric.getBlock(m,[0,r+1],[p-1,p-1]),c=numeric.tensor(numeric.dot(l,s),s),i=0;i<p;i++)for(h=m[i],u=c[i],o=r+1;o<p;o++)h[o]-=2*u[o-r-1];for(l=Array(p-r-1),i=r+1;i<p;i++)l[i-r-1]=f[i];for(c=numeric.tensor(s,numeric.dot(s,l)),i=r+1;i<p;i++)for(d=f[i],u=c[i-r-1],o=0;o<p;o++)d[o]-=2*u[o]}}return{H:m,Q:f}},numeric.epsilon=2220446049250313e-31,numeric.QRFrancis=function(e,t){void 0===t&&(t=1e4),e=numeric.clone(e),numeric.clone(e);var n,i,r,o,a,s,l,c,h,u,d,p,m,f,g,v,y=numeric.dim(e)[0],b=numeric.identity(y);if(y<3)return{Q:b,B:[[0,y-1]]};var _=numeric.epsilon;for(v=0;v<t;v++){for(f=0;f<y-1;f++)if(Math.abs(e[f+1][f])<_*(Math.abs(e[f][f])+Math.abs(e[f+1][f+1]))){var x=numeric.QRFrancis(numeric.getBlock(e,[0,0],[f,f]),t),w=numeric.QRFrancis(numeric.getBlock(e,[f+1,f+1],[y-1,y-1]),t);for(u=Array(f+1),m=0;m<=f;m++)u[m]=b[m];for(d=numeric.dot(x.Q,u),m=0;m<=f;m++)b[m]=d[m];for(u=Array(y-f-1),m=f+1;m<y;m++)u[m-f-1]=b[m];for(d=numeric.dot(w.Q,u),m=f+1;m<y;m++)b[m]=d[m-f-1];return{Q:b,B:x.B.concat(numeric.add(w.B,f+1))}}var S,C,M;for(s=(r=e[y-2][y-2])+(o=e[y-1][y-1]),a=r*o-e[y-2][y-1]*e[y-1][y-2],l=numeric.getBlock(e,[0,0],[2,2]),s*s>=4*a?(S=.5*(s+Math.sqrt(s*s-4*a)),C=.5*(s-Math.sqrt(s*s-4*a)),l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,S+C)),numeric.diag(numeric.rep([3],S*C)))):l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,s)),numeric.diag(numeric.rep([3],a))),i=numeric.house(n=[l[0][0],l[1][0],l[2][0]]),d=numeric.tensor(i,numeric.dot(i,u=[e[0],e[1],e[2]])),m=0;m<3;m++)for(h=e[m],p=d[m],g=0;g<y;g++)h[g]-=2*p[g];for(u=numeric.getBlock(e,[0,0],[y-1,2]),d=numeric.tensor(numeric.dot(u,i),i),m=0;m<y;m++)for(h=e[m],p=d[m],g=0;g<3;g++)h[g]-=2*p[g];for(d=numeric.tensor(i,numeric.dot(i,u=[b[0],b[1],b[2]])),m=0;m<3;m++)for(c=b[m],p=d[m],g=0;g<y;g++)c[g]-=2*p[g];for(f=0;f<y-2;f++){for(g=f;g<=f+1;g++)if(Math.abs(e[g+1][g])<_*(Math.abs(e[g][g])+Math.abs(e[g+1][g+1]))){for(x=numeric.QRFrancis(numeric.getBlock(e,[0,0],[g,g]),t),w=numeric.QRFrancis(numeric.getBlock(e,[g+1,g+1],[y-1,y-1]),t),u=Array(g+1),m=0;m<=g;m++)u[m]=b[m];for(d=numeric.dot(x.Q,u),m=0;m<=g;m++)b[m]=d[m];for(u=Array(y-g-1),m=g+1;m<y;m++)u[m-g-1]=b[m];for(d=numeric.dot(w.Q,u),m=g+1;m<y;m++)b[m]=d[m-g-1];return{Q:b,B:x.B.concat(numeric.add(w.B,g+1))}}for(M=Math.min(y-1,f+3),n=Array(M-f),m=f+1;m<=M;m++)n[m-f-1]=e[m][f];for(i=numeric.house(n),u=numeric.getBlock(e,[f+1,f],[M,y-1]),d=numeric.tensor(i,numeric.dot(i,u)),m=f+1;m<=M;m++)for(h=e[m],p=d[m-f-1],g=f;g<y;g++)h[g]-=2*p[g-f];for(u=numeric.getBlock(e,[0,f+1],[y-1,M]),d=numeric.tensor(numeric.dot(u,i),i),m=0;m<y;m++)for(h=e[m],p=d[m],g=f+1;g<=M;g++)h[g]-=2*p[g-f-1];for(u=Array(M-f),m=f+1;m<=M;m++)u[m-f-1]=b[m];for(d=numeric.tensor(i,numeric.dot(i,u)),m=f+1;m<=M;m++)for(c=b[m],p=d[m-f-1],g=0;g<y;g++)c[g]-=2*p[g]}}throw new Error("numeric: eigenvalue iteration does not converge -- increase maxiter?")},numeric.eig=function e(t,n){var i,r,o,a,s,l,c,h,u,d,p,m,f,g,v,y,b,_=numeric.toUpperHessenberg(t),x=numeric.QRFrancis(_.H,n),w=numeric.T,S=x.B,C=numeric.dot(x.Q,numeric.dot(_.H,numeric.transpose(x.Q))),M=new w(numeric.dot(x.Q,_.Q)),E=S.length,T=Math.sqrt;for(r=0;r<E;r++)if((i=S[r][0])===S[r][1]);else{if(s=C[i][i],c=C[a=i+1][i],h=C[a][a],0===(l=C[i][a])&&0===c)continue;(d=(u=-s-h)*u-4*(s*h-l*c))>=0?((v=(s-(p=u<0?-.5*(u-T(d)):-.5*(u+T(d))))*(s-p)+l*l)>(y=c*c+(h-p)*(h-p))?(f=(s-p)/(v=T(v)),g=l/v):(f=c/(y=T(y)),g=(h-p)/y),o=new w([[g,-f],[f,g]]),M.setRows(i,a,o.dot(M.getRows(i,a)))):(p=-.5*u,m=.5*T(-d),(v=(s-p)*(s-p)+l*l)>(y=c*c+(h-p)*(h-p))?(f=(s-p)/(v=T(v+m*m)),g=l/v,p=0,m/=v):(f=c/(y=T(y+m*m)),g=(h-p)/y,p=m/y,m=0),o=new w([[g,-f],[f,g]],[[p,m],[m,-p]]),M.setRows(i,a,o.dot(M.getRows(i,a))))}var I=M.dot(t).dot(M.transjugate()),A=numeric.T.identity(b=t.length);for(a=0;a<b;a++)if(a>0)for(r=a-1;r>=0;r--){var k=I.get([r,r]),P=I.get([a,a]);numeric.neq(k.x,P.x)||numeric.neq(k.y,P.y)?(p=I.getRow(r).getBlock([r],[a-1]),m=A.getRow(a).getBlock([r],[a-1]),A.set([a,r],I.get([r,a]).neg().sub(p.dot(m)).div(k.sub(P)))):A.setRow(a,A.getRow(r))}for(a=0;a<b;a++)p=A.getRow(a),A.setRow(a,p.div(p.norm2()));return A=A.transpose(),A=M.transjugate().dot(A),{lambda:I.getDiag(),E:A}},numeric.ccsSparse=function e(t){var n,i,r,o=t.length,a=[];for(i=o-1;-1!==i;--i)for(r in n=t[i]){for(r=parseInt(r);r>=a.length;)a[a.length]=0;0!==n[r]&&a[r]++}var s=a.length,l=Array(s+1);for(l[0]=0,i=0;i<s;++i)l[i+1]=l[i]+a[i];var c=Array(l[s]),h=Array(l[s]);for(i=o-1;-1!==i;--i)for(r in n=t[i])0!==n[r]&&(a[r]--,c[l[r]+a[r]]=i,h[l[r]+a[r]]=n[r]);return[l,c,h]},numeric.ccsFull=function e(t){var n,i,r,o=t[0],a=t[1],s=t[2],l=numeric.ccsDim(t),c=l[1],h=numeric.rep([l[0],c],0);for(n=0;n<c;n++)for(r=o[n+1],i=o[n];i<r;++i)h[a[i]][n]=s[i];return h},numeric.ccsTSolve=function e(t,n,i,r,o){var a,s,l,c,h,u,d,p=t[0],m=t[1],f=t[2],g=Math.max,v=0;function y(e){var t;if(0===i[e]){for(i[e]=1,t=p[e];t<p[e+1];++t)y(m[t]);o[v]=e,++v}}for(void 0===r&&(i=numeric.rep([p.length-1],0)),void 0===r&&(r=numeric.linspace(0,i.length-1)),void 0===o&&(o=[]),a=r.length-1;-1!==a;--a)y(r[a]);for(o.length=v,a=o.length-1;-1!==a;--a)i[o[a]]=0;for(a=r.length-1;-1!==a;--a)i[s=r[a]]=n[s];for(a=o.length-1;-1!==a;--a){for(c=g(p[(s=o[a])+1],l=p[s]),h=l;h!==c;++h)if(m[h]===s){i[s]/=f[h];break}for(d=i[s],h=l;h!==c;++h)(u=m[h])!==s&&(i[u]-=d*f[h])}return i},numeric.ccsDFS=function e(t){this.k=Array(t),this.k1=Array(t),this.j=Array(t)},numeric.ccsDFS.prototype.dfs=function e(t,n,i,r,o,a){var s,l,c,h=0,u=o.length,d=this.k,p=this.k1,m=this.j;if(0===r[t])for(r[t]=1,m[0]=t,d[0]=l=n[t],p[0]=c=n[t+1];;)if(l>=c){if(o[u]=m[h],0===h)return;++u,l=d[--h],c=p[h]}else 0===r[s=a[i[l]]]?(r[s]=1,d[h]=l,m[++h]=s,l=n[s],p[h]=c=n[s+1]):++l},numeric.ccsLPSolve=function e(t,n,i,r,o,a,s){var l,c,h,u,d,p,m,f,g,v=t[0],y=t[1],b=t[2],_=n[0],x=n[1],w=n[2];for(c=_[o],h=_[o+1],r.length=0,l=c;l<h;++l)s.dfs(a[x[l]],v,y,i,r,a);for(l=r.length-1;-1!==l;--l)i[r[l]]=0;for(l=c;l!==h;++l)i[u=a[x[l]]]=w[l];for(l=r.length-1;-1!==l;--l){for(p=v[(u=r[l])+1],m=d=v[u];m<p;++m)if(a[y[m]]===u){i[u]/=b[m];break}for(g=i[u],m=d;m<p;++m)(f=a[y[m]])!==u&&(i[f]-=g*b[m])}return i},numeric.ccsLUP1=function e(t,n){var i,r,o,a,s,l,c,h=t[0].length-1,u=[numeric.rep([h+1],0),[],[]],d=[numeric.rep([h+1],0),[],[]],p=u[0],m=u[1],f=u[2],g=d[0],v=d[1],y=d[2],b=numeric.rep([h],0),_=numeric.rep([h],0),x=numeric.ccsLPSolve,w=Math.abs,S=numeric.linspace(0,h-1),C=numeric.linspace(0,h-1),M=new numeric.ccsDFS(h);for(void 0===n&&(n=1),i=0;i<h;++i){for(x(u,t,b,_,i,C,M),a=-1,s=-1,r=_.length-1;-1!==r;--r)(o=_[r])<=i||(l=w(b[o]))>a&&(s=o,a=l);for(w(b[i])<n*a&&(r=S[i],S[i]=a=S[s],C[a]=i,S[s]=r,C[r]=s,a=b[i],b[i]=b[s],b[s]=a),s=g[i],c=b[i],m[a=p[i]]=S[i],f[a]=1,++a,r=_.length-1;-1!==r;--r)l=b[o=_[r]],_[r]=0,b[o]=0,o<=i?(v[s]=o,y[s]=l,++s):(m[a]=S[o],f[a]=l/c,++a);p[i+1]=a,g[i+1]=s}for(r=m.length-1;-1!==r;--r)m[r]=C[m[r]];return{L:u,U:d,P:S,Pinv:C}},numeric.ccsDFS0=function e(t){this.k=Array(t),this.k1=Array(t),this.j=Array(t)},numeric.ccsDFS0.prototype.dfs=function e(t,n,i,r,o,a,s){var l,c,h,u=0,d=o.length,p=this.k,m=this.k1,f=this.j;if(0===r[t])for(r[t]=1,f[0]=t,p[0]=c=n[a[t]],m[0]=h=n[a[t]+1];;){if(isNaN(c))throw new Error("Ow!");if(c>=h){if(o[d]=a[f[u]],0===u)return;++d,c=p[--u],h=m[u]}else 0===r[l=i[c]]?(r[l]=1,p[u]=c,f[++u]=l,c=n[l=a[l]],m[u]=h=n[l+1]):++c}},numeric.ccsLPSolve0=function e(t,n,i,r,o,a,s,l){var c,h,u,d,p,m,f,g,v,y=t[0],b=t[1],_=t[2],x=n[0],w=n[1],S=n[2];for(h=x[o],u=x[o+1],r.length=0,c=h;c<u;++c)l.dfs(w[c],y,b,i,r,a,s);for(c=r.length-1;-1!==c;--c)i[s[d=r[c]]]=0;for(c=h;c!==u;++c)i[d=w[c]]=S[c];for(c=r.length-1;-1!==c;--c){for(g=s[d=r[c]],m=y[d+1],f=p=y[d];f<m;++f)if(b[f]===g){i[g]/=_[f];break}for(v=i[g],f=p;f<m;++f)i[b[f]]-=v*_[f];i[g]=v}},numeric.ccsLUP0=function e(t,n){var i,r,o,a,s,l,c,h=t[0].length-1,u=[numeric.rep([h+1],0),[],[]],d=[numeric.rep([h+1],0),[],[]],p=u[0],m=u[1],f=u[2],g=d[0],v=d[1],y=d[2],b=numeric.rep([h],0),_=numeric.rep([h],0),x=numeric.ccsLPSolve0,w=Math.abs,S=numeric.linspace(0,h-1),C=numeric.linspace(0,h-1),M=new numeric.ccsDFS0(h);for(void 0===n&&(n=1),i=0;i<h;++i){for(x(u,t,b,_,i,C,S,M),a=-1,s=-1,r=_.length-1;-1!==r;--r)(o=_[r])<=i||(l=w(b[S[o]]))>a&&(s=o,a=l);for(w(b[S[i]])<n*a&&(r=S[i],S[i]=a=S[s],C[a]=i,S[s]=r,C[r]=s),s=g[i],c=b[S[i]],m[a=p[i]]=S[i],f[a]=1,++a,r=_.length-1;-1!==r;--r)l=b[S[o=_[r]]],_[r]=0,b[S[o]]=0,o<=i?(v[s]=o,y[s]=l,++s):(m[a]=S[o],f[a]=l/c,++a);p[i+1]=a,g[i+1]=s}for(r=m.length-1;-1!==r;--r)m[r]=C[m[r]];return{L:u,U:d,P:S,Pinv:C}},numeric.ccsLUP=numeric.ccsLUP0,numeric.ccsDim=function e(t){return[numeric.sup(t[1])+1,t[0].length-1]},numeric.ccsGetBlock=function e(t,n,i){var r=numeric.ccsDim(t),o=r[0],a=r[1];void 0===n?n=numeric.linspace(0,o-1):"number"==typeof n&&(n=[n]),void 0===i?i=numeric.linspace(0,a-1):"number"==typeof i&&(i=[i]);var s,l,c,h,u=n.length,d=i.length,p=numeric.rep([a],0),m=[],f=[],g=[p,m,f],v=t[0],y=t[1],b=t[2],_=numeric.rep([o],0),x=0,w=numeric.rep([o],0);for(l=0;l<d;++l){var S=v[h=i[l]],C=v[h+1];for(s=S;s<C;++s)w[c=y[s]]=1,_[c]=b[s];for(s=0;s<u;++s)w[n[s]]&&(m[x]=s,f[x]=_[n[s]],++x);for(s=S;s<C;++s)w[c=y[s]]=0;p[l+1]=x}return g},numeric.ccsDot=function e(t,n){var i,r,o,a,s,l,c,h,u,d,p=t[0],m=t[1],f=t[2],g=n[0],v=n[1],y=n[2],b=numeric.ccsDim(t),_=numeric.ccsDim(n),x=b[0],w=_[1],S=numeric.rep([x],0),C=numeric.rep([x],0),M=Array(x),E=numeric.rep([w],0),T=[],I=[],A=[E,T,I];for(o=0;o!==w;++o){for(s=g[o+1],h=0,r=g[o];r<s;++r)for(d=y[r],l=p[(u=v[r])+1],i=p[u];i<l;++i)0===C[c=m[i]]&&(M[h]=c,C[c]=1,h+=1),S[c]=S[c]+f[i]*d;for(E[o+1]=s=(a=E[o])+h,r=h-1;-1!==r;--r)T[d=a+r]=i=M[r],I[d]=S[i],C[i]=0,S[i]=0;E[o+1]=E[o]+h}return A},numeric.ccsLUPSolve=function e(t,n){var i=t.L,r=t.U,o=n[0],a=!1;"object"!=typeof o&&(o=(n=[[0,n.length],numeric.linspace(0,n.length-1),n])[0],a=!0);var s,l,c,h,u,d=n[1],p=n[2],m=i[0].length-1,f=o.length-1,g=numeric.rep([m],0),v=Array(m),y=numeric.rep([m],0),b=Array(m),_=numeric.rep([f+1],0),x=[],w=[],S=numeric.ccsTSolve,C=0;for(s=0;s<f;++s){for(h=0,c=o[s+1],l=o[s];l<c;++l)b[h]=u=t.Pinv[d[l]],y[u]=p[l],++h;for(b.length=h,S(i,y,g,b,v),l=b.length-1;-1!==l;--l)y[b[l]]=0;if(S(r,g,y,v,b),a)return y;for(l=v.length-1;-1!==l;--l)g[v[l]]=0;for(l=b.length-1;-1!==l;--l)x[C]=u=b[l],w[C]=y[u],y[u]=0,++C;_[s+1]=C}return[_,x,w]},numeric.ccsbinop=function e(t,n){return void 0===n&&(n=""),Function("X","Y","var Xi = X[0], Xj = X[1], Xv = X[2];\nvar Yi = Y[0], Yj = Y[1], Yv = Y[2];\nvar n = Xi.length-1,m = Math.max(numeric.sup(Xj),numeric.sup(Yj))+1;\nvar Zi = numeric.rep([n+1],0), Zj = [], Zv = [];\nvar x = numeric.rep([m],0),y = numeric.rep([m],0);\nvar xk,yk,zk;\nvar i,j,j0,j1,k,p=0;\n"+n+"for(i=0;i<n;++i) {\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Xj[j];\n x[k] = 1;\n Zj[p] = k;\n ++p;\n }\n j0 = Yi[i]; j1 = Yi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Yj[j];\n y[k] = Yv[j];\n if(x[k] === 0) {\n Zj[p] = k;\n ++p;\n }\n }\n Zi[i+1] = p;\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) x[Xj[j]] = Xv[j];\n j0 = Zi[i]; j1 = Zi[i+1];\n for(j=j0;j!==j1;++j) {\n k = Zj[j];\n xk = x[k];\n yk = y[k];\n"+t+"\n Zv[j] = zk;\n }\n j0 = Xi[i]; j1 = Xi[i+1];\n for(j=j0;j!==j1;++j) x[Xj[j]] = 0;\n j0 = Yi[i]; j1 = Yi[i+1];\n for(j=j0;j!==j1;++j) y[Yj[j]] = 0;\n}\nreturn [Zi,Zj,Zv];")},(function(){var k,A,B,C;for(k in numeric.ops2)A=isFinite(eval("1"+numeric.ops2[k]+"0"))?"[Y[0],Y[1],numeric."+k+"(X,Y[2])]":"NaN",B=isFinite(eval("0"+numeric.ops2[k]+"1"))?"[X[0],X[1],numeric."+k+"(X[2],Y)]":"NaN",C=isFinite(eval("1"+numeric.ops2[k]+"0"))&&isFinite(eval("0"+numeric.ops2[k]+"1"))?"numeric.ccs"+k+"MM(X,Y)":"NaN",numeric["ccs"+k+"MM"]=numeric.ccsbinop("zk = xk "+numeric.ops2[k]+"yk;"),numeric["ccs"+k]=Function("X","Y",'if(typeof X === "number") return '+A+';\nif(typeof Y === "number") return '+B+";\nreturn "+C+";\n")})(),numeric.ccsScatter=function e(t){var n,i=t[0],r=t[1],o=t[2],a=numeric.sup(r)+1,s=i.length,l=numeric.rep([a],0),c=Array(s),h=Array(s),u=numeric.rep([a],0);for(n=0;n<s;++n)u[r[n]]++;for(n=0;n<a;++n)l[n+1]=l[n]+u[n];var d,p,m=l.slice(0);for(n=0;n<s;++n)c[d=m[p=r[n]]]=i[n],h[d]=o[n],m[p]=m[p]+1;return[l,c,h]},numeric.ccsGather=function e(t){var n,i,r,o,a=t[0],s=t[1],l=t[2],c=a.length-1,h=s.length,u=Array(h),d=Array(h),p=Array(h);for(o=0,n=0;n<c;++n)for(r=a[n+1],i=a[n];i!==r;++i)d[o]=n,u[o]=s[i],p[o]=l[i],++o;return[u,d,p]},numeric.sdim=function e(t,n,i){if(void 0===n&&(n=[]),"object"!=typeof t)return n;var r;for(r in void 0===i&&(i=0),i in n||(n[i]=0),t.length>n[i]&&(n[i]=t.length),t)t.hasOwnProperty(r)&&e(t[r],n,i+1);return n},numeric.sclone=function e(t,n,i){void 0===n&&(n=0),void 0===i&&(i=numeric.sdim(t).length);var r,o=Array(t.length);if(n===i-1){for(r in t)t.hasOwnProperty(r)&&(o[r]=t[r]);return o}for(r in t)t.hasOwnProperty(r)&&(o[r]=e(t[r],n+1,i));return o},numeric.sdiag=function e(t){var n,i,r=t.length,o=Array(r);for(n=r-1;n>=1;n-=2)i=n-1,o[n]=[],o[n][n]=t[n],o[i]=[],o[i][i]=t[i];return 0===n&&(o[0]=[],o[0][0]=t[n]),o},numeric.sidentity=function e(t){return numeric.sdiag(numeric.rep([t],1))},numeric.stranspose=function e(t){var n,i,r,o=[];for(n in t)if(t.hasOwnProperty(n))for(i in r=t[n])r.hasOwnProperty(i)&&("object"!=typeof o[i]&&(o[i]=[]),o[i][n]=r[i]);return o},numeric.sLUP=function e(t,n){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function e(t,n){var i,r,o,a,s,l,c,h=t.length,u=numeric.stranspose(n),d=u.length,p=Array(h);for(o=h-1;o>=0;o--){for(c=[],i=t[o],s=d-1;s>=0;s--){for(a in l=0,r=u[s],i)i.hasOwnProperty(a)&&a in r&&(l+=i[a]*r[a]);l&&(c[s]=l)}p[o]=c}return p},numeric.sdotMV=function e(t,n){var i,r,o,a,s=t.length,l=Array(s);for(r=s-1;r>=0;r--){for(o in a=0,i=t[r])i.hasOwnProperty(o)&&n[o]&&(a+=i[o]*n[o]);a&&(l[r]=a)}return l},numeric.sdotVM=function e(t,n){var i,r,o,a,s=[];for(i in t)if(t.hasOwnProperty(i))for(r in a=t[i],o=n[i])o.hasOwnProperty(r)&&(s[r]||(s[r]=0),s[r]+=a*o[r]);return s},numeric.sdotVV=function e(t,n){var i,r=0;for(i in t)t[i]&&n[i]&&(r+=t[i]*n[i]);return r},numeric.sdot=function e(t,n){var i=numeric.sdim(t).length,r=numeric.sdim(n).length;switch(1e3*i+r){case 0:return t*n;case 1001:return numeric.sdotVV(t,n);case 2001:return numeric.sdotMV(t,n);case 1002:return numeric.sdotVM(t,n);case 2002:return numeric.sdotMM(t,n);default:throw new Error("numeric.sdot not implemented for tensors of order "+i+" and "+r)}},numeric.sscatter=function e(t){var n,i,r,o,a=t.length,s=[];for(i=t[0].length-1;i>=0;--i)if(t[a-1][i]){for(o=s,r=0;r<a-2;r++)o[n=t[r][i]]||(o[n]=[]),o=o[n];o[t[r][i]]=t[r+1][i]}return s},numeric.sgather=function e(t,n,i){var r,o,a;for(o in void 0===n&&(n=[]),void 0===i&&(i=[]),r=i.length,t)if(t.hasOwnProperty(o))if(i[r]=parseInt(o),"number"==typeof(a=t[o])){if(a){if(0===n.length)for(o=r+1;o>=0;--o)n[o]=[];for(o=r;o>=0;--o)n[o].push(i[o]);n[r+1].push(a)}}else e(a,n,i);return i.length>r&&i.pop(),n},numeric.cLU=function e(t){var n,i,r,o,a,s,l=t[0],c=t[1],h=t[2],u=l.length,d=0;for(n=0;n<u;n++)l[n]>d&&(d=l[n]);d++;var p,m=Array(d),f=Array(d),g=numeric.rep([d],1/0),v=numeric.rep([d],-1/0);for(r=0;r<u;r++)(i=c[r])<g[n=l[r]]&&(g[n]=i),i>v[n]&&(v[n]=i);for(n=0;n<d-1;n++)v[n]>v[n+1]&&(v[n+1]=v[n]);for(n=d-1;n>=1;n--)g[n]<g[n-1]&&(g[n-1]=g[n]);for(n=0;n<d;n++)f[n]=numeric.rep([v[n]-g[n]+1],0),m[n]=numeric.rep([n-g[n]],0);for(r=0;r<u;r++)f[n=l[r]][c[r]-g[n]]=h[r];for(n=0;n<d-1;n++)for(o=n-g[n],_=f[n],i=n+1;g[i]<=n&&i<d;i++)if(s=v[n]-n,p=(x=f[i])[a=n-g[i]]/_[o]){for(r=1;r<=s;r++)x[r+a]-=p*_[r+o];m[i][n-g[i]]=p}var y,b,_=[],x=[],w=[],S=[],C=[],M=[];for(u=0,y=0,n=0;n<d;n++){for(o=g[n],a=v[n],b=f[n],i=n;i<=a;i++)b[i-o]&&(_[u]=n,x[u]=i,w[u]=b[i-o],u++);for(b=m[n],i=o;i<n;i++)b[i-o]&&(S[y]=n,C[y]=i,M[y]=b[i-o],y++);S[y]=n,C[y]=n,M[y]=1,y++}return{U:[_,x,w],L:[S,C,M]}},numeric.cLUsolve=function e(t,n){var i,r,o=t.L,a=t.U,s=numeric.clone(n),l=o[1],c=o[2],h=a[1],u=a[2],d=a[0].length,p=s.length;for(r=0,i=0;i<p;i++){for(;l[r]<i;)s[i]-=c[r]*s[l[r]],r++;r++}for(r=d-1,i=p-1;i>=0;i--){for(;h[r]>i;)s[i]-=u[r]*s[h[r]],r--;s[i]/=u[r],r--}return s},numeric.cgrid=function e(t,n){"number"==typeof t&&(t=[t,t]);var i,r,o,a=numeric.rep(t,-1);if("function"!=typeof n)switch(n){case"L":n=function(e,n){return e>=t[0]/2||n<t[1]/2};break;default:n=function(e,t){return!0}}for(o=0,i=1;i<t[0]-1;i++)for(r=1;r<t[1]-1;r++)n(i,r)&&(a[i][r]=o,o++);return a},numeric.cdelsq=function e(t){var n,i,r,o,a,s=[[-1,0],[0,-1],[0,1],[1,0]],l=numeric.dim(t),c=l[0],h=l[1],u=[],d=[],p=[];for(n=1;n<c-1;n++)for(i=1;i<h-1;i++)if(!(t[n][i]<0)){for(r=0;r<4;r++)t[o=n+s[r][0]][a=i+s[r][1]]<0||(u.push(t[n][i]),d.push(t[o][a]),p.push(-1));u.push(t[n][i]),d.push(t[n][i]),p.push(4)}return[u,d,p]},numeric.cdotMV=function e(t,n){var i,r,o,a=t[0],s=t[1],l=t[2],c=a.length;for(o=0,r=0;r<c;r++)a[r]>o&&(o=a[r]);for(o++,i=numeric.rep([o],0),r=0;r<c;r++)i[a[r]]+=l[r]*n[s[r]];return i},numeric.Spline=function e(t,n,i,r,o){this.x=t,this.yl=n,this.yr=i,this.kl=r,this.kr=o},numeric.Spline.prototype._at=function e(t,n){var i,r,o,a=this.x,s=this.yl,l=this.yr,c=this.kr,h=numeric.add,u=numeric.sub,d=numeric.mul;i=u(d(this.kl[n],a[n+1]-a[n]),u(l[n+1],s[n])),r=h(d(c[n+1],a[n]-a[n+1]),u(l[n+1],s[n]));var p=(o=(t-a[n])/(a[n+1]-a[n]))*(1-o);return h(h(h(d(1-o,s[n]),d(o,l[n+1])),d(i,p*(1-o))),d(r,p*o))},numeric.Spline.prototype.at=function e(t){if("number"==typeof t){var n,i,r,o=this.x,a=o.length,s=Math.floor;for(n=0,i=a-1;i-n>1;)o[r=s((n+i)/2)]<=t?n=r:i=r;return this._at(t,n)}a=t.length;var l,c=Array(a);for(l=a-1;-1!==l;--l)c[l]=this.at(t[l]);return c},numeric.Spline.prototype.diff=function e(){var t,n,i,r=this.x,o=this.yl,a=this.yr,s=this.kl,l=this.kr,c=o.length,h=s,u=l,d=Array(c),p=Array(c),m=numeric.add,f=numeric.mul,g=numeric.div,v=numeric.sub;for(t=c-1;-1!==t;--t)n=r[t+1]-r[t],i=v(a[t+1],o[t]),d[t]=g(m(f(i,6),f(s[t],-4*n),f(l[t+1],-2*n)),n*n),p[t+1]=g(m(f(i,-6),f(s[t],2*n),f(l[t+1],4*n)),n*n);return new numeric.Spline(r,h,u,d,p)},numeric.Spline.prototype.roots=function e(){function t(e){return e*e}var n=[],i=this.x,r=this.yl,o=this.yr,a=this.kl,s=this.kr;"number"==typeof r[0]&&(r=[r],o=[o],a=[a],s=[s]);var l,c,h,u,d,p,m,f,g,v,y,b,_,x,w,S,C,M,E,T,I,A,k,P=r.length,R=i.length-1,L=(n=Array(P),Math.sqrt);for(l=0;l!==P;++l){for(u=r[l],d=o[l],p=a[l],m=s[l],f=[],c=0;c!==R;c++){for(c>0&&d[c]*u[c]<0&&f.push(i[c]),_=(v=m[c+1]/(S=i[c+1]-i[c]))+3*(y=u[c])+2*(g=p[c]/S)-3*(b=d[c+1]),x=3*(v+g+2*(y-b)),(w=t(g-v+3*(y-b))+12*v*y)<=0?C=(M=_/x)>i[c]&&M<i[c+1]?[i[c],M,i[c+1]]:[i[c],i[c+1]]:(M=(_-L(w))/x,E=(_+L(w))/x,C=[i[c]],M>i[c]&&M<i[c+1]&&C.push(M),E>i[c]&&E<i[c+1]&&C.push(E),C.push(i[c+1])),M=this._at(I=C[0],c),h=0;h<C.length-1;h++)if(E=this._at(A=C[h+1],c),0!==M)if(0===E||M*E>0)I=A,M=E;else{for(var N=0;!((k=(M*A-E*I)/(M-E))<=I||k>=A);)if((T=this._at(k,c))*E>0)A=k,E=T,-1===N&&(M*=.5),N=-1;else{if(!(T*M>0))break;I=k,M=T,1===N&&(E*=.5),N=1}f.push(k),M=this._at(I=C[h+1],c)}else f.push(I),I=A,M=E;0===E&&f.push(A)}n[l]=f}return"number"==typeof this.yl[0]?n[0]:n},numeric.spline=function e(t,n,i,r){var o,a=t.length,s=[],l=[],c=[],h=numeric.sub,u=numeric.mul,d=numeric.add;for(o=a-2;o>=0;o--)l[o]=t[o+1]-t[o],c[o]=h(n[o+1],n[o]);"string"!=typeof i&&"string"!=typeof r||(i=r="periodic");var p=[[],[],[]];switch(typeof i){case"undefined":s[0]=u(3/(l[0]*l[0]),c[0]),p[0].push(0,0),p[1].push(0,1),p[2].push(2/l[0],1/l[0]);break;case"string":s[0]=d(u(3/(l[a-2]*l[a-2]),c[a-2]),u(3/(l[0]*l[0]),c[0])),p[0].push(0,0,0),p[1].push(a-2,0,1),p[2].push(1/l[a-2],2/l[a-2]+2/l[0],1/l[0]);break;default:s[0]=i,p[0].push(0),p[1].push(0),p[2].push(1)}for(o=1;o<a-1;o++)s[o]=d(u(3/(l[o-1]*l[o-1]),c[o-1]),u(3/(l[o]*l[o]),c[o])),p[0].push(o,o,o),p[1].push(o-1,o,o+1),p[2].push(1/l[o-1],2/l[o-1]+2/l[o],1/l[o]);switch(typeof r){case"undefined":s[a-1]=u(3/(l[a-2]*l[a-2]),c[a-2]),p[0].push(a-1,a-1),p[1].push(a-2,a-1),p[2].push(1/l[a-2],2/l[a-2]);break;case"string":p[1][p[1].length-1]=0;break;default:s[a-1]=r,p[0].push(a-1),p[1].push(a-1),p[2].push(1)}s="number"!=typeof s[0]?numeric.transpose(s):[s];var m=Array(s.length);if("string"==typeof i)for(o=m.length-1;-1!==o;--o)m[o]=numeric.ccsLUPSolve(numeric.ccsLUP(numeric.ccsScatter(p)),s[o]),m[o][a-1]=m[o][0];else for(o=m.length-1;-1!==o;--o)m[o]=numeric.cLUsolve(numeric.cLU(p),s[o]);return m="number"==typeof n[0]?m[0]:numeric.transpose(m),new numeric.Spline(t,n,n,m,m)},numeric.fftpow2=function e(t,n){var i=t.length;if(1!==i){var r,o,a=Math.cos,s=Math.sin,l=Array(i/2),c=Array(i/2),h=Array(i/2),u=Array(i/2);for(o=i/2,r=i-1;-1!==r;--r)h[--o]=t[r],u[o]=n[r],--r,l[o]=t[r],c[o]=n[r];e(l,c),e(h,u),o=i/2;var d,p,m,f=-6.283185307179586/i;for(r=i-1;-1!==r;--r)-1==--o&&(o=i/2-1),p=a(d=f*r),m=s(d),t[r]=l[o]+p*h[o]-m*u[o],n[r]=c[o]+p*u[o]+m*h[o]}},numeric._ifftpow2=function e(t,n){var i=t.length;if(1!==i){var r,o,a=Math.cos,s=Math.sin,l=Array(i/2),c=Array(i/2),h=Array(i/2),u=Array(i/2);for(o=i/2,r=i-1;-1!==r;--r)h[--o]=t[r],u[o]=n[r],--r,l[o]=t[r],c[o]=n[r];e(l,c),e(h,u),o=i/2;var d,p,m,f=6.283185307179586/i;for(r=i-1;-1!==r;--r)-1==--o&&(o=i/2-1),p=a(d=f*r),m=s(d),t[r]=l[o]+p*h[o]-m*u[o],n[r]=c[o]+p*u[o]+m*h[o]}},numeric.ifftpow2=function e(t,n){numeric._ifftpow2(t,n),numeric.diveq(t,t.length),numeric.diveq(n,n.length)},numeric.convpow2=function e(t,n,i,r){var o,a,s,l,c;for(numeric.fftpow2(t,n),numeric.fftpow2(i,r),o=t.length-1;-1!==o;--o)t[o]=(a=t[o])*(s=i[o])-(l=n[o])*(c=r[o]),n[o]=a*c+l*s;numeric.ifftpow2(t,n)},numeric.T.prototype.fft=function e(){var t,n,i=this.x,r=this.y,o=i.length,a=Math.log,s=a(2),l=Math.ceil(a(2*o-1)/s),c=Math.pow(2,l),h=numeric.rep([c],0),u=numeric.rep([c],0),d=Math.cos,p=Math.sin,m=-3.141592653589793/o,f=numeric.rep([c],0),g=numeric.rep([c],0);for(t=0;t<o;t++)f[t]=i[t];if(void 0!==r)for(t=0;t<o;t++)g[t]=r[t];for(h[0]=1,t=1;t<=c/2;t++)h[t]=d(n=m*t*t),u[t]=p(n),h[c-t]=d(n),u[c-t]=p(n);var v=new numeric.T(f,g),y=new numeric.T(h,u);return v=v.mul(y),numeric.convpow2(v.x,v.y,numeric.clone(y.x),numeric.neg(y.y)),(v=v.mul(y)).x.length=o,v.y.length=o,v},numeric.T.prototype.ifft=function e(){var t,n,i=this.x,r=this.y,o=i.length,a=Math.log,s=a(2),l=Math.ceil(a(2*o-1)/s),c=Math.pow(2,l),h=numeric.rep([c],0),u=numeric.rep([c],0),d=Math.cos,p=Math.sin,m=3.141592653589793/o,f=numeric.rep([c],0),g=numeric.rep([c],0);for(t=0;t<o;t++)f[t]=i[t];if(void 0!==r)for(t=0;t<o;t++)g[t]=r[t];for(h[0]=1,t=1;t<=c/2;t++)h[t]=d(n=m*t*t),u[t]=p(n),h[c-t]=d(n),u[c-t]=p(n);var v=new numeric.T(f,g),y=new numeric.T(h,u);return v=v.mul(y),numeric.convpow2(v.x,v.y,numeric.clone(y.x),numeric.neg(y.y)),(v=v.mul(y)).x.length=o,v.y.length=o,v.div(o)},numeric.gradient=function e(t,n){var i=n.length,r=t(n);if(isNaN(r))throw new Error("gradient: f(x) is a NaN!");var o,a,s,l,c,h,u,d,p,m=Math.max,f=numeric.clone(n),g=Array(i),v=(m=Math.max,Math.abs),y=Math.min,b=0;for(o=0;o<i;o++)for(var _=m(1e-6*r,1e-8);;){if(++b>20)throw new Error("Numerical gradient fails");if(f[o]=n[o]+_,a=t(f),f[o]=n[o]-_,s=t(f),f[o]=n[o],isNaN(a)||isNaN(s))_/=16;else{if(g[o]=(a-s)/(2*_),l=n[o]-_,c=n[o],h=n[o]+_,u=(a-r)/_,d=(r-s)/_,p=m(v(g[o]),v(r),v(a),v(s),v(l),v(c),v(h),1e-8),!(y(m(v(u-g[o]),v(d-g[o]),v(u-d))/p,_/p)>.001))break;_/=16}}return g},numeric.uncmin=function e(t,n,i,r,o,a,s){var l=numeric.gradient;void 0===s&&(s={}),void 0===i&&(i=1e-8),void 0===r&&(r=function(e){return l(t,e)}),void 0===o&&(o=1e3);var c,h,u=(n=numeric.clone(n)).length,d=t(n);if(isNaN(d))throw new Error("uncmin: f(x0) is a NaN!");var p=Math.max,m=numeric.norm2;i=p(i,numeric.epsilon);var f,g,v,y,b,_,x,w,S,C,M=s.Hinv||numeric.identity(u),E=numeric.dot,T=numeric.sub,I=numeric.add,A=numeric.tensor,k=numeric.div,P=numeric.mul,R=numeric.all,L=numeric.isFinite,N=numeric.neg,D=0,O="";for(g=r(n);D<o;){if("function"==typeof a&&a(D,n,d,g,M)){O="Callback returned true";break}if(!R(L(g))){O="Gradient has Infinity or NaN";break}if(!R(L(f=N(E(M,g))))){O="Search direction has Infinity or NaN";break}if((C=m(f))<i){O="Newton step smaller than tol";break}for(S=1,h=E(g,f),b=n;D<o&&!(S*C<i)&&(b=I(n,y=P(f,S)),(c=t(b))-d>=.1*S*h||isNaN(c));)S*=.5,++D;if(S*C<i){O="Line search step size smaller than tol";break}if(D===o){O="maxit reached during line search";break}w=E(_=T(v=r(b),g),y),x=E(M,_),M=T(I(M,P((w+E(_,x))/(w*w),A(y,y))),k(I(A(x,y),A(y,x)),w)),n=b,d=c,g=v,++D}return{solution:n,f:d,gradient:g,invHessian:M,iterations:D,message:O}},numeric.Dopri=function e(t,n,i,r,o,a,s){this.x=t,this.y=n,this.f=i,this.ymid=r,this.iterations=o,this.events=s,this.message=a},numeric.Dopri.prototype._at=function e(t,n){function i(e){return e*e}var r,o,a,s,l,c,h,u,d,p=this,m=p.x,f=p.y,g=p.f,v=numeric.add,y=numeric.mul,b=numeric.sub;return l=f[n+1],c=p.ymid[n],h=b(g[n],y(s=f[n],1/((r=m[n])-(a=r+.5*((o=m[n+1])-r)))+2/(r-o))),u=b(g[n+1],y(l,1/(o-a)+2/(o-r))),v(v(v(v(y(s,(d=[i(t-o)*(t-a)/i(r-o)/(r-a),i(t-r)*i(t-o)/i(r-a)/i(o-a),i(t-r)*(t-a)/i(o-r)/(o-a),(t-r)*i(t-o)*(t-a)/i(r-o)/(r-a),(t-o)*i(t-r)*(t-a)/i(r-o)/(o-a)])[0]),y(c,d[1])),y(l,d[2])),y(h,d[3])),y(u,d[4]))},numeric.Dopri.prototype.at=function e(t){var n,i,r,o=Math.floor;if("number"!=typeof t){var a=t.length,s=Array(a);for(n=a-1;-1!==n;--n)s[n]=this.at(t[n]);return s}var l=this.x;for(n=0,i=l.length-1;i-n>1;)l[r=o(.5*(n+i))]<=t?n=r:i=r;return this._at(t,n)},numeric.dopri=function e(t,n,i,r,o,a,s){void 0===o&&(o=1e-6),void 0===a&&(a=1e3);var l,c,h,u,d,p,m,f,g,v,y,b,_,x=[t],w=[i],S=[r(t,i)],C=[],M=[3/40,9/40],E=[44/45,-56/15,32/9],T=[19372/6561,-25360/2187,64448/6561,-212/729],I=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],A=[35/384,0,500/1113,125/192,-2187/6784,11/84],k=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,5618549.5/235043384],P=[.2,.3,.8,8/9,1,1],R=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,1/40],L=0,N=(n-t)/10,D=0,O=numeric.add,z=numeric.mul,F=Math.min,$=Math.abs,B=numeric.norminf,V=Math.pow,H=numeric.any,U=numeric.lt,G=numeric.and,j=new numeric.Dopri(x,w,S,C,-1,"");for("function"==typeof s&&(y=s(t,i));t<n&&D<a;)if(++D,t+N>n&&(N=n-t),l=r(t+P[0]*N,O(i,z(.2*N,S[L]))),c=r(t+P[1]*N,O(O(i,z(M[0]*N,S[L])),z(M[1]*N,l))),h=r(t+P[2]*N,O(O(O(i,z(E[0]*N,S[L])),z(E[1]*N,l)),z(E[2]*N,c))),u=r(t+P[3]*N,O(O(O(O(i,z(T[0]*N,S[L])),z(T[1]*N,l)),z(T[2]*N,c)),z(T[3]*N,h))),d=r(t+P[4]*N,O(O(O(O(O(i,z(I[0]*N,S[L])),z(I[1]*N,l)),z(I[2]*N,c)),z(I[3]*N,h)),z(I[4]*N,u))),p=r(t+N,g=O(O(O(O(O(i,z(S[L],N*A[0])),z(c,N*A[2])),z(h,N*A[3])),z(u,N*A[4])),z(d,N*A[5]))),(v="number"==typeof(m=O(O(O(O(O(z(S[L],N*R[0]),z(c,N*R[2])),z(h,N*R[3])),z(u,N*R[4])),z(d,N*R[5])),z(p,N*R[6])))?$(m):B(m))>o){if(t+(N=.2*N*V(o/v,.25))===t){j.msg="Step size became too small";break}}else{if(C[L]=O(O(O(O(O(O(i,z(S[L],N*k[0])),z(c,N*k[2])),z(h,N*k[3])),z(u,N*k[4])),z(d,N*k[5])),z(p,N*k[6])),x[++L]=t+N,w[L]=g,S[L]=p,"function"==typeof s){var W,q,X=t,K=t+.5*N;if(b=s(K,C[L-1]),H(_=G(U(y,0),U(0,b)))||(X=K,y=b,b=s(K=t+N,g),_=G(U(y,0),U(0,b))),H(_)){for(var Y,Z,J=0,Q=1,ee=1;;){if("number"==typeof y)q=(ee*b*X-Q*y*K)/(ee*b-Q*y);else for(q=K,f=y.length-1;-1!==f;--f)y[f]<0&&b[f]>0&&(q=F(q,(ee*b[f]*X-Q*y[f]*K)/(ee*b[f]-Q*y[f])));if(q<=X||q>=K)break;Z=s(q,W=j._at(q,L-1)),H(Y=G(U(y,0),U(0,Z)))?(K=q,b=Z,_=Y,ee=1,-1===J?Q*=.5:Q=1,J=-1):(X=q,y=Z,Q=1,1===J?ee*=.5:ee=1,J=1)}return g=j._at(.5*(t+q),L-1),j.f[L]=r(q,W),j.x[L]=q,j.y[L]=W,j.ymid[L-1]=g,j.events=_,j.iterations=D,j}}t+=N,i=g,y=b,N=F(.8*N*V(o/v,.25),4*N)}return j.iterations=D,j},numeric.LU=function(e,t){t=t||!1;var n,i,r,o,a,s,l,c,h,u=Math.abs,d=e.length,p=d-1,m=new Array(d);for(t||(e=numeric.clone(e)),r=0;r<d;++r){for(l=r,h=u((s=e[r])[r]),i=r+1;i<d;++i)h<(o=u(e[i][r]))&&(h=o,l=i);for(m[r]=l,l!=r&&(e[r]=e[l],e[l]=s,s=e[r]),a=s[r],n=r+1;n<d;++n)e[n][r]/=a;for(n=r+1;n<d;++n){for(c=e[n],i=r+1;i<p;++i)c[i]-=c[r]*s[i],c[++i]-=c[r]*s[i];i===p&&(c[i]-=c[r]*s[i])}}return{LU:e,P:m}},numeric.LUsolve=function e(t,n){var i,r,o,a,s,l=t.LU,c=l.length,h=numeric.clone(n),u=t.P;for(i=c-1;-1!==i;--i)h[i]=n[i];for(i=0;i<c;++i)for(o=u[i],u[i]!==i&&(s=h[i],h[i]=h[o],h[o]=s),a=l[i],r=0;r<i;++r)h[i]-=h[r]*a[r];for(i=c-1;i>=0;--i){for(a=l[i],r=i+1;r<c;++r)h[i]-=h[r]*a[r];h[i]/=a[i]}return h},numeric.solve=function e(t,n,i){return numeric.LUsolve(numeric.LU(t,i),n)},numeric.echelonize=function e(t){var n,i,r,o,a,s,l,c,h=numeric.dim(t),u=h[0],d=h[1],p=numeric.identity(u),m=Array(u),f=Math.abs,g=numeric.diveq;for(t=numeric.clone(t),n=0;n<u;++n){for(r=0,a=t[n],s=p[n],i=1;i<d;++i)f(a[r])<f(a[i])&&(r=i);for(m[n]=r,g(s,a[r]),g(a,a[r]),i=0;i<u;++i)if(i!==n){for(c=(l=t[i])[r],o=d-1;-1!==o;--o)l[o]-=a[o]*c;for(l=p[i],o=u-1;-1!==o;--o)l[o]-=s[o]*c}}return{I:p,A:t,P:m}},numeric.__solveLP=function e(t,n,i,r,o,a,s){var l,c=numeric.sum,h=numeric.mul,u=numeric.sub,d=numeric.dot,p=numeric.div,m=numeric.add,f=t.length,g=i.length,v=!1,y=1;numeric.transpose(n);var b,_=numeric.transpose,x=Math.sqrt,w=Math.abs,S=Math.min,C=numeric.all,M=numeric.gt,E=Array(f),T=Array(g);numeric.rep([g],1);var I,A,k=numeric.solve,P=u(i,d(n,a)),R=d(t,t);for(I=0;I<o;++I){var L,N;for(L=g-1;-1!==L;--L)T[L]=p(n[L],P[L]);var D=_(T);for(L=f-1;-1!==L;--L)E[L]=c(D[L]);y=.25*w(R/d(t,E));var O=100*x(R/d(E,E));for((!isFinite(y)||y>O)&&(y=O),A=m(t,h(y,E)),b=d(D,T),L=f-1;-1!==L;--L)b[L][L]+=1;N=k(b,p(A,y),!0);var z=p(P,d(n,N)),F=1;for(L=g-1;-1!==L;--L)z[L]<0&&(F=S(F,-.999*z[L]));if(l=u(a,h(N,F)),!C(M(P=u(i,d(n,l)),0)))return{solution:a,message:"",iterations:I};if(a=l,y<r)return{solution:l,message:"",iterations:I};if(s){var $=d(t,A),B=d(n,A);for(v=!0,L=g-1;-1!==L;--L)if($*B[L]<0){v=!1;break}}else v=!(a[f-1]>=0);if(v)return{solution:l,message:"Unbounded",iterations:I}}return{solution:a,message:"maximum iteration count exceeded",iterations:I}},numeric._solveLP=function e(t,n,i,r,o){var a=t.length,s=i.length,l=numeric.sub,c=numeric.dot,h=numeric.rep([a],0).concat([1]),u=numeric.rep([s,1],-1),d=numeric.blockMatrix([[n,u]]),p=i,m=numeric.rep([a],0).concat(Math.max(0,numeric.sup(numeric.neg(i)))+1),f=numeric.__solveLP(h,d,p,r,o,m,!1),g=numeric.clone(f.solution);if(g.length=a,numeric.inf(l(i,c(n,g)))<0)return{solution:NaN,message:"Infeasible",iterations:f.iterations};var v=numeric.__solveLP(t,n,i,r,o-f.iterations,g,!0);return v.iterations+=f.iterations,v},numeric.solveLP=function e(t,n,i,r,o,a,s){if(void 0===s&&(s=1e3),void 0===a&&(a=numeric.epsilon),void 0===r)return numeric._solveLP(t,n,i,a,s);var l,c=r.length,h=r[0].length,u=n.length,d=numeric.echelonize(r),p=numeric.rep([h],0),m=d.P,f=[];for(l=m.length-1;-1!==l;--l)p[m[l]]=1;for(l=h-1;-1!==l;--l)0===p[l]&&f.push(l);var g=numeric.getRange,v=numeric.linspace(0,c-1),y=numeric.linspace(0,u-1),b=g(r,v,f),_=g(n,y,m),x=g(n,y,f),w=numeric.dot,S=numeric.sub,C=w(_,d.I),M=S(x,w(C,b)),E=S(i,w(C,o)),T=Array(m.length),I=Array(f.length);for(l=m.length-1;-1!==l;--l)T[l]=t[m[l]];for(l=f.length-1;-1!==l;--l)I[l]=t[f[l]];var A=S(I,w(T,w(d.I,b))),k=numeric._solveLP(A,M,E,a,s),P=k.solution;if(P!=P)return k;var R=w(d.I,S(o,w(b,P))),L=Array(t.length);for(l=m.length-1;-1!==l;--l)L[m[l]]=R[l];for(l=f.length-1;-1!==l;--l)L[f[l]]=P[l];return{solution:L,message:k.message,iterations:k.iterations}},numeric.MPStoLP=function e(t){t instanceof String&&t.split("\n");var n,i,r,o,a=0,s=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],l=t.length,c=0,h={},u=[],d=0,p={},m=0,f=[],g=[],v=[];function y(e){throw new Error("MPStoLP: "+e+"\nLine "+n+": "+t[n]+"\nCurrent state: "+s[a]+"\n")}for(n=0;n<l;++n){var b=(r=t[n]).match(/\S*/g),_=[];for(i=0;i<b.length;++i)""!==b[i]&&_.push(b[i]);if(0!==_.length){for(i=0;i<s.length&&r.substr(0,s[i].length)!==s[i];++i);if(i<s.length){if(a=i,1===i&&(o=_[1]),6===i)return{name:o,c:f,A:numeric.transpose(g),b:v,rows:h,vars:p}}else switch(a){case 0:case 1:y("Unexpected line");case 2:switch(_[0]){case"N":0===c?c=_[1]:y("Two or more N rows");break;case"L":h[_[1]]=d,u[d]=1,v[d]=0,++d;break;case"G":h[_[1]]=d,u[d]=-1,v[d]=0,++d;break;case"E":h[_[1]]=d,u[d]=0,v[d]=0,++d;break;default:y("Parse error "+numeric.prettyPrint(_))}break;case 3:p.hasOwnProperty(_[0])||(p[_[0]]=m,f[m]=0,g[m]=numeric.rep([d],0),++m);var x=p[_[0]];for(i=1;i<_.length;i+=2)if(_[i]!==c){var w=h[_[i]];g[x][w]=(u[w]<0?-1:1)*parseFloat(_[i+1])}else f[x]=parseFloat(_[i+1]);break;case 4:for(i=1;i<_.length;i+=2)v[h[_[i]]]=(u[h[_[i]]]<0?-1:1)*parseFloat(_[i+1]);break;case 5:break;case 6:y("Internal error")}}}y("Reached end of file without ENDATA")},numeric.seedrandom={pow:Math.pow,random:Math.random},(function(e,t,n,i,r,o,a){function s(e){var t,i=this,r=e.length,o=0,a=i.i=i.j=i.m=0;for(i.S=[],i.c=[],r||(e=[r++]);o<n;)i.S[o]=o++;for(o=0;o<n;o++)a=h(a+(t=i.S[o])+e[o%r]),i.S[o]=i.S[a],i.S[a]=t;i.g=function e(t){var r=i.S,o=h(i.i+1),a=r[o],s=h(i.j+a),l=r[s];r[o]=l,r[s]=a;for(var c=r[h(a+l)];--t;)o=h(o+1),s=h(s+(a=r[o])),r[o]=l=r[s],r[s]=a,c=c*n+r[h(a+l)];return i.i=o,i.j=s,c},i.g(n)}function l(e,t,n,i,r){if(n=[],r=typeof e,t&&"object"==r)for(i in e)if(i.indexOf("S")<5)try{n.push(l(e[i],t-1))}catch(e){}return n.length?n:e+("string"!=r?"\0":"")}function c(e,t,n,i){for(e+="",n=0,i=0;i<e.length;i++)t[h(i)]=h((n^=19*t[h(i)])+e.charCodeAt(i));for(i in e="",t)e+=String.fromCharCode(t[i]);return e}function h(e){return 255&e}t.seedrandom=function i(h,u){var d,p=[];return h=c(l(u?[h,e]:arguments.length?h:[(new Date).getTime(),e,window],3),p),c((d=new s(p)).S,e),t.random=function e(){for(var t=d.g(6),i=a,s=0;t<r;)t=(t+s)*n,i*=n,s=d.g(1);for(;t>=o;)t/=2,i/=2,s>>>=1;return(t+s)/i},h},a=t.pow(n,6),r=t.pow(2,r),o=2*r,c(t.random(),e)})([],numeric.seedrandom,256,0,52),(function(e){function t(e){if("object"!=typeof e)return e;var n,i=[],r=e.length;for(n=0;n<r;n++)i[n+1]=t(e[n]);return i}function n(e){if("object"!=typeof e)return e;var t,i=[],r=e.length;for(t=1;t<r;t++)i[t-1]=n(e[t]);return i}e.solveQP=function i(e,r,o,a,s,l){e=t(e),r=t(r),o=t(o);var c,h,u,d,p,m=[],f=[],g=[],v=[],y=[];if(s=s||0,l=l?t(l):[void 0,0],a=a?t(a):[],h=e.length-1,u=o[1].length-1,!a)for(c=1;c<=u;c+=1)a[c]=0;for(c=1;c<=u;c+=1)f[c]=0;for(d=Math.min(h,u),c=1;c<=h;c+=1)g[c]=0;for(m[1]=0,c=1;c<=2*h+d*(d+5)/2+2*u+1;c+=1)v[c]=0;for(c=1;c<=2;c+=1)y[c]=0;return(function b(e,t,n,i,r,o,a,s,l,c,h,u,d,p,m,f){var g,v,y,b,_,x,w,S,C,M,E,T,I,A,k,P,R,L,N,D,O,z,F,$,B,V,H;I=Math.min(i,c),y=2*i+I*(I+5)/2+2*c+1,$=1e-60;do{B=1+.1*($+=$),V=1+.2*$}while(B<=1||V<=1);for(g=1;g<=i;g+=1)m[g]=t[g];for(g=i+1;g<=y;g+=1)m[g]=0;for(g=1;g<=c;g+=1)u[g]=0;if(_=[],0===f[1]){if((function U(e,t,n,i){var r,o,a,s,l,c;for(o=1;o<=n;o+=1){if(i[1]=o,c=0,(a=o-1)<1){if((c=e[o][o]-c)<=0)break;e[o][o]=Math.sqrt(c)}else{for(s=1;s<=a;s+=1){for(l=e[s][o],r=1;r<s;r+=1)l-=e[r][o]*e[r][s];e[s][o]=l/=e[s][s],c+=l*l}if((c=e[o][o]-c)<=0)break;e[o][o]=Math.sqrt(c)}i[1]=0}})(e,0,i,_),0!==_[1])return void(f[1]=2);!(function G(e,t,n,i){var r,o,a,s;for(o=1;o<=n;o+=1){for(s=0,r=1;r<o;r+=1)s+=e[r][o]*i[r];i[o]=(i[o]-s)/e[o][o]}for(a=1;a<=n;a+=1)for(i[o=n+1-a]=i[o]/e[o][o],s=-i[o],r=1;r<o;r+=1)i[r]=i[r]+s*e[r][o]})(e,0,i,t),(function j(e,t,n){var i,r,o,a,s;for(o=1;o<=n;o+=1){for(e[o][o]=1/e[o][o],s=-e[o][o],i=1;i<o;i+=1)e[i][o]=s*e[i][o];if(n<(a=o+1))break;for(r=a;r<=n;r+=1)for(s=e[o][r],e[o][r]=0,i=1;i<=o;i+=1)e[i][r]=e[i][r]+s*e[i][o]}})(e,0,i)}else{for(v=1;v<=i;v+=1)for(r[v]=0,g=1;g<=v;g+=1)r[v]=r[v]+e[g][v]*t[g];for(v=1;v<=i;v+=1)for(t[v]=0,g=v;g<=i;g+=1)t[v]=t[v]+e[v][g]*r[g]}for(o[1]=0,v=1;v<=i;v+=1)for(r[v]=t[v],o[1]=o[1]+m[v]*r[v],m[v]=0,g=v+1;g<=i;g+=1)e[g][v]=0;for(o[1]=-o[1]/2,f[1]=0,A=(M=(C=(E=(S=(w=i)+i)+I)+I+1)+I*(I+1)/2)+c,g=1;g<=c;g+=1){for(P=0,v=1;v<=i;v+=1)P+=a[v][g]*a[v][g];m[A+g]=Math.sqrt(P)}function W(){for(p[1]=p[1]+1,y=M,g=1;g<=c;g+=1){for(y+=1,P=-s[g],v=1;v<=i;v+=1)P+=a[v][g]*r[v];if(Math.abs(P)<$&&(P=0),g>h)m[y]=P;else if(m[y]=-Math.abs(P),P>0){for(v=1;v<=i;v+=1)a[v][g]=-a[v][g];s[g]=-s[g]}}for(g=1;g<=d;g+=1)m[M+u[g]]=0;for(T=0,k=0,g=1;g<=c;g+=1)m[M+g]<k*m[A+g]&&(T=g,k=m[M+g]/m[A+g]);return 0===T?999:0}function q(){for(g=1;g<=i;g+=1){for(P=0,v=1;v<=i;v+=1)P+=e[v][g]*a[v][T];m[g]=P}for(b=w,g=1;g<=i;g+=1)m[b+g]=0;for(v=d+1;v<=i;v+=1)for(g=1;g<=i;g+=1)m[b+g]=m[b+g]+e[g][v]*m[v];for(z=!0,g=d;g>=1;g-=1){for(P=m[g],b=(y=C+g*(g+3)/2)-g,v=g+1;v<=d;v+=1)P-=m[y]*m[S+v],y+=v;if(m[S+g]=P/=m[b],u[g]<h)break;if(P<0)break;z=!1,x=g}if(!z)for(R=m[E+x]/m[S+x],g=1;g<=d&&!(u[g]<h)&&!(m[S+g]<0);g+=1)(k=m[E+g]/m[S+g])<R&&(R=k,x=g);for(P=0,g=w+1;g<=w+i;g+=1)P+=m[g]*m[g];if(Math.abs(P)<=$){if(z)return f[1]=1,999;for(g=1;g<=d;g+=1)m[E+g]=m[E+g]-R*m[S+g];return m[E+d+1]=m[E+d+1]+R,700}for(P=0,g=1;g<=i;g+=1)P+=m[w+g]*a[g][T];for(L=-m[M+T]/P,F=!0,z||R<L&&(L=R,F=!1),g=1;g<=i;g+=1)r[g]=r[g]+L*m[w+g],Math.abs(r[g])<$&&(r[g]=0);for(o[1]=o[1]+L*P*(L/2+m[E+d+1]),g=1;g<=d;g+=1)m[E+g]=m[E+g]-L*m[S+g];if(m[E+d+1]=m[E+d+1]+L,!F){for(P=-s[T],v=1;v<=i;v+=1)P+=r[v]*a[v][T];if(T>h)m[M+T]=P;else if(m[M+T]=-Math.abs(P),P>0){for(v=1;v<=i;v+=1)a[v][T]=-a[v][T];s[T]=-s[T]}return 700}for(u[d+=1]=T,y=C+(d-1)*d/2+1,g=1;g<=d-1;g+=1)m[y]=m[g],y+=1;if(d===i)m[y]=m[i];else{for(g=i;g>=d+1&&0!==m[g]&&(N=Math.max(Math.abs(m[g-1]),Math.abs(m[g])),D=Math.min(Math.abs(m[g-1]),Math.abs(m[g])),k=m[g-1]>=0?Math.abs(N*Math.sqrt(1+D*D/(N*N))):-Math.abs(N*Math.sqrt(1+D*D/(N*N))),D=m[g]/k,1!=(N=m[g-1]/k));g-=1)if(0===N)for(m[g-1]=D*k,v=1;v<=i;v+=1)k=e[v][g-1],e[v][g-1]=e[v][g],e[v][g]=k;else for(m[g-1]=k,O=D/(1+N),v=1;v<=i;v+=1)e[v][g]=O*(e[v][g-1]+(k=N*e[v][g-1]+D*e[v][g]))-e[v][g],e[v][g-1]=k;m[y]=m[d]}return 0}function X(){if(0===m[b=(y=C+x*(x+1)/2+1)+x])return 798;if(N=Math.max(Math.abs(m[b-1]),Math.abs(m[b])),D=Math.min(Math.abs(m[b-1]),Math.abs(m[b])),k=m[b-1]>=0?Math.abs(N*Math.sqrt(1+D*D/(N*N))):-Math.abs(N*Math.sqrt(1+D*D/(N*N))),D=m[b]/k,1==(N=m[b-1]/k))return 798;if(0===N){for(g=x+1;g<=d;g+=1)k=m[b-1],m[b-1]=m[b],m[b]=k,b+=g;for(g=1;g<=i;g+=1)k=e[g][x],e[g][x]=e[g][x+1],e[g][x+1]=k}else{for(O=D/(1+N),g=x+1;g<=d;g+=1)m[b]=O*(m[b-1]+(k=N*m[b-1]+D*m[b]))-m[b],m[b-1]=k,b+=g;for(g=1;g<=i;g+=1)e[g][x+1]=O*(e[g][x]+(k=N*e[g][x]+D*e[g][x+1]))-e[g][x+1],e[g][x]=k}return 0}function K(){for(b=y-x,g=1;g<=x;g+=1)m[b]=m[y],y+=1,b+=1;return m[E+x]=m[E+x+1],u[x]=u[x+1],(x+=1)<d?797:0}function Y(){return m[E+d]=m[E+d+1],m[E+d+1]=0,u[d]=0,d-=1,p[2]=p[2]+1,0}for(d=0,p[1]=0,p[2]=0,H=0;;){if(999===(H=W()))return;for(;0!==(H=q());){if(999===H)return;if(700===H)if(x===d)Y();else{for(;X(),797===(H=K()););Y()}}}})(e,r,0,h,g,m,o,a,0,u,s,f,0,y,v,l),p="",1===l[1]&&(p="constraints are inconsistent, no solution!"),2===l[1]&&(p="matrix D in quadratic function is not positive definite!"),{solution:n(g),value:n(m),unconstrained_solution:n(r),iterations:n(y),iact:n(f),message:p}}})(numeric),numeric.svd=function e(t){var n,i=numeric.epsilon,r=1e-64/i,o=0,a=0,s=0,l=0,c=0,h=numeric.clone(t),u=h.length,d=h[0].length;if(u<d)throw"Need more rows than columns";var p=new Array(d),m=new Array(d);for(a=0;a<d;a++)p[a]=m[a]=0;var f=numeric.rep([d,d],0);function g(e,t){return(e=Math.abs(e))>(t=Math.abs(t))?e*Math.sqrt(1+t*t/e/e):0==t?e:t*Math.sqrt(1+e*e/t/t)}var v=0,y=0,b=0,_=0,x=0,w=0,S=0;for(a=0;a<d;a++){for(p[a]=y,S=0,c=a+1,s=a;s<u;s++)S+=h[s][a]*h[s][a];if(S<=r)y=0;else for(v=h[a][a],y=Math.sqrt(S),v>=0&&(y=-y),b=v*y-S,h[a][a]=v-y,s=c;s<d;s++){for(S=0,l=a;l<u;l++)S+=h[l][a]*h[l][s];for(v=S/b,l=a;l<u;l++)h[l][s]+=v*h[l][a]}for(m[a]=y,S=0,s=c;s<d;s++)S+=h[a][s]*h[a][s];if(S<=r)y=0;else{for(v=h[a][a+1],y=Math.sqrt(S),v>=0&&(y=-y),b=v*y-S,h[a][a+1]=v-y,s=c;s<d;s++)p[s]=h[a][s]/b;for(s=c;s<u;s++){for(S=0,l=c;l<d;l++)S+=h[s][l]*h[a][l];for(l=c;l<d;l++)h[s][l]+=S*p[l]}}(x=Math.abs(m[a])+Math.abs(p[a]))>_&&(_=x)}for(a=d-1;-1!=a;a+=-1){if(0!=y){for(b=y*h[a][a+1],s=c;s<d;s++)f[s][a]=h[a][s]/b;for(s=c;s<d;s++){for(S=0,l=c;l<d;l++)S+=h[a][l]*f[l][s];for(l=c;l<d;l++)f[l][s]+=S*f[l][a]}}for(s=c;s<d;s++)f[a][s]=0,f[s][a]=0;f[a][a]=1,y=p[a],c=a}for(a=d-1;-1!=a;a+=-1){for(y=m[a],s=c=a+1;s<d;s++)h[a][s]=0;if(0!=y){for(b=h[a][a]*y,s=c;s<d;s++){for(S=0,l=c;l<u;l++)S+=h[l][a]*h[l][s];for(v=S/b,l=a;l<u;l++)h[l][s]+=v*h[l][a]}for(s=a;s<u;s++)h[s][a]=h[s][a]/y}else for(s=a;s<u;s++)h[s][a]=0;h[a][a]+=1}for(i*=_,l=d-1;-1!=l;l+=-1)for(var C=0;C<50;C++){var M=!1;for(c=l;-1!=c;c+=-1){if(Math.abs(p[c])<=i){M=!0;break}if(Math.abs(m[c-1])<=i)break}if(!M){o=0,S=1;var E=c-1;for(a=c;a<l+1&&(v=S*p[a],p[a]=o*p[a],!(Math.abs(v)<=i));a++)for(b=g(v,y=m[a]),m[a]=b,o=y/b,S=-v/b,s=0;s<u;s++)h[s][E]=(x=h[s][E])*o+(w=h[s][a])*S,h[s][a]=-x*S+w*o}if(w=m[l],c==l){if(w<0)for(m[l]=-w,s=0;s<d;s++)f[s][l]=-f[s][l];break}if(C>=49)throw"Error: no convergence.";for(_=m[c],y=g(v=(((x=m[l-1])-w)*(x+w)+((y=p[l-1])-(b=p[l]))*(y+b))/(2*b*x),1),v=v<0?((_-w)*(_+w)+b*(x/(v-y)-b))/_:((_-w)*(_+w)+b*(x/(v+y)-b))/_,o=1,S=1,a=c+1;a<l+1;a++){for(x=m[a],b=S*(y=p[a]),y*=o,w=g(v,b),p[a-1]=w,v=_*(o=v/w)+y*(S=b/w),y=-_*S+y*o,b=x*S,x*=o,s=0;s<d;s++)f[s][a-1]=(_=f[s][a-1])*o+(w=f[s][a])*S,f[s][a]=-_*S+w*o;for(w=g(v,b),m[a-1]=w,v=(o=v/w)*y+(S=b/w)*x,_=-S*y+o*x,s=0;s<u;s++)h[s][a-1]=(x=h[s][a-1])*o+(w=h[s][a])*S,h[s][a]=-x*S+w*o}p[c]=0,p[l]=v,m[l]=_}for(a=0;a<m.length;a++)m[a]<i&&(m[a]=0);for(a=0;a<d;a++)for(s=a-1;s>=0;s--)if(m[s]<m[a]){for(o=m[s],m[s]=m[a],m[a]=o,l=0;l<h.length;l++)n=h[l][a],h[l][a]=h[l][s],h[l][s]=n;for(l=0;l<f.length;l++)n=f[l][a],f[l][a]=f[l][s],f[l][s]=n;a=s}return{U:h,S:m,V:f}}})),utils=createCommonjsModule((function(e,t){var n=commonjsGlobal&&commonjsGlobal.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};function i(e,t){return Math.floor(t()*e)}function r(e){for(var t=[],n=0;n<e;n++)t.push(void 0);return t}function o(e,t){return r(e).map((function(){return t}))}function a(e){return o(e,0)}function s(e){return e.reduce((function(e,t){return e+t}))}Object.defineProperty(t,"__esModule",{value:!0}),t.tauRandInt=i,t.tauRand=function l(e){return e()},t.norm=function c(e){var t,i,r=0;try{for(var o=n(e),a=o.next();!a.done;a=o.next())r+=Math.pow(a.value,2)}catch(e){t={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}return Math.sqrt(r)},t.empty=r,t.range=function h(e){return r(e).map((function(e,t){return t}))},t.filled=o,t.zeros=a,t.ones=function u(e){return o(e,1)},t.linear=function d(e,t,n){return r(n).map((function(i,r){return e+r*((t-e)/(n-1))}))},t.sum=s,t.mean=function p(e){return s(e)/e.length},t.max=function m(e){for(var t=0,n=0;n<e.length;n++)t=e[n]>t?e[n]:t;return t},t.max2d=function f(e){for(var t=0,n=0;n<e.length;n++)for(var i=0;i<e[n].length;i++)t=e[n][i]>t?e[n][i]:t;return t},t.rejectionSample=function g(e,t,n){for(var r=a(e),o=0;o<e;o++)for(var s=!0;s;){for(var l=i(t,n),c=!1,h=0;h<o;h++)if(l===r[h]){c=!0;break}c||(s=!1),r[o]=l}return r},t.reshape2d=function v(e,t,n){var i=[],r=0;if(e.length!==t*n)throw new Error("Array dimensions must match input length.");for(var o=0;o<t;o++){for(var a=[],s=0;s<n;s++)a.push(e[r]),r+=1;i.push(a)}return i}})),heap=createCommonjsModule((function(e,t){var n=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var i=n(utils);function r(e,t){var n=function(n){return i.empty(e).map((function(){return i.filled(t,n)}))},r=[];return r.push(n(-1)),r.push(n(1/0)),r.push(n(0)),r}function o(e,t,n,i,r){t=Math.floor(t);var o=e[0][t];if(n>=e[1][t][0])return 0;for(var s=0;s<o.length;s++)if(i===o[s])return 0;return a(e,t,n,i,r)}function a(e,t,n,i,r){var o=e[0][t],a=e[1][t],s=e[2][t];if(n>=a[0])return 0;a[0]=n,o[0]=i,s[0]=r;for(var l=0,c=0;;){var h=2*l+1,u=h+1,d=e[0][0].length;if(h>=d)break;if(u>=d){if(!(a[h]>n))break;c=h}else if(a[h]>=a[u]){if(!(n<a[h]))break;c=h}else{if(!(n<a[u]))break;c=u}a[l]=a[c],o[l]=o[c],s[l]=s[c],l=c}return a[l]=n,o[l]=i,s[l]=r,1}function s(e,t,n,i){for(;2*i+1<n;){var r=2*i+1,o=r+1,a=i;if(e[a]<e[r]&&(a=r),o<n&&e[a]<e[o]&&(a=o),a===i)break;var s=e[i];e[i]=e[a],e[a]=s;var l=t[i];t[i]=t[a],t[a]=l,i=a}}t.makeHeap=r,t.rejectionSample=function l(e,t,n){for(var r=i.zeros(e),o=0;o<e;o++){for(var a=!0,s=0;a;){s=i.tauRandInt(t,n);for(var l=!1,c=0;c<o;c++)if(s===r[c]){l=!0;break}l||(a=!1)}r[o]=s}return r},t.heapPush=o,t.uncheckedHeapPush=a,t.buildCandidates=function c(e,t,n,a,s){for(var l=r(t,a),c=0;c<t;c++)for(var h=0;h<n;h++)if(!(e[0][c][h]<0)){var u=e[0][c][h],d=e[2][c][h],p=i.tauRand(s);o(l,c,p,u,d),o(l,u,p,c,d),e[2][c][h]=0}return l},t.deheapSort=function h(e){for(var t=e[0],n=e[1],i=0;i<t.length;i++)for(var r=t[i],o=n[i],a=0;a<r.length-1;a++){var l=r.length-a-1,c=o.length-a-1,h=r[0];r[0]=r[l],r[l]=h;var u=o[0];o[0]=o[c],o[c]=u,s(o,r,c,0)}return{indices:t,weights:n}},t.smallestFlagged=function u(e,t){for(var n=e[0][t],i=e[1][t],r=e[2][t],o=1/0,a=-1,s=0;s>n.length;s++)1===r[s]&&i[s]<o&&(o=i[s],a=s);return a>=0?(r[a]=0,Math.floor(n[a])):-1}})),matrix=createCommonjsModule((function(e,t){var n,i=commonjsGlobal&&commonjsGlobal.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a},r=commonjsGlobal&&commonjsGlobal.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}},o=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var a=o(utils),s=(function(){function e(e,t,n,i){if(this.entries=new Map,this.nRows=0,this.nCols=0,e.length!==t.length||e.length!==n.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=i[0],this.nCols=i[1];for(var r=0;r<n.length;r++){var o=e[r],a=t[r];this.checkDims(o,a);var s=this.makeKey(o,a);this.entries.set(s,{value:n[r],row:o,col:a})}}return e.prototype.makeKey=function(e,t){return e+":"+t},e.prototype.checkDims=function(e,t){if(!(e<this.nRows&&t<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")},e.prototype.set=function(e,t,n){this.checkDims(e,t);var i=this.makeKey(e,t);this.entries.has(i)?this.entries.get(i).value=n:this.entries.set(i,{value:n,row:e,col:t})},e.prototype.get=function(e,t,n){void 0===n&&(n=0),this.checkDims(e,t);var i=this.makeKey(e,t);return this.entries.has(i)?this.entries.get(i).value:n},e.prototype.getAll=function(e){void 0===e&&(e=!0);var t=[];return this.entries.forEach((function(e){t.push(e)})),e&&t.sort((function(e,t){return e.row===t.row?e.col-t.col:e.row-t.row})),t},e.prototype.getDims=function(){return[this.nRows,this.nCols]},e.prototype.getRows=function(){return Array.from(this.entries,(function(e){return i(e,2)[1].row}))},e.prototype.getCols=function(){return Array.from(this.entries,(function(e){return i(e,2)[1].col}))},e.prototype.getValues=function(){return Array.from(this.entries,(function(e){return i(e,2)[1].value}))},e.prototype.forEach=function(e){this.entries.forEach((function(t){return e(t.value,t.row,t.col)}))},e.prototype.map=function(t){var n=[];this.entries.forEach((function(e){n.push(t(e.value,e.row,e.col))}));var i=[this.nRows,this.nCols];return new e(this.getRows(),this.getCols(),n,i)},e.prototype.toArray=function(){var e=this,t=a.empty(this.nRows).map((function(){return a.zeros(e.nCols)}));return this.entries.forEach((function(e){t[e.row][e.col]=e.value})),t},e})();t.SparseMatrix=s,t.transpose=function l(e){var t=[],n=[],i=[];return e.forEach((function(e,r,o){t.push(r),n.push(o),i.push(e)})),new s(n,t,i,[e.nCols,e.nRows])},t.identity=function c(e){for(var t=i(e,1)[0],n=new s([],[],[],e),r=0;r<t;r++)n.set(r,r,1);return n},t.pairwiseMultiply=function h(e,t){return y(e,t,(function(e,t){return e*t}))},t.add=function u(e,t){return y(e,t,(function(e,t){return e+t}))},t.subtract=function d(e,t){return y(e,t,(function(e,t){return e-t}))},t.maximum=function p(e,t){return y(e,t,(function(e,t){return e>t?e:t}))},t.multiplyScalar=function m(e,t){return e.map((function(e){return e*t}))},t.eliminateZeros=function f(e){for(var t=new Set,n=e.getValues(),i=e.getRows(),r=e.getCols(),o=0;o<n.length;o++)0===n[o]&&t.add(o);var a=function(e,n){return!t.has(n)},l=n.filter(a),c=i.filter(a),h=r.filter(a);return new s(c,h,l,e.getDims())},t.normalize=function g(e,t){var n,i;void 0===t&&(t="l2");var o=v[t],a=new Map;e.forEach((function(e,t,n){var i=a.get(t)||[];i.push(n),a.set(t,i)}));var l=new s([],[],[],e.getDims()),c=function(t){for(var n=a.get(t).sort(),i=n.map((function(n){return e.get(t,n)})),r=o(i),s=0;s<r.length;s++)l.set(t,n[s],r[s])};try{for(var h=r(a.keys()),u=h.next();!u.done;u=h.next())c(u.value)}catch(e){n={error:e}}finally{try{u&&!u.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}return l};var v=((n={}).max=function(e){for(var t=-1/0,n=0;n<e.length;n++)t=e[n]>t?e[n]:t;return e.map((function(e){return e/t}))},n.l1=function(e){for(var t=0,n=0;n<e.length;n++)t+=e[n];return e.map((function(e){return e/t}))},n.l2=function(e){for(var t=0,n=0;n<e.length;n++)t+=Math.pow(e[n],2);return e.map((function(e){return Math.sqrt(Math.pow(e,2)/t)}))},n);function y(e,t,n){for(var i=new Set,r=[],o=[],a=[],l=function(i,s){r.push(i),o.push(s);var l=n(e.get(i,s),t.get(i,s));a.push(l)},c=e.getValues(),h=e.getRows(),u=e.getCols(),d=0;d<c.length;d++)i.add((g=h[d])+":"+(v=u[d])),l(g,v);var p=t.getValues(),m=t.getRows(),f=t.getCols();for(d=0;d<p.length;d++){var g,v;i.has((g=m[d])+":"+(v=f[d]))||l(g,v)}return new s(r,o,a,[e.nRows,e.nCols])}t.getCSR=function b(e){var t=[];e.forEach((function(e,n,i){t.push({value:e,row:n,col:i})})),t.sort((function(e,t){return e.row===t.row?e.col-t.col:e.row-t.row}));for(var n=[],i=[],r=[],o=-1,a=0;a<t.length;a++){var s=t[a],l=s.row,c=s.col,h=s.value;l!==o&&(o=l,r.push(a)),n.push(c),i.push(h)}return{indices:n,values:i,indptr:r}}})),tree=createCommonjsModule((function(e,t){var n=commonjsGlobal&&commonjsGlobal.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a},i=commonjsGlobal&&commonjsGlobal.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(n(arguments[t]));return e},r=commonjsGlobal&&commonjsGlobal.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}},o=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var a,s=o(utils);function l(e,t,n,i,r){if(void 0===n&&(n=30),t.length>n){var o=(function a(e,t,n){for(var i=e[0].length,r=s.tauRandInt(t.length,n),o=s.tauRandInt(t.length,n),a=t[r],l=t[o=(o+=r===o?1:0)%t.length],c=0,h=s.zeros(i),u=0;u<h.length;u++)h[u]=e[a][u]-e[l][u],c-=h[u]*(e[a][u]+e[l][u])/2;var d=0,p=0,m=s.zeros(t.length);for(u=0;u<t.length;u++){for(var f=c,g=0;g<i;g++)f+=h[g]*e[t[u]][g];0===f?(m[u]=s.tauRandInt(2,n),0===m[u]?d+=1:p+=1):f>0?(m[u]=0,d+=1):(m[u]=1,p+=1)}var v=s.zeros(d),y=s.zeros(p);for(d=0,p=0,u=0;u<m.length;u++)0===m[u]?(v[d]=t[u],d+=1):(y[p]=t[u],p+=1);return{indicesLeft:v,indicesRight:y,hyperplane:h,offset:c}})(e,t,r),c=o.indicesRight,h=o.hyperplane,u=o.offset;return{leftChild:l(e,o.indicesLeft,n,i+1,r),rightChild:l(e,c,n,i+1,r),isLeaf:!1,hyperplane:h,offset:u}}return{indices:t,isLeaf:!0}}function c(e,t,n,r,o,a,s){var l;if(e.isLeaf)return r[a][0]=-s,(l=o[s]).splice.apply(l,i([0,e.indices.length],e.indices)),{nodeNum:a,leafNum:s+=1};t[a]=e.hyperplane,n[a]=e.offset,r[a][0]=a+1;var h=a,u=c(e.leftChild,t,n,r,o,a+1,s);return s=u.leafNum,r[h][1]=(a=u.nodeNum)+1,{nodeNum:(u=c(e.rightChild,t,n,r,o,a+1,s)).nodeNum,leafNum:u.leafNum}}function h(e){return e.isLeaf?1:1+h(e.leftChild)+h(e.rightChild)}function u(e){return e.isLeaf?1:u(e.leftChild)+u(e.rightChild)}function d(e,t,n,i){for(var r=t,o=0;o<n.length;o++)r+=e[o]*n[o];return 0===r?s.tauRandInt(2,i):r>0?0:1}t.FlatTree=a=function a(e,t,n,i){this.hyperplanes=e,this.offsets=t,this.children=n,this.indices=i},t.makeForest=function p(e,t,n,i){var r=Math.max(10,t);return s.range(n).map((function(t,n){return(function o(e,t,n,i){return void 0===t&&(t=30),l(e,s.range(e.length),t,n,i)})(e,r,n,i)})).map((function(e){return(function t(e,n){var i=h(e),r=u(e),o=s.range(i).map((function(){return s.zeros(e.hyperplane?e.hyperplane.length:0)})),l=s.zeros(i),d=s.range(i).map((function(){return[-1,-1]})),p=s.range(r).map((function(){return s.range(n).map((function(){return-1}))}));return c(e,o,l,d,p,0,0),new a(o,l,d,p)})(e,r)}))},t.makeLeafArray=function m(e){var t,n;if(e.length>0){var o=[];try{for(var a=r(e),s=a.next();!s.done;s=a.next())o.push.apply(o,i(s.value.indices))}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o}return[[-1]]},t.searchFlatTree=function f(e,t,n){for(var i=0;t.children[i][0]>0;)i=0===d(t.hyperplanes[i],t.offsets[i],e,n)?t.children[i][0]:t.children[i][1];return t.indices[-1*t.children[i][0]]}})),nn_descent=createCommonjsModule((function(e,t){var n=commonjsGlobal&&commonjsGlobal.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}},i=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var r=i(heap),o=i(matrix),a=i(tree),s=i(utils);t.makeNNDescent=function l(e,t){return function n(i,o,a,l,c,h,u,d){void 0===l&&(l=10),void 0===c&&(c=50),void 0===h&&(h=.001),void 0===u&&(u=.5),void 0===d&&(d=!0);for(var p=i.length,m=r.makeHeap(i.length,a),f=0;f<i.length;f++)for(var g=r.rejectionSample(a,i.length,t),v=0;v<g.length;v++){var y=e(i[f],i[g[v]]);r.heapPush(m,f,y,g[v],1),r.heapPush(m,g[v],y,f,1)}if(d)for(var b=0;b<o.length;b++)for(f=0;f<o[b].length&&!(o[b][f]<0);f++)for(v=f+1;v<o[b].length&&!(o[b][v]<0);v++)y=e(i[o[b][f]],i[o[b][v]]),r.heapPush(m,o[b][f],y,o[b][v],1),r.heapPush(m,o[b][v],y,o[b][f],1);for(b=0;b<l;b++){var _=r.buildCandidates(m,p,a,c,t),x=0;for(f=0;f<p;f++)for(v=0;v<c;v++){var w=Math.floor(_[0][f][v]);if(!(w<0||s.tauRand(t)<u))for(var S=0;S<c;S++){var C=Math.floor(_[0][f][S]);C<0||!_[2][f][v]&&!_[2][f][S]||(y=e(i[w],i[C]),x+=r.heapPush(m,w,y,C,1),x+=r.heapPush(m,C,y,w,1))}}if(x<=h*a*i.length)break}return r.deheapSort(m)}},t.makeInitializations=function c(e){return{initFromRandom:function t(n,i,o,a,l){for(var c=0;c<o.length;c++)for(var h=s.rejectionSample(n,i.length,l),u=0;u<h.length;u++)if(!(h[u]<0)){var d=e(i[h[u]],o[c]);r.heapPush(a,c,d,h[u],1)}},initFromTree:function n(t,i,o,s,l){for(var c=0;c<o.length;c++)for(var h=a.searchFlatTree(o[c],t,l),u=0;u<h.length;u++){if(h[u]<0)return;var d=e(i[h[u]],o[c]);r.heapPush(s,c,d,h[u],1)}}}},t.makeInitializedNNSearch=function h(e){return function t(i,a,s,l){for(var c,h,u=o.getCSR(a),d=u.indices,p=u.indptr,m=0;m<l.length;m++)for(var f=new Set(s[0][m]);;){var g=r.smallestFlagged(s,m);if(-1===g)break;var v=d.slice(p[g],p[g+1]);try{for(var y=n(v),b=y.next();!b.done;b=y.next()){var _=b.value;if(_!==g&&-1!==_&&!f.has(_)){var x=e(i[_],l[m]);r.uncheckedHeapPush(s,m,x,_,1),f.add(_)}}}catch(e){c={error:e}}finally{try{b&&!b.done&&(h=y.return)&&h.call(y)}finally{if(c)throw c.error}}}return s}},t.initializeSearch=function u(e,t,i,o,a,s,l){var c,h,u=r.makeHeap(i.length,o);if(a(o,t,i,u,l),e)try{for(var d=n(e),p=d.next();!p.done;p=d.next())s(p.value,t,i,u,l)}catch(e){c={error:e}}finally{try{p&&!p.done&&(h=d.return)&&h.call(d)}finally{if(c)throw c.error}}return u}}));const toString$1=Object.prototype.toString;function isAnyArray$1(e){return toString$1.call(e).endsWith("Array]")}function errorCalculation(e,t,n){let i=0;const r=n(t);for(let t=0;t<e.x.length;t++)i+=Math.abs(e.y[t]-r(e.x[t]));return i}const toString=Object.prototype.toString;function isAnyArray(e){return toString.call(e).endsWith("Array]")}function max$2(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(e))throw new TypeError("input must be an array");if(0===e.length)throw new TypeError("input must not be empty");var n=t.fromIndex,i=void 0===n?0:n,r=t.toIndex,o=void 0===r?e.length:r;if(i<0||i>=e.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>e.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=e[i],s=i+1;s<o;s++)e[s]>a&&(a=e[s]);return a}function min$2(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(e))throw new TypeError("input must be an array");if(0===e.length)throw new TypeError("input must not be empty");var n=t.fromIndex,i=void 0===n?0:n,r=t.toIndex,o=void 0===r?e.length:r;if(i<0||i>=e.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=i||o>e.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=e[i],s=i+1;s<o;s++)e[s]<a&&(a=e[s]);return a}function rescale(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(e))throw new TypeError("input must be an array");if(0===e.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!isAnyArray(n.output))throw new TypeError("output option must be an array if specified");t=n.output}else t=new Array(e.length);var i=min$2(e),r=max$2(e);if(i===r)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=n.min,a=void 0===o?n.autoMinMax?i:0:o,s=n.max,l=void 0===s?n.autoMinMax?r:1:s;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var c=(l-a)/(r-i),h=0;h<e.length;h++)t[h]=(e[h]-i)*c+a;return t}const indent=" ".repeat(2),indentData=" ".repeat(4);function inspectMatrix(){return inspectMatrixWithOptions(this)}function inspectMatrixWithOptions(e,t={}){const{maxRows:n=15,maxColumns:i=10,maxNumSize:r=8}=t;return`${e.constructor.name} {\n${indent}[\n${indentData}${inspectData(e,n,i,r)}\n${indent}]\n${indent}rows: ${e.rows}\n${indent}columns: ${e.columns}\n}`}function inspectData(e,t,n,i){const{rows:r,columns:o}=e,a=Math.min(r,t),s=Math.min(o,n),l=[];for(let t=0;t<a;t++){let n=[];for(let r=0;r<s;r++)n.push(formatNumber(e.get(t,r),i));l.push(`${n.join(" ")}`)}return s!==o&&(l[l.length-1]+=` ... ${o-n} more columns`),a!==r&&l.push(`... ${r-t} more rows`),l.join(`\n${indentData}`)}function formatNumber(e,t){const n=String(e);if(n.length<=t)return n.padEnd(t," ");const i=e.toPrecision(t-2);if(i.length<=t)return i;const r=e.toExponential(t-2),o=r.indexOf("e"),a=r.slice(o);return r.slice(0,t-a.length)+a}function installMathOperations(e,t){e.prototype.add=function e(t){return"number"==typeof t?this.addS(t):this.addM(t)},e.prototype.addS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},e.prototype.addM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)+n.get(e,t));return this},e.add=function e(n,i){return new t(n).add(i)},e.prototype.sub=function e(t){return"number"==typeof t?this.subS(t):this.subM(t)},e.prototype.subS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},e.prototype.subM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)-n.get(e,t));return this},e.sub=function e(n,i){return new t(n).sub(i)},e.prototype.subtract=e.prototype.sub,e.prototype.subtractS=e.prototype.subS,e.prototype.subtractM=e.prototype.subM,e.subtract=e.sub,e.prototype.mul=function e(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},e.prototype.mulS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},e.prototype.mulM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)*n.get(e,t));return this},e.mul=function e(n,i){return new t(n).mul(i)},e.prototype.multiply=e.prototype.mul,e.prototype.multiplyS=e.prototype.mulS,e.prototype.multiplyM=e.prototype.mulM,e.multiply=e.mul,e.prototype.div=function e(t){return"number"==typeof t?this.divS(t):this.divM(t)},e.prototype.divS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},e.prototype.divM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)/n.get(e,t));return this},e.div=function e(n,i){return new t(n).div(i)},e.prototype.divide=e.prototype.div,e.prototype.divideS=e.prototype.divS,e.prototype.divideM=e.prototype.divM,e.divide=e.div,e.prototype.mod=function e(t){return"number"==typeof t?this.modS(t):this.modM(t)},e.prototype.modS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},e.prototype.modM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)%n.get(e,t));return this},e.mod=function e(n,i){return new t(n).mod(i)},e.prototype.modulus=e.prototype.mod,e.prototype.modulusS=e.prototype.modS,e.prototype.modulusM=e.prototype.modM,e.modulus=e.mod,e.prototype.and=function e(t){return"number"==typeof t?this.andS(t):this.andM(t)},e.prototype.andS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},e.prototype.andM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)&n.get(e,t));return this},e.and=function e(n,i){return new t(n).and(i)},e.prototype.or=function e(t){return"number"==typeof t?this.orS(t):this.orM(t)},e.prototype.orS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},e.prototype.orM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)|n.get(e,t));return this},e.or=function e(n,i){return new t(n).or(i)},e.prototype.xor=function e(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},e.prototype.xorS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},e.prototype.xorM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)^n.get(e,t));return this},e.xor=function e(n,i){return new t(n).xor(i)},e.prototype.leftShift=function e(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},e.prototype.leftShiftS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},e.prototype.leftShiftM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)<<n.get(e,t));return this},e.leftShift=function e(n,i){return new t(n).leftShift(i)},e.prototype.signPropagatingRightShift=function e(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},e.prototype.signPropagatingRightShiftS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},e.prototype.signPropagatingRightShiftM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)>>n.get(e,t));return this},e.signPropagatingRightShift=function e(n,i){return new t(n).signPropagatingRightShift(i)},e.prototype.rightShift=function e(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},e.prototype.rightShiftS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},e.prototype.rightShiftM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)>>>n.get(e,t));return this},e.rightShift=function e(n,i){return new t(n).rightShift(i)},e.prototype.zeroFillRightShift=e.prototype.rightShift,e.prototype.zeroFillRightShiftS=e.prototype.rightShiftS,e.prototype.zeroFillRightShiftM=e.prototype.rightShiftM,e.zeroFillRightShift=e.rightShift,e.prototype.not=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,~this.get(e,t));return this},e.not=function e(n){return new t(n).not()},e.prototype.abs=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.abs(this.get(e,t)));return this},e.abs=function e(n){return new t(n).abs()},e.prototype.acos=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.acos(this.get(e,t)));return this},e.acos=function e(n){return new t(n).acos()},e.prototype.acosh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.acosh(this.get(e,t)));return this},e.acosh=function e(n){return new t(n).acosh()},e.prototype.asin=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.asin(this.get(e,t)));return this},e.asin=function e(n){return new t(n).asin()},e.prototype.asinh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.asinh(this.get(e,t)));return this},e.asinh=function e(n){return new t(n).asinh()},e.prototype.atan=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.atan(this.get(e,t)));return this},e.atan=function e(n){return new t(n).atan()},e.prototype.atanh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.atanh(this.get(e,t)));return this},e.atanh=function e(n){return new t(n).atanh()},e.prototype.cbrt=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cbrt(this.get(e,t)));return this},e.cbrt=function e(n){return new t(n).cbrt()},e.prototype.ceil=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.ceil(this.get(e,t)));return this},e.ceil=function e(n){return new t(n).ceil()},e.prototype.clz32=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.clz32(this.get(e,t)));return this},e.clz32=function e(n){return new t(n).clz32()},e.prototype.cos=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cos(this.get(e,t)));return this},e.cos=function e(n){return new t(n).cos()},e.prototype.cosh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cosh(this.get(e,t)));return this},e.cosh=function e(n){return new t(n).cosh()},e.prototype.exp=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.exp(this.get(e,t)));return this},e.exp=function e(n){return new t(n).exp()},e.prototype.expm1=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.expm1(this.get(e,t)));return this},e.expm1=function e(n){return new t(n).expm1()},e.prototype.floor=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.floor(this.get(e,t)));return this},e.floor=function e(n){return new t(n).floor()},e.prototype.fround=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.fround(this.get(e,t)));return this},e.fround=function e(n){return new t(n).fround()},e.prototype.log=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log(this.get(e,t)));return this},e.log=function e(n){return new t(n).log()},e.prototype.log1p=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log1p(this.get(e,t)));return this},e.log1p=function e(n){return new t(n).log1p()},e.prototype.log10=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log10(this.get(e,t)));return this},e.log10=function e(n){return new t(n).log10()},e.prototype.log2=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log2(this.get(e,t)));return this},e.log2=function e(n){return new t(n).log2()},e.prototype.round=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.round(this.get(e,t)));return this},e.round=function e(n){return new t(n).round()},e.prototype.sign=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sign(this.get(e,t)));return this},e.sign=function e(n){return new t(n).sign()},e.prototype.sin=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sin(this.get(e,t)));return this},e.sin=function e(n){return new t(n).sin()},e.prototype.sinh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sinh(this.get(e,t)));return this},e.sinh=function e(n){return new t(n).sinh()},e.prototype.sqrt=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sqrt(this.get(e,t)));return this},e.sqrt=function e(n){return new t(n).sqrt()},e.prototype.tan=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.tan(this.get(e,t)));return this},e.tan=function e(n){return new t(n).tan()},e.prototype.tanh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.tanh(this.get(e,t)));return this},e.tanh=function e(n){return new t(n).tanh()},e.prototype.trunc=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.trunc(this.get(e,t)));return this},e.trunc=function e(n){return new t(n).trunc()},e.pow=function e(n,i){return new t(n).pow(i)},e.prototype.pow=function e(t){return"number"==typeof t?this.powS(t):this.powM(t)},e.prototype.powS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},e.prototype.powM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.pow(this.get(e,t),n.get(e,t)));return this}}function checkRowIndex(e,t,n){if(t<0||t>(n?e.rows:e.rows-1))throw new RangeError("Row index out of range")}function checkColumnIndex(e,t,n){if(t<0||t>(n?e.columns:e.columns-1))throw new RangeError("Column index out of range")}function checkRowVector(e,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==e.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function checkColumnVector(e,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==e.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function checkIndices(e,t,n){return{row:checkRowIndices(e,t),column:checkColumnIndices(e,n)}}function checkRowIndices(e,t){if("object"!=typeof t)throw new TypeError("unexpected type for row indices");if(t.some((t=>t<0||t>=e.rows)))throw new RangeError("row indices are out of range");return Array.isArray(t)||(t=Array.from(t)),t}function checkColumnIndices(e,t){if("object"!=typeof t)throw new TypeError("unexpected type for column indices");if(t.some((t=>t<0||t>=e.columns)))throw new RangeError("column indices are out of range");return Array.isArray(t)||(t=Array.from(t)),t}function checkRange(e,t,n,i,r){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(checkNumber("startRow",t),checkNumber("endRow",n),checkNumber("startColumn",i),checkNumber("endColumn",r),t>n||i>r||t<0||t>=e.rows||n<0||n>=e.rows||i<0||i>=e.columns||r<0||r>=e.columns)throw new RangeError("Submatrix indices are out of range")}function newArray(e,t=0){let n=[];for(let i=0;i<e;i++)n.push(t);return n}function checkNumber(e,t){if("number"!=typeof t)throw new TypeError(`${e} must be a number`)}function checkNonEmpty(e){if(e.isEmpty())throw new Error("Empty matrix has no elements to index")}function sumByRow(e){let t=newArray(e.rows);for(let n=0;n<e.rows;++n)for(let i=0;i<e.columns;++i)t[n]+=e.get(n,i);return t}function sumByColumn(e){let t=newArray(e.columns);for(let n=0;n<e.rows;++n)for(let i=0;i<e.columns;++i)t[i]+=e.get(n,i);return t}function sumAll(e){let t=0;for(let n=0;n<e.rows;n++)for(let i=0;i<e.columns;i++)t+=e.get(n,i);return t}function productByRow(e){let t=newArray(e.rows,1);for(let n=0;n<e.rows;++n)for(let i=0;i<e.columns;++i)t[n]*=e.get(n,i);return t}function productByColumn(e){let t=newArray(e.columns,1);for(let n=0;n<e.rows;++n)for(let i=0;i<e.columns;++i)t[i]*=e.get(n,i);return t}function productAll(e){let t=1;for(let n=0;n<e.rows;n++)for(let i=0;i<e.columns;i++)t*=e.get(n,i);return t}function varianceByRow(e,t,n){const i=e.rows,r=e.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,l=0;for(let t=0;t<r;t++)l=e.get(a,t)-n[a],i+=l,s+=l*l;o.push(t?(s-i*i/r)/(r-1):(s-i*i/r)/r)}return o}function varianceByColumn(e,t,n){const i=e.rows,r=e.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,l=0;for(let t=0;t<i;t++)l=e.get(t,a)-n[a],r+=l,s+=l*l;o.push(t?(s-r*r/i)/(i-1):(s-r*r/i)/i)}return o}function varianceAll(e,t,n){const i=e.rows,r=e.columns,o=i*r;let a=0,s=0,l=0;for(let t=0;t<i;t++)for(let i=0;i<r;i++)l=e.get(t,i)-n,a+=l,s+=l*l;return t?(s-a*a/o)/(o-1):(s-a*a/o)/o}function centerByRow(e,t){for(let n=0;n<e.rows;n++)for(let i=0;i<e.columns;i++)e.set(n,i,e.get(n,i)-t[n])}function centerByColumn(e,t){for(let n=0;n<e.rows;n++)for(let i=0;i<e.columns;i++)e.set(n,i,e.get(n,i)-t[i])}function centerAll(e,t){for(let n=0;n<e.rows;n++)for(let i=0;i<e.columns;i++)e.set(n,i,e.get(n,i)-t)}function getScaleByRow(e){const t=[];for(let n=0;n<e.rows;n++){let i=0;for(let t=0;t<e.columns;t++)i+=Math.pow(e.get(n,t),2)/(e.columns-1);t.push(Math.sqrt(i))}return t}function scaleByRow(e,t){for(let n=0;n<e.rows;n++)for(let i=0;i<e.columns;i++)e.set(n,i,e.get(n,i)/t[n])}function getScaleByColumn(e){const t=[];for(let n=0;n<e.columns;n++){let i=0;for(let t=0;t<e.rows;t++)i+=Math.pow(e.get(t,n),2)/(e.rows-1);t.push(Math.sqrt(i))}return t}function scaleByColumn(e,t){for(let n=0;n<e.rows;n++)for(let i=0;i<e.columns;i++)e.set(n,i,e.get(n,i)/t[i])}function getScaleAll(e){const t=e.size-1;let n=0;for(let i=0;i<e.columns;i++)for(let r=0;r<e.rows;r++)n+=Math.pow(e.get(r,i),2)/t;return Math.sqrt(n)}function scaleAll(e,t){for(let n=0;n<e.rows;n++)for(let i=0;i<e.columns;i++)e.set(n,i,e.get(n,i)/t)}class AbstractMatrix{static from1DArray(e,t,n){if(e*t!==n.length)throw new RangeError("data length does not match given dimensions");let i=new Matrix(e,t);for(let r=0;r<e;r++)for(let e=0;e<t;e++)i.set(r,e,n[r*t+e]);return i}static rowVector(e){let t=new Matrix(1,e.length);for(let n=0;n<e.length;n++)t.set(0,n,e[n]);return t}static columnVector(e){let t=new Matrix(e.length,1);for(let n=0;n<e.length;n++)t.set(n,0,e[n]);return t}static zeros(e,t){return new Matrix(e,t)}static ones(e,t){return new Matrix(e,t).fill(1)}static rand(e,t,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:i=Math.random}=n;let r=new Matrix(e,t);for(let n=0;n<e;n++)for(let e=0;e<t;e++)r.set(n,e,i());return r}static randInt(e,t,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:i=0,max:r=1e3,random:o=Math.random}=n;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(r))throw new TypeError("max must be an integer");if(i>=r)throw new RangeError("min must be smaller than max");let a=r-i,s=new Matrix(e,t);for(let n=0;n<e;n++)for(let e=0;e<t;e++){let t=i+Math.round(o()*a);s.set(n,e,t)}return s}static eye(e,t,n){void 0===t&&(t=e),void 0===n&&(n=1);let i=Math.min(e,t),r=this.zeros(e,t);for(let e=0;e<i;e++)r.set(e,e,n);return r}static diag(e,t,n){let i=e.length;void 0===t&&(t=i),void 0===n&&(n=t);let r=Math.min(i,t,n),o=this.zeros(t,n);for(let t=0;t<r;t++)o.set(t,t,e[t]);return o}static min(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let n=e.rows,i=e.columns,r=new Matrix(n,i);for(let o=0;o<n;o++)for(let n=0;n<i;n++)r.set(o,n,Math.min(e.get(o,n),t.get(o,n)));return r}static max(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let n=e.rows,i=e.columns,r=new this(n,i);for(let o=0;o<n;o++)for(let n=0;n<i;n++)r.set(o,n,Math.max(e.get(o,n),t.get(o,n)));return r}static checkMatrix(e){return AbstractMatrix.isMatrix(e)?e:new Matrix(e)}static isMatrix(e){return null!=e&&"Matrix"===e.klass}get size(){return this.rows*this.columns}apply(e){if("function"!=typeof e)throw new TypeError("callback must be a function");for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.call(this,t,n);return this}to1DArray(){let e=[];for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}to2DArray(){let e=[];for(let t=0;t<this.rows;t++){e.push([]);for(let n=0;n<this.columns;n++)e[t].push(this.get(t,n))}return e}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let e=0;e<this.rows;e++)for(let t=0;t<=e;t++)if(this.get(e,t)!==this.get(t,e))return!1;return!0}return!1}isEchelonForm(){let e=0,t=0,n=-1,i=!0,r=!1;for(;e<this.rows&&i;){for(t=0,r=!1;t<this.columns&&!1===r;)0===this.get(e,t)?t++:1===this.get(e,t)&&t>n?(r=!0,n=t):(i=!1,r=!0);e++}return i}isReducedEchelonForm(){let e=0,t=0,n=-1,i=!0,r=!1;for(;e<this.rows&&i;){for(t=0,r=!1;t<this.columns&&!1===r;)0===this.get(e,t)?t++:1===this.get(e,t)&&t>n?(r=!0,n=t):(i=!1,r=!0);for(let n=t+1;n<this.rows;n++)0!==this.get(e,n)&&(i=!1);e++}return i}echelonForm(){let e=this.clone(),t=0,n=0;for(;t<e.rows&&n<e.columns;){let i=t;for(let r=t;r<e.rows;r++)e.get(r,n)>e.get(i,n)&&(i=r);if(0===e.get(i,n))n++;else{e.swapRows(t,i);let r=e.get(t,n);for(let i=n;i<e.columns;i++)e.set(t,i,e.get(t,i)/r);for(let i=t+1;i<e.rows;i++){let r=e.get(i,n)/e.get(t,n);e.set(i,n,0);for(let o=n+1;o<e.columns;o++)e.set(i,o,e.get(i,o)-e.get(t,o)*r)}t++,n++}}return e}reducedEchelonForm(){let e=this.echelonForm(),t=e.columns,n=e.rows,i=n-1;for(;i>=0;)if(0===e.maxRow(i))i--;else{let r=0,o=!1;for(;r<n&&!1===o;)1===e.get(i,r)?o=!0:r++;for(let n=0;n<i;n++){let o=e.get(n,r);for(let a=r;a<t;a++){let t=e.get(n,a)-o*e.get(i,a);e.set(n,a,t)}}i--}return e}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(e={}){if("object"!=typeof e)throw new TypeError("options must be an object");const{rows:t=1,columns:n=1}=e;if(!Number.isInteger(t)||t<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let i=new Matrix(this.rows*t,this.columns*n);for(let e=0;e<t;e++)for(let t=0;t<n;t++)i.setSubMatrix(this,this.rows*e,this.columns*t);return i}fill(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,e);return this}neg(){return this.mulS(-1)}getRow(e){checkRowIndex(this,e);let t=[];for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}getRowVector(e){return Matrix.rowVector(this.getRow(e))}setRow(e,t){checkRowIndex(this,e),t=checkRowVector(this,t);for(let n=0;n<this.columns;n++)this.set(e,n,t[n]);return this}swapRows(e,t){checkRowIndex(this,e),checkRowIndex(this,t);for(let n=0;n<this.columns;n++){let i=this.get(e,n);this.set(e,n,this.get(t,n)),this.set(t,n,i)}return this}getColumn(e){checkColumnIndex(this,e);let t=[];for(let n=0;n<this.rows;n++)t.push(this.get(n,e));return t}getColumnVector(e){return Matrix.columnVector(this.getColumn(e))}setColumn(e,t){checkColumnIndex(this,e),t=checkColumnVector(this,t);for(let n=0;n<this.rows;n++)this.set(n,e,t[n]);return this}swapColumns(e,t){checkColumnIndex(this,e),checkColumnIndex(this,t);for(let n=0;n<this.rows;n++){let i=this.get(n,e);this.set(n,e,this.get(n,t)),this.set(n,t,i)}return this}addRowVector(e){e=checkRowVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e[n]);return this}subRowVector(e){e=checkRowVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e[n]);return this}mulRowVector(e){e=checkRowVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e[n]);return this}divRowVector(e){e=checkRowVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e[n]);return this}addColumnVector(e){e=checkColumnVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e[t]);return this}subColumnVector(e){e=checkColumnVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e[t]);return this}mulColumnVector(e){e=checkColumnVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e[t]);return this}divColumnVector(e){e=checkColumnVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e[t]);return this}mulRow(e,t){checkRowIndex(this,e);for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this}mulColumn(e,t){checkColumnIndex(this,e);for(let n=0;n<this.rows;n++)this.set(n,e,this.get(n,e)*t);return this}max(){if(this.isEmpty())return NaN;let e=this.get(0,0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxIndex(){checkNonEmpty(this);let e=this.get(0,0),t=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)>e&&(e=this.get(n,i),t[0]=n,t[1]=i);return t}min(){if(this.isEmpty())return NaN;let e=this.get(0,0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minIndex(){checkNonEmpty(this);let e=this.get(0,0),t=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)<e&&(e=this.get(n,i),t[0]=n,t[1]=i);return t}maxRow(e){if(checkRowIndex(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let n=1;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}maxRowIndex(e){checkRowIndex(this,e),checkNonEmpty(this);let t=this.get(e,0),n=[e,0];for(let i=1;i<this.columns;i++)this.get(e,i)>t&&(t=this.get(e,i),n[1]=i);return n}minRow(e){if(checkRowIndex(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let n=1;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}minRowIndex(e){checkRowIndex(this,e),checkNonEmpty(this);let t=this.get(e,0),n=[e,0];for(let i=1;i<this.columns;i++)this.get(e,i)<t&&(t=this.get(e,i),n[1]=i);return n}maxColumn(e){if(checkColumnIndex(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let n=1;n<this.rows;n++)this.get(n,e)>t&&(t=this.get(n,e));return t}maxColumnIndex(e){checkColumnIndex(this,e),checkNonEmpty(this);let t=this.get(0,e),n=[0,e];for(let i=1;i<this.rows;i++)this.get(i,e)>t&&(t=this.get(i,e),n[0]=i);return n}minColumn(e){if(checkColumnIndex(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let n=1;n<this.rows;n++)this.get(n,e)<t&&(t=this.get(n,e));return t}minColumnIndex(e){checkColumnIndex(this,e),checkNonEmpty(this);let t=this.get(0,e),n=[0,e];for(let i=1;i<this.rows;i++)this.get(i,e)<t&&(t=this.get(i,e),n[0]=i);return n}diag(){let e=Math.min(this.rows,this.columns),t=[];for(let n=0;n<e;n++)t.push(this.get(n,n));return t}norm(e="frobenius"){let t=0;if("max"===e)return this.max();if("frobenius"===e){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n)*this.get(e,n);return Math.sqrt(t)}throw new RangeError(`unknown norm type: ${e}`)}cumulativeSum(){let e=0;for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n),this.set(t,n,e);return this}dot(e){AbstractMatrix.isMatrix(e)&&(e=e.to1DArray());let t=this.to1DArray();if(t.length!==e.length)throw new RangeError("vectors do not have the same size");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}mmul(e){e=Matrix.checkMatrix(e);let t=this.rows,n=this.columns,i=e.columns,r=new Matrix(t,i),o=new Float64Array(n);for(let a=0;a<i;a++){for(let t=0;t<n;t++)o[t]=e.get(t,a);for(let e=0;e<t;e++){let t=0;for(let i=0;i<n;i++)t+=this.get(e,i)*o[i];r.set(e,a,t)}}return r}strassen2x2(e){e=Matrix.checkMatrix(e);let t=new Matrix(2,2);const n=this.get(0,0),i=e.get(0,0),r=this.get(0,1),o=e.get(0,1),a=this.get(1,0),s=e.get(1,0),l=this.get(1,1),c=e.get(1,1),h=(n+l)*(i+c),u=(a+l)*i,d=n*(o-c),p=l*(s-i),m=(n+r)*c,f=d+m,g=u+p,v=h-u+d+(a-n)*(i+o);return t.set(0,0,h+p-m+(r-l)*(s+c)),t.set(0,1,f),t.set(1,0,g),t.set(1,1,v),t}strassen3x3(e){e=Matrix.checkMatrix(e);let t=new Matrix(3,3);const n=this.get(0,0),i=this.get(0,1),r=this.get(0,2),o=this.get(1,0),a=this.get(1,1),s=this.get(1,2),l=this.get(2,0),c=this.get(2,1),h=this.get(2,2),u=e.get(0,0),d=e.get(0,1),p=e.get(0,2),m=e.get(1,0),f=e.get(1,1),g=e.get(1,2),v=e.get(2,0),y=e.get(2,1),b=e.get(2,2),_=(n-o)*(-d+f),x=(-n+o+a)*(u-d+f),w=(o+a)*(-u+d),S=n*u,C=(-n+l+c)*(u-p+g),M=(-n+l)*(p-g),E=(l+c)*(-u+p),T=(-r+c+h)*(f+v-y),I=(r-h)*(f-y),A=r*v,k=(c+h)*(-v+y),P=(-r+a+s)*(g+v-b),R=(r-s)*(g-b),L=(a+s)*(-v+b),N=(n+i+r-o-a-c-h)*f+x+w+S+T+A+k,D=S+C+E+(n+i+r-a-s-l-c)*g+A+P+L,O=_+a*(-u+d+m-f-g-v+b)+x+S+A+P+R,z=_+x+w+S+s*y,F=A+P+R+L+o*p,$=S+C+M+c*(-u+p+m-f-g-v+y)+T+I+A,B=T+I+A+k+l*d,V=S+C+M+E+h*b;return t.set(0,0,S+A+i*m),t.set(0,1,N),t.set(0,2,D),t.set(1,0,O),t.set(1,1,z),t.set(1,2,F),t.set(2,0,$),t.set(2,1,B),t.set(2,2,V),t}mmulStrassen(e){e=Matrix.checkMatrix(e);let t=this.clone(),n=t.rows,i=t.columns,r=e.rows,o=e.columns;function a(e,t,n){if(e.rows===t&&e.columns===n)return e;{let i=AbstractMatrix.zeros(t,n);return i=i.setSubMatrix(e,0,0),i}}i!==r&&console.warn(`Multiplying ${n} x ${i} and ${r} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,r),l=Math.max(i,o);return t=a(t,s,l),(function e(t,n,i,r){if(i<=512||r<=512)return t.mmul(n);i%2==1&&r%2==1?(t=a(t,i+1,r+1),n=a(n,i+1,r+1)):i%2==1?(t=a(t,i+1,r),n=a(n,i+1,r)):r%2==1&&(t=a(t,i,r+1),n=a(n,i,r+1));let o=parseInt(t.rows/2,10),s=parseInt(t.columns/2,10),l=t.subMatrix(0,o-1,0,s-1),c=n.subMatrix(0,o-1,0,s-1),h=t.subMatrix(0,o-1,s,t.columns-1),u=n.subMatrix(0,o-1,s,n.columns-1),d=t.subMatrix(o,t.rows-1,0,s-1),p=n.subMatrix(o,n.rows-1,0,s-1),m=t.subMatrix(o,t.rows-1,s,t.columns-1),f=n.subMatrix(o,n.rows-1,s,n.columns-1),g=e(AbstractMatrix.add(l,m),AbstractMatrix.add(c,f),o,s),v=e(AbstractMatrix.add(d,m),c,o,s),y=e(l,AbstractMatrix.sub(u,f),o,s),b=e(m,AbstractMatrix.sub(p,c),o,s),_=e(AbstractMatrix.add(l,h),f,o,s),x=e(AbstractMatrix.sub(d,l),AbstractMatrix.add(c,u),o,s),w=e(AbstractMatrix.sub(h,m),AbstractMatrix.add(p,f),o,s),S=AbstractMatrix.add(g,b);S.sub(_),S.add(w);let C=AbstractMatrix.add(y,_),M=AbstractMatrix.add(v,b),E=AbstractMatrix.sub(g,v);E.add(y),E.add(x);let T=AbstractMatrix.zeros(2*S.rows,2*S.columns);return T=T.setSubMatrix(S,0,0),T=T.setSubMatrix(C,S.rows,0),T=T.setSubMatrix(M,0,S.columns),T=T.setSubMatrix(E,S.rows,S.columns),T.subMatrix(0,i-1,0,r-1)})(t,e=a(e,s,l),s,l)}scaleRows(e={}){if("object"!=typeof e)throw new TypeError("options must be an object");const{min:t=0,max:n=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(t>=n)throw new RangeError("min must be smaller than max");let i=new Matrix(this.rows,this.columns);for(let e=0;e<this.rows;e++){const r=this.getRow(e);r.length>0&&rescale(r,{min:t,max:n,output:r}),i.setRow(e,r)}return i}scaleColumns(e={}){if("object"!=typeof e)throw new TypeError("options must be an object");const{min:t=0,max:n=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(t>=n)throw new RangeError("min must be smaller than max");let i=new Matrix(this.rows,this.columns);for(let e=0;e<this.columns;e++){const r=this.getColumn(e);r.length&&rescale(r,{min:t,max:n,output:r}),i.setColumn(e,r)}return i}flipRows(){const e=Math.ceil(this.columns/2);for(let t=0;t<this.rows;t++)for(let n=0;n<e;n++){let e=this.get(t,n),i=this.get(t,this.columns-1-n);this.set(t,n,i),this.set(t,this.columns-1-n,e)}return this}flipColumns(){const e=Math.ceil(this.rows/2);for(let t=0;t<this.columns;t++)for(let n=0;n<e;n++){let e=this.get(n,t),i=this.get(this.rows-1-n,t);this.set(n,t,i),this.set(this.rows-1-n,t,e)}return this}kroneckerProduct(e){e=Matrix.checkMatrix(e);let t=this.rows,n=this.columns,i=e.rows,r=e.columns,o=new Matrix(t*i,n*r);for(let a=0;a<t;a++)for(let t=0;t<n;t++)for(let n=0;n<i;n++)for(let s=0;s<r;s++)o.set(i*a+n,r*t+s,this.get(a,t)*e.get(n,s));return o}kroneckerSum(e){if(e=Matrix.checkMatrix(e),!this.isSquare()||!e.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let t=this.rows,n=e.rows,i=this.kroneckerProduct(Matrix.eye(n,n)),r=Matrix.eye(t,t).kroneckerProduct(e);return i.add(r)}transpose(){let e=new Matrix(this.columns,this.rows);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.set(n,t,this.get(t,n));return e}sortRows(e=compareNumbers){for(let t=0;t<this.rows;t++)this.setRow(t,this.getRow(t).sort(e));return this}sortColumns(e=compareNumbers){for(let t=0;t<this.columns;t++)this.setColumn(t,this.getColumn(t).sort(e));return this}subMatrix(e,t,n,i){checkRange(this,e,t,n,i);let r=new Matrix(t-e+1,i-n+1);for(let o=e;o<=t;o++)for(let t=n;t<=i;t++)r.set(o-e,t-n,this.get(o,t));return r}subMatrixRow(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=this.columns-1),t>n||t<0||t>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let i=new Matrix(e.length,n-t+1);for(let r=0;r<e.length;r++)for(let o=t;o<=n;o++){if(e[r]<0||e[r]>=this.rows)throw new RangeError(`Row index out of range: ${e[r]}`);i.set(r,o-t,this.get(e[r],o))}return i}subMatrixColumn(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=this.rows-1),t>n||t<0||t>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let i=new Matrix(n-t+1,e.length);for(let r=0;r<e.length;r++)for(let o=t;o<=n;o++){if(e[r]<0||e[r]>=this.columns)throw new RangeError(`Column index out of range: ${e[r]}`);i.set(o-t,r,this.get(o,e[r]))}return i}setSubMatrix(e,t,n){if((e=Matrix.checkMatrix(e)).isEmpty())return this;checkRange(this,t,t+e.rows-1,n,n+e.columns-1);for(let i=0;i<e.rows;i++)for(let r=0;r<e.columns;r++)this.set(t+i,n+r,e.get(i,r));return this}selection(e,t){let n=checkIndices(this,e,t),i=new Matrix(e.length,t.length);for(let e=0;e<n.row.length;e++){let t=n.row[e];for(let r=0;r<n.column.length;r++)i.set(e,r,this.get(t,n.column[r]))}return i}trace(){let e=Math.min(this.rows,this.columns),t=0;for(let n=0;n<e;n++)t+=this.get(n,n);return t}clone(){let e=new Matrix(this.rows,this.columns);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.set(t,n,this.get(t,n));return e}sum(e){switch(e){case"row":return sumByRow(this);case"column":return sumByColumn(this);case void 0:return sumAll(this);default:throw new Error(`invalid option: ${e}`)}}product(e){switch(e){case"row":return productByRow(this);case"column":return productByColumn(this);case void 0:return productAll(this);default:throw new Error(`invalid option: ${e}`)}}mean(e){const t=this.sum(e);switch(e){case"row":for(let e=0;e<this.rows;e++)t[e]/=this.columns;return t;case"column":for(let e=0;e<this.columns;e++)t[e]/=this.rows;return t;case void 0:return t/this.size;default:throw new Error(`invalid option: ${e}`)}}variance(e,t={}){if("object"==typeof e&&(t=e,e=void 0),"object"!=typeof t)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:i=this.mean(e)}=t;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(e){case"row":if(!Array.isArray(i))throw new TypeError("mean must be an array");return varianceByRow(this,n,i);case"column":if(!Array.isArray(i))throw new TypeError("mean must be an array");return varianceByColumn(this,n,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return varianceAll(this,n,i);default:throw new Error(`invalid option: ${e}`)}}standardDeviation(e,t){"object"==typeof e&&(t=e,e=void 0);const n=this.variance(e,t);if(void 0===e)return Math.sqrt(n);for(let e=0;e<n.length;e++)n[e]=Math.sqrt(n[e]);return n}center(e,t={}){if("object"==typeof e&&(t=e,e=void 0),"object"!=typeof t)throw new TypeError("options must be an object");const{center:n=this.mean(e)}=t;switch(e){case"row":if(!Array.isArray(n))throw new TypeError("center must be an array");return centerByRow(this,n),this;case"column":if(!Array.isArray(n))throw new TypeError("center must be an array");return centerByColumn(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return centerAll(this,n),this;default:throw new Error(`invalid option: ${e}`)}}scale(e,t={}){if("object"==typeof e&&(t=e,e=void 0),"object"!=typeof t)throw new TypeError("options must be an object");let n=t.scale;switch(e){case"row":if(void 0===n)n=getScaleByRow(this);else if(!Array.isArray(n))throw new TypeError("scale must be an array");return scaleByRow(this,n),this;case"column":if(void 0===n)n=getScaleByColumn(this);else if(!Array.isArray(n))throw new TypeError("scale must be an array");return scaleByColumn(this,n),this;case void 0:if(void 0===n)n=getScaleAll(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return scaleAll(this,n),this;default:throw new Error(`invalid option: ${e}`)}}toString(e){return inspectMatrixWithOptions(this,e)}}function compareNumbers(e,t){return e-t}AbstractMatrix.prototype.klass="Matrix","undefined"!=typeof Symbol&&(AbstractMatrix.prototype[Symbol.for("nodejs.util.inspect.custom")]=inspectMatrix),AbstractMatrix.random=AbstractMatrix.rand,AbstractMatrix.randomInt=AbstractMatrix.randInt,AbstractMatrix.diagonal=AbstractMatrix.diag,AbstractMatrix.prototype.diagonal=AbstractMatrix.prototype.diag,AbstractMatrix.identity=AbstractMatrix.eye,AbstractMatrix.prototype.negate=AbstractMatrix.prototype.neg,AbstractMatrix.prototype.tensorProduct=AbstractMatrix.prototype.kroneckerProduct;class Matrix extends AbstractMatrix{constructor(e,t){if(super(),Matrix.isMatrix(e))return e.clone();if(Number.isInteger(e)&&e>=0){if(this.data=[],!(Number.isInteger(t)&&t>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<e;n++)this.data.push(new Float64Array(t))}else{if(!Array.isArray(e))throw new TypeError("First argument must be a positive number or an array");{const n=e;if("number"!=typeof(t=(e=n.length)?n[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<e;i++){if(n[i].length!==t)throw new RangeError("Inconsistent array dimensions");this.data.push(Float64Array.from(n[i]))}}}this.rows=e,this.columns=t}set(e,t,n){return this.data[e][t]=n,this}get(e,t){return this.data[e][t]}removeRow(e){return checkRowIndex(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,t){return void 0===t&&(t=e,e=this.rows),checkRowIndex(this,e,!0),t=Float64Array.from(checkRowVector(this,t)),this.data.splice(e,0,t),this.rows+=1,this}removeColumn(e){checkColumnIndex(this,e);for(let t=0;t<this.rows;t++){const n=new Float64Array(this.columns-1);for(let i=0;i<e;i++)n[i]=this.data[t][i];for(let i=e+1;i<this.columns;i++)n[i-1]=this.data[t][i];this.data[t]=n}return this.columns-=1,this}addColumn(e,t){void 0===t&&(t=e,e=this.columns),checkColumnIndex(this,e,!0),t=checkColumnVector(this,t);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let r=0;for(;r<e;r++)i[r]=this.data[n][r];for(i[r++]=t[n];r<this.columns+1;r++)i[r]=this.data[n][r-1];this.data[n]=i}return this.columns+=1,this}}installMathOperations(AbstractMatrix,Matrix);class WrapperMatrix2D extends AbstractMatrix{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,t,n){return this.data[e][t]=n,this}get(e,t){return this.data[e][t]}}class LuDecomposition{constructor(e){let t,n,i,r,o,a,s,l,c,h=(e=WrapperMatrix2D.checkMatrix(e)).clone(),u=h.rows,d=h.columns,p=new Float64Array(u),m=1;for(t=0;t<u;t++)p[t]=t;for(l=new Float64Array(u),n=0;n<d;n++){for(t=0;t<u;t++)l[t]=h.get(t,n);for(t=0;t<u;t++){for(c=Math.min(t,n),o=0,i=0;i<c;i++)o+=h.get(t,i)*l[i];l[t]-=o,h.set(t,n,l[t])}for(r=n,t=n+1;t<u;t++)Math.abs(l[t])>Math.abs(l[r])&&(r=t);if(r!==n){for(i=0;i<d;i++)a=h.get(r,i),h.set(r,i,h.get(n,i)),h.set(n,i,a);s=p[r],p[r]=p[n],p[n]=s,m=-m}if(n<u&&0!==h.get(n,n))for(t=n+1;t<u;t++)h.set(t,n,h.get(t,n)/h.get(n,n))}this.LU=h,this.pivotVector=p,this.pivotSign=m}isSingular(){let e=this.LU,t=e.columns;for(let n=0;n<t;n++)if(0===e.get(n,n))return!0;return!1}solve(e){e=Matrix.checkMatrix(e);let t=this.LU;if(t.rows!==e.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,i,r,o=e.columns,a=e.subMatrixRow(this.pivotVector,0,o-1),s=t.columns;for(r=0;r<s;r++)for(n=r+1;n<s;n++)for(i=0;i<o;i++)a.set(n,i,a.get(n,i)-a.get(r,i)*t.get(n,r));for(r=s-1;r>=0;r--){for(i=0;i<o;i++)a.set(r,i,a.get(r,i)/t.get(r,r));for(n=0;n<r;n++)for(i=0;i<o;i++)a.set(n,i,a.get(n,i)-a.get(r,i)*t.get(n,r))}return a}get determinant(){let e=this.LU;if(!e.isSquare())throw new Error("Matrix must be square");let t=this.pivotSign,n=e.columns;for(let i=0;i<n;i++)t*=e.get(i,i);return t}get lowerTriangularMatrix(){let e=this.LU,t=e.rows,n=e.columns,i=new Matrix(t,n);for(let r=0;r<t;r++)for(let t=0;t<n;t++)i.set(r,t,r>t?e.get(r,t):r===t?1:0);return i}get upperTriangularMatrix(){let e=this.LU,t=e.rows,n=e.columns,i=new Matrix(t,n);for(let r=0;r<t;r++)for(let t=0;t<n;t++)i.set(r,t,r<=t?e.get(r,t):0);return i}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function hypotenuse(e,t){let n=0;return Math.abs(e)>Math.abs(t)?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0!==t?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0}class QrDecomposition{constructor(e){let t,n,i,r,o=(e=WrapperMatrix2D.checkMatrix(e)).clone(),a=e.rows,s=e.columns,l=new Float64Array(s);for(i=0;i<s;i++){let e=0;for(t=i;t<a;t++)e=hypotenuse(e,o.get(t,i));if(0!==e){for(o.get(i,i)<0&&(e=-e),t=i;t<a;t++)o.set(t,i,o.get(t,i)/e);for(o.set(i,i,o.get(i,i)+1),n=i+1;n<s;n++){for(r=0,t=i;t<a;t++)r+=o.get(t,i)*o.get(t,n);for(r=-r/o.get(i,i),t=i;t<a;t++)o.set(t,n,o.get(t,n)+r*o.get(t,i))}}l[i]=-e}this.QR=o,this.Rdiag=l}solve(e){e=Matrix.checkMatrix(e);let t=this.QR,n=t.rows;if(e.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let i,r,o,a,s=e.columns,l=e.clone(),c=t.columns;for(o=0;o<c;o++)for(r=0;r<s;r++){for(a=0,i=o;i<n;i++)a+=t.get(i,o)*l.get(i,r);for(a=-a/t.get(o,o),i=o;i<n;i++)l.set(i,r,l.get(i,r)+a*t.get(i,o))}for(o=c-1;o>=0;o--){for(r=0;r<s;r++)l.set(o,r,l.get(o,r)/this.Rdiag[o]);for(i=0;i<o;i++)for(r=0;r<s;r++)l.set(i,r,l.get(i,r)-l.get(o,r)*t.get(i,o))}return l.subMatrix(0,c-1,0,s-1)}isFullRank(){let e=this.QR.columns;for(let t=0;t<e;t++)if(0===this.Rdiag[t])return!1;return!0}get upperTriangularMatrix(){let e,t,n=this.QR,i=n.columns,r=new Matrix(i,i);for(e=0;e<i;e++)for(t=0;t<i;t++)r.set(e,t,e<t?n.get(e,t):e===t?this.Rdiag[e]:0);return r}get orthogonalMatrix(){let e,t,n,i,r=this.QR,o=r.rows,a=r.columns,s=new Matrix(o,a);for(n=a-1;n>=0;n--){for(e=0;e<o;e++)s.set(e,n,0);for(s.set(n,n,1),t=n;t<a;t++)if(0!==r.get(n,n)){for(i=0,e=n;e<o;e++)i+=r.get(e,n)*s.get(e,t);for(i=-i/r.get(n,n),e=n;e<o;e++)s.set(e,t,s.get(e,t)+i*r.get(e,n))}}return s}}class SingularValueDecomposition{constructor(e,t={}){if((e=WrapperMatrix2D.checkMatrix(e)).isEmpty())throw new Error("Matrix must be non-empty");let n=e.rows,i=e.columns;const{computeLeftSingularVectors:r=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=t;let s,l=Boolean(r),c=Boolean(o),h=!1;if(n<i)if(a){s=e.transpose(),n=s.rows,i=s.columns,h=!0;let t=l;l=c,c=t}else s=e.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=e.clone();let u=Math.min(n,i),d=Math.min(n+1,i),p=new Float64Array(d),m=new Matrix(n,u),f=new Matrix(i,i),g=new Float64Array(i),v=new Float64Array(n),y=new Float64Array(d);for(let e=0;e<d;e++)y[e]=e;let b=Math.min(n-1,i),_=Math.max(0,Math.min(i-2,n)),x=Math.max(b,_);for(let e=0;e<x;e++){if(e<b){p[e]=0;for(let t=e;t<n;t++)p[e]=hypotenuse(p[e],s.get(t,e));if(0!==p[e]){s.get(e,e)<0&&(p[e]=-p[e]);for(let t=e;t<n;t++)s.set(t,e,s.get(t,e)/p[e]);s.set(e,e,s.get(e,e)+1)}p[e]=-p[e]}for(let t=e+1;t<i;t++){if(e<b&&0!==p[e]){let i=0;for(let r=e;r<n;r++)i+=s.get(r,e)*s.get(r,t);i=-i/s.get(e,e);for(let r=e;r<n;r++)s.set(r,t,s.get(r,t)+i*s.get(r,e))}g[t]=s.get(e,t)}if(l&&e<b)for(let t=e;t<n;t++)m.set(t,e,s.get(t,e));if(e<_){g[e]=0;for(let t=e+1;t<i;t++)g[e]=hypotenuse(g[e],g[t]);if(0!==g[e]){g[e+1]<0&&(g[e]=0-g[e]);for(let t=e+1;t<i;t++)g[t]/=g[e];g[e+1]+=1}if(g[e]=-g[e],e+1<n&&0!==g[e]){for(let t=e+1;t<n;t++)v[t]=0;for(let t=e+1;t<n;t++)for(let n=e+1;n<i;n++)v[t]+=g[n]*s.get(t,n);for(let t=e+1;t<i;t++){let i=-g[t]/g[e+1];for(let r=e+1;r<n;r++)s.set(r,t,s.get(r,t)+i*v[r])}}if(c)for(let t=e+1;t<i;t++)f.set(t,e,g[t])}}let w=Math.min(i,n+1);if(b<i&&(p[b]=s.get(b,b)),n<w&&(p[w-1]=0),_+1<w&&(g[_]=s.get(_,w-1)),g[w-1]=0,l){for(let e=b;e<u;e++){for(let t=0;t<n;t++)m.set(t,e,0);m.set(e,e,1)}for(let e=b-1;e>=0;e--)if(0!==p[e]){for(let t=e+1;t<u;t++){let i=0;for(let r=e;r<n;r++)i+=m.get(r,e)*m.get(r,t);i=-i/m.get(e,e);for(let r=e;r<n;r++)m.set(r,t,m.get(r,t)+i*m.get(r,e))}for(let t=e;t<n;t++)m.set(t,e,-m.get(t,e));m.set(e,e,1+m.get(e,e));for(let t=0;t<e-1;t++)m.set(t,e,0)}else{for(let t=0;t<n;t++)m.set(t,e,0);m.set(e,e,1)}}if(c)for(let e=i-1;e>=0;e--){if(e<_&&0!==g[e])for(let t=e+1;t<i;t++){let n=0;for(let r=e+1;r<i;r++)n+=f.get(r,e)*f.get(r,t);n=-n/f.get(e+1,e);for(let r=e+1;r<i;r++)f.set(r,t,f.get(r,t)+n*f.get(r,e))}for(let t=0;t<i;t++)f.set(t,e,0);f.set(e,e,1)}let S=w-1,C=Number.EPSILON;for(;w>0;){let e,t;for(e=w-2;e>=-1&&-1!==e;e--){const t=Number.MIN_VALUE+C*Math.abs(p[e]+Math.abs(p[e+1]));if(Math.abs(g[e])<=t||Number.isNaN(g[e])){g[e]=0;break}}if(e===w-2)t=4;else{let n;for(n=w-1;n>=e&&n!==e;n--){let t=(n!==w?Math.abs(g[n]):0)+(n!==e+1?Math.abs(g[n-1]):0);if(Math.abs(p[n])<=C*t){p[n]=0;break}}n===e?t=3:n===w-1?t=1:(t=2,e=n)}switch(e++,t){case 1:{let t=g[w-2];g[w-2]=0;for(let n=w-2;n>=e;n--){let r=hypotenuse(p[n],t),o=p[n]/r,a=t/r;if(p[n]=r,n!==e&&(t=-a*g[n-1],g[n-1]=o*g[n-1]),c)for(let e=0;e<i;e++)r=o*f.get(e,n)+a*f.get(e,w-1),f.set(e,w-1,-a*f.get(e,n)+o*f.get(e,w-1)),f.set(e,n,r)}break}case 2:{let t=g[e-1];g[e-1]=0;for(let i=e;i<w;i++){let r=hypotenuse(p[i],t),o=p[i]/r,a=t/r;if(p[i]=r,t=-a*g[i],g[i]=o*g[i],l)for(let t=0;t<n;t++)r=o*m.get(t,i)+a*m.get(t,e-1),m.set(t,e-1,-a*m.get(t,i)+o*m.get(t,e-1)),m.set(t,i,r)}break}case 3:{const t=Math.max(Math.abs(p[w-1]),Math.abs(p[w-2]),Math.abs(g[w-2]),Math.abs(p[e]),Math.abs(g[e])),r=p[w-1]/t,o=p[w-2]/t,a=g[w-2]/t,s=p[e]/t,h=g[e]/t,u=((o+r)*(o-r)+a*a)/2,d=r*a*(r*a);let v=0;0===u&&0===d||(v=u<0?0-Math.sqrt(u*u+d):Math.sqrt(u*u+d),v=d/(u+v));let y=(s+r)*(s-r)+v,b=s*h;for(let t=e;t<w-1;t++){let r=hypotenuse(y,b);0===r&&(r=Number.MIN_VALUE);let o=y/r,a=b/r;if(t!==e&&(g[t-1]=r),y=o*p[t]+a*g[t],g[t]=o*g[t]-a*p[t],b=a*p[t+1],p[t+1]=o*p[t+1],c)for(let e=0;e<i;e++)r=o*f.get(e,t)+a*f.get(e,t+1),f.set(e,t+1,-a*f.get(e,t)+o*f.get(e,t+1)),f.set(e,t,r);if(r=hypotenuse(y,b),0===r&&(r=Number.MIN_VALUE),o=y/r,a=b/r,p[t]=r,y=o*g[t]+a*p[t+1],p[t+1]=-a*g[t]+o*p[t+1],b=a*g[t+1],g[t+1]=o*g[t+1],l&&t<n-1)for(let e=0;e<n;e++)r=o*m.get(e,t)+a*m.get(e,t+1),m.set(e,t+1,-a*m.get(e,t)+o*m.get(e,t+1)),m.set(e,t,r)}g[w-2]=y;break}case 4:if(p[e]<=0&&(p[e]=p[e]<0?-p[e]:0,c))for(let t=0;t<=S;t++)f.set(t,e,-f.get(t,e));for(;e<S&&!(p[e]>=p[e+1]);){let t=p[e];if(p[e]=p[e+1],p[e+1]=t,c&&e<i-1)for(let n=0;n<i;n++)t=f.get(n,e+1),f.set(n,e+1,f.get(n,e)),f.set(n,e,t);if(l&&e<n-1)for(let i=0;i<n;i++)t=m.get(i,e+1),m.set(i,e+1,m.get(i,e)),m.set(i,e,t);e++}w--}}if(h){let e=f;f=m,m=e}this.m=n,this.n=i,this.s=p,this.U=m,this.V=f}solve(e){let t=e,n=this.threshold,i=this.s.length,r=Matrix.zeros(i,i);for(let e=0;e<i;e++)Math.abs(this.s[e])<=n?r.set(e,e,0):r.set(e,e,1/this.s[e]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(r),l=a.rows,c=o.rows,h=Matrix.zeros(l,c);for(let e=0;e<l;e++)for(let t=0;t<c;t++){let n=0;for(let r=0;r<i;r++)n+=s.get(e,r)*o.get(t,r);h.set(e,t,n)}return h.mmul(t)}solveForDiagonal(e){return this.solve(Matrix.diag(e))}inverse(){let e=this.V,t=this.threshold,n=e.rows,i=e.columns,r=new Matrix(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<i;n++)Math.abs(this.s[n])>t&&r.set(o,n,e.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,l=new Matrix(n,a);for(let e=0;e<n;e++)for(let t=0;t<a;t++){let n=0;for(let i=0;i<s;i++)n+=r.get(e,i)*o.get(t,i);l.set(e,t,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let e=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,t=0,n=this.s;for(let i=0,r=n.length;i<r;i++)n[i]>e&&t++;return t}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return Matrix.diag(this.s)}}function inverse(e,t=!1){return e=WrapperMatrix2D.checkMatrix(e),t?new SingularValueDecomposition(e).inverse():solve(e,Matrix.eye(e.rows))}function solve(e,t,n=!1){return e=WrapperMatrix2D.checkMatrix(e),t=WrapperMatrix2D.checkMatrix(t),n?new SingularValueDecomposition(e).solve(t):e.isSquare()?new LuDecomposition(e).solve(t):new QrDecomposition(e).solve(t)}function gradientFunction(e,t,n,i,r){const o=n.length,a=e.x.length;let s=new Array(o);for(let l=0;l<o;l++){s[l]=new Array(a);let o=n.slice();o[l]+=i;let c=r(o);for(let n=0;n<a;n++)s[l][n]=t[n]-c(e.x[n])}return new Matrix(s)}function matrixFunction(e,t){const n=e.x.length;let i=new Array(n);for(let r=0;r<n;r++)i[r]=[e.y[r]-t[r]];return new Matrix(i)}function step$3(e,t,n,i,r){let o=Matrix.eye(t.length,t.length,n*i*i);const a=r(t);let s=new Float64Array(e.x.length);for(let t=0;t<e.x.length;t++)s[t]=a(e.x[t]);let l=gradientFunction(e,s,t,i,r),c=matrixFunction(e,s),h=inverse(o.add(l.mmul(l.transpose())));return(t=(t=new Matrix([t])).sub(h.mmul(l).mmul(c).mul(i).transpose())).to1DArray()}function levenbergMarquardt(e,t,n={}){let{maxIterations:i=100,gradientDifference:r=.1,damping:o=0,errorTolerance:a=.01,minValues:s,maxValues:l,initialValues:c}=n;if(o<=0)throw new Error("The damping option must be a positive number");if(!e.x||!e.y)throw new Error("The data parameter must have x and y elements");if(!isAnyArray$1(e.x)||e.x.length<2||!isAnyArray$1(e.y)||e.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(e.x.length!==e.y.length)throw new Error("The data parameter elements must have the same size");let h=c||new Array(t.length).fill(1),u=h.length;if(l=l||new Array(u).fill(Number.MAX_SAFE_INTEGER),s=s||new Array(u).fill(Number.MIN_SAFE_INTEGER),l.length!==s.length)throw new Error("minValues and maxValues must be the same size");if(!isAnyArray$1(h))throw new Error("initialValues must be an array");let d,p=errorCalculation(e,h,t),m=p<=a;for(d=0;d<i&&!m;d++){h=step$3(e,h,o,r,t);for(let e=0;e<u;e++)h[e]=Math.min(Math.max(s[e],h[e]),l[e]);if(p=errorCalculation(e,h,t),isNaN(p))break;m=p<=a}return{parameterValues:h,parameterError:p,iterations:d}}var src=Object.freeze({__proto__:null,default:levenbergMarquardt}),require$$5=getAugmentedNamespace(src),umap=createCommonjsModule((function(e,t){var n=commonjsGlobal&&commonjsGlobal.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{l(i.next(e))}catch(e){o(e)}}function s(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(a,s)}l((i=i.apply(e,t||[])).next())}))},i=commonjsGlobal&&commonjsGlobal.__generator||function(e,t){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return(function l(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}})([o,s])}}},r=commonjsGlobal&&commonjsGlobal.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a},o=commonjsGlobal&&commonjsGlobal.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e},a=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},s=commonjsGlobal&&commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var l=a(heap),c=a(matrix),h=a(nn_descent),u=a(tree),d=a(utils),p=s(require$$5),m=1e-5,f=.001,g=(function(){function e(e){void 0===e&&(e={});var t=this;this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=v,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new b;var n=function(n){void 0!==e[n]&&(t[n]=e[n])};n("distanceFn"),n("learningRate"),n("localConnectivity"),n("minDist"),n("nComponents"),n("nEpochs"),n("nNeighbors"),n("negativeSampleRate"),n("random"),n("repulsionStrength"),n("setOpMixRatio"),n("spread"),n("transformQueueSize")}return e.prototype.fit=function(e){return this.initializeFit(e),this.optimizeLayout(),this.embedding},e.prototype.fitAsync=function(e,t){return void 0===t&&(t=function(){return!0}),n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return this.initializeFit(e),[4,this.optimizeLayoutAsync(t)];case 1:return n.sent(),[2,this.embedding]}}))}))},e.prototype.setSupervisedProjection=function(e,t){void 0===t&&(t={}),this.Y=e,this.targetMetric=t.targetMetric||this.targetMetric,this.targetWeight=t.targetWeight||this.targetWeight,this.targetNNeighbors=t.targetNNeighbors||this.targetNNeighbors},e.prototype.setPrecomputedKNN=function(e,t){this.knnIndices=e,this.knnDistances=t},e.prototype.initializeFit=function(e){if(e.length<=this.nNeighbors)throw new Error("Not enough data points ("+e.length+") to create nNeighbors: "+this.nNeighbors+". Add more data points or adjust the configuration.");if(this.X===e&&this.isInitialized)return this.getNEpochs();if(this.X=e,!this.knnIndices&&!this.knnDistances){var t=this.nearestNeighbors(e);this.knnIndices=t.knnIndices,this.knnDistances=t.knnDistances}this.graph=this.fuzzySimplicialSet(e,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(e),this.processGraphForSupervisedProjection();var n=this.initializeSimplicialSetEmbedding(),i=n.tail,r=n.epochsPerSample;return this.optimizationState.head=n.head,this.optimizationState.tail=i,this.optimizationState.epochsPerSample=r,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()},e.prototype.makeSearchFns=function(){var e=h.makeInitializations(this.distanceFn),t=e.initFromRandom;this.initFromTree=e.initFromTree,this.initFromRandom=t,this.search=h.makeInitializedNNSearch(this.distanceFn)},e.prototype.makeSearchGraph=function(e){for(var t=this.knnIndices,n=this.knnDistances,i=new c.SparseMatrix([],[],[],[e.length,e.length]),r=0;r<t.length;r++)for(var o=t[r],a=n[r],s=0;s<o.length;s++){var l=a[s];l>0&&i.set(r,o[s],l)}var h=c.transpose(i);return c.maximum(i,h)},e.prototype.transform=function(e){var t=this,n=this.X;if(void 0===n||0===n.length)throw new Error("No data has been fit.");var i=Math.floor(this.nNeighbors*this.transformQueueSize);i=Math.min(n.length,i);var r=h.initializeSearch(this.rpForest,n,e,i,this.initFromRandom,this.initFromTree,this.random),o=this.search(n,this.searchGraph,r,e),a=l.deheapSort(o),s=a.indices,u=a.weights;s=s.map((function(e){return e.slice(0,t.nNeighbors)})),u=u.map((function(e){return e.slice(0,t.nNeighbors)}));var p=Math.max(0,this.localConnectivity-1),m=this.smoothKNNDistance(u,this.nNeighbors,p),f=this.computeMembershipStrengths(s,u,m.sigmas,m.rhos),g=new c.SparseMatrix(f.rows,f.cols,f.vals,[e.length,n.length]),v=c.normalize(g,"l1"),y=c.getCSR(v),b=e.length,_=M(d.reshape2d(y.indices,b,this.nNeighbors),d.reshape2d(y.values,b,this.nNeighbors),this.embedding),x=this.nEpochs?this.nEpochs/3:g.nRows<=1e4?100:30,w=g.getValues().reduce((function(e,t){return t>e?t:e}),0);g=g.map((function(e){return e<w/x?0:e})),g=c.eliminateZeros(g);var S=this.makeEpochsPerSample(g.getValues(),x),C=g.getRows(),E=g.getCols();return this.assignOptimizationStateParameters({headEmbedding:_,tailEmbedding:this.embedding,head:C,tail:E,currentEpoch:0,nEpochs:x,nVertices:g.getDims()[1],epochsPerSample:S}),this.prepareForOptimizationLoop(),this.optimizeLayout()},e.prototype.processGraphForSupervisedProjection=function(){var e=this.Y;if(e){if(e.length!==this.X.length)throw new Error("Length of X and y must be equal");"categorical"===this.targetMetric&&(this.graph=this.categoricalSimplicialSetIntersection(this.graph,e,this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12))}},e.prototype.step=function(){var e=this.optimizationState.currentEpoch;return e<this.getNEpochs()&&this.optimizeLayoutStep(e),this.optimizationState.currentEpoch},e.prototype.getEmbedding=function(){return this.embedding},e.prototype.nearestNeighbors=function(e){var t,n=this.nNeighbors,i=h.makeNNDescent(this.distanceFn,this.random),r=5+Math.floor(.5==(t=Math.pow(e.length,.5)/20)?0:Math.round(t)),o=Math.max(5,Math.floor(Math.round((function(e){return Math.log(e)/Math.log(2)})(e.length))));this.rpForest=u.makeForest(e,n,r,this.random);var a=i(e,u.makeLeafArray(this.rpForest),n,o);return{knnIndices:a.indices,knnDistances:a.weights}},e.prototype.fuzzySimplicialSet=function(e,t,n){void 0===n&&(n=1);var i=this,r=i.knnIndices,o=void 0===r?[]:r,a=i.knnDistances,s=void 0===a?[]:a,l=this.smoothKNNDistance(s,t,i.localConnectivity),h=this.computeMembershipStrengths(o,s,l.sigmas,l.rhos),u=new c.SparseMatrix(h.rows,h.cols,h.vals,[e.length,e.length]),d=c.transpose(u),p=c.pairwiseMultiply(u,d),m=c.subtract(c.add(u,d),p),f=c.multiplyScalar(m,n),g=c.multiplyScalar(p,1-n);return c.add(f,g)},e.prototype.categoricalSimplicialSetIntersection=function(e,t,n,i){void 0===i&&(i=1);var r=S(e,t,i,n);return C(r=c.eliminateZeros(r))},e.prototype.smoothKNNDistance=function(e,t,n,i,r){void 0===n&&(n=1),void 0===i&&(i=64),void 0===r&&(r=1);for(var o=Math.log(t)/Math.log(2)*r,a=d.zeros(e.length),s=d.zeros(e.length),l=0;l<e.length;l++){var c=0,h=1/0,u=1,p=e[l],g=p.filter((function(e){return e>0}));if(g.length>=n){var v=Math.floor(n),y=n-v;v>0?(a[l]=g[v-1],y>m&&(a[l]+=y*(g[v]-g[v-1]))):a[l]=y*g[0]}else g.length>0&&(a[l]=d.max(g));for(var b=0;b<i;b++){for(var _=0,x=1;x<e[l].length;x++){var w=e[l][x]-a[l];_+=w>0?Math.exp(-w/u):1}if(Math.abs(_-o)<m)break;_>o?u=(c+(h=u))/2:(c=u,h===1/0?u*=2:u=(c+h)/2)}if(s[l]=u,a[l]>0){var S=d.mean(p);s[l]<f*S&&(s[l]=f*S)}else{var C=d.mean(e.map(d.mean));s[l]<f*C&&(s[l]=f*C)}}return{sigmas:s,rhos:a}},e.prototype.computeMembershipStrengths=function(e,t,n,i){for(var r=e.length,o=e[0].length,a=d.zeros(r*o),s=d.zeros(r*o),l=d.zeros(r*o),c=0;c<r;c++)for(var h=0;h<o;h++){var u=0;-1!==e[c][h]&&(u=e[c][h]===c?0:t[c][h]-i[c]<=0?1:Math.exp(-(t[c][h]-i[c])/n[c]),a[c*o+h]=c,s[c*o+h]=e[c][h],l[c*o+h]=u)}return{rows:a,cols:s,vals:l}},e.prototype.initializeSimplicialSetEmbedding=function(){for(var e=this,t=this.getNEpochs(),n=this.nComponents,i=this.graph.getValues(),r=0,o=0;o<i.length;o++)r<i[o]&&(r=i[o]);var a=this.graph.map((function(e){return e<r/t?0:e}));this.embedding=d.zeros(a.nRows).map((function(){return d.zeros(n).map((function(){return 20*d.tauRand(e.random)-10}))}));var s=[],l=[],c=[],h=a.getAll();for(o=0;o<h.length;o++){var u=h[o];u.value&&(s.push(u.value),c.push(u.row),l.push(u.col))}return{head:l,tail:c,epochsPerSample:this.makeEpochsPerSample(s,t)}},e.prototype.makeEpochsPerSample=function(e,t){var n=d.filled(e.length,-1),i=d.max(e),r=e.map((function(e){return e/i*t}));return r.forEach((function(e,i){e>0&&(n[i]=t/r[i])})),n},e.prototype.assignOptimizationStateParameters=function(e){Object.assign(this.optimizationState,e)},e.prototype.prepareForOptimizationLoop=function(){var e=this,t=e.repulsionStrength,n=e.learningRate,i=e.negativeSampleRate,r=this.optimizationState,a=r.epochsPerSample,s=r.headEmbedding,l=s[0].length,c=s.length===r.tailEmbedding.length,h=a.map((function(e){return e/i})),u=o(h),d=o(a);this.assignOptimizationStateParameters({epochOfNextSample:d,epochOfNextNegativeSample:u,epochsPerNegativeSample:h,moveOther:c,initialAlpha:n,alpha:n,gamma:t,dim:l})},e.prototype.initializeOptimization=function(){var e=this.embedding,t=this.embedding,n=this.optimizationState,i=n.head,r=n.tail,o=n.epochsPerSample,a=this.getNEpochs(),s=this.graph.nCols,l=w(this.spread,this.minDist);this.assignOptimizationStateParameters({headEmbedding:e,tailEmbedding:t,head:i,tail:r,epochsPerSample:o,a:l.a,b:l.b,nEpochs:a,nVertices:s})},e.prototype.optimizeLayoutStep=function(e){for(var t=this.optimizationState,n=t.head,i=t.tail,r=t.headEmbedding,o=t.tailEmbedding,a=t.epochsPerSample,s=t.epochOfNextSample,l=t.epochOfNextNegativeSample,c=t.epochsPerNegativeSample,h=t.moveOther,u=t.initialAlpha,p=t.alpha,m=t.gamma,f=t.a,g=t.b,v=t.dim,y=t.nEpochs,b=t.nVertices,w=0;w<a.length;w++)if(!(s[w]>e)){var S=n[w],C=r[S],M=o[i[w]],E=x(C,M),T=0;E>0&&(T=-2*f*g*Math.pow(E,g-1),T/=f*Math.pow(E,g)+1);for(var I=0;I<v;I++){var A=_(T*(C[I]-M[I]),4);C[I]+=A*p,h&&(M[I]+=-A*p)}s[w]+=a[w];for(var k=Math.floor((e-l[w])/c[w]),P=0;P<k;P++){var R=d.tauRandInt(b,this.random),L=o[R],N=x(C,L),D=0;if(N>0)D=2*m*g,D/=(.001+N)*(f*Math.pow(N,g)+1);else if(S===R)continue;for(I=0;I<v;I++)A=4,D>0&&(A=_(D*(C[I]-L[I]),4)),C[I]+=A*p}l[w]+=k*c[w]}return t.alpha=u*(1-e/y),t.currentEpoch+=1,r},e.prototype.optimizeLayoutAsync=function(e){var t=this;return void 0===e&&(e=function(){return!0}),new Promise((function(r,o){var a=function(){return n(t,void 0,void 0,(function(){var t,n,s,l,c;return i(this,(function(i){try{if(n=(t=this.optimizationState).nEpochs,this.embedding=this.optimizeLayoutStep(t.currentEpoch),l=!1===e(s=this.optimizationState.currentEpoch),c=s===n,l||c)return[2,r(c)];setTimeout((function(){return a()}),0)}catch(e){o(e)}return[2]}))}))};setTimeout((function(){return a()}),0)}))},e.prototype.optimizeLayout=function(e){void 0===e&&(e=function(){return!0});for(var t=!1,n=[];!t;){var i=this.optimizationState,r=i.nEpochs;n=this.optimizeLayoutStep(i.currentEpoch);var o=this.optimizationState.currentEpoch,a=!1===e(o);t=o===r||a}return n},e.prototype.getNEpochs=function(){if(this.nEpochs>0)return this.nEpochs;var e=this.graph.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},e})();function v(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(e[i]-t[i],2);return Math.sqrt(n)}t.UMAP=g,t.euclidean=v,t.cosine=function y(e,t){for(var n=0,i=0,r=0,o=0;o<e.length;o++)n+=e[o]*t[o],i+=Math.pow(e[o],2),r+=Math.pow(t[o],2);return 0===i&&0===r?0:0===i||0===r?1:1-n/Math.sqrt(i*r)};var b=function b(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0};function _(e,t){return e>t?t:e<-t?-t:e}function x(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(e[i]-t[i],2);return n}function w(e,t){var n=d.linear(0,3*e,300).map((function(e){return e<t?1:e})),i=d.zeros(n.length).map((function(i,r){return n[r]>=t?Math.exp(-(n[r]-t)/e):i})),o=p.default({x:n,y:i},(function(e){var t=r(e,2),n=t[0],i=t[1];return function(e){return 1/(1+n*Math.pow(e,2*i))}}),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,a=r(o,2);return{a:a[0],b:a[1]}}function S(e,t,n,i){return void 0===n&&(n=1),void 0===i&&(i=5),e.map((function(e,r,o){return-1===t[r]||-1===t[o]?e*Math.exp(-n):t[r]!==t[o]?e*Math.exp(-i):e}))}function C(e){e=c.normalize(e,"max");var t=c.transpose(e),n=c.pairwiseMultiply(t,e);return e=c.add(e,c.subtract(t,n)),c.eliminateZeros(e)}function M(e,t,n){for(var i=d.zeros(e.length).map((function(e){return d.zeros(n[0].length)})),r=0;r<e.length;r++)for(var o=0;o<e[0].length;o++)for(var a=0;a<n[0].length;a++)i[r][a]+=t[r][o]*n[e[r][o]][a];return i}t.findABParams=w,t.fastIntersection=S,t.resetLocalConnectivity=C,t.initTransform=M})),dist$1=createCommonjsModule((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.UMAP=umap.UMAP}));class SPTree{constructor(e){if(e.length<1)throw new Error("There should be at least 1 data point");this.dim=e[0].length,this.masks=new Array(Math.pow(2,this.dim));for(let e=0;e<this.masks.length;++e)this.masks[e]=1<<e;let t=new Array(this.dim);fillArray(t,Number.POSITIVE_INFINITY);let n=new Array(this.dim);fillArray(n,Number.NEGATIVE_INFINITY);for(let i=0;i<e.length;++i)for(let r=0;r<this.dim;++r)t[r]=Math.min(t[r],e[i][r]),n[r]=Math.max(n[r],e[i][r]);let i=new Array(this.dim),r=0;for(let e=0;e<this.dim;++e){let o=n[e]-t[e];i[e]=t[e]+o/2,r=Math.max(r,o/2)}this.root={box:{center:i,halfDim:r},point:e[0]};for(let t=1;t<e.length;++t)this.insert(this.root,e[t])}visit(e,t=!1){this.visitNode(this.root,e,t)}visitNode(e,t,n){let i;if(n)i=t(e);else{let n=new Array(this.dim),r=new Array(this.dim);for(let t=0;t<this.dim;++t)n[t]=e.box.center[t]-e.box.halfDim,r[t]=e.box.center[t]+e.box.halfDim;i=t(e,n,r)}if(e.children&&!i)for(let i=0;i<e.children.length;++i){let r=e.children[i];r&&this.visitNode(r,t,n)}}insert(e,t){null==e.children&&(e.children=new Array(this.masks.length));let n=0;for(let i=0;i<this.dim;++i)t[i]>e.box.center[i]&&(n|=this.masks[i]);null==e.children[n]?this.makeChild(e,n,t):this.insert(e.children[n],t)}makeChild(e,t,n){let i=e.box.center,r=e.box.halfDim/2,o=new Array(this.dim);for(let e=0;e<this.dim;++e)o[e]=t&1<<e?i[e]+r:i[e]-r;e.children[t]={box:{center:o,halfDim:r},point:n}}}function fillArray(e,t){for(let n=0;n<e.length;++n)e[n]=t}const THETA=.8,MIN_POSSIBLE_PROB=1e-9;let return_v=!1,v_val=0;function dist2_2D(e,t){let n=e[0]-t[0],i=e[1]-t[1];return n*n+i*i}function dist2_3D(e,t){let n=e[0]-t[0],i=e[1]-t[1],r=e[2]-t[2];return n*n+i*i+r*r}function gaussRandom(e){if(return_v)return return_v=!1,v_val;let t=2*e()-1,n=2*e()-1,i=t*t+n*n;if(0===i||i>1)return gaussRandom(e);let r=Math.sqrt(-2*Math.log(i)/i);return v_val=n*r,return_v=!0,t*r}function randn(e,t,n){return t+gaussRandom(e)*n}function zeros$2(e){return new Float64Array(e)}function randnMatrix(e,t,n){let i=e*t,r=zeros$2(i);for(let e=0;e<i;++e)r[e]=randn(n,0,1e-4);return r}function arrayofs(e,t,n){let i=[];for(let r=0;r<e;++r)i.push(3===t?[n,n,n]:[n,n]);return i}function nearest2P(e,t,n){let i=e.length,r=Math.log(t),o=zeros$2(i*i),a=new Array(e[0].length);for(let t=0;t<i;++t){let s=e[t],l=-1/0,c=1/0,h=1,u=50,d=0;for(;;){let e=0;for(let n=0;n<s.length;++n){let i=s[n],r=t===i.index?0:Math.exp(-i.dist*h);r=Math.max(r,MIN_POSSIBLE_PROB),a[n]=r,e+=r}let i=0;for(let t=0;t<a.length;++t){a[t]/=e;let n=a[t];n>1e-7&&(i-=n*Math.log(n))}if(i>r?(l=h,c===1/0?h*=2:h=(h+c)/2):(c=h,l===-1/0?h/=2:h=(h+l)/2),d++,d>=u||Math.abs(i-r)<n)break}for(let e=0;e<a.length;++e)o[t*i+s[e].index]=a[e]}let s=2*i;for(let e=0;e<i;++e)for(let t=e+1;t<i;++t){let n=e*i+t,r=t*i+e,a=(o[n]+o[r])/s;o[n]=a,o[r]=a}return o}function sign$3(e){return e>0?1:e<0?-1:0}function computeForce_2d(e,t,n,i){e[0]+=t*(n[0]-i[0]),e[1]+=t*(n[1]-i[1])}function computeForce_3d(e,t,n,i){e[0]+=t*(n[0]-i[0]),e[1]+=t*(n[1]-i[1]),e[2]+=t*(n[2]-i[2])}class TSNE{constructor(e){if(this.iter=0,this.perplexity=(e=e||{dim:2}).perplexity||30,this.epsilon=e.epsilon||10,this.rng=e.rng||Math.random,this.dim=e.dim,2===e.dim)this.dist2=dist2_2D,this.computeForce=computeForce_2d;else{if(3!==e.dim)throw new Error("Only 2D and 3D is supported");this.dist2=dist2_3D,this.computeForce=computeForce_3d}}initDataDist(e){let t=e.length;this.nearest=e,this.P=nearest2P(e,this.perplexity,1e-4),this.N=t,this.initSolution()}initSolution(){this.Y=randnMatrix(this.N,this.dim,this.rng),this.gains=arrayofs(this.N,this.dim,1),this.ystep=arrayofs(this.N,this.dim,0),this.iter=0}getDim(){return this.dim}getSolution(){return this.Y}perturb(){let e=this.N,t=0,n=3===this.dim?[0,0,0]:[0,0];for(let n=0;n<e;++n){let e=0;for(let t=0;t<this.dim;++t)e+=Math.pow(this.Y[n*this.dim+t],2);e>t&&(t=e)}let i=Math.pow(t,.5);for(let r=0;r<e;++r){let e=new Array(this.dim);for(;;){let n=0;for(let t=0;t<this.dim;++t)e[t]=.1*i*(Math.random()-.5),n+=Math.pow(this.Y[r*this.dim+t]+e[t],2);if(n<t)break}for(let t=0;t<this.dim;++t)this.Y[r*this.dim+t]+=e[t],n[t]+=this.Y[r*this.dim+t]}for(let t=0;t<e;++t)for(let i=0;i<this.dim;++i)this.Y[t*this.dim+i]-=n[i]/e}step(){this.iter+=1;let e=this.N,t=this.costGrad(this.Y),n=3===this.dim?[0,0,0]:[0,0];for(let i=0;i<e;++i)for(let e=0;e<this.dim;++e){let r=this.ystep[i][e],o=this.gains[i][e],a=sign$3(t[i][e])===sign$3(r)?.8*o:o+.2;a<.01&&(a=.01),this.gains[i][e]=a;let s=(this.iter<250?.5:.8)*r-this.epsilon*a*t[i][e];this.ystep[i][e]=s;let l=i*this.dim+e;this.Y[l]+=s,n[e]+=this.Y[l]}for(let t=0;t<e;++t)for(let i=0;i<this.dim;++i)this.Y[t*this.dim+i]-=n[i]/e}setSupervision(e,t){null!=e&&(this.labels=e,this.labelCounts={},Array.from(new Set(e)).forEach((e=>this.labelCounts[e]=0)),e.forEach((e=>this.labelCounts[e]+=1))),null!=t&&(this.unlabeledClass=t)}setSuperviseFactor(e){null!=e&&(this.superviseFactor=e)}costGrad(e){let t=this.N,n=this.P,i=this.iter<100?4:1,r=this.superviseFactor/100,o=this.unlabeledClass,a=this.labels,s=this.labelCounts,l=null!=r&&r>0&&null!=a&&null!=s,c=l&&null!=o&&""!==o?s[o]:0,h=new Array(t);for(let n=0;n<t;++n){let t=n*this.dim,i=new Array(this.dim);for(let n=0;n<this.dim;++n)i[n]=e[t+n];h[n]=i}let u=new SPTree(h),d=e=>{let t=1;if(null==e.children)return e.numCells=t,e.yCell=e.point,{numCells:t,yCell:e.yCell};let n=e.point.slice();for(let i=0;i<e.children.length;++i){let r=e.children[i];if(null==r)continue;let o=d(r);t+=o.numCells;for(let e=0;e<this.dim;++e)n[e]+=o.yCell[e]}return e.numCells=t,e.yCell=n.map((e=>e/t)),{numCells:t,yCell:n}};d(u.root),u.visit(((e,t,n)=>(e.rCell=n[0]-t[0],!1)));let p=[],m=0,f=0,g=new Array(t);for(let e=0;e<t;++e){let i=h[e];if(l)var v=s[a[e]],y=t-v-c;let d=3===this.dim?[0,0,0]:[0,0],p=this.nearest[e];for(let s=0;s<p.length;++s){let c=p[s].index,u=n[e*t+c];l&&(a[e]===o||a[c]===o?u*=1/t:a[e]!==a[c]?u*=Math.max(1/t-r/y,1e-7):a[e]===a[c]&&(u*=Math.min(1/t+r/v,1-1e-7)),f+=u);let m=h[c],g=this.dist2(i,m);this.computeForce(d,u/(1+g),i,m)}let b=3===this.dim?[0,0,0]:[0,0];u.visit((e=>{let t=this.dist2(i,e.yCell);if(null==e.children||t>0&&e.rCell/Math.sqrt(t)<THETA){let n=1/(1+t),r=e.numCells*n;return m+=r,r*=n,this.computeForce(b,r,i,e.yCell),!0}let n=1/(1+this.dist2(i,e.point));return m+=n,n*=n,this.computeForce(b,n,i,e.point),!1}),!0),g[e]=[d,b]}let b=4*i;l&&(b/=f);const _=4/m;for(let e=0;e<t;++e){let[t,n]=g[e],i=new Array(this.dim);for(let e=0;e<this.dim;++e)i[e]=b*t[e]-_*n[e];p.push(i)}return p}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const EPSILON_FLOAT32$1=1e-7,EPSILON_FLOAT16$1=1e-4;class DataStorage{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class KernelBackend{refCount(e){return notYetImplemented("refCount")}incRef(e){return notYetImplemented("incRef")}timerAvailable(){return!0}time(e){return notYetImplemented("time")}read(e){return notYetImplemented("read")}readSync(e){return notYetImplemented("readSync")}numDataIds(){return notYetImplemented("numDataIds")}disposeData(e,t){return notYetImplemented("disposeData")}write(e,t,n){return notYetImplemented("write")}move(e,t,n,i,r){return notYetImplemented("move")}memory(){return notYetImplemented("memory")}floatPrecision(){return notYetImplemented("floatPrecision")}epsilon(){return 32===this.floatPrecision()?EPSILON_FLOAT32$1:EPSILON_FLOAT16$1}dispose(){return notYetImplemented("dispose")}}function notYetImplemented(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function clamp(e,t,n){return Math.max(e,Math.min(t,n))}function nearestLargerEven(e){return e%2==0?e:e+1}function sum$3(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function assert$1(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function assertShapesMatch(e,t,n=""){assert$1(arraysEqual$1(e,t),(()=>n+` Shapes ${e} and ${t} must match`))}function flatten$1(e,t=[],n=!1){if(null==t&&(t=[]),Array.isArray(e)||isTypedArray(e)&&!n)for(let i=0;i<e.length;++i)flatten$1(e[i],t,n);else t.push(e);return t}function sizeFromShape(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function arraysEqual$1(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function isInt(e){return e%1==0}function sizeToSquarishShape(e){const t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function rightPad(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function repeatedTry(e,t=(e=>0),n){return new Promise(((i,r)=>{let o=0;const a=()=>{if(e())return void i();o++;const s=t(o);null!=n&&o>=n?r():setTimeout(a,s)};a()}))}function inferFromImplicitShape(e,t){let n=1,i=-1;for(let t=0;t<e.length;++t)if(e[t]>=0)n*=e[t];else if(-1===e[t]){if(-1!==i)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${i} and dim ${t}`);i=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===i){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===n)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);const r=e.slice();return r[i]=t/n,r}function parseAxisParam(e,t){const n=t.length;return assert$1((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e<n)),(()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),assert$1(e.every((e=>isInt(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function squeezeShape(e,t){const n=[],i=[],r=null!=t&&Array.isArray(t)&&0===t.length,o=null==t||r?null:parseAxisParam(t,e).sort();let a=0;for(let t=0;t<e.length;++t){if(null!=o){if(o[a]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==o[a]||o[a]>t)&&1===e[t]&&(n.push(e[t]),i.push(t)),o[a]<=t&&a++}1!==e[t]&&(n.push(e[t]),i.push(t))}return{newShape:n,keptDims:i}}function getTypedArrayFromDType(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error(`Unknown data type ${e}`);n=new Uint8Array(t)}return n}function getArrayFromDType(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function checkConversionForErrors(e,t){for(let n=0;n<e.length;n++){const i=e[n];if(isNaN(i)||!isFinite(i))throw Error(`A tensor of type ${t} being uploaded contains ${i}.`)}}function isValidDtype(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function hasEncodingLoss(e,t){return!("complex64"===t||"float32"===t&&"complex64"!==e||"int32"===t&&"float32"!==e&&"complex64"!==e||"bool"===t&&"bool"===e)}function isTypedArray(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array}function bytesPerElement(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function bytesFromStringArray(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}function isString(e){return"string"==typeof e||e instanceof String}function isBoolean(e){return"boolean"==typeof e}function isNumber(e){return"number"==typeof e}function inferDtype(e){return Array.isArray(e)?inferDtype(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":isNumber(e)?"float32":isString(e)?"string":isBoolean(e)?"bool":"float32"}function isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)}function nearestDivisor(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function computeStrides(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let i=t-3;i>=0;--i)n[i]=n[i+1]*e[i+1];return n}function createNestedArray(e,t,n,i=!1){const r=new Array;if(1===t.length){const o=t[0]*(i?2:1);for(let t=0;t<o;t++)r[t]=n[e+t]}else{const o=t[0],a=t.slice(1),s=a.reduce(((e,t)=>e*t))*(i?2:1);for(let t=0;t<o;t++)r[t]=createNestedArray(e+t*s,a,n,i)}return r}function toNestedArray(e,t,n=!1){if(0===e.length)return t[0];const i=e.reduce(((e,t)=>e*t))*(n?2:1);if(0===i)return[];if(i!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return createNestedArray(0,e,t,n)}function makeOnesTypedArray(e,t){const n=makeZerosTypedArray(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}function makeZerosTypedArray(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function makeZerosNestedTypedArray(e,t){const n=e.reduce(((e,t)=>e*t),1);if(null==t||"float32"===t)return toNestedArray(e,new Float32Array(n));if("int32"===t)return toNestedArray(e,new Int32Array(n));if("bool"===t)return toNestedArray(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function assertNonNegativeIntegerDimensions(e){e.forEach((t=>{assert$1(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function locToIndex(e,t,n){if(0===t)return 0;if(1===t)return e[0];let i=e[e.length-1];for(let t=0;t<e.length-1;++t)i+=n[t]*e[t];return i}function indexToLoc(e,t,n){if(0===t)return[];if(1===t)return[e];const i=new Array(t);for(let t=0;t<i.length-1;++t)i[t]=Math.floor(e/n[t]),e-=i[t]*n[t];return i[i.length-1]=e,i}function isPromise(e){return e&&e.then&&"function"==typeof e.then} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const TENSORFLOWJS_FLAGS_PREFIX="tfjsflags";class Environment{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=getQueryParams,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(isPromise(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);TENSORFLOWJS_FLAGS_PREFIX in e&&e[TENSORFLOWJS_FLAGS_PREFIX].split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=parseValue(t,n)}))}}function getQueryParams(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(decodeParam(t,n[0],n[1]),n.join("=")))),t}function decodeParam(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function parseValue(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}function env(){return ENV$2}let ENV$2=null,globalNameSpace;function setEnvironmentGlobal(e){ENV$2=e} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getGlobalNamespace(){if(null==globalNameSpace){let e;if("undefined"!=typeof window)e=window;else if("undefined"!=typeof global)e=global;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}globalNameSpace=e}return globalNameSpace}function getGlobalMap(){const e=getGlobalNamespace();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}function getGlobal(e,t){const n=getGlobalMap();if(n.has(e))return n.get(e);{const i=t();return n.set(e,i),n.get(e)}}const Abs="Abs",Acos="Acos",Acosh="Acosh",Add="Add",AddN="AddN",All="All",Any="Any",ArgMax="ArgMax",ArgMin="ArgMin",Asin="Asin",Asinh="Asinh",Atan="Atan",Atanh="Atanh",Atan2="Atan2",AvgPool="AvgPool",AvgPoolGrad="AvgPoolGrad",AvgPool3D="AvgPool3D",AvgPool3DGrad="AvgPool3DGrad",BatchMatMul="BatchMatMul",BatchToSpaceND="BatchToSpaceND",Bincount="Bincount",Cast="Cast",Ceil="Ceil",ClipByValue="ClipByValue",Complex="Complex",ComplexAbs="ComplexAbs",Concat="Concat",Conv2D="Conv2D",Conv2DBackpropFilter="Conv2DBackpropFilter",Conv2DBackpropInput="Conv2DBackpropInput",Conv3D="Conv3D",Conv3DBackpropFilterV2="Conv3DBackpropFilterV2",Conv3DBackpropInputV2="Conv3DBackpropInputV2",Cos="Cos",Cosh="Cosh",Cumsum="Cumsum",CropAndResize="CropAndResize",DenseBincount="DenseBincount",DepthToSpace="DepthToSpace",DepthwiseConv2dNative="DepthwiseConv2dNative",DepthwiseConv2dNativeBackpropFilter="DepthwiseConv2dNativeBackpropFilter",DepthwiseConv2dNativeBackpropInput="DepthwiseConv2dNativeBackpropInput",Diag="Diag",Dilation2D="Dilation2D",Dilation2DBackpropInput="Dilation2DBackpropInput",Dilation2DBackpropFilter="Dilation2DBackpropFilter",RealDiv="RealDiv",Einsum="Einsum",Elu="Elu",EluGrad="EluGrad",Erf="Erf",Equal="Equal",Exp="Exp",ExpandDims="ExpandDims",Expm1="Expm1",FFT="FFT",Fill="Fill",FlipLeftRight="FlipLeftRight",Floor="Floor",FloorDiv="FloorDiv",FusedBatchNorm="FusedBatchNorm",GatherV2="GatherV2",GatherNd="GatherNd",Greater="Greater",GreaterEqual="GreaterEqual",Identity="Identity",IFFT="IFFT",Imag="Imag",IsFinite="IsFinite",IsInf="IsInf",IsNan="IsNan",LeakyRelu="LeakyRelu",Less="Less",LessEqual="LessEqual",LinSpace="LinSpace",Log="Log",Log1p="Log1p",LogicalAnd="LogicalAnd",LogicalNot="LogicalNot",LogicalOr="LogicalOr",LRN="LRN",LRNGrad="LRNGrad",Max="Max",Maximum="Maximum",MaxPool="MaxPool",MaxPoolGrad="MaxPoolGrad",MaxPool3D="MaxPool3D",MaxPool3DGrad="MaxPool3DGrad",MaxPoolWithArgmax="MaxPoolWithArgmax",Mean="Mean",Min="Min",Minimum="Minimum",MirrorPad="MirrorPad",Mod="Mod",Multinomial="Multinomial",Multiply="Multiply",Neg="Neg",NotEqual="NotEqual",NonMaxSuppressionV3="NonMaxSuppressionV3",NonMaxSuppressionV4="NonMaxSuppressionV4",NonMaxSuppressionV5="NonMaxSuppressionV5",OnesLike="OnesLike",OneHot="OneHot",Pack="Pack",PadV2="PadV2",Pow="Pow",Prelu="Prelu",Prod="Prod",Range="Range",Real="Real",Reciprocal="Reciprocal",Relu="Relu",Reshape="Reshape",ResizeNearestNeighbor="ResizeNearestNeighbor",ResizeNearestNeighborGrad="ResizeNearestNeighborGrad",ResizeBilinear="ResizeBilinear",ResizeBilinearGrad="ResizeBilinearGrad",Relu6="Relu6",Reverse="Reverse",Round="Round",Rsqrt="Rsqrt",ScatterNd="ScatterNd",Select="Select",Selu="Selu",Slice="Slice",Sin="Sin",Sinh="Sinh",Sign="Sign",Sigmoid="Sigmoid",Softplus="Softplus",Sqrt="Sqrt",Sum="Sum",SpaceToBatchND="SpaceToBatchND",SplitV="SplitV",Softmax="Softmax",SquaredDifference="SquaredDifference",Square="Square",Sub="Sub",SparseToDense="SparseToDense",StridedSlice="StridedSlice",Tan="Tan",Tanh="Tanh",Tile="Tile",TopK="TopK",Transform="Transform",Transpose="Transpose",Unique="Unique",Unpack="Unpack",UnsortedSegmentSum="UnsortedSegmentSum",ZerosLike="ZerosLike",Step="Step",FromPixels="FromPixels",RotateWithOffset="RotateWithOffset",_FusedMatMul="_FusedMatMul",FusedConv2D="FusedConv2D",FusedDepthwiseConv2D="FusedDepthwiseConv2D",kernelRegistry=getGlobal("kernelRegistry",(()=>new Map)),gradRegistry=getGlobal("gradRegistry",(()=>new Map));function getKernel(e,t){const n=makeKey(e,t);return kernelRegistry.get(n)}function getGradient(e){return gradRegistry.get(e)}function getKernelsForBackend(e){const t=kernelRegistry.entries(),n=[];for(;;){const{done:i,value:r}=t.next();if(i)break;const[o,a]=r,[s]=o.split("_");s===e&&n.push(a)}return n}function registerKernel(e){const{kernelName:t,backendName:n}=e,i=makeKey(t,n);kernelRegistry.has(i)&&console.warn(`The kernel '${t}' for backend '${n}' is already registered`),kernelRegistry.set(i,e)}function makeKey(e,t){return`${t}_${e}`} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function createScalarValue(e,t){return"string"===t?encodeString(e):toTypedArray$1([e],t)}function noConversionNeeded(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}function toTypedArray$1(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=flatten$1(e)),env().getBool("DEBUG")&&checkConversionForErrors(e,t),noConversionNeeded(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n<t.length;++n)0!==Math.round(e[n])&&(t[n]=1);return t}throw new Error(`Unknown data type ${t}`)}function now(){return env().platform.now()}function encodeString(e,t="utf-8"){return t=t||"utf-8",env().platform.encode(e,t)}function decodeString(e,t="utf-8"){return t=t||"utf-8",env().platform.decode(e,t)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class Profiler{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new Logger)}profileKernel(e,t,n){let i;const r=()=>{i=n()};let o;const a=now();if(this.backendTimer.timerAvailable())o=this.backendTimer.time(r);else{r();for(const e of i)e.dataSync();o=Promise.resolve({kernelMs:now()-a})}if(env().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<i.length;t++){const n=i[t];n.data().then((t=>{checkComputationForErrors(t,n.dtype,e)}))}return{kernelName:e,outputs:i,inputs:t,timeMs:o.then((e=>e.kernelMs)),extraInfo:o.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:i,inputs:r,extraInfo:o}=e;n.forEach((e=>{Promise.all([e.data(),i,o]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],r,n[2])}))}))}}function checkComputationForErrors(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const i=e[t];if(isNaN(i)||!isFinite(i))return console.warn(`Found ${i} in the result of '${n}'`),!0}return!1}class Logger{logKernelProfile(e,t,n,i,r,o){const a="number"==typeof i?rightPad(`${i}ms`,9):i.error,s=rightPad(e,25),l=t.rank,c=t.size,h=rightPad(t.shape.toString(),14);let u="";for(const e in r){const n=r[e];if(null!=n){const i=n.shape||t.shape,r=i.length;u+=`${e}: ${r}D ${r>0?i:""} `}}console.log(`%c${s}\t%c${a}\t%c${l}D ${h}\t%c${c}\t%c${u}\t%c${o}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getFilteredNodesXToY(e,t,n){const i={},r={};for(let e=0;e<t.length;e++)i[t[e].id]=!0;for(let n=0;n<e.length;n++){const o=e[n],a=o.inputs;for(const e in a){const n=a[e];let s=!1;for(let e=0;e<t.length;e++)if(i[n.id]){o.outputs.forEach((e=>i[e.id]=!0)),s=!0,r[o.id]=!0;break}if(s)break}}const o={};o[n.id]=!0;const a={};for(let t=e.length-1;t>=0;t--){const n=e[t],i=n.inputs;for(let e=0;e<n.outputs.length;e++)if(o[n.outputs[e].id]){for(const e in i)o[i[e].id]=!0,a[n.id]=!0;break}}const s=[];for(let t=0;t<e.length;t++){const n=e[t];if(r[n.id]&&a[n.id]){const e={};for(const t in n.inputs){const r=n.inputs[t];i[r.id]&&(e[t]=r)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,s.push(t)}}return s}function backpropagateGradients(e,t,n,i){for(let r=t.length-1;r>=0;r--){const o=t[r],a=[];if(o.outputs.forEach((t=>{const n=e[t.id];a.push(null!=n?n:null)})),null==o.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${o.kernelName}.`);const s=o.gradient(a);for(const t in o.inputs){if(!(t in s))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(s)}.`);const r=n((()=>s[t]()));if("float32"!==r.dtype)throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${r.dtype}'`);const a=o.inputs[t];if(!arraysEqual$1(r.shape,a.shape))throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input '${t}' has shape '${r.shape}', which does not match the shape of the input '${a.shape}'`);if(null==e[a.id])e[a.id]=r;else{const t=e[a.id];e[a.id]=i(t,r),t.dispose()}}}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const FORMAT_LIMIT_NUM_VALS=20,FORMAT_NUM_FIRST_LAST_VALS=3,FORMAT_NUM_SIG_DIGITS=7;function tensorToString(e,t,n,i){const r=computeStrides(t),o=computeMaxSizePerColumn(e,t,n,r),a=t.length,s=subTensorToString(e,t,n,r,o),l=["Tensor"];return i&&(l.push(` dtype: ${n}`),l.push(` rank: ${a}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(s.map((e=>" "+e)).join("\n")),l.join("\n")}function computeMaxSizePerColumn(e,t,n,i){const r=sizeFromShape(t),o=i[i.length-1],a=new Array(o).fill(0),s=t.length,l="complex64"===n?createComplexTuples(e):e;if(s>1)for(let e=0;e<r/o;e++){const t=e*o;for(let e=0;e<o;e++)a[e]=Math.max(a[e],valToString(l[t+e],0,n).length)}return a}function valToString(e,t,n){let i;return i=Array.isArray(e)?`${parseFloat(e[0].toFixed(FORMAT_NUM_SIG_DIGITS))} + ${parseFloat(e[1].toFixed(FORMAT_NUM_SIG_DIGITS))}j`:isString(e)?`'${e}'`:"bool"===n?boolNumToString(e):parseFloat(e.toFixed(FORMAT_NUM_SIG_DIGITS)).toString(),rightPad(i,t)}function boolNumToString(e){return 0===e?"false":"true"}function subTensorToString(e,t,n,i,r,o=!0){const a="complex64"===n?2:1,s=t[0],l=t.length;if(0===l)return"complex64"===n?[valToString(createComplexTuples(e)[0],0,n)]:"bool"===n?[boolNumToString(e[0])]:[e[0].toString()];if(1===l){if(s>FORMAT_LIMIT_NUM_VALS){let t=Array.from(e.slice(0,FORMAT_NUM_FIRST_LAST_VALS*a)),i=Array.from(e.slice((s-FORMAT_NUM_FIRST_LAST_VALS)*a,s*a));return"complex64"===n&&(t=createComplexTuples(t),i=createComplexTuples(i)),["["+t.map(((e,t)=>valToString(e,r[t],n))).join(", ")+", ..., "+i.map(((e,t)=>valToString(e,r[s-FORMAT_NUM_FIRST_LAST_VALS+t],n))).join(", ")+"]"]}return["["+("complex64"===n?createComplexTuples(e):Array.from(e)).map(((e,t)=>valToString(e,r[t],n))).join(", ")+"]"]}const c=t.slice(1),h=i.slice(1),u=i[0]*a,d=[];if(s>FORMAT_LIMIT_NUM_VALS){for(let t=0;t<FORMAT_NUM_FIRST_LAST_VALS;t++){const i=t*u;d.push(...subTensorToString(e.slice(i,i+u),c,n,h,r,!1))}d.push("...");for(let t=s-FORMAT_NUM_FIRST_LAST_VALS;t<s;t++){const i=t*u;d.push(...subTensorToString(e.slice(i,i+u),c,n,h,r,t===s-1))}}else for(let t=0;t<s;t++){const i=t*u;d.push(...subTensorToString(e.slice(i,i+u),c,n,h,r,t===s-1))}const p=2===l?",":"";d[0]="["+d[0]+p;for(let e=1;e<d.length-1;e++)d[e]=" "+d[e]+p;let m=",\n";for(let e=2;e<l;e++)m+="\n";return d[d.length-1]=" "+d[d.length-1]+"]"+(o?"":m),d}function createComplexTuples(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class TensorBuffer{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=sizeFromShape(e),null!=n){const e=n.length;assert$1(e===this.size,(()=>`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===t)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||getArrayFromDType(t,this.size),this.strides=computeStrides(e)}set(e,...t){0===t.length&&(t=[0]),assert$1(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t])throw new Error(`Requested out of range element at ${e}. Buffer shape=${this.shape}`);t++}let n=e[e.length-1];for(let t=0;t<e.length-1;++t)n+=this.strides[t]*e[t];return this.values[n]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];const t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return trackerFn().makeTensor(this.values,this.shape,this.dtype)}}let trackerFn=null,opHandler$1=null;function setTensorTracker(e){trackerFn=e}function setOpHandler(e){opHandler$1=e}class Tensor{constructor(e,t,n,i){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=sizeFromShape(e),this.strides=computeStrides(e),this.dataId=n,this.id=i,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return opHandler$1.buffer(this.shape,this.dtype,e)}bufferSync(){return opHandler$1.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return toNestedArray(this.shape,e,"complex64"===this.dtype)}arraySync(){return toNestedArray(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=trackerFn().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>decodeString(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataSync(){this.throwIfDisposed();const e=trackerFn().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>decodeString(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();const e=await trackerFn().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(trackerFn().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return opHandler$1.print(this,e)}clone(){return this.throwIfDisposed(),opHandler$1.clone(this)}toString(e=!1){return tensorToString(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),opHandler$1.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),trackerFn().makeVariable(this,e,t,n)}}function getGlobalTensorClass(){return getGlobal("Tensor",(()=>Tensor))}Object.defineProperty(Tensor,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),getGlobalTensorClass();class Variable extends Tensor{constructor(e,t,n,i){super(e.shape,e.dtype,e.dataId,i),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!arraysEqual$1(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);trackerFn().disposeTensor(this),this.dataId=e.dataId,trackerFn().incRef(this,null)}dispose(){trackerFn().disposeVariable(this),this.isDisposedInternal=!0}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ var Rank,UpcastInt32AndMap,UpcastBoolAndMap,UpcastFloat32AndMap,UpcastComplex64AndMap;Object.defineProperty(Variable,Symbol.hasInstance,{value:e=>e instanceof Tensor&&null!=e.assign&&e.assign instanceof Function}),(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(Rank||(Rank={})),(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(UpcastInt32AndMap||(UpcastInt32AndMap={})),(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(UpcastBoolAndMap||(UpcastBoolAndMap={})),(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(UpcastFloat32AndMap||(UpcastFloat32AndMap={})),(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(UpcastComplex64AndMap||(UpcastComplex64AndMap={}));const upcastTypeMap={float32:UpcastFloat32AndMap,int32:UpcastInt32AndMap,bool:UpcastBoolAndMap,complex64:UpcastComplex64AndMap};function upcastType(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return upcastTypeMap[e][t]}function sumOutType(e){return upcastType(e,"int32")} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function makeTypesMatch(e,t){if(e.dtype===t.dtype)return[e,t];const n=upcastType(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function getTensorsInContainer(e){const t=[];return walkTensorContainer(e,t,new Set),t}function walkTensorContainer(e,t,n){if(null==e)return;if(e instanceof Tensor)return void t.push(e);if(!isIterable(e))return;const i=e;for(const e in i){const r=i[e];n.has(r)||(n.add(r),walkTensorContainer(r,t,n))}}function isIterable(e){return Array.isArray(e)||"object"==typeof e} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function isRegisteredKernelInvocation(e){return null!=e.kernelName}class EngineState{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class Engine{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new EngineState}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(console.warn(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new Profiler(this.backendInstance),!0}setupRegisteredKernels(){getKernelsForBackend(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){getKernelsForBackend(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof KernelBackend||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,i=n.then((n=>!(t<this.pendingBackendInitId||(this.registry[e]=n,this.pendingBackendInit=null,0)))).catch((n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,console.warn(`Initialization of backend ${e} failed`),console.warn(n.stack||n.message)),!1)));return this.pendingBackendInit=i,{success:i,asyncInit:!0}}}catch(t){return console.warn(`Initialization of backend ${e} failed`),console.warn(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:i,asyncInit:r}=this.initializeBackend(n);if(r||i)return{name:n,asyncInit:r}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),i=n.backend,r=this.readSync(t),o=i.refCount(t);i.disposeData(t,!0),n.backend=e,e.move(t,r,n.shape,n.dtype,o),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,i=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");i=e}return this.scopedRun((()=>this.startScope(i)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return Engine.nextTensorId++}nextVariableId(){return Engine.nextVariableId++}clone(e){const t=ENGINE.runKernel(Identity,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],(e=>({x:()=>ENGINE.runKernel(Cast,{x:e},{dtype:"float32"})})),[],{}),t}runKernel(e,t,n){if(null==getKernel(e,this.backendName))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const i=this.backend.numDataIds();let r=0;n.forEach((e=>{r+="complex64"===e.dtype?3:1}));const o=i-t-r-this.state.numDataMovesStack[this.state.numDataMovesStack.length-1];if(o>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${o} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const i=this.isTapeOn(),r=this.state.numBytes,o=this.state.numTensors;let a,s;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);const l=isRegisteredKernelInvocation(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(isRegisteredKernelInvocation(e)){const{kernelName:t,inputs:r,attrs:o}=e,l=getKernel(t,this.backendName);assert$1(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),a=()=>{const e=this.backend.numDataIds();s=l.kernelFunc({inputs:r,attrs:o,backend:this.backend});const a=Array.isArray(s)?s:[s];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,a);const c=a.map((e=>{if(null!=e.rank)return e;const{dataId:t,shape:n,dtype:i}=e;return this.makeTensorFromDataId(t,n,i)}));if(i){const e=this.getTensorsForGradient(t,r,c);n=this.saveTensorsForBackwardMode(e)}return c}}else{const{forwardFunc:t}=e,r=e=>{i&&(n=e.map((e=>this.keep(this.clone(e)))))};a=()=>{const e=this.backend.numDataIds();s=this.tidy((()=>t(this.backend,r)));const n=Array.isArray(s)?s:[s];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:c,attrs:h}=e,u=isRegisteredKernelInvocation(e)?null:e.backwardsFunc;let d;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(d=this.profiler.profileKernel(l,c,(()=>a())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs):t=a()})),i&&this.addTapeNode(l,c,t,u,n,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-r,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-o,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(c).map((e=>null!=c[e]?c[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(s)?t:t[0]}saveTensorsForBackwardMode(e){return e.map((e=>this.keep(this.clone(e))))}getTensorsForGradient(e,t,n){const i=getGradient(e);if(null!=i){const e=i.inputsToSave||[],r=i.outputsToSave||[];let o;i.saveAllInputs?(assert$1(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),o=Object.keys(t).map((e=>t[e]))):o=e.map((e=>t[e]));const a=n.filter(((e,t)=>r[t]));return o.concat(a)}return[]}makeTensor(e,t,n,i){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");i=i||this.backend;let r=e;"string"===(n=n||"float32")&&isString(e[0])&&(r=e.map((e=>encodeString(e))));const o=i.write(r,t,n),a=new Tensor(t,n,o,this.nextTensorId());if(this.trackTensor(a,i),"string"===n){const e=this.state.tensorInfo.get(o),t=bytesFromStringArray(r);this.state.numBytes+=t-e.bytes,e.bytes=t}return a}makeTensorFromDataId(e,t,n,i){const r=new Tensor(t,n=n||"float32",e,this.nextTensorId());return this.trackTensor(r,i),r}makeVariable(e,t=!0,n,i){n=n||this.nextVariableId().toString(),null!=i&&i!==e.dtype&&(e=e.cast(i));const r=new Variable(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[r.name])throw new Error(`Variable with name ${r.name} was already registered`);return this.state.registeredVariables[r.name]=r,this.incRef(r,this.backend),r}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*bytesPerElement(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof Variable||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*bytesPerElement(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables)this.disposeVariable(this.state.registeredVariables[e])}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,i,r,o){const a={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:r},s=getGradient(e);null!=s&&(i=s.gradFunc),null!=i&&(a.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],i=makeZerosTypedArray(e.size,e.dtype);return this.makeTensor(i,e.shape,e.dtype)}return e})),i(e.length>1?e:e[0],r,o))),this.state.activeTape.push(a)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=getTensorsInContainer(e),n=new Set(t.map((e=>e.id)));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const i=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach((e=>{e.kept||e.scopeId!==i.id||this.track(e)}))}gradients(e,t,n,i=!1){if(assert$1(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const r=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));assert$1(r instanceof Tensor,(()=>"The result y returned by f() must be a tensor."));const o=getFilteredNodesXToY(this.state.activeTape,t,r);if(!i&&0===o.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[r.id]=null==n?ones(r.shape):n,backpropagateGradients(e,o,(e=>this.tidy(e)),add$1);const i=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:r,grads:i}}))}customGrad(e){return assert$1(isFunction(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;assert$1(t.every((e=>e instanceof Tensor)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const i={};return t.forEach(((e,t)=>{i[t]=e})),this.runKernelFunc({forwardFunc:(i,r)=>(n=e(...t,r),assert$1(n.value instanceof Tensor,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),assert$1(isFunction(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,i)=>{const r=n.gradFunc(e,i),o=Array.isArray(r)?r:[r];assert$1(o.length===t.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),assert$1(o.every((e=>e instanceof Tensor)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const a={};return o.forEach(((e,t)=>{a[t]=()=>e})),a},inputs:i})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}async time(e){const t=now(),n=await this.backend.time(e);return n.wallMs=now()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new EngineState;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function ones(e){const t=makeOnesTypedArray(sizeFromShape(e),"float32");return ENGINE.makeTensor(t,e,"float32")}function getOrMakeEngine(){const e=getGlobalNamespace();if(null==e._tfengine){const t=new Environment(e);e._tfengine=new Engine(t)}return setEnvironmentGlobal(e._tfengine.ENV),setTensorTracker((()=>e._tfengine)),e._tfengine}Engine.nextTensorId=0,Engine.nextVariableId=0;const ENGINE=getOrMakeEngine();function add$1(e,t){return ENGINE.runKernel(Add,{a:e,b:t})} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function _isNavigatorDefined(){return"undefined"!=typeof navigator&&null!=navigator}function isMobile(e){if(e||_isNavigatorDefined()){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function isBrowser(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const ENV$1=env(); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function inferShape(e,t){let n=e;if(isTypedArray(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];const i=[];for(;Array.isArray(n)||isTypedArray(n)&&"string"!==t;)i.push(n.length),n=n[0];return Array.isArray(e)&&env().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&deepAssertShapeConsistency(e,i,[]),i}function deepAssertShapeConsistency(e,t,n){if(n=n||[],!Array.isArray(e)&&!isTypedArray(e))return void assert$1(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));assert$1(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),assert$1(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const i=t.slice(1);for(let t=0;t<e.length;++t)deepAssertShapeConsistency(e[t],i,n.concat(t))}function assertDtype(e,t,n,i){if("string_or_numeric"!==e){if(null==e)throw new Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw new Error(`Argument '${n}' passed to '${i}' must be ${e} tensor, but got ${t} tensor`)}}function convertToTensor(e,t,n,i="numeric"){if(e instanceof Tensor)return assertDtype(i,e.dtype,t,n),e;let r=inferDtype(e);if("string"!==r&&["bool","int32","float32"].indexOf(i)>=0&&(r=i),assertDtype(i,r,t,n),null==e||!isTypedArray(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${null==e?"null":e.constructor.name}'`);const o=inferShape(e,r);isTypedArray(e)||Array.isArray(e)||(e=[e]);const a="string"!==r?toTypedArray$1(e,r):flatten$1(e,[],!0);return ENGINE.makeTensor(a,o,r)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ENV$1.registerFlag("DEBUG",(()=>!1),(e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),ENV$1.registerFlag("IS_BROWSER",(()=>isBrowser())),ENV$1.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),ENV$1.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),ENV$1.registerFlag("PROD",(()=>!1)),ENV$1.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>ENV$1.getBool("DEBUG"))),ENV$1.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),ENV$1.registerFlag("IS_TEST",(()=>!1)),ENV$1.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),ENV$1.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1));const OP_SCOPE_SUFFIX="__op";function op(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const i=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=OP_SCOPE_SUFFIX;const r=(...e)=>{ENGINE.startScope(n);try{const t=i(...e);return isPromise(t)&&console.error("Cannot return a Promise inside of tidy."),ENGINE.endScope(t),t}catch(e){throw ENGINE.endScope(null),e}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function complex_(e,t){const n=convertToTensor(e,"real","complex"),i=convertToTensor(t,"imag","complex");return assertShapesMatch(n.shape,i.shape,`real and imag shapes, ${n.shape} and ${i.shape}, must match in call to tf.complex().`),ENGINE.runKernel(Complex,{real:n,imag:i})}const complex$2=op({complex_:complex_}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function makeTensor(e,t,n,i){if(null==i&&(i=inferDtype(e)),"complex64"===i)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!isTypedArray(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){assertNonNegativeIntegerDimensions(t);const e=sizeFromShape(t),i=sizeFromShape(n);assert$1(e===i,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${i}`));for(let e=0;e<n.length;++e){const i=n[e],r=e!==n.length-1||i!==sizeFromShape(t.slice(e));assert$1(n[e]===t[e]||!r,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return isTypedArray(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==i?toTypedArray$1(e,i):flatten$1(e,[],!0),ENGINE.makeTensor(e,t,i)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function tensor(e,t,n){return makeTensor(e,t,inferShape(e,n),n)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const useNodeBuffer="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function stringByteLength(e){return useNodeBuffer?Buffer.byteLength(e):new Blob([e]).size}function arrayBufferToBase64String(e){if(useNodeBuffer)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,i=t.length;e<i;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function base64StringToArrayBuffer(e){if(useNodeBuffer){const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}function getModelArtifactsInfoForJSON(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:stringByteLength(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:stringByteLength(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class IORouterRegistry{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==IORouterRegistry.instance&&(IORouterRegistry.instance=new IORouterRegistry),IORouterRegistry.instance}static registerSaveRouter(e){IORouterRegistry.getInstance().saveRouters.push(e)}static registerLoadRouter(e){IORouterRegistry.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return IORouterRegistry.getHandlers(e,"save")}static getLoadHandlers(e,t){return IORouterRegistry.getHandlers(e,"load",t)}static getHandlers(e,t,n){const i=[];return("load"===t?IORouterRegistry.getInstance().loadRouters:IORouterRegistry.getInstance().saveRouters).forEach((t=>{const r=t(e,n);null!==r&&i.push(r)})),i}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const DATABASE_NAME="tensorflowjs",DATABASE_VERSION=1,MODEL_STORE_NAME="models_store",INFO_STORE_NAME="model_info_store";function getIndexedDBFactory(){if(!env().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function setUpDatabase(e){const t=e.result;t.createObjectStore(MODEL_STORE_NAME,{keyPath:"modelPath"}),t.createObjectStore(INFO_STORE_NAME,{keyPath:"modelPath"})}class BrowserIndexedDB{constructor(e){if(this.indexedDB=getIndexedDBFactory(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const i=this.indexedDB.open(DATABASE_NAME,DATABASE_VERSION);i.onupgradeneeded=()=>setUpDatabase(i),i.onsuccess=()=>{const r=i.result;if(null==t){const t=r.transaction(MODEL_STORE_NAME,"readonly"),i=t.objectStore(MODEL_STORE_NAME).get(this.modelPath);i.onsuccess=()=>{if(null==i.result)return r.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(i.result.modelArtifacts)},i.onerror=e=>(r.close(),n(i.error)),t.oncomplete=()=>r.close()}else{const i=getModelArtifactsInfoForJSON(t),o=r.transaction(INFO_STORE_NAME,"readwrite");let a=o.objectStore(INFO_STORE_NAME);const s=a.put({modelPath:this.modelPath,modelArtifactsInfo:i});let l;s.onsuccess=()=>{l=r.transaction(MODEL_STORE_NAME,"readwrite");const s=l.objectStore(MODEL_STORE_NAME).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});s.onsuccess=()=>e({modelArtifactsInfo:i}),s.onerror=e=>{a=o.objectStore(INFO_STORE_NAME);const t=a.delete(this.modelPath);t.onsuccess=()=>(r.close(),n(s.error)),t.onerror=e=>(r.close(),n(s.error))}},s.onerror=e=>(r.close(),n(s.error)),o.oncomplete=()=>{null==l?r.close():l.oncomplete=()=>r.close()}}},i.onerror=e=>n(i.error)}))}}BrowserIndexedDB.URL_SCHEME="indexeddb://";const indexedDBRouter=e=>env().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(BrowserIndexedDB.URL_SCHEME)?browserIndexedDB(e.slice(BrowserIndexedDB.URL_SCHEME.length)):null;function browserIndexedDB(e){return new BrowserIndexedDB(e)}function maybeStripScheme$1(e){return e.startsWith(BrowserIndexedDB.URL_SCHEME)?e.slice(BrowserIndexedDB.URL_SCHEME.length):e}IORouterRegistry.registerSaveRouter(indexedDBRouter),IORouterRegistry.registerLoadRouter(indexedDBRouter);class BrowserIndexedDBManager{constructor(){this.indexedDB=getIndexedDBFactory()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(DATABASE_NAME,DATABASE_VERSION);n.onupgradeneeded=()=>setUpDatabase(n),n.onsuccess=()=>{const i=n.result,r=i.transaction(INFO_STORE_NAME,"readonly"),o=r.objectStore(INFO_STORE_NAME).getAll();o.onsuccess=()=>{const t={};for(const e of o.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},o.onerror=e=>(i.close(),t(o.error)),r.oncomplete=()=>i.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){return e=maybeStripScheme$1(e),new Promise(((t,n)=>{const i=this.indexedDB.open(DATABASE_NAME,DATABASE_VERSION);i.onupgradeneeded=()=>setUpDatabase(i),i.onsuccess=()=>{const r=i.result,o=r.transaction(INFO_STORE_NAME,"readwrite"),a=o.objectStore(INFO_STORE_NAME),s=a.get(e);let l;s.onsuccess=()=>{if(null==s.result)return r.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const i=a.delete(e),o=()=>{l=r.transaction(MODEL_STORE_NAME,"readwrite");const i=l.objectStore(MODEL_STORE_NAME).delete(e);i.onsuccess=()=>t(s.result.modelArtifactsInfo),i.onerror=e=>n(s.error)};i.onsuccess=o,i.onerror=e=>(o(),r.close(),n(s.error))}},s.onerror=e=>(r.close(),n(s.error)),o.oncomplete=()=>{null==l?r.close():l.oncomplete=()=>r.close()}},i.onerror=e=>n(i.error)}))}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const PATH_SEPARATOR="/",PATH_PREFIX="tensorflowjs_models",INFO_SUFFIX="info",MODEL_TOPOLOGY_SUFFIX="model_topology",WEIGHT_SPECS_SUFFIX="weight_specs",WEIGHT_DATA_SUFFIX="weight_data",MODEL_METADATA_SUFFIX="model_metadata";function getModelKeys(e){return{info:[PATH_PREFIX,e,INFO_SUFFIX].join(PATH_SEPARATOR),topology:[PATH_PREFIX,e,MODEL_TOPOLOGY_SUFFIX].join(PATH_SEPARATOR),weightSpecs:[PATH_PREFIX,e,WEIGHT_SPECS_SUFFIX].join(PATH_SEPARATOR),weightData:[PATH_PREFIX,e,WEIGHT_DATA_SUFFIX].join(PATH_SEPARATOR),modelMetadata:[PATH_PREFIX,e,MODEL_METADATA_SUFFIX].join(PATH_SEPARATOR)}}function getModelPathFromKey(e){const t=e.split(PATH_SEPARATOR);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(PATH_SEPARATOR)}function maybeStripScheme(e){return e.startsWith(BrowserLocalStorage.URL_SCHEME)?e.slice(BrowserLocalStorage.URL_SCHEME.length):e}class BrowserLocalStorage{constructor(e){if(!env().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=getModelKeys(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),i=getModelArtifactsInfoForJSON(e);try{this.LS.setItem(this.keys.info,JSON.stringify(i)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,arrayBufferToBase64String(e.weightData));const r={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};return null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer),this.LS.setItem(this.keys.modelMetadata,JSON.stringify(r)),{modelArtifactsInfo:i}}catch(e){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${i.modelTopologyBytes}, weightSpecsBytes=${i.weightSpecsBytes}, weightDataBytes=${i.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const i=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==i)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=i;const r=this.LS.getItem(this.keys.modelMetadata);if(null!=r){const e=JSON.parse(r);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer)}const o=this.LS.getItem(this.keys.weightData);if(null==o)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=base64StringToArrayBuffer(o),t}}BrowserLocalStorage.URL_SCHEME="localstorage://";const localStorageRouter=e=>env().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(BrowserLocalStorage.URL_SCHEME)?browserLocalStorage(e.slice(BrowserLocalStorage.URL_SCHEME.length)):null;function browserLocalStorage(e){return new BrowserLocalStorage(e)}IORouterRegistry.registerSaveRouter(localStorageRouter),IORouterRegistry.registerLoadRouter(localStorageRouter);class BrowserLocalStorageManager{constructor(){assert$1(env().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),assert$1("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=PATH_PREFIX+PATH_SEPARATOR,n=PATH_SEPARATOR+INFO_SUFFIX;for(let i=0;i<this.LS.length;++i){const r=this.LS.key(i);r.startsWith(t)&&r.endsWith(n)&&(e[getModelPathFromKey(r)]=JSON.parse(this.LS.getItem(r)))}return e}async removeModel(e){const t=getModelKeys(e=maybeStripScheme(e));if(null==this.LS.getItem(t.info))throw new Error(`Cannot find model at path '${e}'`);const n=JSON.parse(this.LS.getItem(t.info));return this.LS.removeItem(t.info),this.LS.removeItem(t.topology),this.LS.removeItem(t.weightSpecs),this.LS.removeItem(t.weightData),n}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const URL_SCHEME_SUFFIX="://";class ModelStoreManagerRegistry{constructor(){this.managers={}}static getInstance(){return null==ModelStoreManagerRegistry.instance&&(ModelStoreManagerRegistry.instance=new ModelStoreManagerRegistry),ModelStoreManagerRegistry.instance}static registerManager(e,t){assert$1(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith(URL_SCHEME_SUFFIX)&&(e=e.slice(0,e.indexOf(URL_SCHEME_SUFFIX))),assert$1(e.length>0,(()=>"scheme must not be an empty string."));const n=ModelStoreManagerRegistry.getInstance();assert$1(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=this.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class PlatformBrowser{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}}if(env().get("IS_BROWSER")){env().setPlatform("browser",new PlatformBrowser);try{ModelStoreManagerRegistry.registerManager(BrowserLocalStorage.URL_SCHEME,new BrowserLocalStorageManager)}catch(e){}try{ModelStoreManagerRegistry.registerManager(BrowserIndexedDB.URL_SCHEME,new BrowserIndexedDBManager)}catch(e){}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const getNodeFetch={importFetch:()=>require("node-fetch")};let systemFetch;class PlatformNode{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=env().global.fetch?env().global.fetch(e,t):(null==systemFetch&&(systemFetch=getNodeFetch.importFetch()),systemFetch(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}} /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function buffer(e,t="float32",n){return t=t||"float32",assertNonNegativeIntegerDimensions(e),new TensorBuffer(e,t,n)} /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function cast_(e,t){const n=convertToTensor(e,"x","cast");if(!isValidDtype(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");return ENGINE.runKernel(Cast,{x:n},{dtype:t})}env().get("IS_NODE")&&env().setPlatform("node",new PlatformNode);const cast$2=op({cast_:cast_}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function clone_(e){const t=convertToTensor(e,"x","clone","string_or_numeric");return ENGINE.runKernel(Identity,{x:t})}const clone=op({clone_:clone_}); /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function print(e,t=!1){console.log(e.toString(t))} /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */getOrMakeEngine();const opHandler={buffer:buffer,cast:cast$2,clone:clone,print:print}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function matMul_(e,t,n=!1,i=!1){let r=convertToTensor(e,"a","matMul"),o=convertToTensor(t,"b","matMul");return[r,o]=makeTypesMatch(r,o),ENGINE.runKernel(BatchMatMul,{a:r,b:o},{transposeA:n,transposeB:i})}setOpHandler(opHandler);const matMul=op({matMul_:matMul_}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function transpose_(e,t){const n=convertToTensor(e,"x","transpose");return null==t&&(t=n.shape.map(((e,t)=>t)).reverse()),assert$1(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`)),t.forEach((e=>{assert$1(e>=0&&e<n.rank,(()=>"All entries in 'perm' must be between 0 and "+(n.rank-1)+` but got ${t}`))})),n.rank<=1?n.clone():ENGINE.runKernel(Transpose,{x:n},{perm:t})}const transpose$2=op({transpose_:transpose_});function prepareAndValidate(e,t){const n=e.shape.length,i=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(i<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${i}.`);if("int32"!==t.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[i-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[i-1]} vs. ${n}`);if(0===sizeFromShape(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const r=t.shape,o=r[r.length-1];let a=1;for(let e=0;e<r.length-1;++e)a*=r[e];const s=e.shape,l=r.slice();l.pop();let c=1;for(let e=o;e<n;++e)c*=s[e],l.push(s[e]);const h=[...computeStrides(e.shape).map((e=>e/c)),1].slice(0,o);return[l,a,c,h]}function validateUpdateShape(e,t,n){const i=t.rank>1?t.shape[t.rank-1]:1,r=t.rank>1?t.rank-1:1,o=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${i}, and batchDim: ${r}.`;if(n.rank<r)throw new Error(o+` update.rank < ${r}. `);if(e.length<i+(n.rank-r))throw new Error(o+` Output shape length < ${i+(n.rank-r)}`);if(n.rank!==r+e.length-i)throw new Error(o+" update.rank != "+(r+e.length-i));for(let e=0;e<r;++e)if(n.shape[e]!==t.shape[e])throw new Error(o+` updates.shape[${e}] (${n.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`);for(let t=0;t<n.rank-r;++t)if(n.shape[t+r]!==e[t+i])throw new Error(o+` updates.shape[${t+r}] (${n.shape[t+r]}) != shape[${t+r}] (${e[t+r]})`)}function validateInput(e,t,n){if(t.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==t.dtype)throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(n.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`);if(0===n.length){if(0===t.size)throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(0===e.size)throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`)}validateUpdateShape(n,t,e)}function calculateShapes(e,t,n){const i=t.shape.length,r=i>1?t.shape[i-1]:1,o=n.length;let a=1;for(let e=r;e<o;++e)a*=n[e];const s=r<1?1:r;return{sliceRank:r,numUpdates:sizeFromShape(t.shape)/s,sliceSize:a,strides:[...computeStrides(n.slice(0,r)),1],outputSize:sizeFromShape(n)}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function assertParamsValid(e,t,n){const i=e.shape.length;assert$1(i===t.length,(()=>`Error in slice${i}D: Length of begin ${t} must match the rank of the array (${i}).`)),assert$1(i===n.length,(()=>`Error in slice${i}D: Length of size ${n} must match the rank of the array (${i}).`));for(let r=0;r<i;++r)assert$1(t[r]+n[r]<=e.shape[r],(()=>`Error in slice${i}D: begin[${r}] + size[${r}] (${t[r]+n[r]}) would overflow input.shape[${r}] (${e.shape[r]})`))}function maskToAxes(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function computeOutShape$2(e,t,n){const i=[];for(let r=0;r<e.length;r++)i[r]=Math.ceil((t[r]-e[r])/n[r]);return i}function stridesWithElidedDims(e,t,n,i){const r=[...e];for(let e=r.length;e<i.length;e++)r.push(1);for(let e=0;e<n;e++)0===e?r[t]=1:(r.splice(t,0,1),r.pop());return r}function unnormalizeAxis(e,t,n){return n<=e?n:n-(t-1)}function getElidedAxes(e,t){const n=[];for(let i=0;i<e;i++)n.push(t+i);return n}function getNormalizedAxes(e,t,n,i,r,o,a,s,l){const c=e.length;let h=new Array(c),u=new Array(c),d=new Array(c);if(t.length&&n>0){const l=t[0],c=n+1;h=startIndicesWithElidedDims(a,l,c,i,e),u=stopIndicesWithElidedDims(s,l,c,r,e),d=stridesWithElidedDims(o,l,c,e)}else for(let t=0;t<c;t++)h[t]=startForAxis(a,i,o,e,t,l),u[t]=stopForAxis(s,r,o,e,t,l),d[t]=stridesForAxis(o,t,l);return{begin:h,end:u,strides:d}}function startIndicesWithElidedDims(e,t,n,i,r){const o=[...r],a=getElidedAxes(n,t);for(let r=0;r<o.length;r++)if(a.indexOf(r)>-1)o[r]=0;else{const a=unnormalizeAxis(t,n,r);let s=i[a];e&1<<a&&(s=0),o[r]=s}return o}function stopIndicesWithElidedDims(e,t,n,i,r){const o=[...r],a=getElidedAxes(n,t);for(let r=0;r<o.length;r++)if(a.indexOf(r)>-1)o[r]=Number.MAX_SAFE_INTEGER;else{const a=unnormalizeAxis(t,n,r);let s=i[a];e&1<<a&&(s=Number.MAX_SAFE_INTEGER),o[r]=s}for(let e=0;e<o.length;e++){const t=r[e];o[e]<0&&(o[e]+=t),o[e]=clamp(0,o[e],r[e])}return o}function stridesForAxis(e,t,n){let i=e[t];return(n&1<<t||null==i)&&(i=1),i}function startForAxis(e,t,n,i,r,o){let a=t[r];(e&1<<r||o&1<<r||null==a)&&(a=(n[r]||1)>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const s=i[r];return a<0&&(a+=s),a=clamp(0,a,s-1),a}function stopForAxis(e,t,n,i,r,o){let a=t[r];const s=n[r]||1;(e&1<<r||o&1<<r||null==a)&&(a=s>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const l=i[r];return a<0&&(a+=l),a=s>0?clamp(0,a,l):clamp(-1,a,l-1),a}function isSliceContinous(e,t,n){let i=n.length;for(let e=0;e<n.length;e++)if(n[e]>1){i=e;break}for(let r=i+1;r<n.length;r++)if(t[r]>0||n[r]!==e[r])return!1;return!0}function computeFlatOffset(e,t){let n=e.length>0?e[e.length-1]:1;for(let i=0;i<e.length-1;i++)n+=e[i]*t[i];return n}function parseSliceParams(e,t,n){let i;const r=e.shape.length;let o;return i="number"==typeof t?[t,...new Array(r-1).fill(0)]:t.length<r?t.concat(new Array(r-t.length).fill(0)):t.slice(),i.forEach((e=>{assert$1(-1!==e,(()=>"slice() does not support negative begin indexing."))})),o=null==n?new Array(r).fill(-1):"number"==typeof n?[n,...new Array(r-1).fill(-1)]:n.length<r?n.concat(new Array(r-n.length).fill(-1)):n,o=o.map(((t,n)=>t>=0?t:(assert$1(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-i[n]))),[i,o]}function sliceInfo(e,t,n,i,r,o,a,s,l){let c=t.slice(),h=n.slice(),u=i;null==i&&(u=new Array(c.length));const d=maskToAxes(a);if(d.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(0!==a&&0!==s)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(0!==a&&0!==l)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");const p=e.length-c.length,m=maskToAxes(s),f=e.slice();m.forEach((e=>{c[e]=0,h[e]=1,f.splice(e,0,1)}));const{begin:g,end:v,strides:y}=getNormalizedAxes(f,d,p,c,h,u,r,o,a);c=g,h=v,u=y;const b=maskToAxes(l);b.forEach((e=>{h[e]=c[e]+1,u[e]=1}));const _=computeOutShape$2(c,h,u),x=_.filter(((e,t)=>-1===b.indexOf(t)));return{nonStrided:u.every((e=>1===e)),$begin:c,$end:h,$strides:u,size:_,newShape:f,outShape:x}}var slice_util=Object.freeze({__proto__:null,assertParamsValid:assertParamsValid,maskToAxes:maskToAxes,computeOutShape:computeOutShape$2,stridesWithElidedDims:stridesWithElidedDims,getNormalizedAxes:getNormalizedAxes,startIndicesWithElidedDims:startIndicesWithElidedDims,stopIndicesWithElidedDims:stopIndicesWithElidedDims,stridesForAxis:stridesForAxis,startForAxis:startForAxis,stopForAxis:stopForAxis,isSliceContinous:isSliceContinous,computeFlatOffset:computeFlatOffset,parseSliceParams:parseSliceParams,sliceInfo:sliceInfo}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function engine(){return ENGINE}function tidy(e,t){return ENGINE.tidy(e,t)}function ready(){return ENGINE.ready()}function getBackend(){return ENGINE.backendName}function registerBackend(e,t,n=1){return ENGINE.registerBackend(e,t,n)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function mul_(e,t){let n=convertToTensor(e,"a","mul"),i=convertToTensor(t,"b","mul");return[n,i]=makeTypesMatch(n,i),ENGINE.runKernel(Multiply,{a:n,b:i})}const mul=op({mul_:mul_}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function computeDilation2DInfo(e,t,n,i,r="NHWC",o){return computeConv2DInfo(e,[...t,e[3]],n,o,i,null,null,convertConv2DDataFormat(r))}function computePool2DInfo(e,t,n,i,r,o,a="channelsLast"){const[s,l]=parseTupleParam(t);let c;if("channelsLast"===a)c=[s,l,e[3],e[3]];else{if("channelsFirst"!==a)throw new Error(`Unknown dataFormat ${a}`);c=[s,l,e[1],e[1]]}return computeConv2DInfo(e,c,n,i,r,o,!1,a)}function computePool3DInfo(e,t,n,i,r,o,a="NDHWC"){const[s,l,c]=parse3TupleParam(t);let h,u;if("NDHWC"===a)u="channelsLast",h=[s,l,c,e[4],e[4]];else{if("NCDHW"!==a)throw new Error(`Unknown dataFormat ${a}`);u="channelsFirst",h=[s,l,c,e[1],e[1]]}return computeConv3DInfo(e,h,n,i,r,!1,u,o)}function computeConv2DInfo(e,t,n,i,r,o,a=!1,s="channelsLast"){let[l,c,h,u]=[-1,-1,-1,-1];if("channelsLast"===s)[l,c,h,u]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[l,u,c,h]=e}const[d,p,,m]=t,[f,g]=parseTupleParam(n),[v,y]=parseTupleParam(i),b=getEffectiveFilterSize(d,v),_=getEffectiveFilterSize(p,y),{padInfo:x,outHeight:w,outWidth:S}=getPadAndOutInfo(r,c,h,f,g,b,_,o,s),C=a?m*u:m;let M;return"channelsFirst"===s?M=[l,C,w,S]:"channelsLast"===s&&(M=[l,w,S,C]),{batchSize:l,dataFormat:s,inHeight:c,inWidth:h,inChannels:u,outHeight:w,outWidth:S,outChannels:C,padInfo:x,strideHeight:f,strideWidth:g,filterHeight:d,filterWidth:p,effectiveFilterHeight:b,effectiveFilterWidth:_,dilationHeight:v,dilationWidth:y,inShape:e,outShape:M,filterShape:t}}function computeConv3DInfo(e,t,n,i,r,o=!1,a="channelsLast",s){let[l,c,h,u,d]=[-1,-1,-1,-1,-1];if("channelsLast"===a)[l,c,h,u,d]=e;else{if("channelsFirst"!==a)throw new Error(`Unknown dataFormat ${a}`);[l,d,c,h,u]=e}const[p,m,f,,g]=t,[v,y,b]=parse3TupleParam(n),[_,x,w]=parse3TupleParam(i),S=getEffectiveFilterSize(p,_),C=getEffectiveFilterSize(m,x),M=getEffectiveFilterSize(f,w),{padInfo:E,outDepth:T,outHeight:I,outWidth:A}=get3DPadAndOutInfo(r,c,h,u,v,y,b,S,C,M,s),k=o?g*d:g;let P;return"channelsFirst"===a?P=[l,k,T,I,A]:"channelsLast"===a&&(P=[l,T,I,A,k]),{batchSize:l,dataFormat:a,inDepth:c,inHeight:h,inWidth:u,inChannels:d,outDepth:T,outHeight:I,outWidth:A,outChannels:k,padInfo:E,strideDepth:v,strideHeight:y,strideWidth:b,filterDepth:p,filterHeight:m,filterWidth:f,effectiveFilterDepth:S,effectiveFilterHeight:C,effectiveFilterWidth:M,dilationDepth:_,dilationHeight:x,dilationWidth:w,inShape:e,outShape:P,filterShape:t}}function computeOutputShape2D(e,t,n,i,r){null==i&&(i=computeDefaultPad(e,t,n));const o=e[1];return[round$2((e[0]-t+2*i)/n+1,r),round$2((o-t+2*i)/n+1,r)]}function computeOutputShape4D(e,t,n,i,r,o){null==r&&(r=computeDefaultPad(e,t,i));const a=e[1],s=e[2];return[round$2((e[0]-t+2*r)/i+1,o),round$2((a-t+2*r)/i+1,o),round$2((s-t+2*r)/i+1,o),n]}function computeDefaultPad(e,t,n,i=1){const r=getEffectiveFilterSize(t,i);return Math.floor((e[0]*(n-1)-n+r)/2)}function parseTupleParam(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function parse3TupleParam(e){return"number"==typeof e?[e,e,e]:e}function getEffectiveFilterSize(e,t){return t<=1?e:e+(e-1)*(t-1)}function getPadAndOutInfo(e,t,n,i,r,o,a,s,l){let c,h,u;if("number"==typeof e){c={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const r=computeOutputShape2D([t,n],o,i,e,s);h=r[0],u=r[1]}else if("same"===e){h=Math.ceil(t/i),u=Math.ceil(n/r);const e=Math.max(0,(h-1)*i+o-t),s=Math.max(0,(u-1)*r+a-n),l=Math.floor(e/2),d=e-l,p=Math.floor(s/2);c={top:l,bottom:d,left:p,right:s-p,type:"SAME"}}else if("valid"===e)c={top:0,bottom:0,left:0,right:0,type:"VALID"},h=Math.ceil((t-o+1)/i),u=Math.ceil((n-a+1)/r);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const d="channelsLast"===l?e[1][0]:e[2][0],p="channelsLast"===l?e[1][1]:e[2][1],m="channelsLast"===l?e[2][0]:e[3][0],f="channelsLast"===l?e[2][1]:e[3][1];c={top:d,bottom:p,left:m,right:f,type:0===d&&0===p&&0===m&&0===f?"VALID":"EXPLICIT"},h=round$2((t-o+d+p)/i+1,s),u=round$2((n-a+m+f)/r+1,s)}}return{padInfo:c,outHeight:h,outWidth:u}}function get3DPadAndOutInfo(e,t,n,i,r,o,a,s,l,c,h){let u,d,p,m;if("number"==typeof e){u={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const o=computeOutputShape4D([t,n,i,1],s,1,r,e,h);d=o[0],p=o[1],m=o[2]}else if("same"===e){d=Math.ceil(t/r),p=Math.ceil(n/o),m=Math.ceil(i/a);const e=(d-1)*r+s-t,h=(p-1)*o+l-n,f=(m-1)*a+c-i,g=Math.floor(e/2),v=e-g,y=Math.floor(h/2),b=h-y,_=Math.floor(f/2);u={top:y,bottom:b,left:_,right:f-_,front:g,back:v,type:"SAME"}}else{if("valid"!==e)throw Error(`Unknown padding parameter: ${e}`);u={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},d=Math.ceil((t-s+1)/r),p=Math.ceil((n-l+1)/o),m=Math.ceil((i-c+1)/a)}return{padInfo:u,outDepth:d,outHeight:p,outWidth:m}}function round$2(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function tupleValuesAreOne(e){const[t,n,i]=parseTupleParam(e);return 1===t&&1===n&&1===i}function eitherStridesOrDilationsAreOne(e,t){return tupleValuesAreOne(e)||tupleValuesAreOne(t)}function convertConv2DDataFormat(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function reshape_(e,t){const n=convertToTensor(e,"x","reshape","string_or_numeric");return ENGINE.runKernel(Reshape,{x:n},{shape:t})}const reshape$2=op({reshape_:reshape_}); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getBroadcastDims$1(e,t){const n=e.length,i=[];for(let r=0;r<n;r++){const o=n-1-r,a=e[o]||1;(t[t.length-1-r]||1)>1&&1===a&&i.unshift(o)}return i}function getReductionAxes(e,t){const n=[];for(let i=0;i<t.length;i++){const r=e[e.length-i-1],o=t.length-i-1,a=t[o];(null==r||1===r&&a>1)&&n.unshift(o)}return n}function assertAndGetBroadcastShape(e,t){const n=[],i=Math.max(e.length,t.length);for(let r=0;r<i;r++){let i=e[e.length-r-1];null==i&&(i=1);let o=t[t.length-r-1];if(null==o&&(o=1),1===i)n.unshift(o);else if(1===o)n.unshift(i);else{if(i!==o)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);n.unshift(i)}}return n} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function elu_(e){const t=convertToTensor(e,"x","elu");return ENGINE.runKernel(Elu,{x:t})}const elu$2=op({elu_:elu_}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function leakyRelu_(e,t=.2){const n=convertToTensor(e,"x","leakyRelu");return ENGINE.runKernel(LeakyRelu,{x:n},{alpha:t})}const leakyRelu$2=op({leakyRelu_:leakyRelu_}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function sub_(e,t){let n=convertToTensor(e,"a","sub"),i=convertToTensor(t,"b","sub");return[n,i]=makeTypesMatch(n,i),ENGINE.runKernel(Sub,{a:n,b:i})}const sub$3=op({sub_:sub_}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function sum_(e,t=null,n=!1){let i=convertToTensor(e,"x","sum");return"bool"===i.dtype&&(i=cast$2(i,"int32")),ENGINE.runKernel(Sum,{x:i},{axis:t,keepDims:n})}const sum$2=op({sum_:sum_}); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function axesAreInnerMostDims(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function combineLocations(e,t,n){const i=e.length+t.length,r=[];let o=0,a=0;for(let s=0;s<i;s++)-1===n.indexOf(s)?r.push(e[o++]):r.push(t[a++]);return r}function computeOutAndReduceShapes(e,t){const n=[],i=e.length;for(let r=0;r<i;r++)-1===t.indexOf(r)&&n.push(e[r]);return[n,t.map((t=>e[t]))]}function expandShapeToKeepDim(e,t){return combineLocations(e,t.map((e=>1)),t)}function assertAxesAreInnerMostDims(e,t,n){assert$1(axesAreInnerMostDims(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function getAxesPermutation(e,t){if(axesAreInnerMostDims(e,t))return null;const n=[];for(let i=0;i<t;++i)-1===e.indexOf(i)&&n.push(i);return e.forEach((e=>n.push(e))),n}function getUndoAxesPermutation(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function getInnerMostAxes(e,t){const n=[];for(let i=t-e;i<t;++i)n.push(i);return n} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function zeros$1(e,t="float32"){if("complex64"===t){const t=zeros$1(e,"float32"),n=zeros$1(e,"float32");return complex$2(t,n)}const n=makeZerosTypedArray(sizeFromShape(e),t);return ENGINE.makeTensor(n,e,t)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function pad_(e,t,n=0){const i=convertToTensor(e,"x","pad");if(0===i.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");return ENGINE.runKernel(PadV2,{x:i},{paddings:t,constantValue:n})}const pad=op({pad_:pad_}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function prelu_(e,t){const n=convertToTensor(e,"x","prelu"),i=convertToTensor(t,"alpha","prelu");return ENGINE.runKernel(Prelu,{x:n,alpha:i})}const prelu$2=op({prelu_:prelu_});var alea=createCommonjsModule((function(e){!(function(e,t,n){function i(e){var t=this,n=(function i(){var e=4022871197;return function(t){t=t.toString();for(var n=0;n<t.length;n++){var i=.02519603282416938*(e+=t.charCodeAt(n));i-=e=i>>>0,e=(i*=e)>>>0,e+=4294967296*(i-=e)}return 2.3283064365386963e-10*(e>>>0)}})();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function r(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function o(e,t){var n=new i(e),o=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,o&&("object"==typeof o&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:this.alea=o})(0,e)})),xor128=createCommonjsModule((function(e){!(function(e,t,n){function i(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var i=0;i<n.length+64;i++)t.x^=0|n.charCodeAt(i),t.next()}function r(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function o(e,t){var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&("object"==typeof o&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:this.xor128=o})(0,e)})),xorwow=createCommonjsModule((function(e){!(function(e,t,n){function i(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var i=0;i<n.length+64;i++)t.x^=0|n.charCodeAt(i),i==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function r(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function o(e,t){var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&("object"==typeof o&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:this.xorwow=o})(0,e)})),xorshift7=createCommonjsModule((function(e){!(function(e,t,n){function i(e){var t=this;t.next=function(){var e,n,i=t.x,r=t.i;return e=i[r],n=(e^=e>>>7)^e<<24,n^=(e=i[r+1&7])^e>>>10,n^=(e=i[r+3&7])^e>>>3,n^=(e=i[r+4&7])^e<<7,e=i[r+7&7],i[r]=n^=(e^=e<<13)^e<<9,t.i=r+1&7,n},(function n(e,t){var n,i=[];if(t===(0|t))i[0]=t;else for(t=""+t,n=0;n<t.length;++n)i[7&n]=i[7&n]<<15^t.charCodeAt(n)+i[n+1&7]<<13;for(;i.length<8;)i.push(0);for(n=0;n<8&&0===i[n];++n);for(8==n&&(i[7]=-1),e.x=i,e.i=0,n=256;n>0;--n)e.next()})(t,e)}function r(e,t){return t.x=e.x.slice(),t.i=e.i,t}function o(e,t){null==e&&(e=+new Date);var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&(o.x&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:this.xorshift7=o})(0,e)})),xor4096=createCommonjsModule((function(e){!(function(e,t,n){function i(e){var t=this;t.next=function(){var e,n,i=t.w,r=t.X,o=t.i;return t.w=i=i+1640531527|0,n=r[o+34&127],e=r[o=o+1&127],n^=n<<13,e^=e<<17,n=r[o]=(n^=n>>>15)^(e^=e>>>12),t.i=o,n+(i^i>>>16)|0},(function n(e,t){var n,i,r,o,a,s=[],l=128;for(t===(0|t)?(i=t,t=null):(t+="\0",i=0,l=Math.max(l,t.length)),r=0,o=-32;o<l;++o)t&&(i^=t.charCodeAt((o+32)%t.length)),0===o&&(a=i),i^=i<<10,i^=i>>>15,i^=i<<4,i^=i>>>13,o>=0&&(r=0==(n=s[127&o]^=i+(a=a+1640531527|0))?r+1:0);for(r>=128&&(s[127&(t&&t.length||0)]=-1),r=127,o=512;o>0;--o)i=s[r+34&127],n=s[r=r+1&127],i^=i<<13,n^=n<<17,s[r]=(i^=i>>>15)^(n^=n>>>12);e.w=a,e.X=s,e.i=r})(t,e)}function r(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function o(e,t){null==e&&(e=+new Date);var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&(o.X&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:this.xor4096=o})(0,e)})),tychei=createCommonjsModule((function(e){!(function(e,t,n){function i(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,i=t.d,r=t.a;return e=e<<25^e>>>7^n,n=n-i|0,i=i<<24^i>>>8^r,r=r-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-i|0,t.d=i<<16^n>>>16^r,t.a=r-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var i=0;i<n.length+20;i++)t.b^=0|n.charCodeAt(i),t.next()}function r(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function o(e,t){var n=new i(e),o=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,o&&("object"==typeof o&&r(o,n),a.state=function(){return r(n,{})}),a}t&&t.exports?t.exports=o:this.tychei=o})(0,e)})),_nodeResolve_empty={},_nodeResolve_empty$1=Object.freeze({__proto__:null,default:_nodeResolve_empty}),require$$0=getAugmentedNamespace(_nodeResolve_empty$1),seedrandom$1=createCommonjsModule((function(e){!(function(t,n){var i,r=this,o=256,a=n.pow(o,6),s=n.pow(2,52),l=2*s,c=255;function h(e,c,h){var g=[],v=m(p((c=1==c?{entropy:!0}:c||{}).entropy?[e,f(t)]:null==e?(function y(){try{var e;return i&&(e=i.randomBytes)?e=e(o):(e=new Uint8Array(o),(r.crypto||r.msCrypto).getRandomValues(e)),f(e)}catch(e){var n=r.navigator,a=n&&n.plugins;return[+new Date,r,a,r.screen,f(t)]}})():e,3),g),b=new u(g),_=function(){for(var e=b.g(6),t=a,n=0;e<s;)e=(e+n)*o,t*=o,n=b.g(1);for(;e>=l;)e/=2,t/=2,n>>>=1;return(e+n)/t};return _.int32=function(){return 0|b.g(4)},_.quick=function(){return b.g(4)/4294967296},_.double=_,m(f(b.S),t),(c.pass||h||function(e,t,i,r){return r&&(r.S&&d(r,b),e.state=function(){return d(b,{})}),i?(n.random=e,t):e})(_,v,"global"in c?c.global:this==n,c.state)}function u(e){var t,n=e.length,i=this,r=0,a=i.i=i.j=0,s=i.S=[];for(n||(e=[n++]);r<o;)s[r]=r++;for(r=0;r<o;r++)s[r]=s[a=c&a+e[r%n]+(t=s[r])],s[a]=t;(i.g=function(e){for(var t,n=0,r=i.i,a=i.j,s=i.S;e--;)t=s[r=c&r+1],n=n*o+s[c&(s[r]=s[a=c&a+t])+(s[a]=t)];return i.i=r,i.j=a,n})(o)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function p(e,t){var n,i=[],r=typeof e;if(t&&"object"==r)for(n in e)try{i.push(p(e[n],t-1))}catch(e){}return i.length?i:"string"==r?e:e+"\0"}function m(e,t){for(var n,i=e+"",r=0;r<i.length;)t[c&r]=c&(n^=19*t[c&r])+i.charCodeAt(r++);return f(t)}function f(e){return String.fromCharCode.apply(0,e)}if(n.seedrandom=h,m(n.random(),t),e.exports){e.exports=h;try{i=require$$0}catch(e){}}})([],Math)}));seedrandom$1.alea=alea,seedrandom$1.xor128=xor128,seedrandom$1.xorwow=xorwow,seedrandom$1.xorshift7=xorshift7,seedrandom$1.xor4096=xor4096,seedrandom$1.tychei=tychei;var seedrandom=seedrandom$1; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function relu_(e){const t=convertToTensor(e,"x","relu");return ENGINE.runKernel(Relu,{x:t})}const relu$2=op({relu_:relu_}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function relu6_(e){const t=convertToTensor(e,"x","relu6");return ENGINE.runKernel(Relu6,{x:t})}const relu6$2=op({relu6_:relu6_}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function scalar(e,t){if((isTypedArray(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&isTypedArray(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return makeTensor(e,[],[],t)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function split_(e,t,n=0){const i=convertToTensor(e,"x","split");return ENGINE.runKernel(SplitV,{x:i},{numOrSizeSplits:t,axis:n})}const split=op({split_:split_}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function step_(e,t=0){const n=convertToTensor(e,"x","step");return ENGINE.runKernel(Step,{x:n},{alpha:t})}const step$2=op({step_:step_}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function whereImpl$2(e,t){const n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(e);const i=buffer(e,"int32"),r=buffer([n.length,e.length],"int32");for(let t=0;t<n.length;t++){const o=i.indexToLoc(n[t]);r.values.set(o,t*e.length)}return r.toTensor()} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getFusedDyActivation(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return mul(e,step$2(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function getFusedBiasGradient(e,t){let n=t;const i=getReductionAxes(e.shape,t.shape);return i.length>0&&(n=sum$2(n,i)),reshape$2(n,e.shape)}function applyActivation$1(e,t,n,i){if("linear"===t)return e;if("relu"===t)return relu$2(e);if("elu"===t)return elu$2(e);if("relu6"===t)return relu6$2(e);if("prelu"===t)return prelu$2(e,n);if("leakyrelu"===t)return leakyRelu$2(e,i);throw new Error(`Unknown fused activation ${t}.`)}const shouldFuse=(e,t)=>!(e>0)||"linear"===t; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function binaryInsert(e,t,n){const i=binarySearch(e,t,n);e.splice(i<0?-(i+1):i,0,t)}function binarySearch(e,t,n){return binarySearch_(e,t,n||defaultComparator)}function defaultComparator(e,t){return e>t?1:e<t?-1:0}function binarySearch_(e,t,n){let i=0,r=e.length,o=0,a=!1;for(;i<r;){o=i+(r-i>>>1);const s=n(t,e[o]);s>0?i=o+1:(r=o,a=!s)}return a?i:-i-1} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function nonMaxSuppressionV3Impl$2(e,t,n,i,r){return nonMaxSuppressionImpl_(e,t,n,i,r,0)}function nonMaxSuppressionV4Impl$2(e,t,n,i,r,o){return nonMaxSuppressionImpl_(e,t,n,i,r,0,!1,o,!0)}function nonMaxSuppressionV5Impl$2(e,t,n,i,r,o){return nonMaxSuppressionImpl_(e,t,n,i,r,o,!0)}function nonMaxSuppressionImpl_(e,t,n,i,r,o,a=!1,s=!1,l=!1){const c=[];for(let e=0;e<t.length;e++)t[e]>r&&c.push({score:t[e],boxIndex:e,suppressBeginIndex:0});c.sort(ascendingComparator$1);const h=o>0?-.5/o:0,u=[],d=[];for(;u.length<n&&c.length>0;){const t=c.pop(),{score:n,boxIndex:o,suppressBeginIndex:a}=t;if(n<r)break;let s=!1;for(let n=u.length-1;n>=a;--n){const a=intersectionOverUnion(e,o,u[n]);if(a>=i){s=!0;break}if(t.score=t.score*suppressWeight(i,h,a),t.score<=r)break}t.suppressBeginIndex=u.length,s||(t.score===n?(u.push(o),d.push(t.score)):t.score>r&&binaryInsert(c,t,ascendingComparator$1))}const p=u.length,m=n-p;s&&m>0&&(u.push(...new Array(m).fill(0)),d.push(...new Array(m).fill(0)));const f={selectedIndices:u};return a&&(f.selectedScores=d),l&&(f.validOutputs=p),f}function intersectionOverUnion(e,t,n){const i=e.subarray(4*t,4*t+4),r=e.subarray(4*n,4*n+4),o=Math.min(i[0],i[2]),a=Math.min(i[1],i[3]),s=Math.max(i[0],i[2]),l=Math.max(i[1],i[3]),c=Math.min(r[0],r[2]),h=Math.min(r[1],r[3]),u=Math.max(r[0],r[2]),d=Math.max(r[1],r[3]),p=(s-o)*(l-a),m=(u-c)*(d-h);if(p<=0||m<=0)return 0;const f=Math.max(o,c),g=Math.max(a,h),v=Math.min(s,u),y=Math.min(l,d),b=Math.max(v-f,0)*Math.max(y-g,0);return b/(p+m-b)}function suppressWeight(e,t,n){const i=Math.exp(t*n*n);return n<=e?i:0}function ascendingComparator$1(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function assertParamsConsistent(e,t){const n=e[0].length;e.forEach(((e,t)=>{assert$1(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),assert$1(t>=0&&t<n,(()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const i=e[0];e.forEach(((e,r)=>{for(let o=0;o<n;o++)assert$1(o===t||e[o]===i[o],(()=>`Error in concat${n}D: Shape of tensors[${r}] (${e}) does not match the shape of the rest (${i}) along the non-concatenated axis ${r}.`))}))}function computeOutShape$1(e,t){const n=e[0].slice();for(let i=1;i<e.length;i++)n[t]+=e[i][t];return n} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const PARALLELIZE_THRESHOLD=30;function computeOptimalWindowSize(e){return e<=PARALLELIZE_THRESHOLD?e:nearestDivisor(e,Math.floor(Math.sqrt(e)))} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getImageCenter(e,t,n){return[n*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getReshaped(e,t,n,i=!0){let r=[];if(i)r=r.concat(t.slice(0)),r.push(e[0]/n),r=r.concat(e.slice(1));else{r=r.concat(e[0]);const n=t.length;for(let i=0;i<n;++i)r=r.concat([e[i+1]/t[i],t[i]]);r=r.concat(e.slice(n+1))}return r}function getPermuted(e,t,n=!0){const i=[];if(n){i.push(t);for(let n=t+1;n<e;++n)n<=2*t?(i.push(n),i.push(n-(t+1))):i.push(n)}else{const n=[],r=[];for(let i=1;i<e;++i)i>=2*t+1||i%2==1?r.push(i):n.push(i);i.push(...n),i.push(0),i.push(...r)}return i}function getReshapedPermuted(e,t,n,i=!0){const r=[];r.push(i?e[0]/n:e[0]*n);for(let n=1;n<e.length;++n)r.push(n<=t.length?i?t[n-1]*e[n]:e[n]/t[n-1]:e[n]);return r}function getSliceBeginCoords(e,t){const n=[0];for(let i=0;i<t;++i)n.push(e[i][0]);return n}function getSliceSize(e,t,n){const i=e.slice(0,1);for(let r=0;r<n;++r)i.push(e[r+1]-t[r][0]-t[r][1]);return i} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const SELU_SCALEALPHA=1.7580993408473768,SELU_SCALE=1.0507009873554805,ERF_P=.3275911,ERF_A1=.254829592,ERF_A2=-.284496736,ERF_A3=1.421413741,ERF_A4=-1.453152027,ERF_A5=1.061405429; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function warn(...e){env().getBool("IS_TEST")||console.warn(...e)}function log$2(...e){env().getBool("IS_TEST")||console.log(...e)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function mergeRealAndImagArrays(e,t){if(e.length!==t.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);const n=new Float32Array(2*e.length);for(let i=0;i<n.length;i+=2)n[i]=e[i/2],n[i+1]=t[i/2];return n}function splitRealAndImagArrays(e){const t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let i=0;i<e.length;i+=2)t[i/2]=e[i],n[i/2]=e[i+1];return{real:t,imag:n}}function complexWithEvenIndex(e){const t=Math.ceil(e.length/4),n=new Float32Array(t),i=new Float32Array(t);for(let t=0;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],i[Math.floor(t/4)]=e[t+1];return{real:n,imag:i}}function complexWithOddIndex(e){const t=Math.floor(e.length/4),n=new Float32Array(t),i=new Float32Array(t);for(let t=2;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],i[Math.floor(t/4)]=e[t+1];return{real:n,imag:i}}function getComplexWithIndex(e,t){return{real:e[2*t],imag:e[2*t+1]}}function assignToTypedArray(e,t,n,i){e[2*i]=t,e[2*i+1]=n}function exponents(e,t){const n=new Float32Array(e/2),i=new Float32Array(e/2);for(let r=0;r<Math.ceil(e/2);r++){const o=(t?2:-2)*Math.PI*(r/e);n[r]=Math.cos(o),i[r]=Math.sin(o)}return{real:n,imag:i}}function exponent$1(e,t,n){const i=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(i),imag:Math.sin(i)}} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const ARROW="->",ARROW_REGEX=/->/g,COMMA=",",ELLIPSIS="...";function decodeEinsumEquation(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(ARROW_REGEX,"").length)/ARROW.length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error(`Equation must contain exactly one arrow ("${ARROW}").`);const[i,r]=e.split(ARROW);assert$1(-1===i.indexOf(ELLIPSIS),(()=>`The ellipsis notation ("${ELLIPSIS}") is not supported yet.`));const o=i.split(COMMA),a=o.length;if(t!==a)throw new Error(`Expected ${a} input tensors, received ${t}`);if(a>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const s=[];for(let e=0;e<r.length;++e){const t=r[e];if(!o.some((e=>-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===s.indexOf(t)&&s.push(t)}for(let e=0;e<i.length;++e){const t=i[e];-1===s.indexOf(t)&&t!==COMMA&&s.push(t)}const l=new Array(o.length);for(let e=0;e<a;++e){if(new Set(o[e].split("")).size!==o[e].length)throw new Error(`Found duplicate axes in input component ${o[e]}. Support for duplicate axes in input is not implemented yet.`);l[e]=[];for(let t=0;t<o[e].length;++t)l[e].push(s.indexOf(o[e][t]))}const c=s.length,h=[];for(let e=r.length;e<c;++e)h.push(e);return{allDims:s,summedDims:h,idDims:l}}function getEinsumPermutation(e,t){let n=new Array(e);n.fill(-1);for(let e=0;e<t.length;++e)n[t[e]]=e;const i=[];for(let t=0;t<e;++t)-1===n[t]&&i.push(t);return n=n.filter((e=>-1!==e)),{permutationIndices:n,expandDims:i}}function checkEinsumDimSizes(e,t,n){const i=new Array(e);for(let e=0;e<n.length;++e){const r=n[e].shape;for(let n=0;n<t[e].length;++n)void 0===i[t[e][n]]?i[t[e][n]]=r[n]:assert$1(i[t[e][n]]===r[n],(()=>`Expected dimension ${i[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(r)}, but got dimension ${r[n]}`))}}function getEinsumComputePath(e,t){const n=e,i=[];let r=0;0===e.length&&n.push(-1),r=e.length+1;for(let e=0;e<r;++e)i.push([]);const o=[];for(let e=0;e<n.length;++e){const r=findTermsWithDim(t,n[e]);for(const t of r)-1===o.indexOf(t)&&(i[e].push(t),o.push(t))}return{path:n,steps:i}}function isIdentityPermutation(e){return e.every(((e,t)=>e===t))}function findTermsWithDim(e,t){const n=[];for(let i=0;i<e.length;++i)0!==e[i].length&&-1===e[i].indexOf(t)&&-1!==t||n.push(i);return n}function prepareSplitSize(e,t,n=0){let i=[];if("number"==typeof t)assert$1(e.shape[n]%t==0,(()=>"Number of splits must evenly divide the axis.")),i=new Array(t).fill(e.shape[n]/t);else{assert$1(t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0)<=1,(()=>"There should be only one negative value in split array."));const r=t.indexOf(-1);if(-1!==r){const i=t.reduce(((e,t)=>t>0?e+t:e));t[r]=e.shape[n]-i}assert$1(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),i=t}return i} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function segOpComputeOptimalWindowSize(e,t){let n,i=!1;for(e<=PARALLELIZE_THRESHOLD?(n=e,i=!0):n=nearestDivisor(e,Math.floor(Math.sqrt(e)));!i;)n>t||n===e?i=!0:n=nearestDivisor(e,n+1);return n}function computeOutShape(e,t,n){const i=[],r=e.length;for(let o=0;o<r;o++)i.push(o!==t?e[o]:n);return i}function collectGatherOpShapeInfo(e,t,n,i){const r=t.shape.length,o=e.shape.length;if(0!==i&&(i<-r||i>r))throw new Error(`Expect batchDims in the range of [-${r}, ${r}], but got ${i}`);if(i<0&&(i+=r),i>o)throw new Error(`batchDims (${i}) must be less than rank(x) (\n ${o}).`);if(n<i)throw new Error(`batchDims (${i}) must be less than or equal to axis (${n}).`);for(let n=0;n<i;++n)if(e.shape[n]!==t.shape[n])throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);const a=e.shape[n],s=[];let l=1,c=1,h=1;for(let t=0;t<i;++t)s.push(e.shape[t]),l*=e.shape[t];for(let t=i;t<n;t++)s.push(e.shape[t]),c*=e.shape[t];for(let e=i;e<r;e++)s.push(t.shape[e]);for(let t=n+1;t<o;t++)s.push(e.shape[t]),h*=e.shape[t];return{batchSize:l,sliceSize:h,outerSize:c,dimSize:a,outputShape:s}}var segment_util=Object.freeze({__proto__:null,segOpComputeOptimalWindowSize:segOpComputeOptimalWindowSize,computeOutShape:computeOutShape,collectGatherOpShapeInfo:collectGatherOpShapeInfo}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fromUint8ToStringArray(e){try{return e.map((e=>decodeString(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function fromStringArrayToUint8(e){return e.map((e=>encodeString(e)))}var backend_util=Object.freeze({__proto__:null,slice_util:slice_util,segment_util:segment_util,fromUint8ToStringArray:fromUint8ToStringArray,fromStringArrayToUint8:fromStringArrayToUint8,upcastType:upcastType,axesAreInnerMostDims:axesAreInnerMostDims,combineLocations:combineLocations,computeOutAndReduceShapes:computeOutAndReduceShapes,expandShapeToKeepDim:expandShapeToKeepDim,assertAxesAreInnerMostDims:assertAxesAreInnerMostDims,getAxesPermutation:getAxesPermutation,getUndoAxesPermutation:getUndoAxesPermutation,getInnerMostAxes:getInnerMostAxes,getBroadcastDims:getBroadcastDims$1,getReductionAxes:getReductionAxes,assertAndGetBroadcastShape:assertAndGetBroadcastShape,assertParamsConsistent:assertParamsConsistent,computeOutShape:computeOutShape$1,computeDilation2DInfo:computeDilation2DInfo,computePool2DInfo:computePool2DInfo,computePool3DInfo:computePool3DInfo,computeConv2DInfo:computeConv2DInfo,computeConv3DInfo:computeConv3DInfo,computeDefaultPad:computeDefaultPad,tupleValuesAreOne:tupleValuesAreOne,eitherStridesOrDilationsAreOne:eitherStridesOrDilationsAreOne,convertConv2DDataFormat:convertConv2DDataFormat,getFusedDyActivation:getFusedDyActivation,getFusedBiasGradient:getFusedBiasGradient,applyActivation:applyActivation$1,shouldFuse:shouldFuse,PARALLELIZE_THRESHOLD:PARALLELIZE_THRESHOLD,computeOptimalWindowSize:computeOptimalWindowSize,getImageCenter:getImageCenter,getReshaped:getReshaped,getPermuted:getPermuted,getReshapedPermuted:getReshapedPermuted,getSliceBeginCoords:getSliceBeginCoords,getSliceSize:getSliceSize,prepareAndValidate:prepareAndValidate,validateUpdateShape:validateUpdateShape,validateInput:validateInput,calculateShapes:calculateShapes,SELU_SCALEALPHA:SELU_SCALEALPHA,SELU_SCALE:SELU_SCALE,ERF_P:ERF_P,ERF_A1:ERF_A1,ERF_A2:ERF_A2,ERF_A3:ERF_A3,ERF_A4:ERF_A4,ERF_A5:ERF_A5,warn:warn,log:log$2,mergeRealAndImagArrays:mergeRealAndImagArrays,splitRealAndImagArrays:splitRealAndImagArrays,complexWithEvenIndex:complexWithEvenIndex,complexWithOddIndex:complexWithOddIndex,getComplexWithIndex:getComplexWithIndex,assignToTypedArray:assignToTypedArray,exponents:exponents,exponent:exponent$1,decodeEinsumEquation:decodeEinsumEquation,getEinsumPermutation:getEinsumPermutation,checkEinsumDimSizes:checkEinsumDimSizes,getEinsumComputePath:getEinsumComputePath,isIdentityPermutation:isIdentityPermutation,prepareSplitSize:prepareSplitSize}); /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function assertNotComplex$1(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&assert$1("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const whereImpl$1=whereImpl$2;class MathBackendCPU extends KernelBackend{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new DataStorage(this,engine())}nextDataId(){return MathBackendCPU.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,env().get("IS_NODE")&&warn("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================"));const i={id:this.nextDataId()};return this.data.set(i,{values:e,dtype:n,refCount:1}),i}makeTensorInfo(e,t,n){let i;if("string"===t&&null!=n&&n.length>0&&isString(n[0])){const r=n.map((e=>encodeString(e)));i=this.write(r,e,t)}else i=this.write(n,e,t);return{dataId:i,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){this.data.get(e).refCount++}decRef(e){this.data.has(e)&&this.data.get(e).refCount--}move(e,t,n,i,r){this.data.set(e,{values:t,dtype:i,refCount:r})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);return"complex64"===t?mergeRealAndImagArrays(this.readSync(n.real.dataId),this.readSync(n.imag.dataId)):this.data.get(e).values}bufferSync(e){const t=this.readSync(e.dataId);let n=t;if("string"===e.dtype)try{n=t.map((e=>decodeString(e)))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return buffer(e.shape,e.dtype,n)}makeOutput(e,t,n){const i=this.write(e,t,n);return engine().makeTensorFromDataId(i,t,n,this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=now();return e(),{kernelMs:now()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){assertNotComplex$1([e],"where");const t=this.readSync(e.dataId);return whereImpl$1(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function simpleAbsImpl(e){const t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}MathBackendCPU.nextDataId=0;const abs$1=e=>{const{x:t}=e.inputs,n=e.backend;assertNotComplex$1(t,"abs");let i=new Float32Array(sizeFromShape(t.shape));return i=simpleAbsImpl(n.data.get(t.dataId).values),n.makeOutput(i,t.shape,"float32")},absConfig$1={kernelName:Abs,backendName:"cpu",kernelFunc:abs$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function createSimpleBinaryKernelImpl(e){return(t,n,i,r,o)=>{const a=assertAndGetBroadcastShape(t,n),s=a.length,l=computeStrides(a),c=getTypedArrayFromDType(o,sizeFromShape(a)),h=t.length,u=n.length,d=computeStrides(t),p=computeStrides(n),m=getBroadcastDims$1(t,a),f=getBroadcastDims$1(n,a);if(m.length+f.length===0)for(let t=0;t<c.length;++t)c[t]=e(i[t%i.length],r[t%r.length]);else for(let t=0;t<c.length;++t){const n=indexToLoc(t,s,l),o=n.slice(-h);m.forEach((e=>o[e]=0));const a=locToIndex(o,h,d),g=n.slice(-u);f.forEach((e=>g[e]=0));const v=locToIndex(g,u,p);c[t]=e(i[a],r[v])}return[c,a]}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function complex$1(e){const{inputs:t,backend:n}=e,{real:i,imag:r}=t,o=n.data.get(i.dataId).values,a=n.data.get(r.dataId).values,s=n.makeTensorInfo(i.shape,"complex64");return n.data.get(s.dataId).complexTensorInfos={real:n.makeTensorInfo(i.shape,"float32",o),imag:n.makeTensorInfo(r.shape,"float32",a)},s}const complexConfig$1={kernelName:Complex,backendName:"cpu",kernelFunc:complex$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function zeros(e,t,n="float32"){if("complex64"===n)return complex$1({inputs:{real:zeros(e,t,"float32"),imag:zeros(e,t,"float32")},backend:e});const i=makeZerosTypedArray(sizeFromShape(t),n);return e.makeTensorInfo(t,n,i)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function identity$3(e){const{inputs:t,backend:n}=e,{x:i}=t;return n.incRef(i.dataId),{dataId:i.dataId,shape:i.shape,dtype:i.dtype}}const identityConfig$1={kernelName:Identity,backendName:"cpu",kernelFunc:identity$3}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function real$1(e){const{inputs:t,backend:n}=e,{input:i}=t,r=n.data.get(i.dataId).complexTensorInfos.real,o=n.data.get(r.dataId).values;return n.makeTensorInfo(r.shape,r.dtype,o)}const realConfig$1={kernelName:Real,backendName:"cpu",kernelFunc:real$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function cast$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{dtype:o}=i;if("complex64"===o){if("complex64"===r.dtype)return identity$3({inputs:{x:r},backend:n});const e=zeros(n,r.shape,r.dtype),t=cast$1({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),i=complex$1({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),i}if("complex64"===r.dtype){const e=real$1({inputs:{input:r},backend:n}),t=cast$1({inputs:{x:e},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(e),t}if(!hasEncodingLoss(r.dtype,o)){const e=identity$3({inputs:{x:r},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:o}}if("int32"===o){const e=n.data.get(r.dataId).values,t=Int32Array.from(e);return n.makeTensorInfo(r.shape,"int32",t)}if("bool"===o){const e=n.data.get(r.dataId).values,t=toTypedArray$1([0],r.dtype),[i,o]=createSimpleBinaryKernelImpl(((e,t)=>e!==t?1:0))(r.shape,[],e,t,"bool");return n.makeTensorInfo(o,"bool",i)}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${o}`)}const castConfig$1={kernelName:Cast,backendName:"cpu",kernelFunc:cast$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function binaryKernelFunc$1(e,t,n,i){return null==n?({inputs:n,backend:r})=>{const{a:o,b:a}=n,s=r;assertNotComplex$1([o,a],e);const l=s.data.get(o.dataId).values,c=s.data.get(a.dataId).values,h=i||o.dtype,[u,d]=t(o.shape,a.shape,l,c,h);return s.makeTensorInfo(d,h,u)}:({inputs:e,backend:r})=>{const{a:o,b:a}=e,s=r;if("complex64"===o.dtype||"complex64"===a.dtype){const e=cast$1({inputs:{x:o},backend:s,attrs:{dtype:"complex64"}}),t=s.data.get(e.dataId),i=t.complexTensorInfos.imag,r=s.data.get(t.complexTensorInfos.real.dataId).values,l=s.data.get(i.dataId).values,c=cast$1({inputs:{x:a},backend:s,attrs:{dtype:"complex64"}}),h=s.data.get(c.dataId),u=h.complexTensorInfos.imag,d=s.data.get(h.complexTensorInfos.real.dataId).values,p=s.data.get(u.dataId).values,[m,f,g]=n(o.shape,a.shape,r,l,d,p),v=s.makeTensorInfo(g,"float32",m),y=s.makeTensorInfo(g,"float32",f),b=complex$1({inputs:{real:v,imag:y},backend:s});return s.disposeIntermediateTensorInfo(e),s.disposeIntermediateTensorInfo(c),s.disposeIntermediateTensorInfo(v),s.disposeIntermediateTensorInfo(y),b}{const e=s.data.get(o.dataId).values,n=s.data.get(a.dataId).values,r=i||o.dtype,[l,c]=t(o.shape,a.shape,e,n,r);return s.makeTensorInfo(c,r,l)}}}function createComplexBinaryKernelImpl(e){return(t,n,i,r,o,a)=>{const s=assertAndGetBroadcastShape(t,n),l=sizeFromShape(s),c=s.length,h=computeStrides(s),u=getTypedArrayFromDType("float32",l),d=getTypedArrayFromDType("float32",l),p=getBroadcastDims$1(t,s),m=getBroadcastDims$1(n,s),f=mergeRealAndImagArrays(i,r),g=mergeRealAndImagArrays(o,a),v=t.length,y=computeStrides(t),b=n.length,_=computeStrides(n);if(p.length+m.length===0)for(let t=0;t<u.length;t++){const n=t%f.length,i=t%g.length,r=e(f[2*n],f[2*n+1],g[2*i],g[2*i+1]);u[t]=r.real,d[t]=r.imag}else for(let t=0;t<u.length;t++){const n=indexToLoc(t,c,h),i=n.slice(-v);p.forEach((e=>i[e]=0));const r=locToIndex(i,v,y),o=n.slice(-b);m.forEach((e=>o[e]=0));const a=locToIndex(o,b,_),s=e(f[2*r],f[2*r+1],g[2*a],g[2*a+1]);u[t]=s.real,d[t]=s.imag}return[u,d,s]}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const addImpl=createSimpleBinaryKernelImpl(((e,t)=>e+t)),addComplexImpl=createComplexBinaryKernelImpl(((e,t,n,i)=>({real:e+n,imag:t+i}))),add=binaryKernelFunc$1(Add,addImpl,addComplexImpl),addConfig$1={kernelName:Add,backendName:"cpu",kernelFunc:add}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function bincountImpl(e,t,n,i,r){const o=sizeFromShape(i),a=makeZerosTypedArray(r,n);for(let n=0;n<e.length;n++){const i=e[n];if(i<0)throw new Error("Input x must be non-negative!");i>=r||(a[i]+=o>0?t[n]:1)}return a}function bincountReduceImpl(e,t,n,i=!1){const r=e.shape[0],o=e.shape[1],a=buffer([r,n],t.dtype);for(let s=0;s<r;s++)for(let r=0;r<o;r++){const o=e.get(s,r);if(o<0)throw new Error("Input x must be non-negative!");o>=n||a.set(i?1:t.size>0?a.get(s,o)+t.get(s,r):a.get(s,o)+1,s,o)}return a} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function createSimpleUnaryImpl(e){return(t,n,i)=>{const r=getTypedArrayFromDType(n,t.length);for(let n=0;n<t.length;++n)r[n]=e(t[n],i);return r}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function unaryKernelFunc$1(e,t,n){return({inputs:i,attrs:r,backend:o})=>{const{x:a}=i;if(assertNotComplex$1(a,e),"string"===a.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const s=o,l=s.data.get(a.dataId).values,c=sizeFromShape(a.shape),h=n||a.dtype,u=getArrayFromDType(h,c);for(let e=0;e<c;++e)u[e]=t(l[e],r);return s.makeTensorInfo(a.shape,h,u)}}function unaryKernelFuncFromImpl(e,t,n){return({inputs:i,attrs:r,backend:o})=>{const{x:a}=i;if(assertNotComplex$1(a,e),"string"===a.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const s=o,l=s.data.get(a.dataId).values,c=n||a.dtype,h=t(l,c,r);return s.makeTensorInfo(a.shape,c,h)}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const ceilImpl=createSimpleUnaryImpl((e=>Math.ceil(e))),ceil$1=unaryKernelFuncFromImpl(Ceil,ceilImpl),ceilConfig$1={kernelName:Ceil,backendName:"cpu",kernelFunc:ceil$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function concatImpl$1(e,t,n,i){const r=getArrayFromDType(n,sizeFromShape(t));if(i&&"string"!==n){let t=0;e.forEach((e=>{const n=sizeFromShape(e.shape);r.set(e.vals,t),t+=n}))}else{let i=0;e.forEach((e=>{const o="string"===n?fromUint8ToStringArray(e.vals):e.vals;let a=0;for(let n=0;n<e.shape[0];++n){const s=n*t[1]+i;for(let t=0;t<e.shape[1];++t)r[s+t]=o[a++]}i+=e.shape[1]}))}return r} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const expImpl=createSimpleUnaryImpl((e=>Math.exp(e))),exp$1=unaryKernelFuncFromImpl(Exp,expImpl),expConfig$1={kernelName:Exp,backendName:"cpu",kernelFunc:exp$1},expm1Impl=createSimpleUnaryImpl((e=>Math.expm1(e))),expm1$1=unaryKernelFuncFromImpl(Expm1,expm1Impl),expm1Config$1={kernelName:Expm1,backendName:"cpu",kernelFunc:expm1$1},floorImpl=createSimpleUnaryImpl((e=>Math.floor(e))),floor$1=unaryKernelFuncFromImpl(Floor,floorImpl),floorConfig$1={kernelName:Floor,backendName:"cpu",kernelFunc:floor$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function gatherV2Impl(e,t,n){const i=buffer(n,e.dtype);for(let n=0;n<i.size;++n){const r=i.indexToLoc(n).slice(),o=t.locToIndex([r[0],r[2]]);r[2]=t.values[o];const a=e.locToIndex(r);i.values[n]=e.values[a]}return i} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const greaterImpl=createSimpleBinaryKernelImpl(((e,t)=>e>t?1:0)),greater$1=binaryKernelFunc$1(Greater,greaterImpl,null,"bool"),greaterConfig$1={kernelName:Greater,backendName:"cpu",kernelFunc:greater$1},lessImpl=createSimpleBinaryKernelImpl(((e,t)=>e<t?1:0)),less$1=binaryKernelFunc$1(Less,lessImpl,null,"bool"),lessConfig$1={kernelName:Less,backendName:"cpu",kernelFunc:less$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function linSpaceImpl(e,t,n){const i=(t-e)/(n-1),r=makeZerosTypedArray(n,"float32");r[0]=e;for(let e=1;e<r.length;e++)r[e]=r[e-1]+i;return r} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const logImpl=createSimpleUnaryImpl((e=>Math.log(e))),log$1=unaryKernelFuncFromImpl(Log,logImpl),logConfig$1={kernelName:Log,backendName:"cpu",kernelFunc:log$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function maxImpl$1(e,t,n,i){const r=getTypedArrayFromDType(i,sizeFromShape(n));for(let n=0;n<r.length;++n){const i=n*t;let o=e[i];for(let n=0;n<t;++n){const t=e[i+n];t>o&&(o=t)}r[n]=o}return r} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const maximumImpl=createSimpleBinaryKernelImpl(((e,t)=>Math.max(e,t))),maximum$1=binaryKernelFunc$1(Maximum,maximumImpl),maximumConfig$1={kernelName:Maximum,backendName:"cpu",kernelFunc:maximum$1},minimumImpl=createSimpleBinaryKernelImpl(((e,t)=>Math.min(e,t))),minimum$1=binaryKernelFunc$1(Minimum,minimumImpl),minimumConfig$1={kernelName:Minimum,backendName:"cpu",kernelFunc:minimum$1},multiplyImpl=createSimpleBinaryKernelImpl(((e,t)=>e*t)),multiplyComplexImpl=createComplexBinaryKernelImpl(((e,t,n,i)=>({real:e*n-t*i,imag:e*i+t*n}))),multiply$1=binaryKernelFunc$1(Multiply,multiplyImpl,multiplyComplexImpl),multiplyConfig$1={kernelName:Multiply,backendName:"cpu",kernelFunc:multiply$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function negImpl(e,t,n){const i=createScalarValue(-1,n);return multiplyImpl([],t,i,e,n)}function neg$1(e){const{inputs:t,backend:n}=e,{x:i}=t;assertNotComplex$1(i,"neg");const r=n.data.get(i.dataId).values,[o,a]=negImpl(r,i.shape,i.dtype);return n.makeTensorInfo(a,i.dtype,o)}const negConfig$1={kernelName:Neg,backendName:"cpu",kernelFunc:neg$1},notEqualImpl=createSimpleBinaryKernelImpl(((e,t)=>e!==t?1:0)),notEqual$1=binaryKernelFunc$1(NotEqual,notEqualImpl,null,"bool"),notEqualConfig$1={kernelName:NotEqual,backendName:"cpu",kernelFunc:notEqual$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function transposeImpl$1(e,t,n,i,r){const o=t.length,a=sizeFromShape(t),s=computeStrides(t),l=computeStrides(r),c=getTypedArrayFromDType(n,sizeFromShape(r));for(let t=0;t<a;++t){const n=indexToLoc(t,o,s),r=new Array(n.length);for(let e=0;e<r.length;e++)r[e]=n[i[e]];c[locToIndex(r,o,l)]=e[t]}return c} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function transpose$1(e){const{inputs:t,attrs:n,backend:i}=e,{x:r}=t,{perm:o}=n;assertNotComplex$1(r,"transpose");const a=new Array(r.shape.length);for(let e=0;e<a.length;e++)a[e]=r.shape[o[e]];const s=transposeImpl$1(i.data.get(r.dataId).values,r.shape,r.dtype,o,a);return{dataId:i.write(s,a,r.dtype),shape:a,dtype:r.dtype}}const transposeConfig$1={kernelName:Transpose,backendName:"cpu",kernelFunc:transpose$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function prodImpl(e,t,n,i){const[r,o]=computeOutAndReduceShapes(e,i),a=upcastType(t,"int32"),s=makeZerosTypedArray(sizeFromShape(r),a),l=sizeFromShape(o);for(let e=0;e<s.length;++e){const t=e*l;let i=1;for(let e=0;e<l;++e)i*=n[t+e];s[e]=i}return{outVals:s,outShape:r,outDtype:a}}function prod$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i;assertNotComplex$1(r,"prod");const s=r.shape.length,l=parseAxisParam(o,r.shape),c=getAxesPermutation(l,s);let h=l,u=r;const d=[];null!=c&&(u=transpose$1({inputs:{x:r},backend:n,attrs:{perm:c}}),d.push(u),h=getInnerMostAxes(h.length,s));const p=n.data.get(u.dataId).values,{outVals:m,outShape:f,outDtype:g}=prodImpl(u.shape,u.dtype,p,h);let v=f;return a&&(v=expandShapeToKeepDim(f,l)),d.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(v,g,m)}const prodConfig$1={kernelName:Prod,backendName:"cpu",kernelFunc:prod$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function rangeImpl(e,t,n,i){if(e===t||e<t&&n<0||t<e&&n>1)return makeZerosTypedArray(0,i);const r=makeZerosTypedArray(Math.abs(Math.ceil((t-e)/n)),i);t<e&&1===n&&(n=-1),r[0]=e;for(let e=1;e<r.length;e++)r[e]=r[e-1]+n;return r} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const rsqrtImpl=createSimpleUnaryImpl((e=>1/Math.sqrt(e))),rsqrt$1=unaryKernelFuncFromImpl(Rsqrt,rsqrtImpl),rsqrtConfig$1={kernelName:Rsqrt,backendName:"cpu",kernelFunc:rsqrt$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function sliceImpl(e,t,n,i,r){const o=isSliceContinous(i,t,n),a=sizeFromShape(n),s=computeStrides(i);if(o){const n=computeFlatOffset(t,s);return"string"===r?e.slice(n,n+a):e.subarray(n,n+a)}const l=buffer(i,r,"string"===r?fromUint8ToStringArray(e):e),c=buffer(n,r);for(let e=0;e<c.size;++e){const n=c.indexToLoc(e),i=n.map(((e,n)=>e+t[n]));c.set(l.get(...i),...n)}return"string"===r?fromStringArrayToUint8(c.values):c.values}function slice$2(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{begin:o,size:a}=i;assertNotComplex$1(r,"slice");const[s,l]=parseSliceParams(r,o,a);assertParamsValid(r,s,l);const c=sliceImpl(n.data.get(r.dataId).values,s,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,c)}const sliceConfig$1={kernelName:Slice,backendName:"cpu",kernelFunc:slice$2},squaredDifferenceImpl=createSimpleBinaryKernelImpl(((e,t)=>{const n=e-t;return n*n})),squaredDifference$1=binaryKernelFunc$1(SquaredDifference,squaredDifferenceImpl),squaredDifferenceConfig$1={kernelName:SquaredDifference,backendName:"cpu",kernelFunc:squaredDifference$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function stridedSliceImpl(e,t,n,i){const r=buffer(e,t.dtype);for(let e=0;e<r.size;e++){const o=r.indexToLoc(e),a=new Array(o.length);for(let e=0;e<a.length;e++)a[e]=o[e]*n[e]+i[e];r.set(t.get(...a),...o)}return r} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const subImpl=createSimpleBinaryKernelImpl(((e,t)=>e-t)),subComplexImpl=createComplexBinaryKernelImpl(((e,t,n,i)=>({real:e-n,imag:t-i}))),sub$2=binaryKernelFunc$1(Sub,subImpl,subComplexImpl),subConfig$1={kernelName:Sub,backendName:"cpu",kernelFunc:sub$2}; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function tileImpl(e,t){const n=new Array(e.rank);for(let i=0;i<n.length;i++)n[i]=e.shape[i]*t[i];const i=buffer(n,e.dtype);for(let t=0;t<i.values.length;++t){const n=i.indexToLoc(t),r=new Array(e.rank);for(let t=0;t<r.length;t++)r[t]=n[t]%e.shape[t];const o=e.locToIndex(r);i.values[t]=e.values[o]}return i} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function topKImpl(e,t,n,i,r){const o=t[t.length-1],[a,s]=[e.length/o,o],l=getTypedArrayFromDType(n,a*i),c=getTypedArrayFromDType("int32",a*i);for(let t=0;t<a;t++){const n=t*s,r=e.subarray(n,n+s),o=[];for(let e=0;e<r.length;e++)o.push({value:r[e],index:e});o.sort(((e,t)=>t.value-e.value));const a=t*i,h=l.subarray(a,a+i),u=c.subarray(a,a+i);for(let e=0;e<i;e++)h[e]=o[e].value,u[e]=o[e].index}const h=t.slice();return h[h.length-1]=i,[buffer(h,n,l),buffer(h,"int32",c)]} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function uniqueImpl(e,t,n,i){const r=parseAxisParam(t,n)[0],o=[1,n[0],1];for(let e=0;e<r;e++)o[0]*=n[e];o[1]=n[r];for(let e=r+1;e<n.length;e++)o[2]*=n[e];const a={},s=new Int32Array(n[r]),l=new TensorBuffer(o,i,e),c=[],h=1===o[0]&&1===o[2];for(let t=0;t<n[r];t++){let n;if(h)n=e[t].toString();else{const e=[];for(let n=0;n<o[0];n++)for(let i=0;i<o[2];i++)e.push(l.get(n,t,i));n=e.join(",")}if(void 0!==a[n])s[t]=a[n];else{const e=Object.keys(a).length;a[n]=e,s[t]=e,c.push(t)}}const u=o.slice();u[1]=Object.keys(a).length;const d=new TensorBuffer(u,i);c.forEach(((e,t)=>{for(let n=0;n<o[0];n++)for(let i=0;i<o[2];i++)d.set(l.get(n,e,i),n,t,i)}));const p=n.slice();return p[r]=u[1],{outputValues:d.values,outputShape:p,indices:s}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */var shared=Object.freeze({__proto__:null,simpleAbsImpl:simpleAbsImpl,addImpl:addImpl,bincountImpl:bincountImpl,bincountReduceImpl:bincountReduceImpl,ceilImpl:ceilImpl,concatImpl:concatImpl$1,expImpl:expImpl,expm1Impl:expm1Impl,floorImpl:floorImpl,gatherV2Impl:gatherV2Impl,greaterImpl:greaterImpl,lessImpl:lessImpl,linSpaceImpl:linSpaceImpl,logImpl:logImpl,maxImpl:maxImpl$1,maximumImpl:maximumImpl,minimumImpl:minimumImpl,multiplyImpl:multiplyImpl,negImpl:negImpl,notEqualImpl:notEqualImpl,prodImpl:prodImpl,rangeImpl:rangeImpl,rsqrtImpl:rsqrtImpl,sliceImpl:sliceImpl,squaredDifferenceImpl:squaredDifferenceImpl,stridedSliceImpl:stridedSliceImpl,subImpl:subImpl,tileImpl:tileImpl,topKImpl:topKImpl,transposeImpl:transposeImpl$1,uniqueImpl:uniqueImpl}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */registerBackend("cpu",(()=>new MathBackendCPU),1); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const elu$1=unaryKernelFunc$1(Elu,(e=>e>=0?e:Math.exp(e)-1)),eluConfig$1={kernelName:Elu,backendName:"cpu",kernelFunc:elu$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function leakyRelu$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{alpha:o}=i;assertNotComplex$1([r],"leakyRelu");const a=sizeFromShape(r.shape),s=n.data.get(r.dataId).values,l=getTypedArrayFromDType("float32",a);for(let e=0;e<s.length;e++)l[e]=s[e]<0?o*s[e]:s[e];return n.makeTensorInfo(r.shape,"float32",l)}const leakyReluConfig$1={kernelName:LeakyRelu,backendName:"cpu",kernelFunc:leakyRelu$1},preluImpl=createSimpleBinaryKernelImpl(((e,t)=>e<0?t*e:e)); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function prelu$1(e){const{inputs:t,backend:n}=e,{x:i,alpha:r}=t;assertNotComplex$1([i,r],"prelu");const o=n.data.get(i.dataId).values,a=n.data.get(r.dataId).values,[s,l]=preluImpl(i.shape,r.shape,o,a,i.dtype);return n.makeTensorInfo(l,i.dtype,s)}const preluConfig$1={kernelName:Prelu,backendName:"cpu",kernelFunc:prelu$1},relu$1=unaryKernelFunc$1(Relu,(e=>Math.max(0,e))),reluConfig$1={kernelName:Relu,backendName:"cpu",kernelFunc:relu$1},relu6$1=unaryKernelFunc$1(Relu6,(e=>Math.min(Math.max(0,e),6))),relu6Config$1={kernelName:Relu6,backendName:"cpu",kernelFunc:relu6$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function applyActivation(e,t,n,i,r){if("linear"===n)return identity$3({inputs:{x:t},backend:e});if("relu"===n)return relu$1({inputs:{x:t},backend:e});if("elu"===n)return elu$1({inputs:{x:t},backend:e});if("relu6"===n)return relu6$1({inputs:{x:t},backend:e});if("prelu"===n)return prelu$1({inputs:{x:t,alpha:i},backend:e});if("leakyrelu"===n)return leakyRelu$1({inputs:{x:t},backend:e,attrs:{alpha:r}});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function reshape$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{shape:o}=i,a=sizeFromShape(r.shape),s=inferFromImplicitShape(o,a),l=sizeFromShape(s);assert$1(a===l,(()=>`The new shape (${s}) has ${l} elements and the old shape (${r.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(r.dataId);const c=n.data.get(r.dataId);if(null!=c.complexTensorInfos){const e=c.complexTensorInfos.imag;c.complexTensorInfos.real.shape=s,e.shape=s}return{dataId:r.dataId,shape:s,dtype:r.dtype}}const reshapeConfig$1={kernelName:Reshape,backendName:"cpu",kernelFunc:reshape$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function batchMatMul$1(e){const{inputs:t,backend:n,attrs:i}=e,{a:r,b:o}=t,{transposeA:a,transposeB:s}=i;assertNotComplex$1([r,o],"matMul");const l=r.shape.length,c=o.shape.length,h=a?r.shape[l-2]:r.shape[l-1],u=s?o.shape[c-1]:o.shape[c-2],d=a?r.shape[l-1]:r.shape[l-2],p=s?o.shape[c-2]:o.shape[c-1],m=r.shape.slice(0,-2),f=o.shape.slice(0,-2),g=sizeFromShape(m),v=sizeFromShape(f);assert$1(l>=2&&c>=2&&(g===v||1===g||1===v),(()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${m}) and (${f}).`));const y=(g>v?r.shape.slice(0,-2):o.shape.slice(0,-2)).concat([d,p]);assert$1(h===u,(()=>`Error in matMul: inner shapes (${h}) and (${u}) of Tensors with shapes ${r.shape} and ${o.shape} and transposeA=${a} and transposeB=${s} must match.`));const b=s?[v,p,u]:[v,u,p],_=reshape$1({inputs:{x:r},backend:n,attrs:{shape:a?[g,h,d]:[g,d,h]}}),x=reshape$1({inputs:{x:o},backend:n,attrs:{shape:b}}),w=a?_.shape[1]:_.shape[2],S=a?_.shape[2]:_.shape[1],C=s?x.shape[1]:x.shape[2],M=Math.max(g,v),E=n.data.get(_.dataId).values,T=n.data.get(x.dataId).values,I=computeStrides(_.shape),A=computeStrides(x.shape),[k,P,R]=a?[I[0],1,I[1]]:[I[0],I[1],1],[L,N,D]=s?[1,A[1],A[0]]:[A[1],1,A[0]],O=S*C,z=buffer([M,S,C],_.dtype),F=z.values,$=n.blockSize;for(let e=0;e<M;e++)for(let t=0;t<S;t+=$)for(let n=0;n<C;n+=$)for(let i=0;i<w;i+=$){const r=Math.min(t+$,S),o=Math.min(n+$,C),a=Math.min(i+$,w);for(let s=t;s<r;s++)for(let t=n;t<o;t++){let n=0;for(let r=i;r<a;r++){const i=Math.min(e,g-1)*k,o=Math.min(e,v-1)*D;n+=E[i+s*P+r*R]*T[r*L+t*N+o]}F[e*O+(s*C+t)]+=n}}return n.disposeIntermediateTensorInfo(_),n.disposeIntermediateTensorInfo(x),n.makeTensorInfo(y,z.dtype,z.values)}const batchMatMulConfig$1={kernelName:BatchMatMul,backendName:"cpu",kernelFunc:batchMatMul$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function _fusedMatMul$1(e){const{inputs:t,backend:n,attrs:i}=e,{a:r,b:o,bias:a,preluActivationWeights:s}=t,{transposeA:l,transposeB:c,activation:h,leakyreluAlpha:u}=i;let d,p,m;const f=[];d=batchMatMul$1({inputs:{a:r,b:o},attrs:{transposeA:l,transposeB:c},backend:n}),a&&(p=add({inputs:{a:d,b:a},backend:n}),f.push(d),d=p),h&&(m=applyActivation(n,d,h,s,u),f.push(d),d=m);for(const e of f)n.disposeIntermediateTensorInfo(e);return d}const _fusedMatMulConfig$1={kernelName:_FusedMatMul,backendName:"cpu",kernelFunc:_fusedMatMul$1},acos$1=unaryKernelFunc$1(Acos,(e=>Math.acos(e))),acosConfig$1={kernelName:Acos,backendName:"cpu",kernelFunc:acos$1},acosh$1=unaryKernelFunc$1(Acosh,(e=>Math.acosh(e))),acoshConfig$1={kernelName:Acosh,backendName:"cpu",kernelFunc:acosh$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function addN$1(e){const{inputs:t,backend:n}=e,i=t;assertNotComplex$1(t,"addN");const r=i.map((e=>n.data.get(e.dataId).values)),o=buffer(i[0].shape,i[0].dtype),a=o.values;for(let e=0;e<i.length;e++){const t=r[e];for(let e=0;e<a.length;e++)a[e]+=t[e]}return n.makeTensorInfo(o.shape,o.dtype,o.values)}const addNConfig$1={kernelName:AddN,backendName:"cpu",kernelFunc:addN$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function all$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i;assertNotComplex$1(r,"all");const s=parseAxisParam(o,r.shape);let l=s;const c=getAxesPermutation(l,r.shape.length);let h=r;null!=c&&(h=transpose$1({inputs:{x:r},backend:n,attrs:{perm:c}}),l=getInnerMostAxes(l.length,r.shape.length)),assertAxesAreInnerMostDims("all",l,h.shape.length);const[u,d]=computeOutAndReduceShapes(h.shape,l),p=sizeFromShape(d),m=makeZerosTypedArray(sizeFromShape(u),h.dtype),f=n.data.get(h.dataId).values;for(let e=0;e<m.length;++e){const t=e*p;let n=f[t];for(let e=0;e<p;++e){const i=f[t+e];n=n&&i}m[e]=n}null!=c&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(u,h.dtype,m);if(a){const e=reshape$1({inputs:{x:g},backend:n,attrs:{shape:expandShapeToKeepDim(u,s)}});return n.disposeIntermediateTensorInfo(g),e}return g}const allConfig$1={kernelName:All,backendName:"cpu",kernelFunc:all$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function any$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i;assertNotComplex$1(r,"any");const s=parseAxisParam(o,r.shape);let l=s;const c=getAxesPermutation(l,r.shape.length);let h=r;null!=c&&(h=transpose$1({inputs:{x:r},backend:n,attrs:{perm:c}}),l=getInnerMostAxes(l.length,r.shape.length)),assertAxesAreInnerMostDims("any",l,h.shape.length);const[u,d]=computeOutAndReduceShapes(h.shape,l),p=sizeFromShape(d),m=makeZerosTypedArray(sizeFromShape(u),h.dtype),f=n.data.get(h.dataId).values;for(let e=0;e<m.length;++e){const t=e*p;let n=f[t];for(let e=0;e<p;++e){const i=f[t+e];n=n||i}m[e]=n}null!=c&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(u,h.dtype,m);if(a){const e=reshape$1({inputs:{x:g},backend:n,attrs:{shape:expandShapeToKeepDim(u,s)}});return n.disposeIntermediateTensorInfo(g),e}return g}const anyConfig$1={kernelName:Any,backendName:"cpu",kernelFunc:any$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function argMax$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o}=i;assertNotComplex$1(r,"argMax");let a=parseAxisParam(o,r.shape);const s=getAxesPermutation(a,r.shape.length);let l=r;const c=[];null!=s&&(l=transpose$1({inputs:{x:r},backend:n,attrs:{perm:s}}),c.push(l),a=getInnerMostAxes(a.length,l.shape.length)),a=[a[0]],assertAxesAreInnerMostDims("argMax",a,l.shape.length);const[h,u]=computeOutAndReduceShapes(l.shape,a),d=makeZerosTypedArray(sizeFromShape(h),"int32"),p=sizeFromShape(u),m=n.data.get(l.dataId).values;for(let e=0;e<d.length;++e){const t=e*p;let n=m[t],i=0;for(let e=0;e<p;++e){const r=m[t+e];r>n&&(n=r,i=e)}d[e]=i}return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(h,"int32",d)}const argMaxConfig$1={kernelName:ArgMax,backendName:"cpu",kernelFunc:argMax$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function argMin$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o}=i;assertNotComplex$1(r,"argMin");let a=parseAxisParam(o,r.shape);const s=getAxesPermutation(a,r.shape.length);let l=r;const c=[];null!=s&&(l=transpose$1({inputs:{x:r},backend:n,attrs:{perm:s}}),c.push(l),a=getInnerMostAxes(a.length,l.shape.length)),a=[a[0]],assertAxesAreInnerMostDims("argMin",a,l.shape.length);const[h,u]=computeOutAndReduceShapes(l.shape,a),d=makeZerosTypedArray(sizeFromShape(h),"int32"),p=sizeFromShape(u),m=n.data.get(l.dataId).values;for(let e=0;e<d.length;++e){const t=e*p;let n=m[t],i=0;for(let e=0;e<p;++e){const r=m[t+e];r<n&&(n=r,i=e)}d[e]=i}return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(h,"int32",d)}const argMinConfig$1={kernelName:ArgMin,backendName:"cpu",kernelFunc:argMin$1},asin$1=unaryKernelFunc$1(Asin,(e=>Math.asin(e))),asinConfig$1={kernelName:Asin,backendName:"cpu",kernelFunc:asin$1},asinh$1=unaryKernelFunc$1(Asinh,(e=>Math.asinh(e))),asinhConfig$1={kernelName:Asinh,backendName:"cpu",kernelFunc:asinh$1},atan$1=unaryKernelFunc$1(Atan,(e=>Math.atan(e))),atanConfig$1={kernelName:Atan,backendName:"cpu",kernelFunc:atan$1},atan2Impl=createSimpleBinaryKernelImpl(((e,t)=>Math.atan2(e,t))),atan2$1=binaryKernelFunc$1(Atan2,atan2Impl),atan2Config$1={kernelName:Atan2,backendName:"cpu",kernelFunc:atan2$1},atanh$1=unaryKernelFunc$1(Atanh,(e=>Math.atanh(e))),atanhConfig$1={kernelName:Atanh,backendName:"cpu",kernelFunc:atanh$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function pool(e,t,n,i,r,o){const a=r.strideHeight,s=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,h=r.effectiveFilterHeight,u=r.effectiveFilterWidth,d=r.padInfo.top,p=r.padInfo.left,m="max"===o?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,f=buffer(r.outShape,n),g=f.values,v=r.outShape[1]*r.outShape[2]*r.outShape[3],y=r.outShape[2]*r.outShape[3],b=r.outShape[3];for(let t=0;t<r.batchSize;++t){const n=t*v,f=t*i[0];for(let t=0;t<r.inChannels;++t)for(let v=0;v<r.outHeight;++v){const _=v*a-d,x=Math.max(0,_),w=Math.min(r.inHeight,h+_),S=n+v*y;for(let n=0;n<r.outWidth;++n){const a=n*s-p,h=Math.max(0,a),d=Math.min(r.inWidth,u+a);let v=m,y=0,_=0;for(let n=x;n<w;n+=l){const r=f+n*i[1];for(let n=h;n<d;n+=c){const a=e[r+n*i[2]+t];"max"===o&&a>v?v=a:"avg"===o&&(y+=a,_++)}if(isNaN(v))break}g[S+n*b+t]="avg"===o?y/_:v}}}return f}function maxPoolPositions(e,t,n,i,r=!1,o=!1){const a=buffer(i.outShape,"int32"),s=i.strideHeight,l=i.strideWidth,c=i.dilationHeight,h=i.dilationWidth,u=i.effectiveFilterHeight,d=i.effectiveFilterWidth,p=i.padInfo.top,m=i.padInfo.left,f=buffer(t,n,e);for(let e=0;e<i.batchSize;++e)for(let t=0;t<i.inChannels;++t)for(let n=0;n<i.outHeight;++n){const g=n*s-p;let v=g;for(;v<0;)v+=c;const y=Math.min(i.inHeight,u+g);for(let s=0;s<i.outWidth;++s){const u=s*l-m;let p=u;for(;p<0;)p+=h;const b=Math.min(i.inWidth,d+u);let _=Number.NEGATIVE_INFINITY,x=-1;for(let n=v;n<y;n+=c){const a=n-g;for(let s=p;s<b;s+=h){const l=s-u,c=f.get(e,n,s,t);c>_&&(_=c,x=r?o?((e*i.inHeight+n)*i.inWidth+s)*i.inChannels+t:(n*i.inWidth+s)*i.inChannels+t:a*d+l)}}a.set(x,e,n,s,t)}}return a}function pool3d(e,t,n,i,r,o){const a=r.strideDepth,s=r.strideHeight,l=r.strideWidth,c=r.dilationDepth,h=r.dilationHeight,u=r.dilationWidth,d=r.effectiveFilterDepth,p=r.effectiveFilterHeight,m=r.effectiveFilterWidth,f=r.padInfo.front,g=r.padInfo.top,v=r.padInfo.left,y="max"===o?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,b=buffer(r.outShape,n),_=b.values,x=r.outShape[1]*r.outShape[2]*r.outShape[3]*r.outShape[4],w=r.outShape[2]*r.outShape[3]*r.outShape[4],S=r.outShape[3]*r.outShape[4],C=r.outShape[4];for(let t=0;t<r.batchSize;++t){const n=t*x,b=t*i[0];for(let t=0;t<r.inChannels;++t)for(let x=0;x<r.outDepth;++x){const M=x*a-f;let E=M;for(;E<0;)E+=c;const T=Math.min(r.inDepth,d+M),I=n+x*w;for(let n=0;n<r.outHeight;++n){const a=n*s-g;let d=a;for(;d<0;)d+=h;const f=Math.min(r.inHeight,p+a),x=I+n*S;for(let n=0;n<r.outWidth;++n){const a=n*l-v;let s=a;for(;s<0;)s+=u;const p=Math.min(r.inWidth,m+a),g=x+n*C;let w=y,S=0,M=0;for(let n=E;n<T;n+=c){const r=b+n*i[1];for(let n=d;n<f;n+=h){const a=r+n*i[2];for(let n=s;n<p;n+=u){const r=e[a+n*i[3]+t];if("max"===o&&r>w?w=r:"avg"===o&&(S+=r,M++),isNaN(w))break}if(isNaN(w))break}if(isNaN(w))break}_[g+t]="avg"===o?S/M:w}}}}return b}function maxPool3dPositions(e,t){const n=buffer(t.outShape,"int32"),i=t.strideDepth,r=t.strideHeight,o=t.strideWidth,a=t.dilationDepth,s=t.dilationHeight,l=t.dilationWidth,c=t.effectiveFilterDepth,h=t.effectiveFilterHeight,u=t.effectiveFilterWidth,d=t.padInfo.front,p=t.padInfo.top,m=t.padInfo.left;for(let f=0;f<t.batchSize;++f)for(let g=0;g<t.inChannels;++g)for(let v=0;v<t.outDepth;++v){const y=v*i-d;let b=y;for(;b<0;)b+=a;const _=Math.min(t.inDepth,c+y);for(let i=0;i<t.outHeight;++i){const c=i*r-p;let d=c;for(;d<0;)d+=s;const x=Math.min(t.inHeight,h+c);for(let r=0;r<t.outWidth;++r){const p=r*o-m;let w=p;for(;w<0;)w+=l;const S=Math.min(t.inWidth,u+p);let C=Number.NEGATIVE_INFINITY,M=-1;for(let t=b;t<_;t+=a){const n=t-y;for(let i=d;i<x;i+=s){const r=i-c;for(let o=w;o<S;o+=l){const a=o-p,s=e.get(f,t,i,o,g);s>=C&&(C=s,M=n*h*u+r*h+a)}}}n.set(M,f,v,i,r,g)}}}return n} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function avgPool$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t;assertNotComplex$1(r,"avgPool");const{filterSize:o,strides:a,pad:s,dimRoundingMode:l}=i;assert$1(eitherStridesOrDilationsAreOne(a,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const c=computePool2DInfo(r.shape,o,a,1,s,l);let h;if(1===c.filterWidth&&1===c.filterHeight&&arraysEqual$1(c.inShape,c.outShape))h=identity$3({inputs:{x:r},backend:n});else{const e=n.data.get(r.dataId).values,t=computeStrides(r.shape),i=pool(e,r.shape,r.dtype,t,c,"avg");h=n.makeTensorInfo(c.outShape,r.dtype,i.values)}return h}const avgPoolConfig$1={kernelName:AvgPool,backendName:"cpu",kernelFunc:avgPool$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function avgPool3D$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{filterSize:o,strides:a,pad:s,dimRoundingMode:l,dataFormat:c}=i;assertNotComplex$1(r,"avgPool3d");const h=computePool3DInfo(r.shape,o,a,1,s,l,c),u=pool3d(n.data.get(r.dataId).values,r.shape,r.dtype,computeStrides(r.shape),h,"avg");return n.makeTensorInfo(u.shape,"float32",u.values)}const avgPool3DConfig$1={kernelName:AvgPool3D,backendName:"cpu",kernelFunc:avgPool3D$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function avgPool3DGrad$1(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,input:o}=t,{filterSize:a,strides:s,pad:l,dimRoundingMode:c}=i;assertNotComplex$1([r,o],"avgPool3DGrad");const h=computePool3DInfo(o.shape,a,s,1,l,c),u=h.strideDepth,d=h.strideHeight,p=h.strideWidth,m=h.filterDepth,f=h.filterHeight,g=h.filterWidth,v=h.dilationDepth,y=h.dilationHeight,b=h.dilationWidth,_=h.effectiveFilterDepth,x=h.effectiveFilterHeight,w=h.effectiveFilterWidth,S=_-1-h.padInfo.front,C=w-1-h.padInfo.left,M=x-1-h.padInfo.top,E=buffer(o.shape,"float32"),T=1/(m*f*g),I=n.bufferSync(r);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let n=0;n<h.inDepth;++n)for(let i=0;i<h.inHeight;++i)for(let r=0;r<h.inWidth;++r){const o=n-S,a=i-M,s=r-C;let l=0;for(let n=0;n<_;n+=v){const i=(o+n)/u;if(!(i<0||i>=h.outDepth||Math.floor(i)!==i))for(let n=0;n<x;n+=y){const r=(a+n)/d;if(!(r<0||r>=h.outHeight||Math.floor(r)!==r))for(let n=0;n<w;n+=b){const o=(s+n)/p;o<0||o>=h.outWidth||Math.floor(o)!==o||(l+=I.get(e,i,r,o,t))}}}E.set(l*T,e,n,i,r,t)}return n.makeTensorInfo(E.shape,E.dtype,E.values)}const avgPool3DGradConfig={kernelName:AvgPool3DGrad,backendName:"cpu",kernelFunc:avgPool3DGrad$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function avgPoolGrad$1(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,input:o}=t,a=o;assertNotComplex$1([r,o],"avgPoolGrad");const{filterSize:s,strides:l,pad:c}=i,h=computePool2DInfo(a.shape,s,l,1,c),u=h.strideHeight,d=h.strideWidth,p=h.filterHeight,m=h.filterWidth,f=h.dilationHeight,g=h.dilationWidth,v=h.effectiveFilterHeight,y=h.effectiveFilterWidth,b=y-1-h.padInfo.left,_=v-1-h.padInfo.top,x=buffer(a.shape,"float32"),w=1/(p*m),S=n.data.get(r.dataId).values,C=buffer(r.shape,"float32",S);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let n=0;n<h.inHeight;++n)for(let i=0;i<h.inWidth;++i){const r=n-_,o=i-b;let a=0;for(let n=0;n<v;n+=f){const i=(r+n)/u;if(!(i<0||i>=h.outHeight||Math.floor(i)!==i))for(let n=0;n<y;n+=g){const r=(o+n)/d;r<0||r>=h.outWidth||Math.floor(r)!==r||(a+=C.get(e,i,r,t))}}x.set(a*w,e,n,i,t)}return n.makeTensorInfo(x.shape,x.dtype,x.values)}const avgPoolGradConfig$1={kernelName:AvgPoolGrad,backendName:"cpu",kernelFunc:avgPoolGrad$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function batchNorm$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,scale:o,offset:a,mean:s,variance:l}=t;assert$1(s.shape.length===l.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),assert$1(null==a||s.shape.length===a.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),assert$1(null==o||s.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),assertNotComplex$1([r,s,l,o,a],"batchNorm");let{varianceEpsilon:c}=i;null==c&&(c=.001);const h=n.data.get(r.dataId).values,u=n.data.get(s.dataId).values,d=n.data.get(l.dataId).values,p=o?n.data.get(o.dataId).values:new Float32Array([1]),m=a?n.data.get(a.dataId).values:new Float32Array([0]),f=new Float32Array(h.length),g=m.length,v=p.length,y=d.length,b=u.length;let _=0,x=0,w=0,S=0;for(let e=0;e<h.length;++e)f[e]=m[_++]+(h[e]-u[x++])*p[w++]/Math.sqrt(d[S++]+c),_>=g&&(_=0),x>=b&&(x=0),w>=v&&(w=0),S>=y&&(S=0);return n.makeTensorInfo(r.shape,r.dtype,f)}const batchNormConfig$1={kernelName:FusedBatchNorm,backendName:"cpu",kernelFunc:batchNorm$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function batchToSpaceND$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{blockShape:o,crops:a}=i;assertNotComplex$1([r],"batchToSpaceND");const s=o.reduce(((e,t)=>e*t)),l=getReshaped(r.shape,o,s),c=getPermuted(l.length,o.length),h=getReshapedPermuted(r.shape,o,s),u=getSliceBeginCoords(a,o.length),d=getSliceSize(h,a,o.length),p=reshape$1({inputs:{x:r},backend:n,attrs:{shape:l}}),m=transpose$1({inputs:{x:p},backend:n,attrs:{perm:c}}),f=reshape$1({inputs:{x:m},backend:n,attrs:{shape:h}}),g=slice$2({inputs:{x:f},backend:n,attrs:{begin:u,size:d}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),g}const batchToSpaceNDConfig$1={kernelName:BatchToSpaceND,backendName:"cpu",kernelFunc:batchToSpaceND$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function bincount$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,weights:o}=t,{size:a}=i,s=bincountImpl(n.data.get(r.dataId).values,n.data.get(o.dataId).values,o.dtype,o.shape,a);return n.makeTensorInfo([a],o.dtype,s)}const bincountConfig$1={kernelName:Bincount,backendName:"cpu",kernelFunc:bincount$1},clip=unaryKernelFunc$1(ClipByValue,((e,t)=>e>t.clipValueMax?t.clipValueMax:e<t.clipValueMin?t.clipValueMin:e)),clipConfig={kernelName:ClipByValue,backendName:"cpu",kernelFunc:clip},complexAbs$1=e=>{const{x:t}=e.inputs,n=e.backend,i=new Float32Array(sizeFromShape(t.shape)),r=n.data.get(t.dataId),o=r.complexTensorInfos.imag,a=n.data.get(r.complexTensorInfos.real.dataId).values,s=n.data.get(o.dataId).values;for(let e=0;e<a.length;e++)i[e]=Math.hypot(a[e],s[e]);return n.makeOutput(i,t.shape,"float32")},complexAbsConfig$1={kernelName:ComplexAbs,backendName:"cpu",kernelFunc:complexAbs$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function imag$1(e){const{inputs:t,backend:n}=e,{input:i}=t,r=n.data.get(i.dataId).complexTensorInfos.imag,o=n.data.get(r.dataId).values;return n.makeTensorInfo(r.shape,r.dtype,o)}const imagConfig$1={kernelName:Imag,backendName:"cpu",kernelFunc:imag$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function concat$1(e){const{inputs:t,backend:n,attrs:i}=e,{axis:r}=i,o=parseAxisParam(r,t[0].shape)[0];let a=computeOutShape$1(t.map((e=>e.shape)),o);if(0===sizeFromShape(a))return n.makeTensorInfo(a,t[0].dtype,[]);const s=t.filter((e=>sizeFromShape(e.shape)>0));if(1===s.length)return identity$3({inputs:{x:s[0]},backend:n});if(assertParamsConsistent(s.map((e=>e.shape)),o),"complex64"===s[0].dtype){const e=s.map((e=>real$1({inputs:{input:e},backend:n}))),t=s.map((e=>imag$1({inputs:{input:e},backend:n}))),i=concat$1({inputs:e,backend:n,attrs:{axis:o}}),r=concat$1({inputs:t,backend:n,attrs:{axis:o}}),a=complex$1({inputs:{real:i,imag:r},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(r),a}const l=s.map((e=>{const t=sizeFromShape(e.shape.slice(o));return reshape$1({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),c=l.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));a=computeOutShape$1(l.map((e=>e.shape)),1);const h=concatImpl$1(c,a,t[0].dtype,1===l[0].shape[0]),u=computeOutShape$1(s.map((e=>e.shape)),o),d=n.makeTensorInfo(u,t[0].dtype,h);return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}const concatConfig$1={kernelName:Concat,backendName:"cpu",kernelFunc:concat$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv2D(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o}=t,{strides:a,pad:s,dataFormat:l,dilations:c,dimRoundingMode:h}=i;assertNotComplex$1([r,o],"conv2d");const u=convertConv2DDataFormat(l),d=computeConv2DInfo(r.shape,o.shape,a,c,s,h,!1,u),p=d.filterHeight,m=d.filterWidth,f=d.dilationHeight,g=d.dilationWidth,v=d.padInfo.left,y=d.padInfo.top,b="channelsLast"===d.dataFormat,_=new TensorBuffer(d.outShape,r.dtype),x=computeStrides(r.shape),w=computeStrides(o.shape),S=x[0],C=b?x[1]:x[2],M=b?x[2]:1,E=b?1:x[1],T=_.strides[0],I=b?_.strides[1]:_.strides[2],A=b?_.strides[2]:1,k=b?1:_.strides[1],P=n.data.get(r.dataId).values,R=n.data.get(o.dataId).values,L=_.values;for(let e=0;e<d.batchSize;++e){const t=e*S,n=e*T;for(let e=0;e<d.outHeight;++e){const i=n+e*I,r=e*d.strideHeight-y;for(let e=0;e<p;++e){const n=r+e*f;if(n<0||n>=d.inHeight)continue;const o=e*w[0],a=t+n*C;for(let e=0;e<d.outWidth;++e){const t=i+e*A,n=e*d.strideWidth-v;for(let e=0;e<m;++e){const i=n+e*g;if(i<0||i>=d.inWidth)continue;const r=a+i*M;let s=o+e*w[1];for(let e=0;e<d.inChannels;++e){const n=P[r+e*E];for(let e=0;e<d.outChannels;++e)L[t+e*k]+=n*R[s+e];s+=d.outChannels}}}}}}return n.makeTensorInfo(_.shape,_.dtype,L)}const conv2DConfig$1={kernelName:Conv2D,backendName:"cpu",kernelFunc:conv2D}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv2DBackpropFilter$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,dy:o}=t,{strides:a,pad:s,dataFormat:l,dimRoundingMode:c,filterShape:h}=i;assertNotComplex$1([r,o],"conv2dBackpropFilter");const u=convertConv2DDataFormat(l),d=computeConv2DInfo(r.shape,h,a,1,s,c,!1,u),{strideHeight:p,strideWidth:m,filterHeight:f,filterWidth:g}=d,v="channelsLast"===d.dataFormat,y=new TensorBuffer(d.filterShape,"float32"),b=d.padInfo.left,_=d.padInfo.top,x=n.data.get(r.dataId).values,w=n.data.get(o.dataId).values,S=new TensorBuffer(r.shape,r.dtype,x),C=new TensorBuffer(o.shape,o.dtype,w);for(let e=0;e<f;++e){const t=Math.max(0,Math.ceil((_-e)/p)),n=Math.min(d.outHeight,(d.inHeight+_-e)/p);for(let i=0;i<g;++i){const r=Math.max(0,Math.ceil((b-i)/m)),o=Math.min(d.outWidth,(d.inWidth+b-i)/m);for(let a=0;a<d.inChannels;++a)for(let s=0;s<d.outChannels;++s){let l=0;for(let c=0;c<d.batchSize;++c)for(let h=t;h<n;++h){const t=e+h*p-_;for(let e=r;e<o;++e){const n=i+e*m-b;l+=v?S.get(c,t,n,a)*C.get(c,h,e,s):S.get(c,a,t,n)*C.get(c,s,h,e)}}y.set(l,e,i,a,s)}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}const conv2DBackpropFilterConfig$1={kernelName:Conv2DBackpropFilter,backendName:"cpu",kernelFunc:conv2DBackpropFilter$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv2DBackpropInput$1(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,filter:o}=t,{inputShape:a,strides:s,pad:l,dataFormat:c,dimRoundingMode:h}=i;assertNotComplex$1([r,o],"conv2dBackpropInput");const u=computeStrides(o.shape),d=computeStrides(r.shape);let p=convertConv2DDataFormat(c);const m=computeConv2DInfo(a,o.shape,s,1,l,h,!1,p),f=new TensorBuffer(m.inShape,"float32"),g=f.values,v=n.data.get(r.dataId).values,y=n.data.get(o.dataId).values,[b,_,x]=u,{batchSize:w,filterHeight:S,filterWidth:C,inChannels:M,inHeight:E,inWidth:T,outChannels:I,outHeight:A,outWidth:k,strideHeight:P,strideWidth:R}=m;p=m.dataFormat;const L=S-1-m.padInfo.top,N=C-1-m.padInfo.left,D="channelsLast"===p,O=f.strides[0],z=D?f.strides[1]:f.strides[2],F=D?f.strides[2]:1,$=D?1:f.strides[1],B=d[0],V=D?d[1]:d[2],H=D?d[2]:1,U=D?1:d[1];for(let e=0;e<w;++e)for(let t=0;t<M;++t)for(let n=0;n<E;++n){const i=n-L,r=Math.max(0,Math.ceil(i/P)),o=Math.min(A,(S+i)/P);for(let a=0;a<T;++a){const s=a-N,l=Math.max(0,Math.ceil(s/R)),c=Math.min(k,(C+s)/R);let h=0;for(let n=r;n<o;++n){const r=n*P-i;for(let i=l;i<c;++i){const o=B*e+V*n+H*i,a=b*(S-1-r)+_*(C-1-(i*R-s))+x*t;for(let e=0;e<I;++e)h+=v[o+U*e]*y[a+e]}}g[O*e+z*n+F*a+$*t]=h}}return n.makeTensorInfo(f.shape,f.dtype,f.values)}const conv2DBackpropInputConfig$1={kernelName:Conv2DBackpropInput,backendName:"cpu",kernelFunc:conv2DBackpropInput$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv3D$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o}=t,{strides:a,pad:s,dilations:l}=i;assertNotComplex$1([r,o],"conv3d");const c=computeConv3DInfo(r.shape,o.shape,a,l,s),{filterDepth:h,filterHeight:u,filterWidth:d,dilationDepth:p,dilationHeight:m,dilationWidth:f,padInfo:g}=c,v=g.front,y=g.left,b=g.top,_=new TensorBuffer(c.outShape,r.dtype),x=n.data.get(r.dataId).values,w=n.data.get(o.dataId).values,S=_.values,C=computeStrides(r.shape),M=computeStrides(o.shape);for(let e=0;e<c.batchSize;++e){const t=e*C[0],n=e*_.strides[0];for(let e=0;e<c.outDepth;++e){const i=n+e*_.strides[1],r=e*c.strideDepth-v;for(let e=0;e<h;++e){const n=r+e*p;if(n<0||n>=c.inDepth)continue;const o=e*M[0],a=t+n*C[1];for(let e=0;e<c.outHeight;++e){const t=i+e*_.strides[2],n=e*c.strideHeight-b;for(let e=0;e<u;++e){const i=n+e*m;if(i<0||i>=c.inHeight)continue;const r=o+e*M[1],s=a+i*C[2];for(let e=0;e<c.outWidth;++e){const n=t+e*c.outChannels,i=e*c.strideWidth-y;for(let e=0;e<d;++e){const t=i+e*f;if(t<0||t>=c.inWidth)continue;const o=s+t*c.inChannels;let a=r+e*M[2];for(let e=0;e<c.inChannels;++e){const t=x[o+e];for(let e=0;e<c.outChannels;++e)S[n+e]+=t*w[a+e];a+=c.outChannels}}}}}}}}return n.makeTensorInfo(_.shape,_.dtype,_.values)}const conv3DConfig$1={kernelName:Conv3D,backendName:"cpu",kernelFunc:conv3D$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv3DBackpropFilterV2$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,dy:o}=t,{strides:a,pad:s,filterShape:l}=i;assertNotComplex$1([r,o],"conv3dBackpropFilterV2");const c=computeStrides(r.shape),h=computeStrides(o.shape),u=computeConv3DInfo(r.shape,l,a,1,s),d=u.strideDepth,p=u.strideHeight,m=u.strideWidth,f=u.filterDepth,g=u.filterHeight,v=u.filterWidth,y=new TensorBuffer(u.filterShape,"float32"),b=y.values,[_,x,w,S]=y.strides,C=n.data.get(o.dataId).values,[M,E,T,I]=h,A=n.data.get(r.dataId).values,[k,P,R,L]=c,N=u.padInfo.front,D=u.padInfo.left,O=u.padInfo.top;for(let e=0;e<f;++e){const t=Math.max(0,Math.ceil((N-e)/d)),n=Math.min(u.outDepth,(u.inDepth+N-e)/d),i=e*_;for(let r=0;r<g;++r){const o=Math.max(0,Math.ceil((O-r)/p)),a=Math.min(u.outHeight,(u.inHeight+O-r)/p),s=r*x+i;for(let i=0;i<v;++i){const l=Math.max(0,Math.ceil((D-i)/m)),c=Math.min(u.outWidth,(u.inWidth+D-i)/m),h=i*w+s;for(let s=0;s<u.inChannels;++s){const f=s*S+h;for(let h=0;h<u.outChannels;++h){let g=0;for(let f=0;f<u.batchSize;++f){const u=f*k,v=f*M;for(let f=t;f<n;++f){const t=(e+f*d-N)*P+u,n=f*E+v;for(let e=o;e<a;++e){const o=(r+e*p-O)*R+t,a=e*T+n;for(let e=l;e<c;++e)g+=A[(i+e*m-D)*L+o+s]*C[e*I+a+h]}}}b[f+h]=g}}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}const conv3DBackpropFilterV2Config$1={kernelName:Conv3DBackpropFilterV2,backendName:"cpu",kernelFunc:conv3DBackpropFilterV2$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv3DBackpropInputV2(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,filter:o}=t,{pad:a,strides:s,inputShape:l}=i;assertNotComplex$1([r],"conv3dBackpropInputV2");const c=computeStrides(r.shape),h=computeStrides(o.shape),u=computeConv3DInfo(l,o.shape,s,1,a),d=new TensorBuffer(u.inShape,"float32"),p=d.values,[m,f,g,v]=d.strides,y=n.data.get(r.dataId).values,[b,_,x,w]=c,S=n.data.get(o.dataId).values,[C,M,E,T]=h,{batchSize:I,filterDepth:A,filterHeight:k,filterWidth:P,inChannels:R,inDepth:L,inHeight:N,inWidth:D,outChannels:O,outDepth:z,outHeight:F,outWidth:$,strideDepth:B,strideHeight:V,strideWidth:H}=u,U=A-1-u.padInfo.front,G=k-1-u.padInfo.top,j=P-1-u.padInfo.left;for(let e=0;e<I;++e)for(let t=0;t<R;++t)for(let n=0;n<L;++n){const i=n-U,r=Math.max(0,Math.ceil(i/B)),o=Math.min(z,(A+i)/B);for(let a=0;a<N;++a){const s=a-G,l=Math.max(0,Math.ceil(s/V)),c=Math.min(F,(k+s)/V);for(let h=0;h<D;++h){const u=h-j,d=Math.max(0,Math.ceil(u/H)),I=Math.min($,(P+u)/H);let R=0;for(let n=r;n<o;++n){const r=n*B-i;for(let i=l;i<c;++i){const o=i*V-s;for(let a=d;a<I;++a){const s=b*e+_*n+x*i+w*a,l=C*(A-1-r)+M*(k-1-o)+E*(P-1-(a*H-u))+T*t;for(let e=0;e<O;++e)R+=y[s+e]*S[l+e]}}}p[m*e+f*n+g*a+v*h+t]=R}}}return n.makeTensorInfo(d.shape,d.dtype,d.values)}const conv3DBackpropInputV2Config={kernelName:Conv3DBackpropInputV2,backendName:"cpu",kernelFunc:conv3DBackpropInputV2},cos$1=unaryKernelFunc$1(Cos,(e=>Math.cos(e))),cosConfig$1={kernelName:Cos,backendName:"cpu",kernelFunc:cos$1},cosh$1=unaryKernelFunc$1(Cosh,(e=>Math.cosh(e))),coshConfig$1={kernelName:Cosh,backendName:"cpu",kernelFunc:cosh$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function cropAndResize$1(e){const{inputs:t,backend:n,attrs:i}=e,{image:r,boxes:o,boxInd:a}=t,{cropSize:s,method:l,extrapolationValue:c}=i,[h,u,d,p]=r.shape,m=o.shape[0],[f,g]=s,v=buffer([m,f,g,p],"float32"),y=n.data.get(o.dataId).values,b=n.data.get(a.dataId).values,_=n.data.get(r.dataId).values,x=computeStrides(r.shape),w=computeStrides(v.shape);for(let e=0;e<m;e++){const t=4*e,n=y[t],i=y[t+1],r=y[t+2],o=y[t+3],a=b[e];if(a>=h)continue;const s=f>1?(r-n)*(u-1)/(f-1):0,m=g>1?(o-i)*(d-1)/(g-1):0;for(let t=0;t<f;t++){const h=f>1?n*(u-1)+t*s:.5*(n+r)*(u-1);if(h<0||h>u-1)for(let n=0;n<g;n++)for(let i=0;i<p;i++)v.values[i+n*w[2]+t*w[1]+e*w[0]]=c;else if("bilinear"===l){const n=Math.floor(h),r=Math.ceil(h),s=h-n;for(let l=0;l<g;l++){const h=g>1?i*(d-1)+l*m:.5*(i+o)*(d-1);if(h<0||h>d-1){for(let n=0;n<p;n++)v.values[n+l*w[2]+t*w[1]+e*w[0]]=c;continue}const u=Math.floor(h),f=Math.ceil(h),y=h-u;for(let i=0;i<p;i++){let o=i+u*x[2]+n*x[1]+a*x[0];const c=_[o];o=i+f*x[2]+n*x[1]+a*x[0];const h=_[o];o=i+u*x[2]+r*x[1]+a*x[0];const d=_[o];o=i+f*x[2]+r*x[1]+a*x[0];const p=_[o],m=c+(h-c)*y;o=i+l*w[2]+t*w[1]+e*w[0],v.values[o]=m+(d+(p-d)*y-m)*s}}}else for(let n=0;n<g;++n){const r=g>1?i*(d-1)+n*m:.5*(i+o)*(d-1);if(r<0||r>d-1){for(let i=0;i<p;i++)v.values[i+n*w[2]+t*w[1]+e*w[0]]=c;continue}const s=Math.round(r),l=Math.round(h);for(let i=0;i<p;i++)v.values[i+n*w[2]+t*w[1]+e*w[0]]=_[i+s*x[2]+l*x[1]+a*x[0]]}}}return n.makeTensorInfo(v.shape,v.dtype,v.values)}const cropAndResizeConfig$1={kernelName:CropAndResize,backendName:"cpu",kernelFunc:cropAndResize$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function cumsum$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,exclusive:a,reverse:s}=i;assertNotComplex$1(r,"cumsum");const l=getAxesPermutation([o],r.shape.length);let c=r;null!=l&&(c=transpose$1({inputs:{x:r},backend:n,attrs:{perm:l}}));const h=getInnerMostAxes(1,r.shape.length)[0];if(h!==c.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${c.shape.length-1} but got axis=${h}`);const u=upcastType(c.dtype,"int32"),d=makeZerosTypedArray(sizeFromShape(c.shape),u),p=n.data.get(c.dataId).values,m=c.shape[c.shape.length-1],f=s?(e,t)=>e+m-t-1:(e,t)=>e+t;for(let e=0;e<p.length;e+=m)for(let t=0;t<m;t++){const n=f(e,t);if(0===t)d[n]=a?0:p[n];else{const i=f(e,t-1);d[n]=a?p[i]+d[i]:p[n]+d[i]}}const g=n.makeTensorInfo(c.shape,u,d);if(null!=l){const e=transpose$1({inputs:{x:g},backend:n,attrs:{perm:getUndoAxesPermutation(l)}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(c),e}return g}const cumsumConfig$1={kernelName:Cumsum,backendName:"cpu",kernelFunc:cumsum$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function denseBincount$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,weights:o}=t,{size:a,binaryOutput:s}=i;if(1===r.shape.length){const e=bincountImpl(n.data.get(r.dataId).values,n.data.get(o.dataId).values,o.dtype,o.shape,a);return n.makeTensorInfo([a],o.dtype,e)}if(2===r.shape.length){const e=bincountReduceImpl(n.bufferSync(r),n.bufferSync(o),a,s);return n.makeTensorInfo(e.shape,o.dtype,e.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}const denseBincountConfig$1={kernelName:DenseBincount,backendName:"cpu",kernelFunc:denseBincount$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function depthToSpace$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{blockSize:o,dataFormat:a}=i;assert$1("NHWC"===a,(()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${a}`)),assert$1(o>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${o}`));const s=r.shape[0],l=r.shape[1],c=r.shape[2],h=r.shape[3],u=l*o,d=c*o,p=h/(o*o),m=n.data.get(r.dataId).values,f=new Float32Array(s*u*d*p);let g=0;for(let e=0;e<s;++e)for(let t=0;t<u;++t){const n=Math.floor(t/o),i=t%o;for(let t=0;t<d;++t){const r=Math.floor(t/o),a=(i*o+t%o)*p;for(let t=0;t<p;++t)f[g++]=m[t+a+h*(r+c*(n+l*e))]}}return n.makeTensorInfo([s,u,d,p],r.dtype,f)}const depthToSpaceConfig$1={kernelName:DepthToSpace,backendName:"cpu",kernelFunc:depthToSpace$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function depthwiseConv2dNative$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o}=t,{strides:a,pad:s,dilations:l,dimRoundingMode:c}=i;assertNotComplex$1([r,o],"depthwiseConv2DNative");const h=computeStrides(r.shape),u=computeStrides(o.shape);let d=l;null==d&&(d=[1,1]),assert$1(eitherStridesOrDilationsAreOne(a,d),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${d}'`));const p=computeConv2DInfo(r.shape,o.shape,a,d,s,c,!0),{filterHeight:m,filterWidth:f,dilationHeight:g,dilationWidth:v,padInfo:y}=p,b=y.left,_=y.top,x=p.outChannels/p.inChannels,w=new TensorBuffer(p.outShape,r.dtype),S=n.data.get(r.dataId).values,C=n.data.get(o.dataId).values,M=w.values;for(let e=0;e<p.batchSize;++e){const t=e*h[0],n=e*w.strides[0];for(let e=0;e<p.outHeight;++e){const i=n+e*w.strides[1],r=e*p.strideHeight-b;for(let e=0;e<m;++e){const n=r+e*g;if(n<0||n>=p.inHeight)continue;const o=e*u[0],a=t+n*h[1];for(let e=0;e<p.outWidth;++e){const t=i+e*w.strides[2],n=e*p.strideWidth-_;for(let e=0;e<f;++e){const i=n+e*v;if(i<0||i>=p.inWidth)continue;const r=a+i*p.inChannels;let s=t,l=o+e*u[1];for(let e=0;e<p.inChannels;++e){const t=S[r+e];for(let e=0;e<x;++e)M[s+e]+=t*C[l+e];s+=x,l+=x}}}}}}return n.makeTensorInfo(w.shape,w.dtype,w.values)}const depthwiseConv2dNativeConfig$1={kernelName:DepthwiseConv2dNative,backendName:"cpu",kernelFunc:depthwiseConv2dNative$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function depthwiseConv2dNativeBackpropFilter$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,dy:o}=t,{strides:a,dilations:s,pad:l,dimRoundingMode:c,filterShape:h}=i;assertNotComplex$1([r,o],"depthwiseConv2dNativeBackpropFilter");const u=computeConv2DInfo(r.shape,h,a,s,l,c,!0),{strideHeight:d,strideWidth:p,filterHeight:m,filterWidth:f}=u,g=new TensorBuffer(u.filterShape,"float32"),v=u.padInfo.left,y=u.padInfo.top,b=u.outChannels/u.inChannels,_=n.data.get(r.dataId).values,x=new TensorBuffer(r.shape,r.dtype,_),w=n.data.get(o.dataId).values,S=new TensorBuffer(o.shape,o.dtype,w);for(let e=0;e<m;++e){const t=Math.max(0,Math.ceil((y-e)/d)),n=Math.min(u.outHeight,(u.inHeight+y-e)/d);for(let i=0;i<f;++i){const r=Math.max(0,Math.ceil((v-i)/p)),o=Math.min(u.outWidth,(u.inWidth+v-i)/p);for(let a=0;a<u.outChannels;++a){const s=Math.trunc(a/b),l=a%b;let c=0;for(let l=0;l<u.batchSize;++l)for(let h=t;h<n;++h){const t=e+h*d-y;for(let e=r;e<o;++e)c+=x.get(l,t,i+e*p-v,s)*S.get(l,h,e,a)}g.set(c,e,i,s,l)}}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}const depthwiseConv2dNativeBackpropFilterConfig$1={kernelName:DepthwiseConv2dNativeBackpropFilter,backendName:"cpu",kernelFunc:depthwiseConv2dNativeBackpropFilter$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function depthwiseConv2dNativeBackpropInput$1(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,filter:o}=t,{strides:a,dilations:s,pad:l,dimRoundingMode:c,inputShape:h}=i;assertNotComplex$1([r,o],"depthwiseConv2DNativeBackpropInput");const u=computeStrides(r.shape),d=computeStrides(o.shape),p=computeConv2DInfo(h,o.shape,a,s,l,c,!0),m=new TensorBuffer(p.inShape,"float32"),f=m.values,[g,v,y]=m.strides,b=n.data.get(r.dataId).values,[_,x,w]=u,S=n.data.get(o.dataId).values,[C,M,E]=d,{batchSize:T,filterHeight:I,filterWidth:A,inChannels:k,inHeight:P,inWidth:R,outChannels:L,outHeight:N,outWidth:D,strideHeight:O,strideWidth:z}=p,F=I-1-p.padInfo.top,$=A-1-p.padInfo.left,B=L/k;for(let e=0;e<T;++e)for(let t=0;t<k;++t)for(let n=0;n<P;++n){const i=n-F,r=Math.max(0,Math.ceil(i/O)),o=Math.min(N,(I+i)/O);for(let a=0;a<R;++a){const s=a-$,l=Math.max(0,Math.ceil(s/z)),c=Math.min(D,(A+s)/z);let h=0;for(let n=r;n<o;++n){const r=n*O-i;for(let i=l;i<c;++i){const o=_*e+x*n+w*i,a=C*(I-1-r)+M*(A-1-(i*z-s))+E*t;for(let e=0;e<B;++e)h+=b[o+(t*B+e)]*S[a+e]}}f[g*e+v*n+y*a+t]=h}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}const depthwiseConv2dNativeBackpropInputConfig$1={kernelName:DepthwiseConv2dNativeBackpropInput,backendName:"cpu",kernelFunc:depthwiseConv2dNativeBackpropInput$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function diag$1(e){const{inputs:t,backend:n}=e,{x:i}=t,r=sizeFromShape(i.shape),o=n.data.get(i.dataId).values,a=buffer([r,r],i.dtype),s=a.values;for(let e=0;e<o.length;e++)s[e*r+e]=o[e];const l=[...i.shape,...i.shape];return n.makeTensorInfo(l,a.dtype,a.values)}const diagConfig$1={kernelName:Diag,backendName:"cpu",kernelFunc:diag$1},dilation2dConfig={kernelName:Dilation2D,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:i,filter:r}=e,{strides:o,pad:a,dilations:s}=n,l=t,c=l.data.get(i.dataId).values,h=i.shape.length,u=l.data.get(r.dataId).values,d=r.shape.length,{batchSize:p,inHeight:m,inWidth:f,inChannels:g,outHeight:v,outWidth:y,padInfo:b,strideHeight:_,strideWidth:x,filterHeight:w,filterWidth:S,dilationHeight:C,dilationWidth:M,outShape:E}=computeDilation2DInfo(i.shape,r.shape,o,a,"NHWC",s),T=sizeFromShape(E),I=E.length,A=getArrayFromDType(i.dtype,T);for(let e=0;e<p;++e)for(let t=0;t<v;++t){const n=t*_-b.top;for(let o=0;o<y;++o){const a=o*x-b.left;for(let s=0;s<g;++s){let l=Number.MIN_SAFE_INTEGER;for(let t=0;t<w;++t){const o=n+t*C;if(o>=0&&o<m)for(let n=0;n<S;++n){const p=a+n*M;if(p>=0&&p<f){const a=locToIndex([e,o,p,s],h,computeStrides(i.shape)),m=locToIndex([t,n,s],d,computeStrides(r.shape)),f=c[a]+u[m];f>l&&(l=f)}}}A[locToIndex([e,t,o,s],I,computeStrides(E))]=l}}}return{dataId:l.write(toTypedArray$1(A,i.dtype),E,i.dtype),shape:E,dtype:i.dtype}}},dilation2dBackpropFilterConfig={kernelName:Dilation2DBackpropFilter,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:i,filter:r,dy:o}=e,{strides:a,pad:s,dilations:l}=n,c=t,h=toNestedArray(i.shape,c.data.get(i.dataId).values),u=toNestedArray(r.shape,c.data.get(r.dataId).values),{batchSize:d,inHeight:p,inWidth:m,inChannels:f,outHeight:g,outWidth:v,padInfo:y,strideHeight:b,strideWidth:_,filterHeight:x,filterWidth:w,dilationHeight:S,dilationWidth:C,outShape:M}=computeDilation2DInfo(i.shape,r.shape,a,s,"NHWC",l);assert$1(o.rank===M.length,(()=>`Error in ${Dilation2DBackpropFilter}, dy must have the same rank as output ${M.length}, but got ${o.rank}`));const E=toNestedArray(M,c.data.get(o.dataId).values),T=makeZerosNestedTypedArray(r.shape,r.dtype);for(let e=0;e<d;++e)for(let t=0;t<g;++t){const n=t*b-y.top;for(let i=0;i<v;++i){const r=i*_-y.left;for(let o=0;o<f;++o){let a=Number.MIN_SAFE_INTEGER,s=0,l=0;for(let t=0;t<x;++t){const i=n+t*S;if(i>=0&&i<p)for(let n=0;n<w;++n){const c=r+n*C;if(c>=0&&c<m){const r=h[e][i][c][o]+u[t][n][o];r>a&&(a=r,s=t,l=n)}}}T[s][l][o]+=E[e][t][i][o]}}}return{dataId:c.write(toTypedArray$1(T,i.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},dilation2dBackpropInputConfig={kernelName:Dilation2DBackpropInput,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:i,filter:r,dy:o}=e,{strides:a,pad:s,dilations:l}=n,c=t,h=toNestedArray(i.shape,c.data.get(i.dataId).values),u=toNestedArray(r.shape,c.data.get(r.dataId).values),{batchSize:d,inHeight:p,inWidth:m,inChannels:f,outHeight:g,outWidth:v,padInfo:y,strideHeight:b,strideWidth:_,filterHeight:x,filterWidth:w,dilationHeight:S,dilationWidth:C,outShape:M}=computeDilation2DInfo(i.shape,r.shape,a,s,"NHWC",l);assert$1(o.rank===M.length,(()=>`Error in ${Dilation2DBackpropInput}, dy must have the same rank as output ${M.length}, but got ${o.rank}`));const E=toNestedArray(M,c.data.get(o.dataId).values),T=makeZerosNestedTypedArray(i.shape,i.dtype);for(let e=0;e<d;++e)for(let t=0;t<g;++t){const n=t*b-y.top;for(let i=0;i<v;++i){const r=i*_-y.left;for(let o=0;o<f;++o){let a=Number.MIN_SAFE_INTEGER,s=n<0?0:n,l=r<0?0:r;for(let t=0;t<x;++t){const i=n+t*S;if(i>=0&&i<p)for(let n=0;n<w;++n){const c=r+n*C;if(c>=0&&c<m){const r=h[e][i][c][o]+u[t][n][o];r>a&&(a=r,s=i,l=c)}}}T[e][s][l][o]+=E[e][t][i][o]}}}return{dataId:c.write(toTypedArray$1(T,i.dtype),i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function sum$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i;let s;assertNotComplex$1(r,"sum"),s="bool"===r.dtype?cast$1({inputs:{x:r},backend:n,attrs:{dtype:"int32"}}):identity$3({inputs:{x:r},backend:n});const l=s.shape.length,c=parseAxisParam(o,s.shape),h=getAxesPermutation(c,l);let u=c,d=s;null!=h&&(d=transpose$1({inputs:{x:s},backend:n,attrs:{perm:h}}),u=getInnerMostAxes(u.length,l)),assertAxesAreInnerMostDims("sum",u,d.shape.length);const[p,m]=computeOutAndReduceShapes(d.shape,u);let f=zeros(n,p,upcastType(d.dtype,"int32"));const g=sizeFromShape(m),v=n.data.get(f.dataId).values,y=n.data.get(d.dataId).values;for(let e=0;e<v.length;++e){const t=e*g;let n=0;for(let e=0;e<g;++e)n+=y[t+e];v[e]=n}if(a){const e=f;f=reshape$1({inputs:{x:f},backend:n,attrs:{shape:expandShapeToKeepDim(f.shape,c)}}),n.disposeIntermediateTensorInfo(e)}return n.disposeIntermediateTensorInfo(s),null!=h&&n.disposeIntermediateTensorInfo(d),f}const sumConfig$1={kernelName:Sum,backendName:"cpu",kernelFunc:sum$1}; /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function einsum$1(e){const{inputs:t,backend:n,attrs:i}=e,{equation:r}=i,o=t,{allDims:a,summedDims:s,idDims:l}=decodeEinsumEquation(r,o.length);checkEinsumDimSizes(a.length,l,o);const{path:c,steps:h}=getEinsumComputePath(s,l),u=h.length;let d=null,p=a.length;const m=[];for(let e=0;e<u;++e){for(const t of h[e]){const{permutationIndices:e,expandDims:i}=getEinsumPermutation(p,l[t]);let r;isIdentityPermutation(e)?r=o[t]:(r=transpose$1({inputs:{x:o[t]},backend:n,attrs:{perm:e}}),m.push(r));const a=r.shape.slice();for(let e=0;e<i.length;++e)a.splice(i[e],0,1);arraysEqual$1(r.shape,a)||(r=reshape$1({inputs:{x:r},backend:n,attrs:{shape:a}}),m.push(r)),null===d?d=r:(d=multiply$1({inputs:{a:r,b:d},backend:n}),m.push(d))}e<u-1&&(c[e]>=0&&(d=sum$1({inputs:{x:d},backend:n,attrs:{axis:c[e]-(a.length-p),keepDims:!1}}),m.push(d)),p--)}for(const e of m)e!==d&&n.disposeIntermediateTensorInfo(e);return d}const einsumConfig$1={kernelName:Einsum,backendName:"cpu",kernelFunc:einsum$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function eluGrad$1(e){const{inputs:t,backend:n}=e,{dy:i,y:r}=t;assertNotComplex$1([i,r],"eluGrad");const o=new Float32Array(sizeFromShape(r.shape)),a=n.data.get(r.dataId).values,s=n.data.get(i.dataId).values;for(let e=0;e<a.length;++e){const t=a[e];o[e]=t>=1?s[e]:s[e]*(t+1)}return n.makeTensorInfo(r.shape,"float32",o)}const eluGradConfig$1={kernelName:EluGrad,backendName:"cpu",kernelFunc:eluGrad$1},equalImpl=createSimpleBinaryKernelImpl(((e,t)=>e===t?1:0)),equal$1=binaryKernelFunc$1(Equal,equalImpl,null,"bool"),equalConfig$1={kernelName:Equal,backendName:"cpu",kernelFunc:equal$1},p=ERF_P,a1=ERF_A1,a2=ERF_A2,a3=ERF_A3,a4=ERF_A4,a5=ERF_A5,erf$1=unaryKernelFunc$1(Erf,(e=>{const t=Math.sign(e),n=Math.abs(e),i=1/(1+p*n);return t*(1-((((a5*i+a4)*i+a3)*i+a2)*i+a1)*i*Math.exp(-n*n))})),erfConfig$1={kernelName:Erf,backendName:"cpu",kernelFunc:erf$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function expandDims$1(e){const{inputs:t,backend:n,attrs:i}=e,{input:r}=t,{dim:o}=i,a=r.shape.length,s=r.shape.slice();let l=o;return o<0&&(assert$1(-(a+1)<=o,(()=>`Axis must be in the interval [${-(a+1)}, ${a}]`)),l=a+o+1),s.splice(l,0,1),reshape$1({inputs:{x:r},backend:n,attrs:{shape:s}})}const expandDimsConfig$1={kernelName:ExpandDims,backendName:"cpu",kernelFunc:expandDims$1},realDivImpl=createSimpleBinaryKernelImpl(((e,t)=>e/t)),div=binaryKernelFunc$1(RealDiv,realDivImpl),realDivConfig$1={kernelName:RealDiv,backendName:"cpu",kernelFunc:div}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function fftBatch(e,t,n){const i=e.shape,r=i[0],o=i[1],a=n.data.get(e.dataId),s=a.complexTensorInfos.real,l=a.complexTensorInfos.imag,c=[r,o],h=sizeFromShape(c),u=getTypedArrayFromDType("float32",h),d=getTypedArrayFromDType("float32",h);for(let e=0;e<r;e++){const i=slice$2({inputs:{x:s},backend:n,attrs:{begin:[e,0],size:[1,o]}}),r=slice$2({inputs:{x:l},backend:n,attrs:{begin:[e,0],size:[1,o]}}),a=complex$1({inputs:{real:i,imag:r},backend:n}),{real:c,imag:h}=fftImpl$1(a,t,n),p=mergeRealAndImagArrays(c,h);for(let t=0;t<o;t++){const n=getComplexWithIndex(p,t);u[e*o+t]=n.real,d[e*o+t]=n.imag}n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a)}const p=n.makeTensorInfo(c,"float32",u),m=n.makeTensorInfo(c,"float32",d),f=complex$1({inputs:{real:p,imag:m},backend:n});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),f}function fftImpl$1(e,t,n){const i=sizeFromShape(e.shape),r=n.data.get(e.dataId),o=n.data.get(r.complexTensorInfos.real.dataId).values,a=n.data.get(r.complexTensorInfos.imag.dataId).values;if(isExponentOf2(i)){const r=fftRadix2(o,a,i,t,n),s=[e.shape[0],e.shape[1]];if(t){const e=n.makeTensorInfo(s,"float32",r.real),t=n.makeTensorInfo(s,"float32",r.imag),o=n.makeTensorInfo([],"float32",createScalarValue(i,"float32")),a=identity$3({inputs:{x:o},backend:n}),l=realDivConfig$1.kernelFunc({inputs:{a:e,b:o},backend:n}),c=realDivConfig$1.kernelFunc({inputs:{a:t,b:a},backend:n}),h=n.data.get(l.dataId).values,u=n.data.get(c.dataId).values;return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),{real:h,imag:u}}return r}return splitRealAndImagArrays(fourierTransformByMatmul(mergeRealAndImagArrays(o,a),i,t))}function isExponentOf2(e){return 0==(e&e-1)}function fftRadix2(e,t,n,i,r){if(1===n)return{real:e,imag:t};const o=mergeRealAndImagArrays(e,t),a=n/2,s=complexWithEvenIndex(o),l=s.real,c=s.imag,h=[l.length],u=r.makeTensorInfo(h,"float32",l),d=r.makeTensorInfo(h,"float32",c),p=complex$1({inputs:{real:u,imag:d},backend:r}),m=complexWithOddIndex(o),f=m.real,g=m.imag,v=[f.length],y=r.makeTensorInfo(v,"float32",f),b=r.makeTensorInfo(v,"float32",g),_=complex$1({inputs:{real:y,imag:b},backend:r}),x=fftRadix2(l,c,a,i,r),w=x.real,S=x.imag,C=[w.length],M=r.makeTensorInfo(C,"float32",w),E=r.makeTensorInfo(C,"float32",S),T=complex$1({inputs:{real:M,imag:E},backend:r}),I=fftRadix2(f,g,a,i,r),A=I.real,k=I.imag,P=[A.length],R=r.makeTensorInfo(P,"float32",A),L=r.makeTensorInfo(P,"float32",k),N=complex$1({inputs:{real:R,imag:L},backend:r}),D=exponents(n,i),O=[D.real.length],z=r.makeTensorInfo(O,"float32",D.real),F=r.makeTensorInfo(O,"float32",D.imag),$=complex$1({inputs:{real:z,imag:F},backend:r}),B=multiply$1({inputs:{a:$,b:N},backend:r}),V=add({inputs:{a:T,b:B},backend:r}),H=sub$2({inputs:{a:T,b:B},backend:r}),U=real$1({inputs:{input:V},backend:r}),G=real$1({inputs:{input:H},backend:r}),j=imag$1({inputs:{input:V},backend:r}),W=imag$1({inputs:{input:H},backend:r}),q=concat$1({inputs:[U,G],backend:r,attrs:{axis:0}}),X=concat$1({inputs:[j,W],backend:r,attrs:{axis:0}}),K=r.data.get(q.dataId).values,Y=r.data.get(X.dataId).values;return r.disposeIntermediateTensorInfo(u),r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(y),r.disposeIntermediateTensorInfo(b),r.disposeIntermediateTensorInfo(_),r.disposeIntermediateTensorInfo(M),r.disposeIntermediateTensorInfo(E),r.disposeIntermediateTensorInfo(T),r.disposeIntermediateTensorInfo(R),r.disposeIntermediateTensorInfo(L),r.disposeIntermediateTensorInfo(N),r.disposeIntermediateTensorInfo(z),r.disposeIntermediateTensorInfo(F),r.disposeIntermediateTensorInfo($),r.disposeIntermediateTensorInfo(B),r.disposeIntermediateTensorInfo(V),r.disposeIntermediateTensorInfo(H),r.disposeIntermediateTensorInfo(U),r.disposeIntermediateTensorInfo(j),r.disposeIntermediateTensorInfo(G),r.disposeIntermediateTensorInfo(W),r.disposeIntermediateTensorInfo(q),r.disposeIntermediateTensorInfo(X),{real:K,imag:Y}}function fourierTransformByMatmul(e,t,n){const i=new Float32Array(2*t);for(let r=0;r<t;r++){let o=0,a=0;for(let i=0;i<t;i++){const s=exponent$1(r*i,t,n),l=getComplexWithIndex(e,i);o+=l.real*s.real-l.imag*s.imag,a+=l.real*s.imag+l.imag*s.real}n&&(o/=t,a/=t),assignToTypedArray(i,o,a,r)}return i} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fft$1(e){const{inputs:t,backend:n}=e,{input:i}=t,r=sizeFromShape(i.shape),o=i.shape[i.shape.length-1],a=reshape$1({inputs:{x:i},backend:n,attrs:{shape:[r/o,o]}}),s=fftBatch(a,!1,n),l=reshape$1({inputs:{x:s},backend:n,attrs:{shape:i.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(s),l}const fftConfig$1={kernelName:FFT,backendName:"cpu",kernelFunc:fft$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fill$1(e){const{backend:t,attrs:n}=e,{shape:i,value:r,dtype:o}=n,a=o||inferDtype(r),s=getArrayFromDType(a,sizeFromShape(i));return fillValues(s,r,a),t.makeTensorInfo(i,a,s)}const fillConfig$1={kernelName:Fill,backendName:"cpu",kernelFunc:fill$1};function fillValues(e,t,n){e.fill(t)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const flipLeftRightConfig$1={kernelName:FlipLeftRight,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,i=t,r=getTypedArrayFromDType(n.dtype,sizeFromShape(n.shape)),[o,a,s,l]=n.shape,c=i.data.get(n.dataId).values;for(let e=0;e<o;e++){const t=e*s*a*l;for(let e=0;e<a;e++){const n=e*(s*l);for(let i=0;i<s;i++){const a=i*l;for(let h=0;h<l;h++){const u=Math.round(s-[o,e,i,h][2]),d=t+n+a+h;let p=c[d];u>=0&&u<s&&(p=c[t+n+u*l+h]),r[d]=p}}}}return{dataId:i.write(r,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},floorDivImpl=createSimpleBinaryKernelImpl(((e,t)=>Math.floor(e/t))),floorDiv$1=binaryKernelFunc$1(FloorDiv,floorDivImpl,null,"int32"),floorDivConfig$1={kernelName:FloorDiv,backendName:"cpu",kernelFunc:floorDiv$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function fusedConv2D(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o,bias:a,preluActivationWeights:s}=t,{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d,activation:p,leakyreluAlpha:m}=i;let f=conv2D({inputs:{x:r,filter:o},backend:n,attrs:{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d}});if(a){const e=f;f=add({inputs:{a:f,b:a},backend:n}),n.disposeIntermediateTensorInfo(e)}if(p){const e=f;f=applyActivation(n,f,p,s,m),n.disposeIntermediateTensorInfo(e)}return f}const fusedConv2DConfig$1={kernelName:FusedConv2D,backendName:"cpu",kernelFunc:fusedConv2D}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fusedDepthwiseConv2D$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o,bias:a,preluActivationWeights:s}=t,{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d,activation:p,leakyreluAlpha:m}=i;let f=depthwiseConv2dNative$1({inputs:{x:r,filter:o},backend:n,attrs:{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d}});if(a){const e=f;f=add({inputs:{a:f,b:a},backend:n}),n.disposeIntermediateTensorInfo(e)}if(p){const e=f;f=applyActivation(n,f,p,s,m),n.disposeIntermediateTensorInfo(e)}return f}const fusedDepthwiseConv2DConfig$1={kernelName:FusedDepthwiseConv2D,backendName:"cpu",kernelFunc:fusedDepthwiseConv2D$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function gatherNd$1(e){const{inputs:t,backend:n}=e,{params:i,indices:r}=t,o=sizeFromShape(i.shape),a=r.shape,s=a[a.length-1],[l,c,h,u]=prepareAndValidate(i,r);if(0===c)return n.makeTensorInfo(l,i.dtype,[]);const d=buffer([c,h],i.dtype),p=n.data.get(r.dataId).values,m=n.data.get(i.dataId).values;for(let e=0;e<c;e++){const t=[];let n=0;for(let i=0;i<s;i++){const r=p[e*s+i];n+=r*u[i],t.push(r)}if(n<0||n>=o/h)throw new Error(`Invalid indices: ${t} does not index into ${i.shape}`);for(let t=0;t<h;t++)d.values[e*h+t]=m[n*h+t]}return n.makeTensorInfo(l,d.dtype,d.values)}const gatherNdConfig$1={kernelName:GatherNd,backendName:"cpu",kernelFunc:gatherNd$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function gatherV2$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,indices:o}=t,{axis:a,batchDims:s}=i;assertNotComplex$1([r,o],"gatherV2");let l=s;null==s&&(l=0);const c=sizeFromShape(o.shape),h=collectGatherOpShapeInfo(r,o,parseAxisParam(a,r.shape)[0],l),u=reshape$1({inputs:{x:r},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),d=reshape$1({inputs:{x:o},backend:n,attrs:{shape:[h.batchSize,c/h.batchSize]}}),p=[h.batchSize,h.outerSize,c/h.batchSize,h.sliceSize],m=n.bufferSync(d),f=gatherV2Impl(n.bufferSync(u),m,p);return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.makeTensorInfo(h.outputShape,f.dtype,f.values)}const gatherV2Config$1={kernelName:GatherV2,backendName:"cpu",kernelFunc:gatherV2$1},greaterEqualImpl=createSimpleBinaryKernelImpl(((e,t)=>e>=t?1:0)),greaterEqual$1=binaryKernelFunc$1(GreaterEqual,greaterEqualImpl,null,"bool"),greaterEqualConfig$1={kernelName:GreaterEqual,backendName:"cpu",kernelFunc:greaterEqual$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function ifft$1(e){const{inputs:t,backend:n}=e,{input:i}=t,r=sizeFromShape(i.shape),o=i.shape[i.shape.length-1],a=reshape$1({inputs:{x:i},backend:n,attrs:{shape:[r/o,o]}}),s=fftBatch(a,!0,n),l=reshape$1({inputs:{x:s},backend:n,attrs:{shape:i.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(s),l}const ifftConfig$1={kernelName:IFFT,backendName:"cpu",kernelFunc:ifft$1},isFinite$2=unaryKernelFunc$1(IsFinite,(e=>Number.isFinite(e)?1:0),"bool"),isFiniteConfig$1={kernelName:IsFinite,backendName:"cpu",kernelFunc:isFinite$2},isInf$1=unaryKernelFunc$1(IsInf,(e=>Math.abs(e)===1/0?1:0),"bool"),isInfConfig$1={kernelName:IsInf,backendName:"cpu",kernelFunc:isInf$1},isNaN$2=unaryKernelFunc$1(IsNan,(e=>Number.isNaN(e)?1:0),"bool"),isNaNConfig$1={kernelName:IsNan,backendName:"cpu",kernelFunc:isNaN$2},lessEqualImpl=createSimpleBinaryKernelImpl(((e,t)=>e<=t?1:0)),lessEqual$1=binaryKernelFunc$1(LessEqual,lessEqualImpl,null,"bool"),lessEqualConfig$1={kernelName:LessEqual,backendName:"cpu",kernelFunc:lessEqual$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function linSpace$1(e){const{backend:t,attrs:n}=e,{start:i,stop:r,num:o}=n,a=linSpaceImpl(i,r,o);return t.makeTensorInfo([a.length],"float32",a)}const linSpaceConfig$1={kernelName:LinSpace,backendName:"cpu",kernelFunc:linSpace$1},log1p$1=unaryKernelFunc$1(Log1p,(e=>Math.log1p(e))),log1pConfig$1={kernelName:Log1p,backendName:"cpu",kernelFunc:log1p$1},logicalAndImpl=createSimpleBinaryKernelImpl(((e,t)=>e&&t)),logicalAnd$1=binaryKernelFunc$1(LogicalAnd,logicalAndImpl,null,"bool"),logicalAndConfig$1={kernelName:LogicalAnd,backendName:"cpu",kernelFunc:logicalAnd$1},logicalNot$1=unaryKernelFunc$1(LogicalNot,(e=>e?0:1),"bool"),logicalNotConfig$1={kernelName:LogicalNot,backendName:"cpu",kernelFunc:logicalNot$1},logicalOrImpl=createSimpleBinaryKernelImpl(((e,t)=>e||t)),logicalOr$1=binaryKernelFunc$1(LogicalOr,logicalOrImpl,null,"bool"),logicalOrConfig$1={kernelName:LogicalOr,backendName:"cpu",kernelFunc:logicalOr$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function lRN(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{depthRadius:o,bias:a,alpha:s,beta:l}=i;assertNotComplex$1(r,"LRN");const c=r.shape[3],h=c-1,u=n.data.get(r.dataId).values,d=sizeFromShape(r.shape),p=new Float32Array(d);function m(e){const t=e%c;let n=e-t+Math.max(0,t-o);const i=e-t+Math.min(t+o,h);let r=0;for(;n<=i;n++){const e=u[n];r+=e*e}return r}for(let e=0;e<d;e++){const t=m(e),n=u[e]*Math.pow(a+s*t,-l);p[e]=n}return n.makeTensorInfo(r.shape,r.dtype,p)}const lRNConfig={kernelName:LRN,backendName:"cpu",kernelFunc:lRN}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function lRNGrad(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,y:o,dy:a}=t,{depthRadius:s,bias:l,alpha:c,beta:h}=i;assertNotComplex$1(a,"LRNGrad");const u=sizeFromShape(a.shape),d=a.shape[3],p=n.data.get(a.dataId).values,m=n.data.get(r.dataId).values,f=n.data.get(o.dataId).values,g=new Float32Array(u),v=u;for(let e=0;e<v;e++){const t=e%d,n=e-t+Math.max(0,t-s),i=e-t+Math.min(d,t+s+1);let r=0;for(let e=n;e<i;e++)r+=Math.pow(m[e],2);r=c*r+l;for(let t=n;t<i;t++){let n=-2*c*h*m[t]*f[e]/r;e===t&&(n+=Math.pow(r,-h)),n*=p[e],g[t]+=n}}return n.makeTensorInfo(a.shape,r.dtype,g)}const lRNGradConfig={kernelName:LRNGrad,backendName:"cpu",kernelFunc:lRNGrad}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function max$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{reductionIndices:o,keepDims:a}=i,s=n;let l=r.shape;const c=l.length,h=parseAxisParam(o,l);let u=h;const d=getAxesPermutation(u,c);let p=s.data.get(r.dataId).values;if(null!=d){const e=new Array(c);for(let t=0;t<e.length;t++)e[t]=l[d[t]];p=transposeImpl$1(p,l,r.dtype,d,e),u=getInnerMostAxes(u.length,c),l=e}assertNotComplex$1(r,"max"),assertAxesAreInnerMostDims("max",u,c);const[m,f]=computeOutAndReduceShapes(l,u),g=maxImpl$1(p,sizeFromShape(f),m,r.dtype),v=s.write(g,m,r.dtype);let y=m;return a&&(y=expandShapeToKeepDim(m,h)),{dataId:v,shape:y,dtype:r.dtype}}const maxConfig$1={kernelName:Max,backendName:"cpu",kernelFunc:max$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPool$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t;assertNotComplex$1(r,"maxPool");const{filterSize:o,strides:a,pad:s,dimRoundingMode:l}=i;assert$1(eitherStridesOrDilationsAreOne(a,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const c=computePool2DInfo(r.shape,o,a,1,s,l);let h;if(1===c.filterWidth&&1===c.filterHeight&&arraysEqual$1(c.inShape,c.outShape))h=identity$3({inputs:{x:r},backend:n});else{const e=n.data.get(r.dataId).values,t=computeStrides(r.shape),i=pool(e,r.shape,r.dtype,t,c,"max");h=n.makeTensorInfo(c.outShape,r.dtype,i.values)}return h}const maxPoolConfig$1={kernelName:MaxPool,backendName:"cpu",kernelFunc:maxPool$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPool3D(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{filterSize:o,strides:a,pad:s,dimRoundingMode:l,dataFormat:c}=i;assertNotComplex$1(r,"maxPool3d");const h=computePool3DInfo(r.shape,o,a,1,s,l,c),u=pool3d(n.data.get(r.dataId).values,r.shape,r.dtype,computeStrides(r.shape),h,"max");return n.makeTensorInfo(u.shape,"float32",u.values)}const maxPool3DConfig$1={kernelName:MaxPool3D,backendName:"cpu",kernelFunc:maxPool3D}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPool3DGrad$1(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,input:o}=t,{filterSize:a,strides:s,pad:l,dimRoundingMode:c}=i;assertNotComplex$1([r,o],"maxPool3DGrad");const h=computePool3DInfo(o.shape,a,s,1,l,c),u=maxPool3dPositions(n.bufferSync(o),h),d=h.strideDepth,p=h.strideHeight,m=h.strideWidth,f=h.dilationDepth,g=h.dilationHeight,v=h.dilationWidth,y=h.effectiveFilterDepth,b=h.effectiveFilterHeight,_=h.effectiveFilterWidth,x=y-1-h.padInfo.front,w=_-1-h.padInfo.left,S=b-1-h.padInfo.top,C=buffer(o.shape,"float32"),M=n.bufferSync(r);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let n=0;n<h.inDepth;++n)for(let i=0;i<h.inHeight;++i)for(let r=0;r<h.inWidth;++r){const o=n-x,a=i-S,s=r-w;let l=0;for(let n=0;n<y;n+=f){const i=(o+n)/d;if(!(i<0||i>=h.outDepth||Math.floor(i)!==i))for(let r=0;r<b;r+=g){const o=(a+r)/p;if(!(o<0||o>=h.outHeight||Math.floor(o)!==o))for(let a=0;a<_;a+=v){const c=(s+a)/m;if(c<0||c>=h.outWidth||Math.floor(c)!==c)continue;const d=y*b*_-1-u.get(e,i,o,c,t)===n*b*_+r*_+a?1:0;0!==d&&(l+=M.get(e,i,o,c,t)*d)}}}C.set(l,e,n,i,r,t)}return n.makeTensorInfo(C.shape,C.dtype,C.values)}const maxPool3DGradConfig={kernelName:MaxPool3DGrad,backendName:"cpu",kernelFunc:maxPool3DGrad$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPoolGrad$1(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,input:o,output:a}=t,s=o;assertNotComplex$1([o,a],"maxPoolGrad");const{filterSize:l,strides:c,pad:h,dimRoundingMode:u}=i,d=computePool2DInfo(s.shape,l,c,1,h,u),p=n.data.get(s.dataId).values,m=buffer(d.outShape,s.dtype,maxPoolPositions(p,s.shape,s.dtype,d).values),f=d.strideHeight,g=d.strideWidth,v=d.dilationHeight,y=d.dilationWidth,b=d.effectiveFilterHeight,_=d.effectiveFilterWidth,x=_-1-d.padInfo.left,w=b-1-d.padInfo.top,S=buffer(s.shape,"float32"),C=n.data.get(r.dataId).values,M=buffer(r.shape,"float32",C);for(let e=0;e<d.batchSize;++e)for(let t=0;t<d.inChannels;++t)for(let n=0;n<d.inHeight;++n)for(let i=0;i<d.inWidth;++i){const r=n-w,o=i-x;let a=0;for(let n=0;n<b;n+=v){const i=(r+n)/f;if(!(i<0||i>=d.outHeight||Math.floor(i)!==i))for(let r=0;r<_;r+=y){const s=(o+r)/g;if(s<0||s>=d.outWidth||Math.floor(s)!==s)continue;const l=b*_-1-m.get(e,i,s,t)===n*_+r?1:0;0!==l&&(a+=M.get(e,i,s,t)*l)}}S.set(a,e,n,i,t)}return n.makeTensorInfo(S.shape,S.dtype,S.values)}const maxPoolGradConfig$1={kernelName:MaxPoolGrad,backendName:"cpu",kernelFunc:maxPoolGrad$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPoolWithArgmaxImpl$1(e,t,n,i,r){const o=pool(e,t,n,computeStrides(t),r,"max"),a=maxPoolPositions(e,t,n,r,!0,i);return[o.values,a.values]} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const maxPoolWithArgmaxConfig$1={kernelName:MaxPoolWithArgmax,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:i}=e,{filterSize:r,strides:o,pad:a,includeBatchInIndex:s}=t,l=n;assertNotComplex$1(i,"MaxPoolWithArgmax");const c=l.data.get(i.dataId).values,h=computePool2DInfo(i.shape,r,o,[1,1],a),[u,d]=maxPoolWithArgmaxImpl$1(c,i.shape,i.dtype,s,h),p=l.write(u,h.outShape,i.dtype),m=l.write(d,h.outShape,i.dtype);return[{dataId:p,shape:h.outShape,dtype:i.dtype},{dataId:m,shape:h.outShape,dtype:"int32"}]}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function mean(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i,s=parseAxisParam(o,r.shape),l=sizeFromShape(computeOutAndReduceShapes(r.shape,s)[1]),c=[],h=n.makeTensorInfo([],"float32",new Float32Array([l]));c.push(h);const u=cast$1({inputs:{x:r},backend:n,attrs:{dtype:"float32"}});c.push(u);const d=div({inputs:{a:u,b:h},backend:n});c.push(d);const p=sum$1({inputs:{x:d},backend:n,attrs:{axis:o,keepDims:a}});return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),p}const meanConfig$1={kernelName:Mean,backendName:"cpu",kernelFunc:mean}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function min$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i;assertNotComplex$1(r,"min");const s=parseAxisParam(o,r.shape);let l=s;const c=getAxesPermutation(l,r.shape.length);let h=r;null!=c&&(h=transpose$1({inputs:{x:r},backend:n,attrs:{perm:c}}),l=getInnerMostAxes(l.length,r.shape.length)),assertAxesAreInnerMostDims("min",l,h.shape.length);const[u,d]=computeOutAndReduceShapes(h.shape,l),p=sizeFromShape(d),m=makeZerosTypedArray(sizeFromShape(u),h.dtype),f=n.data.get(h.dataId).values;for(let e=0;e<m.length;++e){const t=e*p;let n=f[t];for(let e=0;e<p;++e){const i=f[t+e];i<n&&(n=i)}m[e]=n}null!=c&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(u,h.dtype,m);if(a){const e=reshape$1({inputs:{x:g},backend:n,attrs:{shape:expandShapeToKeepDim(u,s)}});return n.disposeIntermediateTensorInfo(g),e}return g}const minConfig$1={kernelName:Min,backendName:"cpu",kernelFunc:min$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function mirrorPad(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{paddings:o,mode:a}=i;assertNotComplex$1(r,"mirrorPad");const s=o.map(((e,t)=>e[0]+r.shape[t]+e[1])),l=o.map((e=>e[0])),c=o.map(((e,t)=>e[0]+r.shape[t])),h="reflect"===a?0:1,u=n.data.get(r.dataId).values,d=r.shape.length,p=computeStrides(r.shape),m=sizeFromShape(s),f=s.length,g=computeStrides(s),v=getTypedArrayFromDType(r.dtype,m);for(let e=0;e<m;e++){let t=indexToLoc(e,f,g);for(let e=0;e<f;e++)t[e]<l[e]?t[e]=2*l[e]-t[e]-h:t[e]>=c[e]&&(t[e]=2*(c[e]-1)-t[e]+h);t=t.map(((e,t)=>e-l[t]));const n=locToIndex(t,d,p);v[e]=u[n]}return{dataId:n.write(v,s,r.dtype),shape:s,dtype:r.dtype}}const mirrorPadConfig$1={kernelName:MirrorPad,backendName:"cpu",kernelFunc:mirrorPad},modImpl=createSimpleBinaryKernelImpl(((e,t)=>{const n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),mod$1=binaryKernelFunc$1(Mod,modImpl),modConfig$1={kernelName:Mod,backendName:"cpu",kernelFunc:mod$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function softmax$1(e){const{inputs:t,backend:n,attrs:i}=e,{logits:r}=t,{dim:o}=i,a=r.shape.length;let s=o;if(-1===s&&(s=a-1),s!==a-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${a} and dim was ${s}`);const l=parseAxisParam([s],r.shape),c=max$1({inputs:{x:r},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),h=expandShapeToKeepDim(c.shape,l),u=reshape$1({inputs:{x:c},backend:n,attrs:{shape:h}}),d=sub$2({inputs:{a:r,b:u},backend:n}),p=exp$1({inputs:{x:d},backend:n}),m=sum$1({inputs:{x:p},backend:n,attrs:{axis:l,keepDims:!1}}),f=reshape$1({inputs:{x:m},backend:n,attrs:{shape:h}}),g=div({inputs:{a:p,b:f},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),g}const softmaxConfig$1={kernelName:Softmax,backendName:"cpu",kernelFunc:softmax$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function multinomial$1(e){const{inputs:t,backend:n,attrs:i}=e,{logits:r}=t,{numSamples:o,seed:a,normalized:s}=i;assertNotComplex$1(r,"multinomial");const l=s?r:softmax$1({inputs:{logits:r},backend:n,attrs:{dim:-1}}),c=l.shape[0],h=l.shape[1],u=n.data.get(l.dataId).values,d=[c,o],p=makeZerosTypedArray(sizeFromShape(d),"int32");for(let e=0;e<c;++e){const t=e*h,n=new Float32Array(h-1);n[0]=u[t];for(let e=1;e<n.length;++e)n[e]=n[e-1]+u[t+e];const i=seedrandom.alea(a.toString()),r=e*o;for(let e=0;e<o;++e){const t=i();p[r+e]=n.length;for(let i=0;i<n.length;i++)if(t<n[i]){p[r+e]=i;break}}}return s||n.disposeIntermediateTensorInfo(l),n.makeTensorInfo(d,"int32",p)}const multinomialConfig$1={kernelName:Multinomial,backendName:"cpu",kernelFunc:multinomial$1},nonMaxSuppressionV3Impl$1=nonMaxSuppressionV3Impl$2; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function nonMaxSuppressionV3$1(e){const{inputs:t,backend:n,attrs:i}=e,{boxes:r,scores:o}=t,{maxOutputSize:a,iouThreshold:s,scoreThreshold:l}=i;assertNotComplex$1(r,"NonMaxSuppression");const c=n.data.get(r.dataId).values,h=n.data.get(o.dataId).values,{selectedIndices:u}=nonMaxSuppressionV3Impl$1(c,h,a,s,l);return n.makeTensorInfo([u.length],"int32",new Int32Array(u))}const nonMaxSuppressionV3Config$1={kernelName:NonMaxSuppressionV3,backendName:"cpu",kernelFunc:nonMaxSuppressionV3$1},nonMaxSuppressionV4Impl$1=nonMaxSuppressionV4Impl$2; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function nonMaxSuppressionV4$1(e){const{inputs:t,backend:n,attrs:i}=e,{boxes:r,scores:o}=t,{maxOutputSize:a,iouThreshold:s,scoreThreshold:l,padToMaxOutputSize:c}=i;assertNotComplex$1(r,"NonMaxSuppressionPadded");const h=n.data.get(r.dataId).values,u=n.data.get(o.dataId).values,{selectedIndices:d,validOutputs:p}=nonMaxSuppressionV4Impl$1(h,u,a,s,l,c);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([p]))]}const nonMaxSuppressionV4Config$1={kernelName:NonMaxSuppressionV4,backendName:"cpu",kernelFunc:nonMaxSuppressionV4$1},nonMaxSuppressionV5Impl$1=nonMaxSuppressionV5Impl$2; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function nonMaxSuppressionV5$1(e){const{inputs:t,backend:n,attrs:i}=e,{boxes:r,scores:o}=t,{maxOutputSize:a,iouThreshold:s,scoreThreshold:l,softNmsSigma:c}=i;assertNotComplex$1(r,"NonMaxSuppressionWithScore");const h=n.data.get(r.dataId).values,u=n.data.get(o.dataId).values,d=a,p=s,m=l,f=c,{selectedIndices:g,selectedScores:v}=nonMaxSuppressionV5Impl$1(h,u,d,p,m,f);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([v.length],"float32",new Float32Array(v))]}const nonMaxSuppressionV5Config$1={kernelName:NonMaxSuppressionV5,backendName:"cpu",kernelFunc:nonMaxSuppressionV5$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function oneHot$1(e){const{inputs:t,backend:n,attrs:i}=e,{indices:r}=t,{depth:o,onValue:a,offValue:s}=i;assertNotComplex$1(r,"oneHot");const l=sizeFromShape(r.shape),c=new Float32Array(l*o);c.fill(s);const h=n.data.get(r.dataId).values;for(let e=0;e<l;++e)h[e]>=0&&h[e]<o&&(c[e*o+h[e]]=a);return n.makeTensorInfo([...r.shape,o],"int32",c)}const oneHotConfig$1={kernelName:OneHot,backendName:"cpu",kernelFunc:oneHot$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function zerosLike$1(e){const{inputs:t,backend:n}=e,{x:i}=t;if("string"===i.dtype)throw new Error("zerosLike is not supported for string tensors");if("complex64"===i.dtype){const e=real$1({inputs:{input:i},backend:n}),t=zerosLike$1({inputs:{x:e},backend:n}),r=imag$1({inputs:{input:i},backend:n}),o=zerosLike$1({inputs:{x:r},backend:n}),a=complex$1({inputs:{real:t,imag:o},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),a}return fill$1({backend:n,attrs:{shape:i.shape,value:0,dtype:i.dtype}})}const zerosLikeConfig$1={kernelName:ZerosLike,backendName:"cpu",kernelFunc:zerosLike$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function onesLike$1(e){const{inputs:t,backend:n}=e,{x:i}=t;if("string"===i.dtype)throw new Error("onesLike is not supported for string tensors");if("complex64"===i.dtype){const e=real$1({inputs:{input:i},backend:n}),t=onesLike$1({inputs:{x:e},backend:n}),r=imag$1({inputs:{input:i},backend:n}),o=zerosLike$1({inputs:{x:r},backend:n}),a=complex$1({inputs:{real:t,imag:o},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),a}return fill$1({backend:n,attrs:{shape:i.shape,value:1,dtype:i.dtype}})}const onesLikeConfig$1={kernelName:OnesLike,backendName:"cpu",kernelFunc:onesLike$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function pack$1(e){const{inputs:t,backend:n,attrs:i}=e,{axis:r}=i;if(1===t.length)return expandDims$1({inputs:{input:t[0]},backend:n,attrs:{dim:r}});const o=t[0].shape,a=t[0].dtype;t.forEach((e=>{assertShapesMatch(o,e.shape,"All tensors passed to stack must have matching shapes"),assert$1(a===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const s=[],l=concat$1({inputs:t.map((e=>{const t=expandDims$1({inputs:{input:e},backend:n,attrs:{dim:r}});return s.push(t),t})),backend:n,attrs:{axis:r}});return s.forEach((e=>n.disposeIntermediateTensorInfo(e))),l}const packConfig$1={kernelName:Pack,backendName:"cpu",kernelFunc:pack$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function padV2$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{paddings:o,constantValue:a}=i;assertNotComplex$1(r,"pad");const s=o.map(((e,t)=>e[0]+r.shape[t]+e[1])),l=o.map((e=>e[0])),c=n.data.get(r.dataId).values,h=sizeFromShape(r.shape),u=r.shape.length,d=computeStrides(r.shape),p=sizeFromShape(s),m=s.length,f=computeStrides(s),g=getTypedArrayFromDType(r.dtype,p);0!==a&&g.fill(a);for(let e=0;e<h;e++)g[locToIndex(indexToLoc(e,u,d).map(((e,t)=>e+l[t])),m,f)]=c[e];return{dataId:n.write(g,s,r.dtype),shape:s,dtype:r.dtype}}const padV2Config$1={kernelName:PadV2,backendName:"cpu",kernelFunc:padV2$1},powImpl=createSimpleBinaryKernelImpl(((e,t)=>Math.pow(e,t))),pow$2=binaryKernelFunc$1(Pow,powImpl),powConfig$1={kernelName:Pow,backendName:"cpu",kernelFunc:pow$2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function range$2(e){const{backend:t,attrs:n}=e,{start:i,stop:r,dtype:o,step:a}=n,s=rangeImpl(i,r,a,o);return t.makeTensorInfo([s.length],o,s)}const rangeConfig$1={kernelName:Range,backendName:"cpu",kernelFunc:range$2},reciprocal$1=unaryKernelFunc$1(Reciprocal,(e=>1/e)),reciprocalConfig$1={kernelName:Reciprocal,backendName:"cpu",kernelFunc:reciprocal$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function resizeBilinear$1(e){const{inputs:t,backend:n,attrs:i}=e,{images:r}=t,{alignCorners:o,halfPixelCenters:a,size:s}=i;assertNotComplex$1(r,"resizeBilinear");const l=computeStrides(r.shape),[c,h]=s,[u,d,p,m]=r.shape,f=n.data.get(r.dataId).values,g=new Float32Array(sizeFromShape([u,c,h,m])),v=[o&&c>1?d-1:d,o&&h>1?p-1:p],y=[o&&c>1?c-1:c,o&&h>1?h-1:h];let b=0;const _=v[0]/y[0],x=v[1]/y[1];for(let e=0;e<u;e++)for(let t=0;t<c;t++){let n;n=a?_*(t+.5)-.5:_*t;const i=Math.max(0,Math.floor(n)),r=n-i,o=Math.min(d-1,Math.ceil(n)),s=e*l[0]+i*l[1],c=e*l[0]+o*l[1];for(let e=0;e<h;e++){let t;t=a?x*(e+.5)-.5:x*e;const n=Math.max(0,Math.floor(t)),i=t-n,o=Math.min(p-1,Math.ceil(t)),h=s+n*l[2],u=c+n*l[2],d=s+o*l[2],v=c+o*l[2];for(let e=0;e<m;e++){const t=f[h+e],n=f[u+e],o=t+(f[d+e]-t)*i;g[b++]=o+(n+(f[v+e]-n)*i-o)*r}}}return n.makeTensorInfo([u,c,h,m],"float32",g)}const resizeBilinearConfig$1={kernelName:ResizeBilinear,backendName:"cpu",kernelFunc:resizeBilinear$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function resizeBilinearGrad$1(e){const{inputs:t,backend:n,attrs:i}=e,{images:r,dy:o}=t,{alignCorners:a}=i;assertNotComplex$1([o,r],"resizeBilinearGrad");const s=computeStrides(r.shape),[l,c,h,u]=r.shape,[,d,p]=o.shape,m=new Float32Array(l*c*h*u),f=[a&&d>1?c-1:c,a&&p>1?h-1:h],g=[a&&d>1?d-1:d,a&&p>1?p-1:p],v=f[0]/g[0],y=f[1]/g[1],b=n.data.get(o.dataId).values;let _=0;for(let e=0;e<l;e++){const t=e*s[0];for(let e=0;e<d;e++){const n=e*v,i=Math.floor(n),r=Math.min(Math.ceil(n),c-1),o=t+i*s[1],a=t+r*s[1],l=n-i,d=1-l;for(let e=0;e<p;e++){const t=e*y,n=Math.floor(t),i=Math.min(Math.ceil(t),h-1),r=t-n,c=1-r,p=o+n*s[2],f=o+i*s[2],g=a+n*s[2],v=a+i*s[2],x=d*c,w=d*r,S=l*c,C=l*r;for(let e=0;e<u;e++){const t=b[_++];m[p+e]+=t*x,m[f+e]+=t*w,m[g+e]+=t*S,m[v+e]+=t*C}}}}return n.makeTensorInfo([l,h,c,u],"float32",m)}const resizeBilinearGradConfig$1={kernelName:ResizeBilinearGrad,backendName:"cpu",kernelFunc:resizeBilinearGrad$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function resizeNearestNeighbor$1(e){const{inputs:t,backend:n,attrs:i}=e,{images:r}=t,{alignCorners:o,halfPixelCenters:a,size:s}=i;assertNotComplex$1(r,"resizeNearestNeighbor");const l=computeStrides(r.shape),[c,h]=s,[u,d,p,m]=r.shape,f=n.data.get(r.dataId).values,g=new Float32Array(u*c*h*m),v=[o&&c>1?d-1:d,o&&h>1?p-1:p],y=[o&&c>1?c-1:c,o&&h>1?h-1:h],b=v[0]/y[0],_=v[1]/y[1];let x=0;for(let e=0;e<u;e++){const t=e*l[0];for(let e=0;e<c;e++){const n=a?b*(e+.5):b*e;let i=Math.min(d-1,o?Math.round(n):Math.floor(n));a&&(i=Math.max(0,i));const r=t+i*l[1];for(let e=0;e<h;e++){const t=a?_*(e+.5):_*e;let n=Math.min(p-1,o?Math.round(t):Math.floor(t));a&&(n=Math.max(0,n));const i=r+n*l[2];for(let e=0;e<m;e++)g[x++]=f[i+e]}}}return n.makeTensorInfo([u,c,h,m],r.dtype,g)}const resizeNearestNeighborConfig$1={kernelName:ResizeNearestNeighbor,backendName:"cpu",kernelFunc:resizeNearestNeighbor$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function resizeNearestNeighborGrad$1(e){const{inputs:t,backend:n,attrs:i}=e,{images:r,dy:o}=t,{alignCorners:a}=i;assertNotComplex$1([o,r],"resizeNearestNeighborGrad");const s=computeStrides(r.shape),l=computeStrides(o.shape),[c,h,u,d]=r.shape,[,p,m]=o.shape,f=new Float32Array(c*h*u*d),g=n.data.get(o.dataId).values,v=[a&&p>1?h-1:h,a&&m>1?u-1:u],y=[a&&p>1?p-1:p,a&&m>1?m-1:m],b=v[0]/y[0],_=v[1]/y[1],x=1/b,w=1/_,S=2*Math.ceil(x)+2,C=2*Math.ceil(w)+2;for(let e=0;e<c;e++){const t=e*s[0];for(let e=0;e<h;e++){const n=t+e*s[1],i=Math.floor(e*x),r=Math.floor(i-S/2);for(let i=0;i<u;i++){const o=n+i*s[2],c=Math.floor(i*w),v=Math.floor(c-C/2);for(let n=0;n<d;n++){let s=0;for(let o=0;o<S;o++){const c=o+r;if(c<0||c>=p)continue;const d=t+c*l[1],f=c*b;if(e===Math.min(h-1,a?Math.round(f):Math.floor(f)))for(let e=0;e<C;e++){const t=e+v;if(t<0||t>=m)continue;const r=d+t*l[2],o=t*_;i===Math.min(u-1,a?Math.round(o):Math.floor(o))&&(s+=g[r+n])}}f[o+n]=s}}}}return n.makeTensorInfo(r.shape,r.dtype,f)}const resizeNearestNeighborGradConfig$1={kernelName:ResizeNearestNeighborGrad,backendName:"cpu",kernelFunc:resizeNearestNeighborGrad$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function reverse$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{dims:o}=i;assertNotComplex$1(r,"reverse");const a=r.shape.length,s=parseAxisParam(o,r.shape);if(0===a)return identity$3({inputs:{x:r},backend:n});const l=new TensorBuffer(r.shape,r.dtype),c=n.bufferSync(r);for(let e=0;e<l.size;e++){const t=l.indexToLoc(e),n=t.slice();s.forEach((e=>n[e]=r.shape[e]-1-n[e])),l.set(c.get(...n),...t)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}const reverseConfig$1={kernelName:Reverse,backendName:"cpu",kernelFunc:reverse$1},rotateWithOffsetConfig$1={kernelName:RotateWithOffset,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:i}=e,{radians:r,fillValue:o,center:a}=t,s=n,l=getTypedArrayFromDType(i.dtype,sizeFromShape(i.shape)),[c,h,u,d]=i.shape,[p,m]=getImageCenter(a,h,u),f=Math.sin(r),g=Math.cos(r),v=s.data.get(i.dataId).values;for(let e=0;e<c;e++){const t=e*u*h*d;for(let e=0;e<h;e++){const n=e*(u*d);for(let i=0;i<u;i++){const r=i*d;for(let a=0;a<d;a++){const s=[c,e,i,a],y=s[2],b=s[1];let _=(y-p)*g-(b-m)*f,x=(y-p)*f+(b-m)*g;_=Math.round(_+p),x=Math.round(x+m);let w=o;"number"!=typeof o&&(w=3===a?255:o[a]),_>=0&&_<u&&x>=0&&x<h&&(w=v[t+x*(u*d)+_*d+a]),l[t+n+r+a]=w}}}}return{dataId:s.write(l,i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}},round$1=unaryKernelFunc$1(Round,(e=>{const t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),roundConfig$1={kernelName:Round,backendName:"cpu",kernelFunc:round$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function scatterImpl(e,t,n,i,r,o,a,s,l,c){const h=[i/r,r],u=e.values,d=t.values;if(0===i)return buffer(n,t.dtype);const p=buffer(h,t.dtype);p.values.fill(l);for(let e=0;e<o;e++){const o=[];let l=0;for(let t=0;t<a;t++){const n=u[e*a+t];o.push(n),l+=n*s[t]}if(l<0||l>=i/r)throw new Error(`Invalid indices: ${o} does not index into ${n}`);for(let n=0;n<r;n++)c?p.values[l*r+n]+=d[e*r+n]:p.values[l*r+n]=0===t.rank?d[0]:d[e*r+n]}return p} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function scatterNd$1(e){const{inputs:t,backend:n,attrs:i}=e,{indices:r,updates:o}=t,{shape:a}=i,{sliceRank:s,numUpdates:l,sliceSize:c,strides:h,outputSize:u}=calculateShapes(o,r,a),d=scatterImpl(n.bufferSync(r),n.bufferSync(o),a,u,c,l,s,h,0,!0);return n.makeTensorInfo(a,d.dtype,d.values)}const scatterNdConfig$1={kernelName:ScatterNd,backendName:"cpu",kernelFunc:scatterNd$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function select$1(e){const{inputs:t,backend:n}=e,{condition:i,t:r,e:o}=t;assertNotComplex$1([i,r,o],"select");const a=i.shape.length,s=n.data.get(i.dataId).values,l=n.data.get(r.dataId).values,c=n.data.get(o.dataId).values,h=upcastType(r.dtype,o.dtype),u=makeZerosTypedArray(sizeFromShape(r.shape),h);let d=0;const p=0===a||a>1||1===r.shape.length?1:sizeFromShape(r.shape.slice(1));for(let e=0;e<s.length;e++)for(let t=0;t<p;t++)u[d++]=1===s[e]?l[e]:c[e];return n.makeTensorInfo(r.shape,h,u)}const selectConfig$1={kernelName:Select,backendName:"cpu",kernelFunc:select$1},scaleAlpha=SELU_SCALEALPHA,scale=SELU_SCALE,selu$1=unaryKernelFunc$1(Selu,(e=>e>=0?scale*e:scaleAlpha*(Math.exp(e)-1))),seluConfig$1={kernelName:Selu,backendName:"cpu",kernelFunc:selu$1},sigmoid$1=unaryKernelFunc$1(Sigmoid,(e=>1/(1+Math.exp(-e)))),sigmoidConfig$1={kernelName:Sigmoid,backendName:"cpu",kernelFunc:sigmoid$1},sign$2=unaryKernelFunc$1(Sign,(e=>e<0?-1:e>0?1:0)),signConfig$1={kernelName:Sign,backendName:"cpu",kernelFunc:sign$2},sin$1=unaryKernelFunc$1(Sin,(e=>Math.sin(e))),sinConfig$1={kernelName:Sin,backendName:"cpu",kernelFunc:sin$1},sinh$1=unaryKernelFunc$1(Sinh,(e=>Math.sinh(e))),sinhConfig$1={kernelName:Sinh,backendName:"cpu",kernelFunc:sinh$1},epsilon=1.1920928955078125e-7,threshold=Math.log(epsilon)+2,softplus$1=unaryKernelFunc$1(Softplus,(e=>{const t=e>-threshold,n=e<threshold,i=Math.exp(e);let r;return r=n?i:t?e:Math.log(1+i),r})),softplusConfig$1={kernelName:Softplus,backendName:"cpu",kernelFunc:softplus$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function spaceToBatchND$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{blockShape:o,paddings:a}=i;assertNotComplex$1([r],"spaceToBatchND");const s=sizeFromShape(o),l=[[0,0]];l.push(...a);for(let e=1+o.length;e<r.shape.length;++e)l.push([0,0]);const c=padV2Config$1.kernelFunc({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),h=getReshaped(c.shape,o,s,!1),u=getPermuted(h.length,o.length,!1),d=getReshapedPermuted(c.shape,o,s,!1),p=reshape$1({inputs:{x:c},backend:n,attrs:{shape:h}}),m=transpose$1({inputs:{x:p},backend:n,attrs:{perm:u}}),f=reshape$1({inputs:{x:m},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),f}const spaceToBatchNDConfig$1={kernelName:SpaceToBatchND,backendName:"cpu",kernelFunc:spaceToBatchND$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function sparseToDense$1(e){const{inputs:t,backend:n,attrs:i}=e,{sparseIndices:r,sparseValues:o,defaultValue:a}=t,{outputShape:s}=i,{sliceRank:l,numUpdates:c,sliceSize:h,strides:u,outputSize:d}=calculateShapes(o,r,s),p=scatterImpl(n.bufferSync(r),n.bufferSync(o),s,d,h,c,l,u,n.data.get(a.dataId).values[0],!1);return n.makeTensorInfo(s,p.dtype,p.values)}const sparseToDenseConfig$1={kernelName:SparseToDense,backendName:"cpu",kernelFunc:sparseToDense$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function splitV$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{numOrSizeSplits:o,axis:a}=i,s=parseAxisParam(a,r.shape)[0],l=prepareSplitSize(r,o,s),c=new Array(r.shape.length).fill(0),h=r.shape.slice();return l.map((e=>{const t=[...h];t[s]=e;const i=slice$2({inputs:{x:r},backend:n,attrs:{begin:c,size:t}});return c[s]+=e,i}))}const splitVConfig$1={kernelName:SplitV,backendName:"cpu",kernelFunc:splitV$1},sqrt$1=unaryKernelFunc$1(Sqrt,(e=>Math.sqrt(e))),sqrtConfig$1={kernelName:Sqrt,backendName:"cpu",kernelFunc:sqrt$1},squareConfig$1={kernelName:Square,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{x:n}=e,i=t;assertNotComplex$1(n,"square");const r=i.data.get(n.dataId).values,o=new Float32Array(r.length);for(let e=0;e<r.length;++e){const t=r[e];o[e]=t*t}return{dataId:i.write(o,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},step$1=unaryKernelFunc$1(Step,((e,t)=>{const n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),stepConfig$1={kernelName:Step,backendName:"cpu",kernelFunc:step$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function stridedSlice$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{begin:o,end:a,strides:s,beginMask:l,endMask:c,ellipsisMask:h,newAxisMask:u,shrinkAxisMask:d}=i;assertNotComplex$1(r,"stridedSlice");const{nonStrided:p,$begin:m,$strides:f,size:g,newShape:v,outShape:y}=sliceInfo(r.shape,o,a,s,l,c,h,u,d),b=reshape$1({inputs:{x:r},backend:n,attrs:{shape:v}});let _;if(p){const e=slice$2({inputs:{x:b},backend:n,attrs:{begin:m,size:g}});_=reshape$1({inputs:{x:e},backend:n,attrs:{shape:y}}),n.disposeIntermediateTensorInfo(e)}else if(y.some((e=>0===e)))_=n.makeTensorInfo(y,r.dtype,[]);else{const e=stridedSliceImpl(y,n.bufferSync(b),f,m);_=n.makeTensorInfo(e.shape,e.dtype,e.values)}const x=reshape$1({inputs:{x:_},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(b),n.disposeIntermediateTensorInfo(_),x}const stridedSliceConfig$1={kernelName:StridedSlice,backendName:"cpu",kernelFunc:stridedSlice$1},tan$1=unaryKernelFunc$1(Tan,(e=>Math.tan(e))),tanConfig$1={kernelName:Tan,backendName:"cpu",kernelFunc:tan$1},tanh$1=unaryKernelFunc$1(Tanh,(e=>Math.tanh(e))),tanhConfig$1={kernelName:Tanh,backendName:"cpu",kernelFunc:tanh$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function tile$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{reps:o}=i;assertNotComplex$1(r,"tile");const a=tileImpl(n.bufferSync(r),o);return n.makeTensorInfo(a.shape,a.dtype,a.values)}const tileConfig$1={kernelName:Tile,backendName:"cpu",kernelFunc:tile$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function topK$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{k:o}=i;assertNotComplex$1(r,"topk");const a=n.data.get(r.dataId).values,[s,l]=topKImpl(a,r.shape,r.dtype,o);return[n.makeTensorInfo(s.shape,s.dtype,s.values),n.makeTensorInfo(l.shape,l.dtype,l.values)]}const topKConfig$1={kernelName:TopK,backendName:"cpu",kernelFunc:topK$1}; /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function transform$1(e){const{inputs:t,attrs:n,backend:i}=e,{image:r,transforms:o}=t,{interpolation:a,fillMode:s,fillValue:l,outputShape:c}=n,[h,u,d,p]=r.shape,[m,f]=null!=c?c:[u,d],g=[h,m,f,p],v=computeStrides(r.shape),y=v[0],b=v[1],_=v[2],x=getTypedArrayFromDType(r.dtype,sizeFromShape(g));x.fill(l);const w=i.data.get(r.dataId).values,S=i.data.get(o.dataId).values;for(let e=0;e<h;++e){const t=1===o.shape[0]?S:S.subarray(8*e,8*e+8);for(let n=0;n<m;++n)for(let i=0;i<f;++i)for(let r=0;r<p;++r){let o;const c=t[6]*i+t[7]*n+1;if(0===c)continue;const h=(t[3]*i+t[4]*n+t[5])/c,p=mapCoord((t[0]*i+t[1]*n+t[2])/c,d,s),m=mapCoord(h,u,s);switch(a){case"nearest":o=nearestInterpolation(w,u,d,y,b,_,e,m,p,r,l);break;case"bilinear":o=bilinearInterpolation(w,u,d,y,b,_,e,m,p,r,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${a}`)}x[e*y+n*b+i*_+r]=o}return i.makeTensorInfo(g,r.dtype,x)}return{dataId:i.write(x,g,r.dtype),shape:r.shape,dtype:r.dtype}}const transformConfig$1={kernelName:Transform,backendName:"cpu",kernelFunc:transform$1};function mapCoord(e,t,n){switch(n){case"reflect":return mapCoordReflect(e,t);case"wrap":return mapCoordWrap(e,t);case"nearest":return mapCoordNearest(e,t);case"constant":default:return mapCoordConstant(e)}}function mapCoordReflect(e,t){let n=e;if(n<0)if(t<=1)n=0;else{const e=2*t;n<e&&(n=e*Math.trunc(-n/e)+n),n=n<-t?n+e:-n-1}else if(n>t-1)if(t<=1)n=0;else{const e=2*t;n-=e*Math.trunc(n/e),n>=t&&(n=e-n-1)}return clamp(0,n,t-1)}function mapCoordWrap(e,t){let n=e;return n<0?t<=1?n=0:n+=t*(Math.trunc(-n/(t-1))+1):n>t-1&&(t<=1?n=0:n-=t*Math.trunc(n/(t-1))),clamp(0,n,t-1)}function mapCoordConstant(e,t){return e}function mapCoordNearest(e,t){return clamp(0,e,t-1)}function readWithFillValue(e,t,n,i,r,o,a,s,l,c,h){return 0<=s&&s<t&&0<=l&&l<n?e[a*i+s*r+l*o+c]:h}function nearestInterpolation(e,t,n,i,r,o,a,s,l,c,h){return readWithFillValue(e,t,n,i,r,o,a,Math.round(s),Math.round(l),c,h)}function bilinearInterpolation(e,t,n,i,r,o,a,s,l,c,h){const u=Math.floor(s),d=Math.floor(l),p=u+1,m=d+1;return(p-s)*((m-l)*readWithFillValue(e,t,n,i,r,o,a,u,d,c,h)+(l-d)*readWithFillValue(e,t,n,i,r,o,a,u,m,c,h))+(s-u)*((m-l)*readWithFillValue(e,t,n,i,r,o,a,p,d,c,h)+(l-d)*readWithFillValue(e,t,n,i,r,o,a,p,m,c,h))} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function unique$1(e){const{inputs:t,attrs:n,backend:i}=e,{axis:r}=n,{x:o}=t;assertNotComplex$1(o,"unique");const a=i.data.get(o.dataId).values,{outputValues:s,outputShape:l,indices:c}=uniqueImpl(a,r,o.shape,o.dtype);return[i.makeTensorInfo(l,o.dtype,s),i.makeTensorInfo([c.length],"int32",c)]}const uniqueConfig$1={kernelName:Unique,backendName:"cpu",kernelFunc:unique$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function unpack$1(e){const{inputs:t,backend:n,attrs:i}=e,{value:r}=t;let{axis:o}=i;o<0&&(o+=r.shape.length);const a=r.shape.length,s=r.shape[o],l=new Array(a-1);let c=0;for(let e=0;e<a;e++)e!==o&&(l[c++]=r.shape[e]);const h=new Array(a).fill(0),u=r.shape.slice();u[o]=1;const d=new Array(s);for(let e=0;e<d.length;e++){h[o]=e;const t=slice$2({inputs:{x:r},backend:n,attrs:{begin:h,size:u}});d[e]=reshape$1({inputs:{x:t},backend:n,attrs:{shape:l}}),n.disposeIntermediateTensorInfo(t)}return d}const unpackConfig$1={kernelName:Unpack,backendName:"cpu",kernelFunc:unpack$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function unsortedSegmentSum$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,segmentIds:o}=t,{numSegments:a}=i;assertNotComplex$1(r,"unsortedSegmentSum");const s=[],l=[],c=r.shape.length-o.shape.length;let h=o;for(let e=0;e<c;++e){const t=expandDims$1({inputs:{input:h},backend:n,attrs:{dim:e+1}});h=t,l.push(t)}for(let e=0;e<a;++e){const t=createScalarValue(e,"int32"),i=n.makeTensorInfo([],"int32",t),o=equal$1({inputs:{a:i,b:h},backend:n}),a=cast$1({inputs:{x:o},backend:n,attrs:{dtype:"float32"}}),c=multiply$1({inputs:{a:a,b:r},backend:n}),u=sum$1({inputs:{x:c},backend:n,attrs:{axis:0,keepDims:!1}});s.push(u),l.push(i),l.push(o),l.push(a),l.push(c),l.push(u)}const u=pack$1({inputs:s,backend:n,attrs:{axis:0}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}const unsortedSegmentSumConfig$1={kernelName:UnsortedSegmentSum,backendName:"cpu",kernelFunc:unsortedSegmentSum$1},kernelConfigs$1=[_fusedMatMulConfig$1,absConfig$1,acosConfig$1,acoshConfig$1,addConfig$1,addNConfig$1,allConfig$1,anyConfig$1,argMaxConfig$1,argMinConfig$1,asinConfig$1,asinhConfig$1,atanConfig$1,atan2Config$1,atanhConfig$1,avgPoolConfig$1,avgPool3DConfig$1,avgPool3DGradConfig,avgPoolGradConfig$1,batchMatMulConfig$1,batchNormConfig$1,batchToSpaceNDConfig$1,bincountConfig$1,castConfig$1,ceilConfig$1,clipConfig,complexConfig$1,complexAbsConfig$1,concatConfig$1,conv2DBackpropFilterConfig$1,conv2DBackpropInputConfig$1,conv2DConfig$1,conv3DBackpropFilterV2Config$1,conv3DBackpropInputV2Config,conv3DConfig$1,cosConfig$1,coshConfig$1,cropAndResizeConfig$1,cumsumConfig$1,denseBincountConfig$1,depthToSpaceConfig$1,depthwiseConv2dNativeConfig$1,depthwiseConv2dNativeBackpropFilterConfig$1,depthwiseConv2dNativeBackpropInputConfig$1,diagConfig$1,dilation2dConfig,dilation2dBackpropInputConfig,dilation2dBackpropFilterConfig,realDivConfig$1,einsumConfig$1,eluConfig$1,eluGradConfig$1,equalConfig$1,erfConfig$1,expConfig$1,expandDimsConfig$1,expm1Config$1,fftConfig$1,fillConfig$1,flipLeftRightConfig$1,floorConfig$1,floorDivConfig$1,fusedConv2DConfig$1,fusedDepthwiseConv2DConfig$1,gatherNdConfig$1,gatherV2Config$1,greaterConfig$1,greaterEqualConfig$1,identityConfig$1,ifftConfig$1,imagConfig$1,isFiniteConfig$1,isInfConfig$1,isNaNConfig$1,leakyReluConfig$1,lessConfig$1,lessEqualConfig$1,linSpaceConfig$1,logConfig$1,log1pConfig$1,logicalAndConfig$1,logicalNotConfig$1,logicalOrConfig$1,lRNConfig,lRNGradConfig,maximumConfig$1,maxPoolConfig$1,maxPool3DConfig$1,maxPool3DGradConfig,maxPoolGradConfig$1,maxPoolWithArgmaxConfig$1,maxConfig$1,meanConfig$1,minConfig$1,minimumConfig$1,mirrorPadConfig$1,modConfig$1,multinomialConfig$1,multiplyConfig$1,negConfig$1,nonMaxSuppressionV3Config$1,nonMaxSuppressionV4Config$1,nonMaxSuppressionV5Config$1,notEqualConfig$1,oneHotConfig$1,onesLikeConfig$1,packConfig$1,padV2Config$1,powConfig$1,preluConfig$1,prodConfig$1,rangeConfig$1,realConfig$1,reciprocalConfig$1,reluConfig$1,relu6Config$1,reshapeConfig$1,resizeBilinearConfig$1,resizeBilinearGradConfig$1,resizeNearestNeighborConfig$1,resizeNearestNeighborGradConfig$1,reverseConfig$1,rotateWithOffsetConfig$1,roundConfig$1,rsqrtConfig$1,scatterNdConfig$1,selectConfig$1,seluConfig$1,sigmoidConfig$1,signConfig$1,sinConfig$1,sinhConfig$1,sliceConfig$1,softmaxConfig$1,softplusConfig$1,spaceToBatchNDConfig$1,sparseToDenseConfig$1,splitVConfig$1,sqrtConfig$1,squareConfig$1,squaredDifferenceConfig$1,stepConfig$1,stridedSliceConfig$1,subConfig$1,sumConfig$1,tanConfig$1,tanhConfig$1,tileConfig$1,topKConfig$1,transposeConfig$1,transformConfig$1,uniqueConfig$1,unpackConfig$1,unsortedSegmentSumConfig$1,zerosLikeConfig$1]; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */for(const e of kernelConfigs$1)registerKernel(e); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const contexts={},WEBGL_ATTRIBUTES={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function setWebGLContext(e,t){contexts[e]=t}function getWebGLContext(e){if(!(e in contexts)){const t=getWebGLRenderingContext(e);if(null===t)return console.log("Could not get context for WebGL version",e),null;contexts[e]=t}const t=contexts[e];return t.isContextLost()?(delete contexts[e],getWebGLContext(e)):(t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),contexts[e])}function createCanvas(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function getWebGLRenderingContext(e){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const t=createCanvas(e);return t.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete contexts[e]}),!1),1===e?t.getContext("webgl",WEBGL_ATTRIBUTES)||t.getContext("experimental-webgl",WEBGL_ATTRIBUTES):t.getContext("webgl2",WEBGL_ATTRIBUTES)} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */var PackingScheme,TextureUsage,PhysicalTextureType;function getUnpackedMatrixTextureShapeWidthHeight(e,t){return[t,e]}function getUnpackedArraySizeFromMatrixSize(e,t){return e*t}function getDenseTexShape(e){const t=sizeFromShape(e);return sizeToSquarishShape(Math.ceil(t/4))}function getPackedMatrixTextureShapeWidthHeight(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function getPackedRGBAArraySizeFromMatrixShape(e,t){const[n,i]=getPackedMatrixTextureShapeWidthHeight(e,t);return n*i*4}function getTextureConfig(e,t){const n=e;let i,r,o,a,s,l,c,h,u,d;return 2===env().getNumber("WEBGL_VERSION")?(i=n.R32F,r=n.R16F,o=n.RGBA16F,a=n.RGBA32F,s=n.RED,c=4,h=1,u=n.HALF_FLOAT,d=n.FLOAT):(i=e.RGBA,r=e.RGBA,o=e.RGBA,a=n.RGBA,s=e.RGBA,c=4,h=4,u=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT),l=e.RGBA,{internalFormatFloat:i,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:o,internalFormatPackedFloat:a,textureFormatFloat:s,downloadTextureFormat:l,downloadUnpackNumChannels:c,defaultNumChannels:h,textureTypeHalfFloat:u,textureTypeFloat:d}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function callAndCheck(e,t){const n=t();return env().getBool("DEBUG")&&checkWebGLError(e),n}function checkWebGLError(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+getWebGLErrorMessage(e,t))}!(function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"})(PackingScheme||(PackingScheme={})),(function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"})(TextureUsage||(TextureUsage={})),(function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})(PhysicalTextureType||(PhysicalTextureType={}));const MIN_FLOAT16=5.96e-8,MAX_FLOAT16=65504;function canBeRepresented(e){return!!(env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||MIN_FLOAT16<Math.abs(e)&&Math.abs(e)<MAX_FLOAT16)}function getWebGLErrorMessage(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}function getExtensionOrThrow(e,t){return throwIfNull(e,(()=>e.getExtension(t)),'Extension "'+t+'" not supported on this browser.')}function createVertexShader$2(e,t){const n=throwIfNull(e,(()=>e.createShader(e.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(callAndCheck(e,(()=>e.shaderSource(n,t))),callAndCheck(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function createFragmentShader$1(e,t){const n=throwIfNull(e,(()=>e.createShader(e.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(callAndCheck(e,(()=>e.shaderSource(n,t))),callAndCheck(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw logShaderSourceAndInfoLog(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}const lineNumberRegex=/ERROR: [0-9]+:([0-9]+):/g;function logShaderSourceAndInfoLog(e,t){const n=lineNumberRegex.exec(t);if(null==n)return console.log(`Couldn't parse line number in error: ${t}`),void console.log(e);const i=+n[1],r=e.split("\n"),o=r.length.toString().length+2,a=r.map(((e,t)=>rightPad((t+1).toString(),o)+e));let s=0;for(let e=0;e<a.length;e++)s=Math.max(a[e].length,s);const l=a.slice(0,i-1),c=a.slice(i-1,i),h=a.slice(i);console.log(l.join("\n")),console.log(t.split("\n")[0]),console.log(`%c ${rightPad(c[0],s)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(h.join("\n"))}function createProgram(e){return throwIfNull(e,(()=>e.createProgram()),"Unable to create WebGLProgram.")}function linkProgram(e,t){if(callAndCheck(e,(()=>e.linkProgram(t))),!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}function validateProgram(e,t){if(callAndCheck(e,(()=>e.validateProgram(t))),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function createStaticVertexBuffer(e,t){const n=throwIfNull(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return callAndCheck(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),callAndCheck(e,(()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW))),n}function createStaticIndexBuffer(e,t){const n=throwIfNull(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return callAndCheck(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n))),callAndCheck(e,(()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW))),n}function createTexture$1(e){return throwIfNull(e,(()=>e.createTexture()),"Unable to create WebGLTexture.")}function validateTextureSize(e,t){const n=env().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error(`Requested texture size [${e}x${t}] is invalid.`);if(e>n||t>n)throw new Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${n}x${n}].`)}function createFramebuffer(e){return throwIfNull(e,(()=>e.createFramebuffer()),"Unable to create WebGLFramebuffer.")}function bindVertexBufferToProgramAttribute(e,t,n,i,r,o,a){const s=e.getAttribLocation(t,n);return-1!==s&&(callAndCheck(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,i))),callAndCheck(e,(()=>e.vertexAttribPointer(s,r,e.FLOAT,!1,o,a))),callAndCheck(e,(()=>e.enableVertexAttribArray(s))),!0)}function bindTextureUnit(e,t,n){validateTextureUnit(e,n),callAndCheck(e,(()=>e.activeTexture(e.TEXTURE0+n))),callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,t)))}function getProgramUniformLocationOrThrow(e,t,n){return throwIfNull(e,(()=>e.getUniformLocation(t,n)),'uniform "'+n+'" not present in program.')}function getProgramUniformLocation(e,t,n){return e.getUniformLocation(t,n)}function bindTextureToProgramUniformSampler(e,t,n,i){callAndCheck(e,(()=>bindTextureUnit(e,t,i))),callAndCheck(e,(()=>e.uniform1i(n,i)))}function bindColorTextureToFramebuffer(e,t,n){callAndCheck(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,n))),callAndCheck(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)))}function unbindColorTextureFromFramebuffer(e,t){callAndCheck(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,t))),callAndCheck(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)))}function validateFramebuffer(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+getFramebufferErrorMessage(e,t))}function getFramebufferErrorMessage(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}function throwIfNull(e,t,n){const i=callAndCheck(e,(()=>t()));if(null==i)throw new Error(n);return i}function validateTextureUnit(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,i=t+e.TEXTURE0;if(i<e.TEXTURE0||i>n)throw new Error(`textureUnit must be in [gl.TEXTURE0, gl.TEXTURE${n}].`)}function getBatchDim(e,t=2){return sizeFromShape(e.slice(0,e.length-t))}function getRowsCols(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function getShapeAs3D(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[getBatchDim(e),...getRowsCols(e)]),t}function getTextureShapeFromLogicalShape(e,t=!1){let n=env().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(n*=2,1===(e=e.map(((t,n)=>n>=e.length-2?nearestLargerEven(e[n]):e[n]))).length&&(e=[2,e[0]])),2!==e.length){const t=squeezeShape(e);e=t.newShape}let i=sizeFromShape(e);if(e.length<=1&&i<=n)return[1,i];if(2===e.length&&e[0]<=n&&e[1]<=n)return e;if(3===e.length&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){const t=getBatchDim(e);let n=2,r=2;return e.length&&([n,r]=getRowsCols(e)),i=t*(n/2)*(r/2),sizeToSquarishShape(i).map((e=>2*e))}return sizeToSquarishShape(i)}function isEven(e){return e%2==0}function isReshapeFree(e,t){if(arraysEqual$1(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){const n=e.slice(-1)[0],i=t.slice(-1)[0];if(n===i)return!0;if(isEven(n)&&isEven(i)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&isEven(e[0])&&isEven(t[0])}let MAX_TEXTURE_SIZE,MAX_TEXTURES_IN_SHADER;function getWebGLMaxTextureSize(e){if(null==MAX_TEXTURE_SIZE){const t=getWebGLContext(e);MAX_TEXTURE_SIZE=t.getParameter(t.MAX_TEXTURE_SIZE)}return MAX_TEXTURE_SIZE}function getMaxTexturesInShader(e){if(null==MAX_TEXTURES_IN_SHADER){const t=getWebGLContext(e);MAX_TEXTURES_IN_SHADER=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,MAX_TEXTURES_IN_SHADER)}function getWebGLDisjointQueryTimerVersion(e){if(0===e)return 0;let t;const n=getWebGLContext(e);return t=hasExtension(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:hasExtension(n,"EXT_disjoint_timer_query")?1:0,t}function hasExtension(e,t){return null!=e.getExtension(t)}function isWebGLVersionEnabled(e){try{if(null!=getWebGLContext(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function isCapableOfRenderingToFloatTexture(e){if(0===e)return!1;const t=getWebGLContext(e);if(1===e){if(!hasExtension(t,"OES_texture_float"))return!1}else if(!hasExtension(t,"EXT_color_buffer_float"))return!1;return createFloatTextureAndBindToFramebuffer(t)}function isDownloadFloatTextureEnabled(e){if(0===e)return!1;const t=getWebGLContext(e);if(1!==e){if(hasExtension(t,"EXT_color_buffer_float"))return createFloatTextureAndBindToFramebuffer(t);const e="EXT_color_buffer_half_float";if(hasExtension(t,e)){const n=t.getExtension(e);return createHalfFloatTextureAndBindToFramebuffer(t,n)}return!1}return!!hasExtension(t,"OES_texture_float")&&!!hasExtension(t,"WEBGL_color_buffer_float")&&createFloatTextureAndBindToFramebuffer(t)}function createFloatTextureAndBindToFramebuffer(e){const t=getTextureConfig(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);const i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const r=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(i),r}function createHalfFloatTextureAndBindToFramebuffer(e,t){const n=getTextureConfig(e,t),i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i),e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0);const o=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(i),e.deleteFramebuffer(r),o}function isWebGLFenceEnabled(e){return 2===e&&null!=getWebGLContext(e).fenceSync}function assertNotComplex(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&assert$1("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the WebGL backend.`))}))} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const ENV=env(); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function getGlslDifferences(){let e,t,n,i,r,o,a,s,l,c;return 2===env().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",i="in",r="texture",o="outputColor",a="out vec4 outputColor;",s="\n bool isnan_custom(float val) {\n return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ",l="",c="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(e="",t="attribute",n="varying",i="varying",r="texture2D",o="gl_FragColor",a="",s="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",l="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",c="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:e,attribute:t,varyingVs:n,varyingFs:i,texture2D:r,output:o,defineOutput:a,defineSpecialNaN:s,defineSpecialInf:l,defineRound:c}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getLogicalCoordinatesFromFlatIndex(e,t,n="index"){const i=computeStrides(t);return i.map(((t,r)=>`int ${e[r]} = ${n} / ${t}; ${r===i.length-1?`int ${e[r+1]} = ${n} - ${e[r]} * ${t}`:`index -= ${e[r]} * ${t}`};`)).join("")}function getFlatIndexFrom3D(e){const t=computeStrides(e).map((e=>e.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n`}ENV.registerFlag("HAS_WEBGL",(()=>ENV.getNumber("WEBGL_VERSION")>0)),ENV.registerFlag("WEBGL_VERSION",(()=>isWebGLVersionEnabled(2)?2:isWebGLVersionEnabled(1)?1:0)),ENV.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),ENV.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===ENV.get("WEBGL_VERSION"))),ENV.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),ENV.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),ENV.registerFlag("WEBGL_PACK",(()=>ENV.getBool("HAS_WEBGL"))),ENV.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_CLIP",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>!0)),ENV.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_REDUCE",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_LAZILY_UNPACK",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_CONV_IM2COL",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>getWebGLMaxTextureSize(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>getMaxTexturesInShader(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const e=ENV.getNumber("WEBGL_VERSION");return 0===e?0:getWebGLDisjointQueryTimerVersion(e)})),ENV.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>ENV.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!isMobile())),ENV.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>isCapableOfRenderingToFloatTexture(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!ENV.getBool("WEBGL_FORCE_F16_TEXTURES")&&ENV.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),ENV.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>isDownloadFloatTextureEnabled(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>isWebGLFenceEnabled(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>ENV.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),ENV.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)})),ENV.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>isMobile()&&ENV.getBool("IS_CHROME")?1:-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)}));const ENCODE_FLOAT_SNIPPET="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n"; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class DecodeMatrixProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=PackingScheme.DENSE;const t=getDenseTexShape(e),n=getGlslDifferences();this.outputShape=e,this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${getLogicalCoordinatesFromFlatIndex(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = 4 * (resTexRC.x * ${t[1]} + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${n.output} = result;\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class DecodeMatrixPackedProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=PackingScheme.DENSE;const t=getDenseTexShape(e),n=getGlslDifferences();this.outputShape=e,this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${getLogicalCoordinatesFromFlatIndex(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = 4 * (resTexRC.x * ${t[1]} + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${n.output} = result;\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class EncodeFloatProgram{constructor(e){this.variableNames=["A"],this.outTexUsage=TextureUsage.DOWNLOAD;const t=getGlslDifferences();this.outputShape=e,this.userCode=`\n ${ENCODE_FLOAT_SNIPPET}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class EncodeFloatPackedProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=TextureUsage.DOWNLOAD;const t=getGlslDifferences();this.outputShape=e,this.userCode=`\n ${ENCODE_FLOAT_SNIPPET}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${t.output} = encode_float(x);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class EncodeMatrixProgram{constructor(e,t,n=!1){this.variableNames=["A"];const i=getGlslDifferences(),[r,o]=t;this.outputShape=e;let a="result";n&&(a="floor(result * 255. + 0.5)"),this.userCode=`\n ${getFlatIndexFrom3D(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n int flatIndex = getFlatIndex(coords);\n int offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / ${o};\n int c = imod(flatIndex, ${o});\n vec2 uv = (vec2(c, r) + halfCR) / vec2(${o}.0, ${r}.0);\n vec4 values = ${i.texture2D}(A, uv);\n\n float result;\n\n if(offset == 0) {\n result = values[0];\n } else if(offset == 1) {\n result = values[1];\n } else if(offset == 2) {\n result = values[2];\n } else {\n result = values[3];\n }\n\n ${i.output} = vec4(${a}, 0., 0., 0.);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class EncodeMatrixPackedProgram{constructor(e,t,n=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const i=getGlslDifferences(),[r,o]=t;this.outputShape=e;let a="",s="result";n&&(s="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){const s=2*t+n;a+=`\n localCoords = coords;\n if(localCoords[2] + ${n} < ${e[2]}) {\n localCoords[2] += ${n};\n if(localCoords[1] + ${t} < ${e[1]}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n r = flatIndex / ${o};\n c = imod(flatIndex, ${o});\n uv = (vec2(c, r) + halfCR) / vec2(${o}.0, ${r}.0);\n values = ${i.texture2D}(A, uv);\n\n if(offset == 0) {\n result[${s}] = values[0];\n } else if(offset == 1) {\n result[${s}] = values[1];\n } else if(offset == 2) {\n result[${s}] = values[2];\n } else {\n result[${s}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${getFlatIndexFrom3D(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${a}\n\n ${i.output} = ${s};\n }\n `}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function createVertexShader$1(e){const t=getGlslDifferences();return createVertexShader$2(e,`${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}function createVertexBuffer(e){return createStaticVertexBuffer(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function createIndexBuffer(e){return createStaticIndexBuffer(e,new Uint16Array([0,1,2,2,1,3]))}function createAndConfigureTexture(e,t,n,i,r,o){validateTextureSize(t,n);const a=createTexture$1(e),s=e.TEXTURE_2D;return callAndCheck(e,(()=>e.bindTexture(s,a))),callAndCheck(e,(()=>e.texParameteri(s,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE))),callAndCheck(e,(()=>e.texParameteri(s,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))),callAndCheck(e,(()=>e.texParameteri(s,e.TEXTURE_MIN_FILTER,e.NEAREST))),callAndCheck(e,(()=>e.texParameteri(s,e.TEXTURE_MAG_FILTER,e.NEAREST))),callAndCheck(e,(()=>e.texImage2D(s,0,i,t,n,0,r,o,null))),callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,null))),a}function getInternalFormatForFloat32MatrixTexture(e){return e.internalFormatFloat}function createFloat32MatrixTexture(e,t,n,i){const[r,o]=getUnpackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,r,o,getInternalFormatForFloat32MatrixTexture(i),i.textureFormatFloat,e.FLOAT)}function getInternalFormatForFloat16MatrixTexture(e){return e.internalFormatHalfFloat}function createFloat16MatrixTexture(e,t,n,i){const[r,o]=getUnpackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,r,o,getInternalFormatForFloat16MatrixTexture(i),i.textureFormatFloat,i.textureTypeHalfFloat)}function getInternalFormatForUnsignedBytesMatrixTexture(e){return e.downloadTextureFormat}function createUnsignedBytesMatrixTexture(e,t,n,i){const[r,o]=getUnpackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,r,o,getInternalFormatForUnsignedBytesMatrixTexture(i),e.RGBA,e.UNSIGNED_BYTE)}function getInternalFormatForPackedMatrixTexture(e){return e.internalFormatPackedFloat}function createPackedMatrixTexture(e,t,n,i){const[r,o]=getPackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,r,o,getInternalFormatForPackedMatrixTexture(i),e.RGBA,e.FLOAT)}function getInternalFormatForFloat16PackedMatrixTexture(e){return e.internalFormatPackedHalfFloat}function createFloat16PackedMatrixTexture(e,t,n,i){const[r,o]=getPackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,r,o,getInternalFormatForFloat16PackedMatrixTexture(i),e.RGBA,i.textureTypeHalfFloat)}function bindVertexProgramAttributeStreams(e,t,n){return callAndCheck(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),bindVertexBufferToProgramAttribute(e,t,"clipSpacePos",n,3,20,0)&&bindVertexBufferToProgramAttribute(e,t,"uv",n,2,20,12)}function uploadDenseMatrixToTexture(e,t,n,i,r,o){let a,s,l;callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),r instanceof Uint8Array?(a=new Uint8Array(n*i*4),s=e.UNSIGNED_BYTE,l=e.RGBA):(a=new Float32Array(n*i*4),s=e.FLOAT,l=o.internalFormatPackedFloat),a.set(r),callAndCheck(e,(()=>e.texImage2D(e.TEXTURE_2D,0,l,n,i,0,e.RGBA,s,a))),callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}function uploadPixelDataToTexture(e,t,n){callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),n.data instanceof Uint8Array?callAndCheck(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data))):callAndCheck(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n))),callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}function createBufferFromOutputTexture(e,t,n,i){const r=e.createBuffer();callAndCheck(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,r)));const o=16*t*n;return callAndCheck(e,(()=>e.bufferData(e.PIXEL_PACK_BUFFER,o,e.STREAM_READ))),callAndCheck(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0))),callAndCheck(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null))),r}function downloadFloat32MatrixFromBuffer(e,t,n){const i=e,r=new Float32Array(n);return i.bindBuffer(i.PIXEL_PACK_BUFFER,t),i.getBufferSubData(i.PIXEL_PACK_BUFFER,0,r),i.bindBuffer(i.PIXEL_PACK_BUFFER,null),r}function downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n,i){const[r,o]=getUnpackedMatrixTextureShapeWidthHeight(t,n),a=new Uint8Array(getUnpackedArraySizeFromMatrixSize(t*n,4));return callAndCheck(e,(()=>e.readPixels(0,0,r,o,i.downloadTextureFormat,e.UNSIGNED_BYTE,a))),new Float32Array(a.buffer)}function downloadPackedMatrixFromBuffer(e,t,n,i,r,o,a,s){const l=e,c=new Float32Array(getPackedRGBAArraySizeFromMatrixShape(o,a));return l.bindBuffer(l.PIXEL_PACK_BUFFER,t),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,c),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),c}function downloadMatrixFromPackedOutputTexture(e,t,n){const i=new Float32Array(t*n*4);return callAndCheck(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,i))),i} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class GPGPUContext{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const t=env().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,setWebGLContext(t,e)):this.gl=getWebGLContext(t);let n="WEBGL_color_buffer_float";const i="EXT_color_buffer_half_float";if(1===env().getNumber("WEBGL_VERSION")){const e="OES_texture_half_float";if(this.textureFloatExtension=getExtensionOrThrow(this.gl,"OES_texture_float"),hasExtension(this.gl,e))this.textureHalfFloatExtension=getExtensionOrThrow(this.gl,e);else if(env().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),hasExtension(this.gl,i))this.colorBufferHalfFloatExtension=getExtensionOrThrow(this.gl,i);else if(env().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",hasExtension(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!hasExtension(this.gl,i))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(i)}this.vertexBuffer=createVertexBuffer(this.gl),this.indexBuffer=createIndexBuffer(this.gl),this.framebuffer=createFramebuffer(this.gl),this.textureConfig=getTextureConfig(this.gl,this.textureHalfFloatExtension)}get debug(){return env().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const e=this.gl;callAndCheck(e,(()=>e.finish())),callAndCheck(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,null))),callAndCheck(e,(()=>e.deleteFramebuffer(this.framebuffer))),callAndCheck(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,null))),callAndCheck(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null))),callAndCheck(e,(()=>e.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),createFloat32MatrixTexture(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),createFloat16MatrixTexture(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),createUnsignedBytesMatrixTexture(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),uploadPixelDataToTexture(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,i){this.throwIfDisposed(),uploadDenseMatrixToTexture(this.gl,e,t,n,i,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),createFloat16PackedMatrixTexture(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),createPackedMatrixTexture(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(unbindColorTextureFromFramebuffer(this.gl,this.framebuffer),this.outputTexture=null),callAndCheck(this.gl,(()=>this.gl.deleteTexture(e)))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>downloadByteEncodedFloatMatrixFromOutputTexture(this.gl,t,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(e,t,n,i,r,o){return downloadPackedMatrixFromBuffer(this.gl,e,t,n,i,r,o,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return downloadFloat32MatrixFromBuffer(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const i=createBufferFromOutputTexture(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),i}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(env().getBool("WEBGL_FENCE_API_ENABLED")){const i=e,r=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=i.clientWaitSync(r,0,0);return e===i.ALREADY_SIGNALED||e===i.CONDITION_SATISFIED},t=r}else env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>downloadMatrixFromPackedOutputTexture(this.gl,t,n)))}createProgram(e){this.throwIfDisposed();const t=this.gl,n=createFragmentShader$1(t,e),i=createVertexShader$1(t),r=createProgram(t);return callAndCheck(t,(()=>t.attachShader(r,i))),callAndCheck(t,(()=>t.attachShader(r,n))),linkProgram(t,r),this.debug&&validateProgram(t,r),this.vertexAttrsAreBound||(this.setProgram(r),this.vertexAttrsAreBound=bindVertexProgramAttributeStreams(t,this.program,this.vertexBuffer)),r}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&callAndCheck(this.gl,(()=>this.gl.deleteProgram(e)))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&validateProgram(this.gl,this.program),callAndCheck(this.gl,(()=>this.gl.useProgram(e)))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?getProgramUniformLocationOrThrow(this.gl,e,t):getProgramUniformLocation(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),callAndCheck(this.gl,(()=>this.gl.getAttribLocation(e,t)))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),bindTextureToProgramUniformSampler(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[i,r]=getPackedMatrixTextureShapeWidthHeight(t,n);this.setOutputMatrixTextureDriver(e,i,r)}setOutputMatrixWriteRegion(e,t,n,i){this.setOutputMatrixWriteRegionDriver(n,e,i,t)}setOutputPackedMatrixWriteRegion(e,t,n,i){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&validateProgram(this.gl,this.program),validateFramebuffer(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;this.debug&&this.debugValidate(),callAndCheck(e,(()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),callAndCheck(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=getExtensionOrThrow(this.gl,2===env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await repeatedTry((()=>this.disposed||this.isQueryAvailable(e,env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(e,env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),i=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),i&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=linearSearchLastTrue(this.itemsToPoll.map((e=>e.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||repeatedTry((()=>(this.pollItems(),0===this.itemsToPoll.length)))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),bindColorTextureToFramebuffer(this.gl,e,this.framebuffer),this.debug&&validateFramebuffer(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(bindColorTextureToFramebuffer(this.gl,this.outputTexture,this.framebuffer),this.debug&&validateFramebuffer(this.gl)):unbindColorTextureFromFramebuffer(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const i=this.gl;bindColorTextureToFramebuffer(i,e,this.framebuffer),this.debug&&validateFramebuffer(i),this.outputTexture=e,callAndCheck(i,(()=>i.viewport(0,0,t,n))),callAndCheck(i,(()=>i.scissor(0,0,t,n)))}setOutputMatrixWriteRegionDriver(e,t,n,i){this.throwIfDisposed(),callAndCheck(this.gl,(()=>this.gl.scissor(e,t,n,i)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}function linearSearchLastTrue(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const{getBroadcastDims:getBroadcastDims}=backend_util;function makeShader(e,t,n,i){const r=[];e.forEach((e=>{const t=sizeFromShape(e.shapeInfo.logicalShape);e.shapeInfo.isUniform?r.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(r.push(`uniform sampler2D ${e.name};`),r.push(`uniform int offset${e.name};`))}));const o=r.join("\n"),a=e.map((e=>getInputSamplingSnippet(e,t,i))).join("\n"),s=t.texShape,l=getGlslDifferences(),c=getFloatTextureSampleSnippet(l);let h,u,d=getShaderPrefix(l);return t.isPacked?(h=getPackedOutputSamplingSnippet(t.logicalShape,s),u=getFloatTextureSetRGBASnippet(l)):(h=getOutputSamplingSnippet(t.logicalShape,s),u=getFloatTextureSetRSnippet(l)),i&&(d+=SHADER_PACKED_PREFIX),[d,c,u,o,h,a,n].join("\n")}function getSamplerFromInInfo(e){const t=e.shapeInfo.logicalShape;switch(t.length){case 0:return getSamplerScalar(e);case 1:return getSampler1D(e);case 2:return getSampler2D(e);case 3:return getSampler3D(e);case 4:return getSampler4D(e);case 5:return getSampler5D(e);case 6:return getSampler6D(e);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function getPackedSamplerFromInInfo(e){switch(e.shapeInfo.logicalShape.length){case 0:return getPackedSamplerScalar(e);case 1:return getPackedSampler1D(e);case 2:return getPackedSampler2D(e);case 3:return getPackedSampler3D(e);default:return getPackedSamplerND(e)}}function getInputSamplingSnippet(e,t,n=!1){let i="";return i+=n?getPackedSamplerFromInInfo(e):getSamplerFromInInfo(e),e.shapeInfo.logicalShape.length<=t.logicalShape.length&&(i+=n?getPackedSamplerAtOutputCoords(e,t):getSamplerAtOutputCoords(e,t)),i}function getPackedOutputSamplingSnippet(e,t){switch(e.length){case 0:return getOutputScalarCoords();case 1:return getOutputPacked1DCoords(e,t);case 2:return getOutputPacked2DCoords(e,t);case 3:return getOutputPacked3DCoords(e,t);default:return getOutputPackedNDCoords(e,t)}}function getOutputSamplingSnippet(e,t){switch(e.length){case 0:return getOutputScalarCoords();case 1:return getOutput1DCoords(e,t);case 2:return getOutput2DCoords(e,t);case 3:return getOutput3DCoords(e,t);case 4:return getOutput4DCoords(e,t);case 5:return getOutput5DCoords(e,t);case 6:return getOutput6DCoords(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}function getFloatTextureSampleSnippet(e){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n `}function getFloatTextureSetRSnippet(e){return`\n void setOutput(float val) {\n ${e.output} = vec4(val, 0, 0, 0);\n }\n `}function getFloatTextureSetRGBASnippet(e){return`\n void setOutput(vec4 val) {\n ${e.output} = val;\n }\n `}function getShaderPrefix(e){return`${e.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${e.varyingFs} vec2 resultUV;\n ${e.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${e.defineSpecialNaN}\n ${e.defineSpecialInf}\n ${e.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${SAMPLE_1D_SNIPPET}\n ${SAMPLE_2D_SNIPPET}\n ${SAMPLE_3D_SNIPPET}\n `}const SAMPLE_1D_SNIPPET="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",SAMPLE_2D_SNIPPET="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",SAMPLE_3D_SNIPPET="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",SHADER_PACKED_PREFIX="\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";function getOutputScalarCoords(){return"\n int getOutputCoords() {\n return 0;\n }\n "}function getOutputPacked1DCoords(e,t){const n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===n[0]?`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${n[1]}.0);\n }\n `:1===n[1]?`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${n[0]}.0);\n }\n `:`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${n[0]}, ${n[1]}));\n return 2 * (resTexRC.x * ${n[1]} + resTexRC.y);\n }\n `}function getOutput1DCoords(e,t){return 1===t[0]?`\n int getOutputCoords() {\n return int(resultUV.x * ${t[1]}.0);\n }\n `:1===t[1]?`\n int getOutputCoords() {\n return int(resultUV.y * ${t[0]}.0);\n }\n `:`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n return resTexRC.x * ${t[1]} + resTexRC.y;\n }\n `}function getOutputPacked3DCoords(e,t){const n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],i=Math.ceil(e[2]/2),r=i*Math.ceil(e[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${n[0]}, ${n[1]}));\n int index = resTexRC.x * ${n[1]} + resTexRC.y;\n\n int b = index / ${r};\n index -= b * ${r};\n\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec3(b, r, c);\n }\n `}function getOutput3DCoords(e,t){const n=getLogicalCoordinatesFromFlatIndex(["r","c","d"],e);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${n}\n return ivec3(r, c, d);\n }\n `}function getOutputPackedNDCoords(e,t){const n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],i=Math.ceil(e[e.length-1]/2),r=i*Math.ceil(e[e.length-2]/2);let o=r,a="",s="b, r, c";for(let t=2;t<e.length-1;t++)o*=e[e.length-t-1],a=`\n int b${t} = index / ${o};\n index -= b${t} * ${o};\n `+a,s=`b${t}, `+s;return`\n ivec${e.length} getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${n[0]}, ${n[1]}));\n int index = resTexRC.x * ${n[1]} + resTexRC.y;\n\n ${a}\n\n int b = index / ${r};\n index -= b * ${r};\n\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec${e.length}(${s});\n }\n `}function getOutput4DCoords(e,t){const n=getLogicalCoordinatesFromFlatIndex(["r","c","d","d2"],e);return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${n}\n return ivec4(r, c, d, d2);\n }\n `}function getOutput5DCoords(e,t){const n=getLogicalCoordinatesFromFlatIndex(["r","c","d","d2","d3"],e);return`\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},\n ${t[1]}));\n\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n `}function getOutput6DCoords(e,t){const n=getLogicalCoordinatesFromFlatIndex(["r","c","d","d2","d3","d4"],e);return`\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n `}function getOutputPacked2DCoords(e,t){const n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(arraysEqual$1(e,t))return`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${n[0]}, ${n[1]}));\n }\n `;const i=Math.ceil(e[1]/2);return`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${n[0]}, ${n[1]}));\n\n int index = resTexRC.x * ${n[1]} + resTexRC.y;\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec2(r, c);\n }\n `}function getOutput2DCoords(e,t){return arraysEqual$1(e,t)?`\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));\n }\n `:1===e[1]?`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(index, 0);\n }\n `:1===e[0]?`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(0, index);\n }\n `:`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n int r = index / ${e[1]};\n int c = index - r * ${e[1]};\n return ivec2(r, c);\n }\n `}function getFlatOffsetUniformName(e){return`offset${e}`}function getPackedSamplerScalar(e){const t=e.name;return`\n vec4 ${"get"+t.charAt(0).toUpperCase()+t.slice(1)}() {\n return ${getGlslDifferences().texture2D}(${t}, halfCR);\n }\n `}function getSamplerScalar(e){const t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return`float ${n}() {return ${t};}`;const[i,r]=e.shapeInfo.texShape;if(1===i&&1===r)return`\n float ${n}() {\n return sampleTexture(${t}, halfCR);\n }\n `;const[o,a]=e.shapeInfo.texShape;return`\n float ${n}() {\n vec2 uv = uvFromFlat(${o}, ${a}, ${getFlatOffsetUniformName(t)});\n return sampleTexture(${t}, uv);\n }\n `}function getPackedSampler1D(e){const t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),i=e.shapeInfo.texShape,r=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],o=getGlslDifferences();return`\n vec4 ${n}(int index) {\n vec2 uv = packedUVfrom1D(\n ${r[0]}, ${r[1]}, index);\n return ${o.texture2D}(${t}, uv);\n }\n `}function getSampler1D(e){const t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return`\n float ${n}(int index) {\n ${getUniformSampler(e)}\n }\n `;const i=e.shapeInfo.texShape,r=i[0],o=i[1];if(1===o&&1===r)return`\n float ${n}(int index) {\n return sampleTexture(${t}, halfCR);\n }\n `;const a=getFlatOffsetUniformName(t);return 1===o?`\n float ${n}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${a}) + 0.5) / ${r}.0);\n return sampleTexture(${t}, uv);\n }\n `:1===r?`\n float ${n}(int index) {\n vec2 uv = vec2((float(index + ${a}) + 0.5) / ${o}.0, 0.5);\n return sampleTexture(${t}, uv);\n }\n `:`\n float ${n}(int index) {\n vec2 uv = uvFromFlat(${r}, ${o}, index + ${a});\n return sampleTexture(${t}, uv);\n }\n `}function getPackedSampler2D(e){const t=e.shapeInfo.logicalShape,n=e.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),r=e.shapeInfo.texShape,o=r[0],a=r[1],s=getGlslDifferences();if(null!=r&&arraysEqual$1(t,r))return`\n vec4 ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${a}.0, ${o}.0);\n\n return ${s.texture2D}(${n}, uv);\n }\n `;const l=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];return`\n vec4 ${i}(int row, int col) {\n vec2 uv = packedUVfrom2D(${Math.ceil(t[1]/2)}, ${l[0]}, ${l[1]}, row, col);\n return ${s.texture2D}(${n}, uv);\n }\n `}function getSampler2D(e){const t=e.shapeInfo.logicalShape,n=e.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),r=e.shapeInfo.texShape;if(null!=r&&arraysEqual$1(t,r))return`\n float ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r[1]}.0, ${r[0]}.0);\n return sampleTexture(${n}, uv);\n }\n `;const{newShape:o,keptDims:a}=squeezeShape(t);if(o.length<t.length){const t=["row","col"];return`\n ${getSamplerFromInInfo(squeezeInputInfo(e,o))}\n float ${i}(int row, int col) {\n return ${i}(${getSqueezedParams(t,a)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${i}(int row, int col) {\n int index = round(dot(vec2(row, col), vec2(${t[1]}, 1)));\n ${getUniformSampler(e)}\n }\n `;const s=r[0],l=r[1],c=getFlatOffsetUniformName(n);return 1===l?`\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${c}), vec3(${t[1]}, 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / ${s}.0);\n return sampleTexture(${n}, uv);\n }\n `:1===s?`\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${c}), vec3(${t[1]}, 1, 1));\n vec2 uv = vec2((index + 0.5) / ${l}.0, 0.5);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${i}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${t[1]} + col + ${c};\n vec2 uv = uvFromFlat(${s}, ${l}, index);\n return sampleTexture(${n}, uv);\n }\n`}function getPackedSampler3D(e){const t=e.shapeInfo.logicalShape,n=e.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),r=e.shapeInfo.texShape,o=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];if(1===t[0]){const n=[1,2],r=["b","row","col"];return`\n ${getPackedSamplerFromInInfo(squeezeInputInfo(e,t.slice(1)))}\n vec4 ${i}(int b, int row, int col) {\n return ${i}(${getSqueezedParams(r,n)});\n }\n `}const a=o[0],s=o[1],l=Math.ceil(t[2]/2);return`\n vec4 ${i}(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ${a}, ${s}, ${l*Math.ceil(t[1]/2)}, ${l}, b, row, col);\n return ${getGlslDifferences().texture2D}(${n}, uv);\n }\n `}function getSampler3D(e){const t=e.shapeInfo.logicalShape,n=e.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),r=t[1]*t[2],o=t[2],{newShape:a,keptDims:s}=squeezeShape(t);if(a.length<t.length){const t=["row","col","depth"];return`\n ${getSamplerFromInInfo(squeezeInputInfo(e,a))}\n float ${i}(int row, int col, int depth) {\n return ${i}(${getSqueezedParams(t,s)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${i}(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3(${r}, ${o}, 1)));\n ${getUniformSampler(e)}\n }\n `;const l=e.shapeInfo.texShape,c=l[0],h=l[1],u=e.shapeInfo.flatOffset;return h===r&&null==u?`\n float ${i}(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(${o}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${h}.0, ${c}.0);\n return sampleTexture(${n}, uv);\n }\n `:h===o&&null==u?`\n float ${i}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${t[1]}, 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${h}.0, ${c}.0);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${i}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${r} + col * ${o} + depth + ${getFlatOffsetUniformName(n)};\n vec2 uv = uvFromFlat(${c}, ${h}, index);\n return sampleTexture(${n}, uv);\n }\n `}function getPackedSamplerND(e){const t=e.shapeInfo.logicalShape,n=t.length,i=e.name,r="get"+i.charAt(0).toUpperCase()+i.slice(1),o=e.shapeInfo.texShape,a=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],s=a[0],l=a[1],c=Math.ceil(t[n-1]/2);let h=c*Math.ceil(t[n-2]/2),u="int b, int row, int col",d=`b * ${h} + (row / 2) * ${c} + (col / 2)`;for(let e=2;e<n-1;e++)u=`int b${e}, `+u,h*=t[n-e-1],d=`b${e} * ${h} + `+d;return`\n vec4 ${r}(${u}) {\n int index = ${d};\n int texR = index / ${l};\n int texC = index - texR * ${l};\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${l}, ${s});\n return ${getGlslDifferences().texture2D}(${i}, uv);\n }\n `}function getSampler4D(e){const t=e.shapeInfo.logicalShape,n=e.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),r=t[3],o=t[2]*r,a=t[1]*o,{newShape:s,keptDims:l}=squeezeShape(t);if(s.length<t.length){const t=["row","col","depth","depth2"];return`\n ${getSamplerFromInInfo(squeezeInputInfo(e,s))}\n float ${i}(int row, int col, int depth, int depth2) {\n return ${i}(${getSqueezedParams(t,l)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${i}(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4(${a}, ${o}, ${r}, 1)));\n ${getUniformSampler(e)}\n }\n `;const c=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,u=h[0],d=h[1];return d===a&&null==c?`\n float ${i}(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(${o}, ${r}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${u}.0);\n return sampleTexture(${n}, uv);\n }\n `:d===r&&null==c?`\n float ${i}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${t[1]*t[2]}, ${t[2]}, 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${u}.0);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${i}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${a} + col * ${o} +\n depth * ${r} + depth2;\n vec2 uv = uvFromFlat(${u}, ${d}, index + ${getFlatOffsetUniformName(n)});\n return sampleTexture(${n}, uv);\n }\n `}function getSampler5D(e){const t=e.shapeInfo.logicalShape,n=e.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),r=t[4],o=t[3]*r,a=t[2]*o,s=t[1]*a,{newShape:l,keptDims:c}=squeezeShape(t);if(l.length<t.length){const t=["row","col","depth","depth2","depth3"];return`\n ${getSamplerFromInInfo(squeezeInputInfo(e,l))}\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n return ${i}(${getSqueezedParams(t,c)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4(${s}, ${a}, ${o}, ${r})) +\n depth3;\n ${getUniformSampler(e)}\n }\n `;const h=e.shapeInfo.flatOffset,u=e.shapeInfo.texShape,d=u[0],p=u[1];return p===s&&null==h?`\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${a}, ${o}, ${r}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${p}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `:p===r&&null==h?`\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4(${t[1]*t[2]*t[3]},\n ${t[2]*t[3]}, ${t[3]}, 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${p}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${s} + col * ${a} + depth * ${o} +\n depth2 * ${r} + depth3 + ${getFlatOffsetUniformName(n)};\n vec2 uv = uvFromFlat(${d}, ${p}, index);\n return sampleTexture(${n}, uv);\n }\n `}function getSampler6D(e){const t=e.shapeInfo.logicalShape,n=e.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:r,keptDims:o}=squeezeShape(t);if(r.length<t.length){const t=["row","col","depth","depth2","depth3","depth4"];return`\n ${getSamplerFromInInfo(squeezeInputInfo(e,r))}\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return ${i}(${getSqueezedParams(t,o)});\n }\n `}const a=t[5],s=t[4]*a,l=t[3]*s,c=t[2]*l,h=t[1]*c;if(e.shapeInfo.isUniform)return`\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4(${h}, ${c}, ${l}, ${s})) +\n dot(\n vec2(depth3, depth4),\n vec2(${a}, 1)));\n ${getUniformSampler(e)}\n }\n `;const u=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,p=d[0],m=d[1];return m===h&&null==u?`\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${c}, ${l}, ${s}, ${a})) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${m}.0, ${p}.0);\n return sampleTexture(${n}, uv);\n }\n `:m===a&&null==u?`\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4(${t[1]*t[2]*t[3]*t[4]},\n ${t[2]*t[3]*t[4]},\n ${t[3]*t[4]},\n ${t[4]})) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${m}.0, ${p}.0);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${h} + col * ${c} + depth * ${l} +\n depth2 * ${s} + depth3 * ${a} + depth4 + ${getFlatOffsetUniformName(n)};\n vec2 uv = uvFromFlat(${p}, ${m}, index);\n return sampleTexture(${n}, uv);\n }\n `}function getUniformSampler(e){const t=e.name,n=sizeFromShape(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`\n for (int i = 0; i < ${n}; i++) {\n if (i == index) {\n return ${t}[i];\n }\n }\n `}function getPackedSamplerAtOutputCoords(e,t){const n=e.name,i=n.charAt(0).toUpperCase()+n.slice(1),r="get"+i+"AtOutCoords",o=e.shapeInfo.logicalShape.length,a=t.logicalShape.length,s=getBroadcastDims(e.shapeInfo.logicalShape,t.logicalShape),l=getCoordsDataType(a),c=a-o;let h;const u=["x","y","z","w","u","v"];h=0===o?"":a<2&&s.length>=1?"coords = 0;":s.map((e=>`coords.${u[e+c]} = 0;`)).join("\n");let d="";d=a<2&&o>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${u[t+c]}`)).join(", ");let p="return outputValue;";const m=1===sizeFromShape(e.shapeInfo.logicalShape),f=1===sizeFromShape(t.logicalShape);if(1!==o||m||f){if(m&&!f)p=1===a?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(s.length){const e=o-2,t=o-1;s.indexOf(e)>-1&&s.indexOf(t)>-1?p="return vec4(outputValue.x);":s.indexOf(e)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":s.indexOf(t)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}}else p="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${r}() {\n ${l} coords = getOutputCoords();\n ${h}\n vec4 outputValue = get${i}(${d});\n ${p}\n }\n `}function getSamplerAtOutputCoords(e,t){const n=e.name,i=n.charAt(0).toUpperCase()+n.slice(1),r="get"+i+"AtOutCoords",o=e.shapeInfo.logicalShape.length,a=t.logicalShape.length;if(!e.shapeInfo.isUniform&&o===a&&null==e.shapeInfo.flatOffset&&arraysEqual$1(e.shapeInfo.texShape,t.texShape))return`\n float ${r}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const s=getCoordsDataType(a),l=getBroadcastDims(e.shapeInfo.logicalShape,t.logicalShape),c=a-o;let h;const u=["x","y","z","w","u","v"];h=0===o?"":a<2&&l.length>=1?"coords = 0;":l.map((e=>`coords.${u[e+c]} = 0;`)).join("\n");let d="";return d=a<2&&o>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${u[t+c]}`)).join(", "),`\n float ${r}() {\n ${s} coords = getOutputCoords();\n ${h}\n return get${i}(${d});\n }\n `}function getCoordsDataType(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function squeezeInputInfo(e,t){const n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function getSqueezedParams(e,t){return t.map((t=>e[t])).join(", ")} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function compileProgram(e,t,n,i){const r=t.userCode,o=n.map(((e,n)=>{const i={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(i.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:i}})),a=o.map((e=>e.shapeInfo)),s={logicalShape:i.shape,texShape:i.texData.texShape,isUniform:!1,isPacked:i.texData.isPacked,flatOffset:null},l=makeShader(o,s,r,t.packedInputs),c=e.createProgram(l);let h=null;const u=e.getUniformLocation(c,"NAN",!1);1===env().getNumber("WEBGL_VERSION")&&(h=e.getUniformLocation(c,"INFINITY",!1));const d={};for(let n=0;n<t.variableNames.length;n++){const i=t.variableNames[n],r=!1;d[i]=e.getUniformLocation(c,i,r),d[`offset${i}`]=e.getUniformLocation(c,`offset${i}`,r)}return{program:t,source:l,webGLProgram:c,uniformLocations:d,inShapeInfos:a,outShapeInfo:s,infLoc:h,nanLoc:u}}function validateBinaryAndProgram(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach(((e,n)=>{const i=e.logicalShape,r=t[n],o=r.shape;if(!arraysEqual$1(i,o))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${i} and ${o} must match`);if(e.isUniform&&r.isUniform)return;const a=e.texShape,s=r.isUniform?null:r.texData.texShape;if(!arraysEqual$1(a,s))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${a} and ${s} must match`)}))}function runProgram(e,t,n,i,r){validateBinaryAndProgram(t.inShapeInfos,n),validateBinaryAndProgram([t.outShapeInfo],[i]);const o=i.texData.texture,a=i.texData.texShape;i.texData.isPacked?e.setOutputPackedMatrixTexture(o,a[0],a[1]):e.setOutputMatrixTexture(o,a[0],a[1]),e.setProgram(t.webGLProgram),1===env().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach(((n,i)=>{const r=t.program.variableNames[i],o=t.uniformLocations[r],a=t.uniformLocations[`offset${r}`];if(null!=o)if(n.isUniform)if(sizeFromShape(n.shape)<2)e.gl.uniform1f(o,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(o,t)}else null!=n.texData.slice&&null!=a&&e.gl.uniform1i(a,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture,o,i)})),null!=r&&r(e,t.webGLProgram),e.executeProgram()}function makeShaderKey(e,t,n){let i="";t.concat(n).forEach((e=>{i+=`${e.shape}_${e.isUniform?"uniform":e.texData.texShape}_${null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0}`}));let r=e.constructor.name;return r+="_"+i+"_"+e.userCode,r} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const{addImpl:addImplCPU,bincountImpl:bincountImplCPU,bincountReduceImpl:bincountReduceImplCPU,ceilImpl:ceilImplCPU,concatImpl:concatImplCPU,expImpl:expImplCPU,expm1Impl:expm1ImplCPU,floorImpl:floorImplCPU,gatherV2Impl:gatherV2ImplCPU,greaterImpl:greaterImplCPU,lessImpl:lessImplCPU,linSpaceImpl:linSpaceImplCPU,logImpl:logImplCPU,maxImpl:maxImplCPU,maximumImpl:maximumImplCPU,minimumImpl:minimumImplCPU,multiplyImpl:multiplyImplCPU,negImpl:negImplCPU,prodImpl:prodImplCPU,rangeImpl:rangeImplCPU,rsqrtImpl:rsqrtImplCPU,simpleAbsImpl:simpleAbsImplCPU,sliceImpl:sliceImplCPU,stridedSliceImpl:stridedSliceImplCPU,subImpl:subImplCPU,tileImpl:tileImplCPU,topKImpl:topKImplCPU,transposeImpl:transposeImplCPU,uniqueImpl:uniqueImplCPU}=shared; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getVecChannels(e,t){return["x","y","z","w","u","v"].slice(0,t).map((t=>`${e}.${t}`))}function getChannels(e,t){return 1===t?[e]:getVecChannels(e,t)}function getSourceCoords$2(e,t){if(1===e)return"rc";let n="";for(let i=0;i<e;i++)n+=t[i],i<e-1&&(n+=",");return n} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class PackProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e;const t=e.length;if(0===t)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const n=getChannels("rc",t),i=getCoordsDataType(t),r=getOutOfBoundsCondition(t,e,n),o=getSetup(t,e[e.length-1],e[e.length-2],n),a=getOutput(e,n);this.userCode=`\n void main() {\n ${i} rc = getOutputCoords();\n\n if(${r}) {\n setOutput(vec4(0));\n } else {\n ${o}\n\n setOutput(vec4(${a}));\n }\n }\n `}}}function getSourceCoordsArr(e,t){const n=[];for(let i=0;i<=1;i++)for(let r=0;r<=1;r++){let o=`${0===i?"r":"rp1"}, ${0===r?"c":"cp1"}`;for(let n=2;n<e;n++)o=`${t[t.length-1-n]},`+o;n.push(o)}return n}function getOutOfBoundsCondition(e,t,n){if(1===e)return`rc > ${t[0]}`;let i="";for(let r=e-2;r<e;r++)i+=`${n[r]} >= ${t[r]}`,r<e-1&&(i+="||");return i}function getSetup(e,t,n,i){if(1===e)return"";const r=i.slice(-2);return`\n int r = ${r[0]};\n int c = ${r[1]};\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= ${t};\n bool rEdge = rp1 >= ${n};\n `}function getOutput(e,t){const n=e.length,i=getSourceCoordsArr(n,t);return 1===n?`getA(rc),\n rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),\n 0, 0`:`getA(${i[0]}),\n cEdge ? 0. : getA(${i[1]}),\n rEdge ? 0. : getA(${i[2]}),\n rEdge || cEdge ? 0. : getA(${i[3]})`} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ReshapePackedProgram{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n ${t}\n ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e>0?"}":""}\n `}this.userCode=`\n ${getReshapedInputCoords(t)}\n ${getFlatIndexFrom3D(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${e[1]};\n int cols = ${e[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}function getReshapedInputCoords(e){return`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${getLogicalCoordinatesFromFlatIndex(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n `} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class TextureManager{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const i=getPhysicalFromLogicalTextureType(t,n),r=getKeyFromTextureShape(e,i,n);r in this.freeTextures||(this.freeTextures[r]=[]),r in this.usedTextures||(this.usedTextures[r]=[]);const o=computeBytes(e,i,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[r].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=o,this.log();const e=this.freeTextures[r].shift();return this.usedTextures[r].push(e),e}let a;return i===PhysicalTextureType.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):i===PhysicalTextureType.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):i===PhysicalTextureType.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):i===PhysicalTextureType.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):i===PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[r].push(a),this.numUsedTextures++,this._numBytesAllocated+=o,this.log(),a}releaseTexture(e,t,n,i){if(null==this.freeTextures)return;const r=getPhysicalFromLogicalTextureType(n,i),o=getKeyFromTextureShape(t,r,i);o in this.freeTextures||(this.freeTextures[o]=[]);const a=computeBytes(t,r,this.gpgpu.gl,this.gpgpu.textureConfig,i),s=env().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==s&&this._numBytesAllocated>s?(this.gpgpu.deleteMatrixTexture(e),this._numBytesAllocated-=a):(this.freeTextures[o].push(e),this.numFreeTextures++,this._numBytesFree+=a),this.numUsedTextures--;const l=this.usedTextures[o],c=l.indexOf(e);if(c<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(c,1),this.log()}log(){if(!this.logEnabled)return;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${this.numFreeTextures+this.numUsedTextures})`);const e=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*e)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e)}));for(const e in this.usedTextures)this.usedTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function numBytesForInternalFormat(e,t){if(t===e.R32F)return 4;if(t===e.R16F)return 2;if(t===e.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===e.RGBA16F)return 8;throw new Error(`Unknown internal format ${t}`)}function computeBytes(e,t,n,i,r){const o=internalFormatForPhysicalTexType(t,i);let a;if(r){const[t,n]=getPackedMatrixTextureShapeWidthHeight(e[0],e[1]);a=t*n}else{const[t,n]=getUnpackedMatrixTextureShapeWidthHeight(e[0],e[1]);a=t*n}return a*numBytesForInternalFormat(n,o)}function internalFormatForPhysicalTexType(e,t){switch(e){case PhysicalTextureType.PACKED_2X2_FLOAT32:return getInternalFormatForPackedMatrixTexture(t);case PhysicalTextureType.PACKED_2X2_FLOAT16:return getInternalFormatForFloat16PackedMatrixTexture(t);case PhysicalTextureType.UNPACKED_FLOAT32:return getInternalFormatForFloat32MatrixTexture(t);case PhysicalTextureType.UNPACKED_FLOAT16:return getInternalFormatForFloat16MatrixTexture(t);case PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE:return getInternalFormatForUnsignedBytesMatrixTexture(t);default:throw new Error(`Unknown physical texture type ${e}`)}}function getPhysicalTextureForRendering(e){return env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?PhysicalTextureType.PACKED_2X2_FLOAT32:PhysicalTextureType.UNPACKED_FLOAT32:e?PhysicalTextureType.PACKED_2X2_FLOAT16:PhysicalTextureType.UNPACKED_FLOAT16}function getPhysicalFromLogicalTextureType(e,t){if(e===TextureUsage.UPLOAD)return PhysicalTextureType.PACKED_2X2_FLOAT32;if(e===TextureUsage.RENDER||null==e)return getPhysicalTextureForRendering(t);if(e===TextureUsage.DOWNLOAD||e===TextureUsage.PIXELS)return PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function getKeyFromTextureShape(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class UnaryOpProgram{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.userCode=`\n float unaryOperation(float x) {\n ${t}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}const CHECK_NAN_SNIPPET$2="if (isnan(x)) return x;",LINEAR$1="return x;",ABS$1="return abs(x);",ELU$2="return (x >= 0.0) ? x : (exp(x) - 1.0);",RELU$2=CHECK_NAN_SNIPPET$2+"\n return (x < 0.0) ? 0.0 : x;\n",RELU6$2=CHECK_NAN_SNIPPET$2+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",CLONE="return x;",LINEAR="return x;",ELU$1="\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n",RELU$1="\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",RELU6$1="\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n";class UnaryOpPackedProgram{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode=`\n vec4 unaryOperation(vec4 x) {\n ${t}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class UnpackProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;const t=e.length,n=getChannels("rc",t),i=getCoordsDataType(t),r=getSourceCoords$2(t,n),o=n.slice(-2),a=t<=1?"rc":`vec2(${o.join(",")})`;this.userCode=`\n void main() {\n ${i} rc = getOutputCoords();\n vec4 packedInput = getA(${r});\n\n setOutput(getChannel(packedInput, ${a}));\n }\n `}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const whereImpl=whereImpl$2,EPSILON_FLOAT32=1e-7,EPSILON_FLOAT16=1e-4,binaryCaches={};function getBinaryCache(e){return e in binaryCaches||(binaryCaches[e]={}),binaryCaches[e]}const CPU_HANDOFF_SIZE_THRESHOLD=128,BEFORE_PAGING_CONSTANT=600;function numMBBeforeWarning(){return null==env().global.screen?1024:env().global.screen.height*env().global.screen.width*window.devicePixelRatio*BEFORE_PAGING_CONSTANT/1024/1024}class MathBackendWebGL extends KernelBackend{constructor(e){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!env().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==e){const e=getWebGLContext(env().getNumber("WEBGL_VERSION"));this.binaryCache=getBinaryCache(env().getNumber("WEBGL_VERSION")),this.gpgpu=new GPGPUContext(e),this.canvas=e.canvas,this.gpgpuCreatedLocally=!0}else this.gpgpu=e,this.binaryCache={},this.gpgpuCreatedLocally=!1,this.canvas=e.gl.canvas;this.textureManager=new TextureManager(this.gpgpu),this.numMBBeforeWarning=numMBBeforeWarning(),this.texData=new DataStorage(this,engine())}nextDataId(){return MathBackendWebGL.nextDataId++}numDataIds(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes}write(e,t,n){if((env().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||env().getBool("DEBUG"))&&this.checkNumericalProblems(e),"complex64"===n&&null!=e)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const i={id:this.nextDataId()};return this.texData.set(i,{shape:t,dtype:n,values:e,usage:TextureUsage.UPLOAD,refCount:1}),i}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){this.texData.get(e).refCount++}decRef(e){this.texData.has(e)&&this.texData.get(e).refCount--}move(e,t,n,i,r){if(env().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===i)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:i,values:t,usage:TextureUsage.UPLOAD,refCount:r})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:n,dtype:i,complexTensorInfos:r,slice:o,shape:a,isPacked:s}=t;if(null!=o){let t;t=s?new UnaryOpPackedProgram(a,CLONE):new UnaryOpProgram(a,CLONE);const n=this.runWebGLProgram(t,[{dataId:e,shape:a,dtype:i}],i),r=this.readSync(n.dataId);return this.disposeIntermediateTensorInfo(n),r}if(null!=n)return this.convertAndCacheOnCPU(e);if("string"===i)return n;const l=null!=this.activeTimers;let c,h;return l&&(c=now()),h="complex64"===i?mergeRealAndImagArrays(this.readSync(r.real.dataId),this.readSync(r.imag.dataId)):this.getValuesFromTexture(e),l&&(this.downloadWaitMs+=now()-c),this.convertAndCacheOnCPU(e,h)}async read(e){if(this.pendingRead.has(e)){const t=this.pendingRead.get(e);return new Promise((e=>t.push(e)))}const t=this.texData.get(e),{values:n,shape:i,slice:r,dtype:o,complexTensorInfos:a,isPacked:s}=t;if(null!=r){let t;t=s?new UnaryOpPackedProgram(i,CLONE):new UnaryOpProgram(i,CLONE);const n=this.runWebGLProgram(t,[{dataId:e,shape:i,dtype:o}],o),r=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),r}if(null!=n)return this.convertAndCacheOnCPU(e);if(!env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===env().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l,c,h=null;if("complex64"!==o&&env().get("WEBGL_BUFFER_SUPPORTED")){l=this.decode(e);const t=this.texData.get(l.dataId);h=this.gpgpu.createBufferFromTexture(t.texture,...getDenseTexShape(i))}if(this.pendingRead.set(e,[]),"complex64"!==o&&await this.gpgpu.createAndWaitForFence(),"complex64"===o){const e=await Promise.all([this.read(a.real.dataId),this.read(a.imag.dataId)]);c=mergeRealAndImagArrays(e[0],e[1])}else if(null==h)c=this.getValuesFromTexture(e);else{const e=sizeFromShape(i);c=this.gpgpu.downloadFloat32MatrixFromBuffer(h,e)}null!=l&&this.disposeIntermediateTensorInfo(l);const u=this.convertAndCacheOnCPU(e,c),d=this.pendingRead.get(e);return this.pendingRead.delete(e),d.forEach((e=>e(u))),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&engine().removeDataId(e,this),this.pendingDeletes--),u}bufferSync(e){const t=this.readSync(e.dataId);let n=t;if("string"===e.dtype)try{n=t.map((e=>decodeString(e)))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return buffer(e.shape,e.dtype,n)}checkNumericalProblems(e){if(null!=e)for(let t=0;t<e.length;t++){const n=e[t];if(!canBeRepresented(n)){if(env().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`);throw Error(`The value ${n} cannot be represented on this device.`)}}}getValuesFromTexture(e){const{shape:t,dtype:n,isPacked:i}=this.texData.get(e),r=sizeFromShape(t);if(env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const n=this.decode(e),i=this.texData.get(n.dataId),o=this.gpgpu.downloadMatrixFromPackedTexture(i.texture,...getDenseTexShape(t)).subarray(0,r);return this.disposeIntermediateTensorInfo(n),o}const o=env().getBool("WEBGL_PACK")&&!0===i,a=o?getShapeAs3D(t):t,s=o?new EncodeFloatPackedProgram(a):new EncodeFloatProgram(a),l=this.runWebGLProgram(s,[{shape:a,dtype:n,dataId:e}],"float32"),c=this.texData.get(l.dataId),h=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(c.texture,c.texShape[0],c.texShape[1]).subarray(0,r);return this.disposeIntermediateTensorInfo(l),h}timerAvailable(){return env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}async time(e){const t=this.activeTimers,n=[];let i=!1;null==this.programTimersStack?(this.programTimersStack=n,i=!0):this.activeTimers.push(n),this.activeTimers=n,e();const r=flatten$1(this.activeTimers.map((e=>e.query))).filter((e=>null!=e)),o=flatten$1(this.activeTimers.map((e=>e.name))).filter((e=>null!=e));this.activeTimers=t,i&&(this.programTimersStack=null);const a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};if(env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(r);a.kernelMs=sum$3(e),a.getExtraProfileInfo=()=>e.map(((e,t)=>({name:o[t],ms:e}))).map((e=>`${e.name}: ${e.ms}`)).join(", ")}else a.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,a}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:now(),endMs:null}}endTimer(e){return env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=now(),e)}async getQueryTime(e){return env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.waitForQueryAndGetTime(e):e.endMs-e.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:i,usage:r,isPacked:o,slice:a}=this.texData.get(e),s=a&&a.origDataId||e,l=this.dataRefCount.get(s);l>1?this.dataRefCount.set(s,l-1):(this.dataRefCount.delete(s),null!=t&&(this.numBytesInGPU-=this.computeBytes(i,n),this.textureManager.releaseTexture(t,i,r,o)));const c=this.texData.get(e);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=CPU_HANDOFF_SIZE_THRESHOLD){return env().getBool("WEBGL_CPU_FORWARD")&&e.every((e=>null==this.texData.get(e.dataId).texture&&sizeFromShape(e.shape)<t))}getGPGPUContext(){return this.gpgpu}where(e){warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return whereImpl(e.shape,t)}packedUnaryOp(e,t,n){const i=new UnaryOpPackedProgram(e.shape,t),r=this.compileAndRun(i,[e],n);return engine().makeTensorFromDataId(r.dataId,r.shape,r.dtype)}abs(e){if(this.shouldExecuteOnCPU([e])&&"complex64"!==e.dtype){const t=simpleAbsImplCPU(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,t)}if(env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,ABS$1,e.dtype);const t=new UnaryOpProgram(e.shape,ABS$1),n=this.compileAndRun(t,[e]);return engine().makeTensorFromDataId(n.dataId,n.shape,n.dtype)}makeTensorInfo(e,t,n){let i;if("string"===t&&null!=n&&n.length>0&&isString(n[0])){const r=n.map((e=>encodeString(e)));i=this.write(r,e,t)}else i=this.write(n,e,t);return this.texData.get(i).usage=null,{dataId:i,shape:e,dtype:t}}makeOutput(e,t,n){const{dataId:i}=this.makeTensorInfo(e,t,n);return engine().makeTensorFromDataId(i,e,t,this)}unpackTensor(e){const t=new UnpackProgram(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new PackProgram(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[getBatchDim(e.shape),...getRowsCols(e.shape)],i={dtype:e.dtype,shape:n,dataId:e.dataId},r=[getBatchDim(t),...getRowsCols(t)],o=new ReshapePackedProgram(r,n),a=this.runWebGLProgram(o,[i],e.dtype,null,!0);return{dataId:a.dataId,shape:t,dtype:a.dtype}}decode(e){const t=this.texData.get(e),{isPacked:n,shape:i,dtype:r}=t,o=getShapeAs3D(i);let a;return a=n?new DecodeMatrixPackedProgram(o):new DecodeMatrixProgram(o),{dtype:r,shape:i,dataId:this.runWebGLProgram(a,[{shape:o,dtype:r,dataId:e}],r,null,!0).dataId}}runWebGLProgram(e,t,n,i,r=!1){const o=this.makeTensorInfo(e.outputShape,n),a=this.texData.get(o.dataId);if(e.packedOutput&&(a.isPacked=!0),e.outPackingScheme===PackingScheme.DENSE){const t=getDenseTexShape(e.outputShape);a.texShape=t.map((e=>2*e))}if(null!=e.outTexUsage&&(a.usage=e.outTexUsage),0===sizeFromShape(o.shape))return a.values=getTypedArrayFromDType(o.dtype,0),o;const s=[],l=t.map((t=>{if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let n=this.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&sizeFromShape(t.shape)<=env().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}else if(!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),s.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!isReshapeFree(n.shape,t.shape)){const e=t,i=t.shape;t.shape=n.shape,t=this.packedReshape(t,i),s.push(t),n=this.texData.get(t.dataId),e.shape=i}return this.uploadToGPU(t.dataId),{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(o.dataId);const c={shape:o.shape,texData:a,isUniform:!1},h=makeShaderKey(e,l,c),u=this.getAndSaveBinary(h,(()=>compileProgram(this.gpgpu,e,l,c))),d=null!=this.activeTimers;let p;d&&(p=this.startTimer()),runProgram(this.gpgpu,u,l,c,i),s.forEach((e=>this.disposeIntermediateTensorInfo(e))),d&&(p=this.endTimer(p),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(p)}));const m=env().get("WEBGL_FLUSH_THRESHOLD");if(m>0){const e=now();e-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!env().getBool("WEBGL_LAZILY_UNPACK")&&a.isPacked&&!1===r){const e=this.unpackTensor(o);return this.disposeIntermediateTensorInfo(o),e}return o}compileAndRun(e,t,n,i,r=!1){return this.runWebGLProgram(e,t,n=n||t[0].dtype,i,r)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(env().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach((e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]})),this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=tidy((()=>{if(!env().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=env().getBool("DEBUG");env().set("DEBUG",!1);const t=this.abs(scalar(1e-8)).dataSync()[0];if(env().set("DEBUG",e),t>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?EPSILON_FLOAT32:EPSILON_FLOAT16}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:i,values:r,texture:o,usage:a,isPacked:s}=t;if(null!=o)return;const l=null!=this.activeTimers;let c;l&&(c=now());let h=t.texShape;if(null==h&&(h=getTextureShapeFromLogicalShape(n,s),t.texShape=h),null!=r){const e=getShapeAs3D(n);let o,a=h[1],u=h[0];const d=r instanceof Uint8Array;s?([a,u]=getPackedMatrixTextureShapeWidthHeight(h[0],h[1]),o=new EncodeMatrixPackedProgram(e,[u,a],d)):o=new EncodeMatrixProgram(e,[u,a],d);const p=this.makeTensorInfo([u,a],i);this.texData.get(p.dataId).usage=d?TextureUsage.PIXELS:TextureUsage.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(p.dataId),a,u,r);const m=this.runWebGLProgram(o,[p],i,null,!0),f=this.texData.get(m.dataId);t.texture=f.texture,t.texShape=f.texShape,t.isPacked=f.isPacked,t.usage=f.usage,this.disposeIntermediateTensorInfo(p),this.texData.delete(m.dataId),t.values=null,l&&(this.uploadWaitMs+=now()-c)}else{const e=this.acquireTexture(h,a,i,s);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:i}=n;return this.releaseGPUData(e),null!=t&&(n.values=float32ToTypedArray(t,i)),n.values}acquireTexture(e,t,n,i){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){const e=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,i)}computeBytes(e,t){return e[0]*e[1]*bytesPerElement(t)}}function float32ToTypedArray(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t<n.length;++t)n[t]=Math.round(e[t]);return n}throw new Error(`Unknown dtype ${t}`)} /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */MathBackendWebGL.nextDataId=0,isBrowser()&®isterBackend("webgl",(()=>new MathBackendWebGL),2) /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */;const CHECK_NAN_SNIPPET$1="\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n";class BinaryOpProgram{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=assertAndGetBroadcastShape(t,n),this.userCode=`\n float binaryOperation(float a, float b) {\n ${e}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const CHECK_NAN_SNIPPET="\n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n";class BinaryOpPackedProgram{constructor(e,t,n,i=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=assertAndGetBroadcastShape(t,n);const r=this.outputShape.length;let o="";if(i)if(0===r||1===sizeFromShape(this.outputShape))o="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(o=`\n ${getCoordsDataType(r)} coords = getOutputCoords();\n `,1===r)o+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const e=getChannels("coords",r);o+=`\n bool nextRowOutOfBounds =\n (${e[r-2]} + 1) >= ${this.outputShape[r-2]};\n bool nextColOutOfBounds =\n (${e[r-1]} + 1) >= ${this.outputShape[r-1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `}this.userCode=`\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${e}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${o}\n\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function identity$2(e){const{inputs:t,backend:n}=e,{x:i}=t;return n.incRef(i.dataId),{dataId:i.dataId,shape:i.shape,dtype:i.dtype}}const identityConfig={kernelName:Identity,backendName:"webgl",kernelFunc:identity$2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function complex(e){const{inputs:t,backend:n}=e,{real:i,imag:r}=t,o=n.makeTensorInfo(i.shape,"complex64"),a=n.texData.get(o.dataId),s=identity$2({inputs:{x:i},backend:n}),l=identity$2({inputs:{x:r},backend:n});return a.complexTensorInfos={real:s,imag:l},o}const complexConfig={kernelName:Complex,backendName:"webgl",kernelFunc:complex},LEAKYRELU="return (a < 0.) ? b * a : a;",LEAKYRELU_PACKED="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n"; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function leakyRelu(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{alpha:o}=i,a=n.makeTensorInfo([],"float32",createScalarValue(o,"float32")),s=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new BinaryOpPackedProgram(LEAKYRELU_PACKED,r.shape,a.shape):new BinaryOpProgram(LEAKYRELU,r.shape,a.shape),l=n.runWebGLProgram(s,[r,a],r.dtype);return n.disposeIntermediateTensorInfo(a),l}const leakyReluConfig={kernelName:LeakyRelu,backendName:"webgl",kernelFunc:leakyRelu},PRELU="return (a < 0.) ? b * a : a;",PRELU_PACKED="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n"; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function prelu(e){const{inputs:t,backend:n}=e,{x:i,alpha:r}=t,o=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new BinaryOpPackedProgram(PRELU_PACKED,i.shape,r.shape):new BinaryOpProgram(PRELU,i.shape,r.shape);return n.runWebGLProgram(o,[i,r],i.dtype)}const preluConfig={kernelName:Prelu,backendName:"webgl",kernelFunc:prelu},CHECK_NAN_SNIPPET_UNARY="if (isnan(x)) return x;",CHECK_NAN_SNIPPET_BINARY="\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n",CHECK_NAN_SNIPPET_BINARY_PACKED="\n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n"; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function unaryKernelFunc({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:i}){return({inputs:r,backend:o})=>{const{x:a}=r,s=o,l=i||a.dtype;if(s.shouldExecuteOnCPU([a])&&null!=n){const e=s.texData.get(a.dataId),t=n(e.values,l);return s.makeTensorInfo(a.shape,l,t)}let c;return c=env().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new UnaryOpPackedProgram(a.shape,t):new UnaryOpProgram(a.shape,e),s.runWebGLProgram(c,[a],l)}}function binaryKernelFunc({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:i=!1,cpuKernelImpl:r,dtype:o}){return({inputs:a,backend:s})=>{const{a:l,b:c}=a,h=s;if(i&&"complex64"===l.dtype){const t=h.texData.get(l.dataId),n=h.texData.get(c.dataId),[i,r]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((t=>{const[n,i]=t,r={dataId:n.dataId,dtype:n.dtype,shape:l.shape},o={dataId:i.dataId,dtype:i.dtype,shape:c.shape},a=new BinaryOpProgram(e,l.shape,c.shape);return h.runWebGLProgram(a,[r,o],upcastType(n.dtype,i.dtype))})),o=complex({inputs:{real:i,imag:r},backend:h});return h.disposeIntermediateTensorInfo(i),h.disposeIntermediateTensorInfo(r),o}const u=o||upcastType(l.dtype,c.dtype);if(h.shouldExecuteOnCPU([l,c])&&null!=r){const e=h.texData.get(l.dataId),t=h.texData.get(c.dataId),[n,i]=r(l.shape,c.shape,e.values,t.values,u),o=h.makeTensorInfo(i,u);return h.texData.get(o.dataId).values=n,o}let d;return d=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new BinaryOpPackedProgram(t,l.shape,c.shape,n):new BinaryOpProgram(e,l.shape,c.shape),h.runWebGLProgram(d,[l,c],u)}}function mapActivationToShaderProgram(e,t=!1){if("linear"===e)return t?LINEAR:LINEAR$1;if("relu"===e)return t?RELU$1:RELU$2;if("elu"===e)return t?ELU$1:ELU$2;if("relu6"===e)return t?RELU6$1:RELU6$2;if("prelu"===e)return t?PRELU_PACKED:PRELU;if("leakyrelu"===e)return t?LEAKYRELU_PACKED:LEAKYRELU;throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class MatMulPackedProgram{constructor(e,t,n,i=!1,r=!1,o=!1,a=null,s=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n;const c=Math.ceil((i?e[1]:e[2])/2),h=i?"i * 2, rc.y":"rc.y, i * 2",u=r?"rc.z, i * 2":"i * 2, rc.z",d=i?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],p=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",f="";a&&(m=s?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${a}\n }`:l?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${a}\n }`:`vec4 activation(vec4 x) {\n ${a}\n }`,f="result = activation(result);");const g=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let v="rc.x",y="rc.x";e[0]<t[0]?v=`int(min(float(rc.x), ${e[0]-1}.))`:t[0]<e[0]&&(y=`int(min(float(rc.x), ${t[0]-1}.))`),this.userCode=`\n ${m}\n\n const float sharedDimension = ${c}.0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n for (int i = 0; i < ${c}; i++) {\n int batchA = ${v};\n int batchB = ${y};\n vec4 a = getMatrixA(batchA, ${h});\n vec4 b = getMatrixB(batchB, ${u});\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += (${d[0]} * ${p[0]});\n result += (${d[1]} * ${p[1]});\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n ${g}\n\n ${f}\n\n setOutput(result);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const COMPLEX_MULTIPLY={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class BinaryOpComplexProgram{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=assertAndGetBroadcastShape(t,n),this.userCode=`\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n ${e}\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const MUL="return a * b;";function multiply(e){const{inputs:t,backend:n}=e,{a:i,b:r}=t,o=upcastType(i.dtype,r.dtype);if("complex64"===i.dtype){const e=n.texData.get(i.dataId),t=n.texData.get(r.dataId),o=new BinaryOpComplexProgram(COMPLEX_MULTIPLY.REAL,i.shape,r.shape),a=new BinaryOpComplexProgram(COMPLEX_MULTIPLY.IMAG,i.shape,r.shape),s=[{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:i.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:i.shape},{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:r.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:r.shape}],l=n.runWebGLProgram(o,s,"float32"),c=n.runWebGLProgram(a,s,"float32"),h=complex({inputs:{real:l,imag:c},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),h}if(n.shouldExecuteOnCPU([i,r])){const e=n.texData.get(i.dataId),t=n.texData.get(r.dataId),[a,s]=multiplyImplCPU(i.shape,r.shape,e.values,t.values,o),l=n.makeTensorInfo(s,o);return n.texData.get(l.dataId).values=a,l}let a;return a=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new BinaryOpPackedProgram(MUL,i.shape,r.shape):new BinaryOpProgram(MUL,i.shape,r.shape),n.runWebGLProgram(a,[i,r],o)}const multiplyConfig={kernelName:Multiply,backendName:"webgl",kernelFunc:multiply}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function packedReshape(e,t,n){const i=[getBatchDim(e.shape),...getRowsCols(e.shape)],r={dtype:e.dtype,shape:i,dataId:e.dataId},o=[getBatchDim(t),...getRowsCols(t)],a=new ReshapePackedProgram(o,i),s=n.runWebGLProgram(a,[r],e.dtype,null,!0);return{dataId:s.dataId,shape:t,dtype:s.dtype}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function reshape(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{shape:o}=i,a=n,s=sizeFromShape(r.shape),l=inferFromImplicitShape(o,s),c=sizeFromShape(l);assert$1(s===c,(()=>`The new shape (${l}) has ${c} elements and the old shape (${r.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`));const h=a.texData.get(r.dataId);return!h.isPacked||isReshapeFree(r.shape,l)||null!==h.texture&&isReshapeFree(h.shape,l)?(a.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype}):packedReshape(r,l,a)}const reshapeConfig={kernelName:Reshape,backendName:"webgl",kernelFunc:reshape}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class MeanProgram{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:i,inSize:r,outSize:o}=e;this.outputShape=[i,o];const a=4*Math.floor(n/4),s=n%4;let l="sumValue += dot(values, ones);";if(null!=t){const e=1/t;l=`sumValue += dot(values * ${isInt(e)?e.toPrecision(2):e}, ones);`}let c="";r%n>0&&(c=`\n if (inIdx < 0 || inIdx >= ${r}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${c}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${a}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${l}\n }\n\n int inIdx = inOffset + ${a};\n if (${1===s}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${l}\n } else if (${2===s}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${l}\n } else if (${3===s}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${l}\n }\n setOutput(sumValue);\n }\n `}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ReduceProgram{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:i,inSize:r,outSize:o}=e;this.outputShape=[i,o];let a="0.0",s="";"prod"===t?a="1.0":"min"===t?(a="1.0 / 1e-20",s="min"):"max"===t&&(a="-1.0 / 1e-20",s="max");let l=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?l="sumValue":"prod"===t?l="prodValue":"all"===t?l="allValue":"any"===t&&(l="anyValue");const c=4*Math.floor(n/4),h=n%4;let u=`\n if (${"sum"===t}) {\n sumValue += dot(values, ones);\n } else if (${"prod"===t}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${s}(values, minMaxValue);\n }\n `,d="vec4";"all"===t?(a="1.0",u="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",d="bvec4"):"any"===t&&(a="0.0",u="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",d="bvec4");let p="";r%n>0&&(p=`\n if (inIdx < 0 || inIdx >= ${r}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${a};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${p}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${a});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${c}; i += 4) {\n int inIdx = inOffset + i;\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${u}\n }\n\n int inIdx = inOffset + ${c};\n if (${1===h}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${u}\n } else if (${2===h}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${u}\n } else if (${3===h}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${u}\n }\n setOutput(${l});\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function getReductionStages(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],i=computeOptimalWindowSize(n);t.push({inSize:n,windowSize:i,outSize:Math.ceil(n/i)})}return t}function reduce(e,t,n,i){const r=getReductionStages(e.shape);let o=e;for(let a=0;a<r.length;a++){const{inSize:s,windowSize:l,outSize:c}=r[a];let h,u;h="mean"===n?0===a?new MeanProgram({windowSize:l,inSize:s,batchSize:e.shape[0],outSize:c},s):new MeanProgram({windowSize:l,inSize:s,batchSize:e.shape[0],outSize:c}):new ReduceProgram({windowSize:l,inSize:s,batchSize:e.shape[0],outSize:c},n),u=o,o=i.runWebGLProgram(h,[o],t),u.dataId!==e.dataId&&i.disposeIntermediateTensorInfo(u)}return o} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class TransposeProgram{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let i=0;i<n.length;i++)n[i]=e[t[i]];this.outputShape=n,this.rank=n.length;const i=getCoordsDataType(this.rank),r=getSwitchedCoords(t);this.userCode=`\n void main() {\n ${i} resRC = getOutputCoords();\n setOutput(getA(${r}));\n }\n `}}function getSwitchedCoords(e){const t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],i=new Array(t);for(let t=0;t<e.length;t++)i[e[t]]=n[t];return i.join()} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class TransposePackedProgram{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const n=new Array(e.length);for(let i=0;i<n.length;i++)n[i]=e[t[i]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const i=getCoordsDataType(this.rank),r=getVecChannels("rc",this.rank),o=new Array(this.rank);for(let e=0;e<t.length;e++)o[t[e]]=r[e];const a=`vec2(${o.slice(-2).join()})`,s=`++${r[this.rank-1]} < ${n[this.rank-1]}`,l=`getChannel(getA(${o.join()}), ${a})`;this.userCode=`\n void main() {\n ${i} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = ${l};\n if(${s}) {\n result[1] = ${l};\n }\n --${r[this.rank-1]};\n if(++${r[this.rank-2]} < ${n[this.rank-2]}) {\n result[2] = ${l};\n if(${s}) {\n result[3] = ${l};\n }\n }\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function transposeImpl(e,t,n){const i=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new TransposePackedProgram(e.shape,t):new TransposeProgram(e.shape,t);return n.runWebGLProgram(i,[e],e.dtype)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function sumImpl(e,t,n,i){const r=e.shape.length,o=parseAxisParam(t,e.shape);let a=o;const s=getAxesPermutation(a,r),l=null!=s;let c=e;l&&(c=transposeImpl(e,s,i),a=getInnerMostAxes(a.length,r)),assertAxesAreInnerMostDims("sum",a,r);const[h,u]=computeOutAndReduceShapes(c.shape,a);let d=h;n&&(d=expandShapeToKeepDim(h,o));const p=sizeFromShape(u),m=reshape({inputs:{x:c},attrs:{shape:[sizeFromShape(e.shape)/p,p]},backend:i}),f=reduce(m,sumOutType(e.dtype),"sum",i),g=reshape({inputs:{x:f},attrs:{shape:d},backend:i});return i.disposeIntermediateTensorInfo(m),i.disposeIntermediateTensorInfo(f),l&&i.disposeIntermediateTensorInfo(c),g} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function sum(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i;return sumImpl(r,o,a,n)}const sumConfig={kernelName:Sum,backendName:"webgl",kernelFunc:sum}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function transpose(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{perm:o}=i,a=n,s=new Array(r.shape.length);for(let e=0;e<s.length;e++)s[e]=r.shape[o[e]];let l;if(a.shouldExecuteOnCPU([r])){const e=a.texData.get(r.dataId),t=transposeImplCPU(e.values,r.shape,r.dtype,o,s);l=a.makeTensorInfo(s,r.dtype),a.texData.get(l.dataId).values=t}else l=transposeImpl(r,o,a);return l}const transposeConfig={kernelName:Transpose,backendName:"webgl",kernelFunc:transpose},MATMUL_SHARED_DIM_THRESHOLD=1e3; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function batchMatMulImpl({a:e,b:t,transposeA:n,transposeB:i,backend:r,bias:o=null,preluActivationWeights:a=null,leakyreluAlpha:s=0,activation:l=null}){const c=e.shape.length,h=t.shape.length,u=n?e.shape[c-2]:e.shape[c-1],d=i?t.shape[h-1]:t.shape[h-2],p=n?e.shape[c-1]:e.shape[c-2],m=i?t.shape[h-2]:t.shape[h-1],f=e.shape.slice(0,-2),g=t.shape.slice(0,-2),v=sizeFromShape(f),y=sizeFromShape(g);assert$1(c>=2&&h>=2&&(v===y||1===v||1===y),(()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${f}) and (${g}).`));const b=(v>y?e.shape.slice(0,-2):t.shape.slice(0,-2)).concat([p,m]);assert$1(u===d,(()=>`Error in matMul: inner shapes (${u}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${i} must match.`));const _=n?[v,u,p]:[v,p,u],x=i?[y,m,d]:[y,d,m],w=reshape({inputs:{x:e},backend:r,attrs:{shape:_}}),S=reshape({inputs:{x:t},backend:r,attrs:{shape:x}}),C=[w,S],M=Math.max(v,y),E=n?w.shape[1]:w.shape[2],T=null!=o,I=null!=a,A="leakyrelu"===l,k=null!=l?mapActivationToShaderProgram(l,!0):null;let P;if((1===p||1===m)&&E>MATMUL_SHARED_DIM_THRESHOLD&&!1===(T||I||A||null!=k)){let e=w,t=S;n&&(e=transpose({inputs:{x:w},backend:r,attrs:{perm:[0,2,1]}}),C.push(e)),i&&(t=transpose({inputs:{x:S},backend:r,attrs:{perm:[0,2,1]}}),C.push(t));const o=1===m;let a=e;1!==m&&(a=reshape({inputs:{x:e},backend:r,attrs:{shape:[M,E,1]}}),C.push(a));const s=1===m?2:1;let l=t;o&&(l=reshape({inputs:{x:t},backend:r,attrs:{shape:[M,1,E]}}),C.push(l));const c=multiply({inputs:{a:a,b:l},backend:r});P=sum({inputs:{x:c},backend:r,attrs:{axis:s,keepDims:!0}}),C.push(c)}else{const l=upcastType(e.dtype,t.dtype),c=new MatMulPackedProgram(_,x,[M,p,m],n,i,T,k,I,A),h=[w,S];if(null!=o&&h.push(o),I&&h.push(a),A){const e=r.makeTensorInfo([],"float32",createScalarValue(s,"float32"));h.push(e),C.push(e)}P=r.runWebGLProgram(c,h,l)}const R=reshape({inputs:{x:P},backend:r,attrs:{shape:b}});C.push(P);for(const e of C)r.disposeIntermediateTensorInfo(e);return R} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function _fusedMatMul(e){const{inputs:t,backend:n,attrs:i}=e,{a:r,b:o,bias:a,preluActivationWeights:s}=t,{transposeA:l,transposeB:c,activation:h,leakyreluAlpha:u}=i;return batchMatMulImpl({a:r,b:o,transposeA:l,transposeB:c,backend:n,bias:a,preluActivationWeights:s,leakyreluAlpha:u,activation:h})}const _fusedMatMulConfig={kernelName:_FusedMatMul,backendName:"webgl",kernelFunc:_fusedMatMul},ABS="return abs(x);"; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function abs(e){const{inputs:t,backend:n}=e,{x:i}=t;if(n.shouldExecuteOnCPU([i])&&"complex64"!==i.dtype){const e=n.texData.get(i.dataId),t=simpleAbsImplCPU(e.values);return n.makeTensorInfo(i.shape,i.dtype,t)}let r;return r=env().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new UnaryOpPackedProgram(i.shape,ABS):new UnaryOpProgram(i.shape,ABS),n.runWebGLProgram(r,[i],i.dtype)}const absConfig={kernelName:Abs,backendName:"webgl",kernelFunc:abs},ACOS=CHECK_NAN_SNIPPET$2+"\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n",acos=unaryKernelFunc({opSnippet:ACOS}),acosConfig={kernelName:Acos,backendName:"webgl",kernelFunc:acos},ACOSH=CHECK_NAN_SNIPPET$2+"\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));",acosh=unaryKernelFunc({opSnippet:ACOSH}),acoshConfig={kernelName:Acosh,backendName:"webgl",kernelFunc:acosh},ADD="return a + b;",addKernelFunc=binaryKernelFunc({opSnippet:ADD,packedOpSnippet:ADD,supportsComplex:!0,cpuKernelImpl:addImplCPU}),addConfig={kernelName:Add,backendName:"webgl",kernelFunc:addKernelFunc}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class AddNProgram{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`float v${e} = get${e}AtOutCoords();`)}));const i=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n float result = ${i};\n setOutput(result);\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class AddNPackedProgram{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`vec4 v${e} = get${e}AtOutCoords();`)}));const i=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${i};\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function addN(e){const{inputs:t,backend:n}=e,i=t;if(1===i.length)return identity$2({inputs:{x:i[0]},backend:n});if(i.length>env().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const e=Math.floor(i.length/2),t=addN({inputs:i.slice(0,e),backend:n}),r=addN({inputs:i.slice(e),backend:n});return addN({inputs:[t,r],backend:n})}const r=i.map((e=>e.dtype)).reduce(((e,t)=>upcastType(e,t))),o=i.map((e=>e.shape)),a=env().getBool("WEBGL_PACK")?new AddNPackedProgram(i[0].shape,o):new AddNProgram(i[0].shape,o);return n.runWebGLProgram(a,i,r)}const addNConfig={kernelName:AddN,backendName:"webgl",kernelFunc:addN}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function all(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i,s=r.shape.length,l=parseAxisParam(o,r.shape);let c=l;const h=getAxesPermutation(c,s);let u=r;null!=h&&(u=transpose({inputs:{x:r},backend:n,attrs:{perm:h}}),c=getInnerMostAxes(c.length,s)),assertAxesAreInnerMostDims("all",c,s);const[d,p]=computeOutAndReduceShapes(u.shape,c),m=reshape({inputs:{x:u},backend:n,attrs:{shape:[-1,sizeFromShape(p)]}}),f=reduce(m,m.dtype,"all",n);let g;return g=reshape(a?{inputs:{x:f},backend:n,attrs:{shape:expandShapeToKeepDim(d,l)}}:{inputs:{x:f},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),null!=h&&n.disposeIntermediateTensorInfo(u),g}const allConfig={kernelName:All,backendName:"webgl",kernelFunc:all}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function any(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i,s=r.shape.length,l=parseAxisParam(o,r.shape);let c=l;const h=getAxesPermutation(c,s);let u=r;null!=h&&(u=transpose({inputs:{x:r},backend:n,attrs:{perm:h}}),c=getInnerMostAxes(c.length,s)),assertAxesAreInnerMostDims("any",c,s);const[d,p]=computeOutAndReduceShapes(u.shape,c),m=reshape({inputs:{x:u},backend:n,attrs:{shape:[-1,sizeFromShape(p)]}}),f=reduce(m,m.dtype,"any",n);let g;return g=reshape(a?{inputs:{x:f},backend:n,attrs:{shape:expandShapeToKeepDim(d,l)}}:{inputs:{x:f},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),null!=h&&n.disposeIntermediateTensorInfo(u),g}const anyConfig={kernelName:Any,backendName:"webgl",kernelFunc:any}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ArgMinMaxProgram{constructor(e,t,n){this.variableNames=["A"];const{windowSize:i,batchSize:r,outSize:o}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[r,o],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${i};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${i}; i++) {\n int inIdx = ${n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));"};\n float candidate = getA(batch, inIdx);\n if (candidate ${"max"===t?">":"<"} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ArgMinMaxPackedProgram{constructor(e,t,n,i){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,assert$1(e.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const r=Math.ceil(e[e.length-1]/t);this.outputShape=e.slice(0,-1),r>1&&this.outputShape.push(r),i||this.variableNames.push("bestIndicesA");const o=this.outputShape,a=o.length,s=getCoordsDataType(a),l=getChannels("coords",a);let c,h;if(1===r){h=a+1;const e=getCoordsDataType(h);c=`\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[a-1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[a-2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[a-1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[a-2]};`}else h=a,c=`\n ${s} sourceLocR = coords;\n ++${l[a-1]};\n ${s} sourceLocG = coords;\n ++${l[a-2]};\n ${s} sourceLocA = coords;\n --${l[a-1]};\n ${s} sourceLocB = coords;\n --${l[a-2]};`;const u=["x","y","z","w","u","v"].slice(0,h),d="."+u[h-1],p=u.map((e=>"int "+e)),m=getChannels("sourceLocR",h-1).concat("inIdx.r"),f=getChannels("sourceLocG",h-1).concat("inIdx.g"),g=getChannels("sourceLocB",h-1).concat("inIdx.b"),v=getChannels("sourceLocA",h-1).concat("inIdx.a"),y="max"===n?"greaterThan":"lessThan",b=i?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${f.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${v.join()})));`,_=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${f.join()}) : 0.,\n hasNextRow ? getAChannel(${g.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${v.join()}) : 0.)`,x=i?"":`\n float getBestIndicesAChannel(${p.join()}) {\n return getChannel(getBestIndicesA(${u.join()}),\n vec2(${u.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${p.join()}) {\n return getChannel(getA(${u.join()}),\n vec2(${u.slice(-2).join()}));\n }\n ${x}\n void main() {\n ${s} coords = getOutputCoords();\n bool hasNextCol = ${l[a-1]} < ${o[a-1]-1};\n bool hasNextRow = ${l[a-2]} < ${o[a-2]-1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${d}, sourceLocG${d},\n sourceLocB${d}, sourceLocA${d}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${_};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${b}\n vec4 candidate = ${_};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${y}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function argReduce(e,t,n,i=null){let r=t.shape[0],o=t.shape[1];null!=i&&(r=i.shape[0],o=i.shape[1]);const a=computeOptimalWindowSize(o),s={windowSize:a,inSize:o,batchSize:r,outSize:Math.ceil(o/a)},l=new ArgMinMaxProgram(s,n,null==i),c=[t];null!=i&&c.push(i);const h=e.runWebGLProgram(l,c,"int32");if(1===h.shape[1])return h;const u=argReduce(e,t,n,h);return e.disposeIntermediateTensorInfo(h),u}function argReducePacked(e,t,n,i=null){const r=null!=i?i.shape:t.shape,o=computeOptimalWindowSize(r[r.length-1]),a=new ArgMinMaxPackedProgram(r,o,n,null==i),s=e.runWebGLProgram(a,null==i?[t]:[t,i],"int32");if(s.shape.length===t.shape.length){const i=argReducePacked(e,t,n,s);return e.disposeIntermediateTensorInfo(s),i}return s}function argMinMaxReduce(e,t,n,i){const r=[n];if(assertAxesAreInnerMostDims("arg"+i.charAt(0).toUpperCase()+i.slice(1),r,t.shape.length),!env().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],[o,a]=computeOutAndReduceShapes(t.shape,r),s=sizeFromShape(a),l=reshape({inputs:{x:t},backend:e,attrs:{shape:[-1,s]}});n.push(l);const c=argReduce(e,l,i);n.push(c);const h=reshape({inputs:{x:c},backend:e,attrs:{shape:o}});return n.forEach((t=>e.disposeIntermediateTensorInfo(t))),h}return argReducePacked(e,t,i)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function argMax(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o}=i;let a=parseAxisParam(o,r.shape);const s=getAxesPermutation(a,r.shape.length);let l=r;const c=[];null!=s&&(l=transpose({inputs:{x:r},backend:n,attrs:{perm:s}}),c.push(l),a=getInnerMostAxes(a.length,l.shape.length)),assertAxesAreInnerMostDims("argMax",[a[0]],l.shape.length);const h=argMinMaxReduce(n,l,a[0],"max");return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}const argMaxConfig={kernelName:ArgMax,backendName:"webgl",kernelFunc:argMax}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function argMin(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o}=i;let a=parseAxisParam(o,r.shape);const s=getAxesPermutation(a,r.shape.length);let l=r;const c=[];null!=s&&(l=transpose({inputs:{x:r},backend:n,attrs:{perm:s}}),c.push(l),a=getInnerMostAxes(a.length,l.shape.length)),assertAxesAreInnerMostDims("argMin",[a[0]],l.shape.length);const h=argMinMaxReduce(n,l,a[0],"min");return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}const argMinConfig={kernelName:ArgMin,backendName:"webgl",kernelFunc:argMin},ASIN=CHECK_NAN_SNIPPET$2+"\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n",asin=unaryKernelFunc({opSnippet:ASIN}),asinConfig={kernelName:Asin,backendName:"webgl",kernelFunc:asin},ASINH=CHECK_NAN_SNIPPET$2+"return log(x + sqrt(x * x + 1.0));",asinh=unaryKernelFunc({opSnippet:ASINH}),asinhConfig={kernelName:Asinh,backendName:"webgl",kernelFunc:asinh},ATAN=CHECK_NAN_SNIPPET$2+"\n return atan(x);\n",atan=unaryKernelFunc({opSnippet:ATAN}),atanConfig={kernelName:Atan,backendName:"webgl",kernelFunc:atan},ATAN2=CHECK_NAN_SNIPPET_BINARY+"\n return atan(a, b);\n",ATAN2_PACKED="\n vec4 result = atan(a, b);\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n "+CHECK_NAN_SNIPPET_BINARY_PACKED+"\n return result;\n",atan2=binaryKernelFunc({opSnippet:ATAN2,packedOpSnippet:ATAN2_PACKED}),atan2Config={kernelName:Atan2,backendName:"webgl",kernelFunc:atan2},ATANH=CHECK_NAN_SNIPPET$2+"\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;",atanh=unaryKernelFunc({opSnippet:ATANH}),atanhConfig={kernelName:Atanh,backendName:"webgl",kernelFunc:atanh}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Pool2DProgram{constructor(e,t,n,i=!1,r=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,a=e.strideHeight,s=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,h=e.effectiveFilterHeight,u=e.effectiveFilterWidth,d=e.padInfo.top,p=e.padInfo.left;this.outputShape=e.outShape;const m="avg"===t;let f="0.0";if(m||(f="-1.0 / 1e-20"),n)return void(this.userCode=`\n const ivec2 strides = ivec2(${a}, ${s});\n const ivec2 pads = ivec2(${d}, ${p});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${h};\n wR += ${l}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${u};\n wC += ${c}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${i?r?`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`:`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`:`wR * ${u} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `);let g=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(g="avgValue / count");const v=4*Math.floor(o/4),y=o%4,b=`\n if (${m}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${a}, ${s});\n const ivec2 pads = ivec2(${d}, ${p});\n const float initializationValue = ${f};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${f});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${h};\n wR += ${l}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${v}; wC += 4) {\n int xC = xCCorner + wC * ${c};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${c}, d),\n getValue(batch, xR, xC + 2 * ${c}, d),\n getValue(batch, xR, xC + 3 * ${c}, d)\n );\n\n ${b}\n }\n\n int xC = xCCorner + ${v};\n if (${1===y}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${b}\n } else if (${2===y}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${c}, d),\n initializationValue,\n initializationValue\n );\n\n ${b}\n } else if (${3===y}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${c}, d),\n getValue(batch, xR, xC + 2 * ${c}, d),\n initializationValue\n );\n\n ${b}\n }\n }\n setOutput(${g});\n }\n `}}class Pool3DProgram{constructor(e,t,n,i=!1,r=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,a=e.strideDepth,s=e.strideHeight,l=e.strideWidth,c=e.dilationDepth,h=e.dilationHeight,u=e.dilationWidth,d=e.effectiveFilterDepth,p=e.effectiveFilterHeight,m=e.effectiveFilterWidth,f=e.padInfo.front,g=e.padInfo.top,v=e.padInfo.left;this.outputShape=e.outShape;const y="avg"===t;let b="0.0";if(y||(b="-1.0 / 1e-20"),n)return void(this.userCode=`\n const ivec3 strides =\n ivec3(${a}, ${s}, ${l});\n const ivec3 pads = ivec3(${f}, ${g}, ${v});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < ${d};\n wD += ${c}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p};\n wR += ${h}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${m};\n wC += ${u}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value >= currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${i?r?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${p} * ${m} +\n wR * ${m} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `);let _=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(_="avgValue / count");const x=4*Math.floor(o/4),w=o%4,S=`\n if (${y}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec3 strides =\n ivec3(${a}, ${s}, ${l});\n const ivec3 pads = ivec3(${f}, ${g}, ${v});\n const float initializationValue = ${b};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4(${b});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${d};\n wD += ${c}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p};\n wR += ${h}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${x}; wC += 4) {\n int xC = xCCorner + wC * ${u};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${u}, ch),\n getValue(batch, xD, xR, xC + 2 * ${u}, ch),\n getValue(batch, xD, xR, xC + 3 * ${u}, ch)\n );\n\n ${S}\n }\n\n int xC = xCCorner + ${x};\n if (${1===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${S}\n } else if (${2===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${u}, ch),\n initializationValue,\n initializationValue\n );\n\n ${S}\n } else if (${3===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${u}, ch),\n getValue(batch, xD, xR, xC + 2 * ${u}, ch),\n initializationValue\n );\n\n ${S}\n }\n }\n setOutput(${_});\n }\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function avgPool(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t;assertNotComplex(r,"avgPool");const{filterSize:o,strides:a,pad:s,dimRoundingMode:l}=i;assert$1(eitherStridesOrDilationsAreOne(a,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const c=computePool2DInfo(r.shape,o,a,1,s,l);if(1===c.filterWidth&&1===c.filterHeight&&arraysEqual$1(c.inShape,c.outShape))return identity$2({inputs:{x:r},backend:n});const h=new Pool2DProgram(c,"avg",!1);return n.runWebGLProgram(h,[r],"float32")}const avgPoolConfig={kernelName:AvgPool,backendName:"webgl",kernelFunc:avgPool}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function avgPool3D(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{filterSize:o,strides:a,pad:s,dimRoundingMode:l,dataFormat:c}=i,h=computePool3DInfo(r.shape,o,a,[1,1,1],s,l,c),u=new Pool3DProgram(h,"avg",!1);return n.runWebGLProgram(u,[r],"float32")}const avgPool3DConfig={kernelName:AvgPool3D,backendName:"webgl",kernelFunc:avgPool3D}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class AvgPool2DBackpropProgram{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.effectiveFilterHeight,n=e.effectiveFilterWidth;this.userCode=`\n const ivec2 pads = ivec2(${t-1-e.padInfo.top}, ${n-1-e.padInfo.left});\n const float avgMultiplier = float(${1/(e.filterHeight*e.filterWidth)});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t};\n wR += ${e.dilationHeight}) {\n float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${n};\n wC+= ${e.dilationWidth}) {\n float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n `}}class AvgPool3DBackpropProgram{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.effectiveFilterDepth,n=e.effectiveFilterHeight,i=e.effectiveFilterWidth;this.userCode=`\n const ivec3 pads = ivec3(${t-1-e.padInfo.front}, ${n-1-e.padInfo.top}, ${i-1-e.padInfo.left});\n const float avgMultiplier = float(${1/(e.filterDepth*e.filterHeight*e.filterWidth)});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${t};\n wD += ${e.dilationDepth}) {\n float dyD = float(dyDCorner + wD) / ${e.strideDepth}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${n};\n wR += ${e.dilationHeight}) {\n float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${i};\n wC += ${e.dilationWidth}) {\n float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function avgPool3DGrad(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,input:o}=t,a=o,{filterSize:s,strides:l,pad:c,dimRoundingMode:h}=i,u=computePool3DInfo(a.shape,s,l,[1,1,1],c,h),d=new AvgPool3DBackpropProgram(u);return n.runWebGLProgram(d,[r],a.dtype)}const avgPoolGrad3DConfig={kernelName:AvgPool3DGrad,backendName:"webgl",kernelFunc:avgPool3DGrad}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function avgPoolGrad(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,input:o}=t,a=o;assertNotComplex([r,o],"avgPoolGrad");const{filterSize:s,strides:l,pad:c}=i,h=computePool2DInfo(a.shape,s,l,1,c),u=new AvgPool2DBackpropProgram(h);return n.runWebGLProgram(u,[r],a.dtype)}const avgPoolGradConfig={kernelName:AvgPoolGrad,backendName:"webgl",kernelFunc:avgPoolGrad}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function batchMatMul(e){const{inputs:t,backend:n,attrs:i}=e,{a:r,b:o}=t,{transposeA:a,transposeB:s}=i;return batchMatMulImpl({a:r,b:o,transposeA:a,transposeB:s,backend:n})}const batchMatMulConfig={kernelName:BatchMatMul,backendName:"webgl",kernelFunc:batchMatMul}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class BatchNormProgram{constructor(e,t,n,i,r,o){this.outputShape=[],this.variableNames=["x","mean","variance"],assertAndGetBroadcastShape(e,t),assertAndGetBroadcastShape(e,n);let a="0.0";null!=i&&(assertAndGetBroadcastShape(e,i),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let s="1.0";null!=r&&(assertAndGetBroadcastShape(e,r),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${a};\n float scale = ${s};\n float inv = scale * inversesqrt(variance + float(${o}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class BatchNormPackedProgram{constructor(e,t,n,i,r,o){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],assertAndGetBroadcastShape(e,t),assertAndGetBroadcastShape(e,n);let a="vec4(0.0)";null!=i&&(assertAndGetBroadcastShape(e,i),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let s="vec4(1.0)";null!=r&&(assertAndGetBroadcastShape(e,r),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n vec4 offset = ${a};\n vec4 scale = ${s};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${o}));\n\n setOutput((x - mean) * inv + offset);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const batchNorm=({inputs:e,backend:t,attrs:n})=>{const{x:i,mean:r,variance:o,offset:a,scale:s}=e;assert$1(r.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),assert$1(null==a||r.shape.length===a.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),assert$1(null==s||r.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));let{varianceEpsilon:l}=n;null==l&&(l=.001);const c=[i,r,o];let h=null;null!=a&&(h=a.shape,c.push(a));let u=null;null!=s&&(u=s.shape,c.push(s));const d=env().getBool("WEBGL_PACK_NORMALIZATION")?new BatchNormPackedProgram(i.shape,r.shape,o.shape,h,u,l):new BatchNormProgram(i.shape,r.shape,o.shape,h,u,l);return t.runWebGLProgram(d,c,c[0].dtype)},batchNormConfig={kernelName:FusedBatchNorm,backendName:"webgl",kernelFunc:batchNorm}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class SliceProgram{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=getCoordsDataType(this.rank),n=`uniform int start[${this.rank}];`,i=getCoords$1(this.rank);let r;r=`\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${e.map(((e,t)=>`sourceLoc.${coords[t]} = start[${t}] + coords.${coords[t]};`)).join("\n")}\n `,this.userCode=`\n ${n}\n void main() {\n ${r}\n setOutput(getSource(${i}));\n }\n `}getCustomSetupFunc(e){if(e.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${e.length})`);return(t,n)=>{null==this.startLoc&&(this.startLoc=t.getUniformLocationNoThrow(n,"start"),null==this.startLoc)||t.gl.uniform1iv(this.startLoc,e)}}}const coords=["x","y","z","w","u","v"];function getCoords$1(e){if(1===e)return"sourceLoc";if(e<=6)return coords.slice(0,e).map((e=>"sourceLoc."+e)).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class SlicePackedProgram{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length;const t=getCoordsDataType(this.rank),n=getChannels("coords",this.rank),i=getChannels("sourceLoc",this.rank),r=1===this.rank?"sourceLoc":`vec2(${i.slice(-2).join()})`,o=`getChannel(getSource(${i.join()}), ${r})`,a=`\n result.x = ${o};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${i[this.rank-1]};\n result.y = ${o};\n --${i[this.rank-1]};\n }\n `,s=1===this.rank?"":`\n --${n[this.rank-1]};\n if (++${n[this.rank-2]} < ${e[this.rank-2]}) {\n ++${i[this.rank-2]};\n result.z = ${o};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${i[this.rank-1]};\n result.w = ${o};\n }\n }\n `,l=this.rank<=4?`sourceLoc = coords +\n ${t}(${e.map(((e,t)=>`start[${t}]`)).join()});`:e.map(((e,t)=>`${i[t]} = ${n[t]} + start[${t}];`)).join("\n");this.userCode=`\n uniform int start[${this.rank}];\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${l}\n vec4 result = vec4(0.);\n ${a}\n ${s}\n setOutput(result);\n }\n `}getCustomSetupFunc(e){if(e.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${e.length})`);return(t,n)=>{null==this.startLoc&&(this.startLoc=t.getUniformLocationNoThrow(n,"start"),null==this.startLoc)||t.gl.uniform1iv(this.startLoc,e)}}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function shallowSlice(e,t,n,i){const r=i.texData.get(e.dataId),o=i.makeTensorInfo(n,e.dtype),a=i.texData.get(o.dataId);Object.assign(a,r),a.refCount=1,a.shape=n,a.dtype=e.dtype;let s=computeFlatOffset(t,computeStrides(e.shape));r.slice&&(s+=r.slice.flatOffset),a.slice={flatOffset:s,origDataId:r.slice&&r.slice.origDataId||e.dataId};const l=i.dataRefCount.get(a.slice.origDataId)||1;return i.dataRefCount.set(a.slice.origDataId,l+1),o}function slice$1(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{begin:o,size:a}=i,[s,l]=parseSliceParams(r,o,a);if(assertParamsValid(r,s,l),0===sizeFromShape(l))return n.makeTensorInfo(l,r.dtype,[]);if(n.shouldExecuteOnCPU([r])||"string"===r.dtype){const e=n.texData.get(r.dataId),t=sliceImplCPU(e.values,s,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,t)}const{isPacked:c}=n.texData.get(r.dataId),h=isSliceContinous(r.shape,s,l);if(c||!h){const e=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new SlicePackedProgram(l):new SliceProgram(l),t=e.getCustomSetupFunc(s);return n.runWebGLProgram(e,[r],r.dtype,t)}return n.uploadToGPU(r.dataId),shallowSlice(r,s,l,n)}const sliceConfig={kernelName:Slice,backendName:"webgl",kernelFunc:slice$1},batchToSpaceND=e=>{const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{blockShape:o,crops:a}=i;assert$1(r.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const s=o.reduce(((e,t)=>e*t)),l=getReshaped(r.shape,o,s),c=getPermuted(l.length,o.length),h=getReshapedPermuted(r.shape,o,s),u=getSliceBeginCoords(a,o.length),d=getSliceSize(h,a,o.length),p=[],m=reshape({inputs:{x:r},backend:n,attrs:{shape:l}}),f=transpose({inputs:{x:m},backend:n,attrs:{perm:c}}),g=reshape({inputs:{x:f},backend:n,attrs:{shape:h}}),v=slice$1({inputs:{x:g},backend:n,attrs:{begin:u,size:d}});return p.push(m),p.push(f),p.push(g),p.forEach((e=>n.disposeIntermediateTensorInfo(e))),v},batchToSpaceNDConfig={kernelName:BatchToSpaceND,backendName:"webgl",kernelFunc:batchToSpaceND}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function bincount(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,weights:o}=t,{size:a}=i,s=n.readSync(r.dataId),l=n.readSync(o.dataId),c=bincountImplCPU(s,l,o.dtype,o.shape,a);return n.makeTensorInfo([a],o.dtype,c)}const bincountConfig={kernelName:Bincount,backendName:"webgl",kernelFunc:bincount},NOT_EQUAL="return float(a != b);",notEqual=binaryKernelFunc({opSnippet:NOT_EQUAL,dtype:"bool"}),notEqualConfig={kernelName:NotEqual,backendName:"webgl",kernelFunc:notEqual}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function real(e){const{inputs:t,backend:n}=e,{input:i}=t;return identity$2({inputs:{x:n.texData.get(i.dataId).complexTensorInfos.real},backend:n})}const realConfig={kernelName:Real,backendName:"webgl",kernelFunc:real},TO_INT="return float(int(x));"; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function int(e,t){const n=new UnaryOpProgram(e.shape,TO_INT),i=t.runWebGLProgram(n,[e],"int32");return{dataId:i.dataId,shape:i.shape,dtype:i.dtype}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function cast(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{dtype:o}=i;if("complex64"===o){if("complex64"===r.dtype)return identity$2({inputs:{x:r},backend:n});const e=zeros$1(r.shape),t=cast({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),i=complex({inputs:{real:t,imag:e},backend:n});return e.dispose(),n.disposeIntermediateTensorInfo(t),i}if("complex64"===r.dtype){const e=real({inputs:{input:r},backend:n}),t=cast({inputs:{x:e},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(e),t}if(!hasEncodingLoss(r.dtype,o)){const e=identity$2({inputs:{x:r},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:o}}if("int32"===o)return int(r,n);if("bool"===o){const e=n.makeTensorInfo([],"bool",getTypedArrayFromDType("bool",1)),t=notEqual({inputs:{a:r,b:e},backend:n});return n.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${o}`)}const castConfig={kernelName:Cast,backendName:"webgl",kernelFunc:cast},CEIL="return ceil(x);",ceil=unaryKernelFunc({opSnippet:CEIL,packedOpSnippet:CEIL,cpuKernelImpl:ceilImplCPU}),ceilConfig={kernelName:Ceil,backendName:"webgl",kernelFunc:ceil}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class ClipProgram{constructor(e){this.variableNames=["A"],this.outputShape=e,this.userCode="\n uniform float minVal;\n uniform float maxVal;\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}getCustomSetupFunc(e,t){return(n,i)=>{null==this.minLoc&&(this.minLoc=n.getUniformLocationNoThrow(i,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(i,"maxVal")),n.gl.uniform1f(this.minLoc,e),n.gl.uniform1f(this.maxLoc,t)}}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ClipPackedProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode="\n uniform float minVal;\n uniform float maxVal;\n\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}getCustomSetupFunc(e,t){return(n,i)=>{null==this.minLoc&&(this.minLoc=n.getUniformLocationNoThrow(i,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(i,"maxVal")),n.gl.uniform1f(this.minLoc,e),n.gl.uniform1f(this.maxLoc,t)}}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function clipByValue(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{clipValueMin:o,clipValueMax:a}=i;let s;s=env().getBool("WEBGL_PACK_CLIP")?new ClipPackedProgram(r.shape):new ClipProgram(r.shape);const l=s.getCustomSetupFunc(o,a);return n.runWebGLProgram(s,[r],r.dtype,l)}const clipByValueConfig={kernelName:ClipByValue,backendName:"webgl",kernelFunc:clipByValue}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ComplexAbsProgram{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function makeComplexComponentTensorInfo(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}function complexAbs(e){const{inputs:t,backend:n}=e,{x:i}=t,r=n.texData.get(i.dataId),o=new ComplexAbsProgram(i.shape),a=[makeComplexComponentTensorInfo(i,r.complexTensorInfos.real),makeComplexComponentTensorInfo(i,r.complexTensorInfos.imag)];return n.runWebGLProgram(o,a,a[0].dtype)}const complexAbsConfig={kernelName:ComplexAbs,backendName:"webgl",kernelFunc:complexAbs}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ConcatProgram{constructor(e){this.outputShape=[],this.outputShape=computeOutShape$1(e,1),this.variableNames=e.map(((e,t)=>`T${t}`));const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n][1];const n=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let e=1;e<t.length;e++)n.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${t[e-1]}));`);n.push(`else setOutput(getT${t.length}(yR, yC-${t[t.length-1]}));`),this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n ${n.join("\n ")}\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ConcatPackedProgram{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=computeOutShape$1(e,t);const n=this.outputShape,i=n.length,r=getCoordsDataType(i),o=getChannels("coords",i),a=["x","y","z","w","u","v"].slice(0,i);this.variableNames=e.map(((e,t)=>`T${t}`));const s=new Array(e.length-1);s[0]=e[0][t];for(let n=1;n<s.length;n++)s[n]=s[n-1]+e[n][t];const l=a[t],c=a.slice(-2),h=a.join();let u=`if (${l} < ${s[0]}) {\n return getChannel(\n getT0(${h}), vec2(${c.join()}));\n }`;for(let e=1;e<s.length;e++){const t=s[e-1];u+=`\n if (${l} < ${s[e]} && ${l} >= ${s[e-1]}) {\n return getChannel(\n getT${e}(${shiftedChannels(a,l,t)}),\n vec2(${shiftedChannels(c,l,t)}));\n }`}const d=s[s.length-1];u+=`\n return getChannel(\n getT${s.length}(${shiftedChannels(a,l,d)}),\n vec2(${shiftedChannels(c,l,d)}));`,this.userCode=`\n float getValue(${a.map((e=>"int "+e))}) {\n ${u}\n }\n\n void main() {\n ${r} coords = getOutputCoords();\n vec4 result = vec4(getValue(${o}), 0., 0., 0.);\n\n ${o[i-1]} = ${o[i-1]} + 1;\n if (${o[i-1]} < ${n[i-1]}) {\n result.g = getValue(${o});\n }\n\n ${o[i-2]} = ${o[i-2]} + 1;\n if (${o[i-2]} < ${n[i-2]}) {\n result.a = getValue(${o});\n }\n\n ${o[i-1]} = ${o[i-1]} - 1;\n if (${o[i-2]} < ${n[i-2]} &&\n ${o[i-1]} < ${n[i-1]}) {\n result.b = getValue(${o});\n }\n setOutput(result);\n }\n `}}function shiftedChannels(e,t,n){const i=e.indexOf(t);return e.map(((e,t)=>t===i?`${e} - ${n}`:e)).join()} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function imag(e){const{inputs:t,backend:n}=e,{input:i}=t;return identity$2({inputs:{x:n.texData.get(i.dataId).complexTensorInfos.imag},backend:n})}const imagConfig={kernelName:Imag,backendName:"webgl",kernelFunc:imag}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function concatImpl(e,t,n){const i=e[0].dtype;if("complex64"===i){const i=e.map((e=>real({inputs:{input:e},backend:n}))),r=e.map((e=>imag({inputs:{input:e},backend:n}))),o=concatImpl(i,t,n),a=concatImpl(r,t,n),s=complex({inputs:{real:o,imag:a},backend:n});return i.forEach((e=>n.disposeIntermediateTensorInfo(e))),r.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(a),s}if("string"===i){const{tensors2D:r,outShape:o}=computeTensors2D(e,t,n),a=r.map((e=>({vals:n.readSync(e.dataId),shape:e.shape}))),s=concatImplCPU(a,o,i,1===r[0].shape[0]),l=computeOutShape$1(e.map((e=>e.shape)),t),c=n.makeTensorInfo(l,i,s);return r.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}if(e.length>env().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const i=Math.floor(e.length/2),r=concatImpl(e.slice(0,i),t,n),o=concatImpl(e.slice(i),t,n),a=concatImpl([r,o],t,n);return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),a}if(env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){const r=new ConcatPackedProgram(e.map((e=>e.shape)),t);return n.runWebGLProgram(r,e,i)}const{tensors2D:r,outShape:o}=computeTensors2D(e,t,n),a=new ConcatProgram(r.map((e=>e.shape))),s=n.runWebGLProgram(a,r,i);r.forEach((e=>n.disposeIntermediateTensorInfo(e)));const l=reshape({inputs:{x:s},attrs:{shape:o},backend:n});return n.disposeIntermediateTensorInfo(s),l}function computeTensors2D(e,t,n){const i=computeOutShape$1(e.map((e=>e.shape)),t);return{tensors2D:e.map((e=>reshape({inputs:{x:e},attrs:{shape:[-1,sizeFromShape(e.shape.slice(t))]},backend:n}))),outShape:i}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function concat(e){const{inputs:t,backend:n,attrs:i}=e,{axis:r}=i,o=parseAxisParam(r,t[0].shape)[0],a=computeOutShape$1(t.map((e=>e.shape)),o);if(0===sizeFromShape(a))return n.makeTensorInfo(a,t[0].dtype,[]);const s=t.filter((e=>sizeFromShape(e.shape)>0));return 1===s.length?identity$2({inputs:{x:s[0]},backend:n}):(assertParamsConsistent(s.map((e=>e.shape)),o),concatImpl(s,o,n))}const concatConfig={kernelName:Concat,backendName:"webgl",kernelFunc:concat}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class Conv2DProgram{constructor(e,t=!1,n=null,i=!1,r=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const o=e.padInfo.top,a=e.padInfo.left,s=e.strideHeight,l=e.strideWidth,c=e.dilationHeight,h=e.dilationWidth,u=e.filterHeight,d=e.filterWidth,p=4*Math.floor(e.inChannels/4),m=e.inChannels%4,f="channelsLast"===e.dataFormat,g=f?1:2,v=f?2:3,y=f?3:1;let b="",_="";n&&(b=i?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:r?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,_="result = activation(result);");const x=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${b}\n\n const ivec2 strides = ivec2(${s}, ${l});\n const ivec2 pads = ivec2(${o}, ${a});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${y}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${v}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${u}; wR++) {\n int xR = xRCorner + wR * ${c};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${h};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${p}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${f}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1===m}) {\n\n if (${f}) {\n dotProd +=\n getX(batch, xR, xC, ${p}) *\n getW(wR, wC, ${p}, d2);\n } else {\n dotProd +=\n getX(batch, ${p}, xR, xC) *\n getW(wR, wC, ${p}, d2);\n }\n\n } else if (${2===m}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${p}, d2),\n getW(wR, wC, ${p} + 1, d2)\n );\n\n if (${f}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${p}),\n getX(batch, xR, xC, ${p} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${p}, xR, xC),\n getX(batch, ${p} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3===m}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${p}, d2),\n getW(wR, wC, ${p} + 1, d2),\n getW(wR, wC, ${p} + 2, d2)\n );\n\n if (${f}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${p}),\n getX(batch, xR, xC, ${p} + 1),\n getX(batch, xR, xC, ${p} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${p}, xR, xC),\n getX(batch, ${p} + 1, xR, xC),\n getX(batch, ${p} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${x}\n ${_}\n setOutput(result);\n }\n `}}class Conv3DProgram{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,n=e.padInfo.top,i=e.padInfo.left,r=e.strideDepth,o=e.strideHeight,a=e.strideWidth,s=e.dilationDepth,l=e.dilationHeight,c=e.dilationWidth,h=e.filterDepth,u=e.filterHeight,d=e.filterWidth,p=4*Math.floor(e.inChannels/4),m=e.inChannels%4;this.userCode=`\n const ivec3 strides = ivec3(${r}, ${o}, ${a});\n const ivec3 pads = ivec3(${t}, ${n}, ${i});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < ${h}; wF++) {\n int xF = xFCorner + wF * ${s};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${u}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${c};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${p}; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if (${1===m}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${p}) *\n getW(wF, wR, wC, ${p}, d2);\n } else if (${2===m}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${p}),\n getX(batch, xF, xR, xC, ${p} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${p}, d2),\n getW(wF, wR, wC, ${p} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3===m}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${p}),\n getX(batch, xF, xR, xC, ${p} + 1),\n getX(batch, xF, xR, xC, ${p} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${p}, d2),\n getW(wF, wR, wC, ${p} + 1, d2),\n getW(wF, wR, wC, ${p} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class Im2ColPackedProgram{constructor(e,t,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;const{filterWidth:i,inChannels:r,strideWidth:o,strideHeight:a,padInfo:s,outWidth:l,dilationWidth:c,dilationHeight:h,dataFormat:u}=n,{left:d,top:p}=s,m=r*i,f=getGlslDifferences(),g="channelsLast"===u,v=g?0:1,y=g?1:2;let b="";for(let n=0;n<=1;n++)for(let i=0;i<=1;i++)b+=`\n blockIndex = rc.y + ${i};\n pos = rc.x + ${n};\n\n if(blockIndex < ${e[1]} && pos < ${e[0]}) {\n offsetY = int(blockIndex / (${l})) * ${a} - ${p};\n d0 = offsetY + ${h} * (pos / ${m});\n\n if(d0 < ${t[v]} && d0 >= 0) {\n\n offsetX = int(mod(float(blockIndex), ${l}.) * ${o}. - ${d}.);\n d1 = offsetX + ${c} * (int(mod(float(pos), ${m}.) / ${r}.));\n\n if(d1 < ${t[y]} && d1 >= 0) {\n\n ch = int(mod(float(pos), ${r}.));\n\n if (${g}) {\n innerDims = vec2(d1, ch);\n result[${2*n+i}] = getChannel(\n getA(d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*n+i}] = getChannel(\n getA(ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `;this.userCode=`\n void main() {\n ivec2 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${b}\n\n ${f.output} = result;\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv2dByMatMul({x:e,filter:t,convInfo:n,backend:i,bias:r=null,preluActivationWeights:o=null,leakyreluAlpha:a=0,activation:s=null}){const l=e.shape,c=i.texData.get(e.dataId),h="channelsLast"===n.dataFormat;let u;const d=[],p=l[2]%2!=0&&!!c.isPacked;if((1!=l[0]*l[1]*l[2]&&1!==n.outChannels||!(n.inChannels>MATMUL_SHARED_DIM_THRESHOLD))&&env().getBool("WEBGL_LAZILY_UNPACK")&&env().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&p){const p={dataId:e.dataId,shape:[1,h?l[0]*l[1]*(l[2]+1):l[0]*l[2]*(l[3]+1),n.inChannels],dtype:e.dtype},m=c.shape;c.shape=c.shape.slice(),c.shape[c.shape.length-2]++,assert$1(isReshapeFree(c.shape,p.shape),(()=>`packed reshape ${c.shape} to ${p.shape} isn't free`));const f=reshape({inputs:{x:t},backend:i,attrs:{shape:[1,n.inChannels,n.outChannels]}});d.push(f);const g=batchMatMulImpl({a:p,b:f,backend:i,transposeA:!1,transposeB:!1,bias:r,activation:s,preluActivationWeights:o,leakyreluAlpha:a}),v=i.texData.get(g.dataId);assert$1(v.isPacked,(()=>"batchMatMul result is expected to be packed")),c.shape=m,v.shape=n.outShape,u=identity$2({inputs:{x:g},backend:i}),u.shape=n.outShape,d.push(g)}else{const c=reshape({inputs:{x:e},backend:i,attrs:{shape:[1,h?l[0]*l[1]*l[2]:l[0]*l[2]*l[3],n.inChannels]}}),p=reshape({inputs:{x:t},backend:i,attrs:{shape:[1,n.inChannels,n.outChannels]}}),m=batchMatMulImpl({a:c,b:p,transposeA:!1,transposeB:!1,backend:i,bias:r,activation:s,preluActivationWeights:o,leakyreluAlpha:a});u=reshape({inputs:{x:m},backend:i,attrs:{shape:n.outShape}}),d.push(c),d.push(p),d.push(m)}for(const e of d)i.disposeIntermediateTensorInfo(e);return u}function conv2dWithIm2Row({x:e,filter:t,convInfo:n,backend:i,bias:r=null,preluActivationWeights:o=null,leakyreluAlpha:a=0,activation:s=null}){const{filterWidth:l,filterHeight:c,inChannels:h,outWidth:u,outHeight:d,dataFormat:p}=n,m="channelsLast"===p,f=l*c*h,g=d*u,v=[f,g],y=[],b=reshape({inputs:{x:e},backend:i,attrs:{shape:e.shape.slice(1)}}),_=reshape({inputs:{x:t},backend:i,attrs:{shape:[1,f,sizeFromShape(t.shape)/f]}});y.push(b),y.push(_);const x=new Im2ColPackedProgram(v,b.shape,n),w=i.runWebGLProgram(x,[b],"float32"),S=reshape({inputs:{x:w},backend:i,attrs:{shape:[1,v[0],v[1]]}});y.push(w),y.push(S);const C=null!=r,M=null!=o,E="leakyrelu"===s,T=s?mapActivationToShaderProgram(s,!0):null,I=new MatMulPackedProgram(S.shape,_.shape,[1,g,n.outChannels],!0,!1,C,T,M,E),A=[S,_];if(r&&A.push(r),M&&A.push(o),E){const e=i.makeTensorInfo([],"float32",createScalarValue(a,"float32"));A.push(e),y.push(e)}const k=i.runWebGLProgram(I,A,"float32"),P=reshape({inputs:{x:k},backend:i,attrs:{shape:m?[1,d,u,n.outChannels]:[1,n.outChannels,d,u]}});y.push(k);for(const e of y)i.disposeIntermediateTensorInfo(e);return P} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv2d(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o}=t,{strides:a,pad:s,dataFormat:l,dilations:c,dimRoundingMode:h}=i,u=convertConv2DDataFormat(l),d=computeConv2DInfo(r.shape,o.shape,a,c,s,h,!1,u);let p;if(1!==d.filterHeight||1!==d.filterWidth||1!==d.dilationHeight||1!==d.dilationWidth||1!==d.strideHeight||1!==d.strideWidth||"SAME"!==d.padInfo.type&&"VALID"!==d.padInfo.type)if(env().getBool("WEBGL_CONV_IM2COL")&&1===r.shape[0])p=conv2dWithIm2Row({x:r,filter:o,convInfo:d,backend:n});else{const e=new Conv2DProgram(d);p=n.runWebGLProgram(e,[r,o],"float32")}else p=conv2dByMatMul({x:r,filter:o,convInfo:d,backend:n});const m=reshape({inputs:{x:p},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(p),m}const conv2DConfig={kernelName:Conv2D,backendName:"webgl",kernelFunc:conv2d}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class Conv2DDerFilterProgram{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${e.strideHeight} - ${e.padInfo.top};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${e.strideWidth} - ${e.padInfo.left};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n if (${"channelsLast"===e.dataFormat}) {\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n } else {\n float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class Conv2DDerInputProgram{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,i="channelsLast"===e.dataFormat;this.userCode=`\n const ivec2 pads = ivec2(${t-1-e.padInfo.top}, ${n-1-e.padInfo.left});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${i?3:1}];\n\n ivec2 dyCorner = ivec2(coords[${i?1:2}], coords[${i?2:3}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n if (${i}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class Conv3DDerFilterProgram{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape,this.userCode=`\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yF = 0; yF < ${e.outDepth}; yF++) {\n int xF = wF + yF * ${e.strideDepth} - ${e.padInfo.front};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${e.strideHeight} - ${e.padInfo.top};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${e.strideWidth} - ${e.padInfo.left};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class Conv3DDerInputProgram{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,i=e.filterWidth;this.userCode=`\n const ivec3 pads = ivec3(${t-1-e.padInfo.front}, ${n-1-e.padInfo.top}, ${i-1-e.padInfo.left});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < ${t}; wF++) {\n float dyF = float(dyFCorner + wF) / ${e.strideDepth}.0;\n\n if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ${t} - 1 - wF;\n\n for (int wR = 0; wR < ${n}; wR++) {\n float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${n} - 1 - wR;\n\n for (int wC = 0; wC < ${i}; wC++) {\n float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${i} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv2DBackpropFilter(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,dy:o}=t,{strides:a,pad:s,dataFormat:l,dimRoundingMode:c,filterShape:h}=i,u=convertConv2DDataFormat(l),d=computeConv2DInfo(r.shape,h,a,1,s,c,!1,u),p=new Conv2DDerFilterProgram(d);return n.runWebGLProgram(p,[r,o],"float32")}const conv2DBackpropFilterConfig={kernelName:Conv2DBackpropFilter,backendName:"webgl",kernelFunc:conv2DBackpropFilter}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv2DBackpropInput(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,filter:o}=t,{inputShape:a,strides:s,pad:l,dataFormat:c,dimRoundingMode:h}=i,u=convertConv2DDataFormat(c),d=computeConv2DInfo(a,o.shape,s,1,l,h,!1,u),p=new Conv2DDerInputProgram(d);return n.runWebGLProgram(p,[r,o],"float32")}const conv2DBackpropInputConfig={kernelName:Conv2DBackpropInput,backendName:"webgl",kernelFunc:conv2DBackpropInput}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv3D(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o}=t,{strides:a,pad:s,dilations:l}=i,c=computeConv3DInfo(r.shape,o.shape,a,l,s),h=new Conv3DProgram(c);return n.runWebGLProgram(h,[r,o],"float32")}const conv3DConfig={kernelName:Conv3D,backendName:"webgl",kernelFunc:conv3D}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv3DBackpropFilterV2(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,dy:o}=t,{strides:a,pad:s,filterShape:l}=i,c=computeConv3DInfo(r.shape,l,a,1,s),h=new Conv3DDerFilterProgram(c);return n.runWebGLProgram(h,[r,o],"float32")}const conv3DBackpropFilterV2Config={kernelName:Conv3DBackpropFilterV2,backendName:"webgl",kernelFunc:conv3DBackpropFilterV2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function conv3DBackpropInput(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,filter:o}=t,{pad:a,strides:s,inputShape:l}=i,c=computeConv3DInfo(l,o.shape,s,1,a),h=new Conv3DDerInputProgram(c);return n.runWebGLProgram(h,[r,o],"float32")}const conv3DBackpropInputConfig={kernelName:Conv3DBackpropInputV2,backendName:"webgl",kernelFunc:conv3DBackpropInput},COS=CHECK_NAN_SNIPPET_UNARY+"\n return cos(x);\n",cos=unaryKernelFunc({opSnippet:COS}),cosConfig={kernelName:Cos,backendName:"webgl",kernelFunc:cos},COSH="\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n",cosh=unaryKernelFunc({opSnippet:COSH}),coshConfig={kernelName:Cosh,backendName:"webgl",kernelFunc:cosh}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class CropAndResizeProgram{constructor(e,t,n,i,r){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[o,a,s,l]=e,[c]=t,[h,u]=n;this.outputShape=[c,h,u,l];const d="bilinear"===i?1:0,[p,m]=[a-1+".0",s-1+".0"],[f,g,v]=h>1?[""+(a-1)/(h-1),"(y2-y1) * height_ratio",`y1*${p} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${p}`],[y,b,_]=u>1?[""+(s-1)/(u-1),"(x2-x1) * width_ratio",`x1*${m} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${m}`];this.userCode=`\n const float height_ratio = float(${f});\n const float width_ratio = float(${y});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${o}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${b};\n\n float in_y = ${v};\n if( in_y < 0.0 || in_y > ${p} ) {\n setOutput(float(${r}));\n return;\n }\n float in_x = ${_};\n if( in_x < 0.0 || in_x > ${m} ) {\n setOutput(float(${r}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${d} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const cropAndResize=e=>{const{inputs:t,backend:n,attrs:i}=e,{image:r,boxes:o,boxInd:a}=t,{cropSize:s,method:l,extrapolationValue:c}=i,h=new CropAndResizeProgram(r.shape,o.shape,s,l,c);return n.runWebGLProgram(h,[r,o,a],"float32")},cropAndResizeConfig={kernelName:CropAndResize,backendName:"webgl",kernelFunc:cropAndResize};class CumSumProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=e;const i=e.length,r=t?"0.0":`getX(${getCoords(i,"coords")})`,o=e[e.length-1];let a="",s="";t?(a=n?"end != "+(o-1):"end != 0",s=n?"end + 1":"end - 1"):(a=n?`end + pow2 < ${o}`:"end >= pow2",s=n?"end + pow2":"end - pow2"),this.userCode=`\n uniform float index;\n void main() {\n ${getCoordsDataType(i)} coords = getOutputCoords();\n int end = ${getFinalCoord(i,"coords")};\n float val = ${r};\n int pow2 = int(pow(2.0, index));\n if (${a}) {\n int idx = ${s};\n ${getFinalCoord(i,"coords")} = idx;\n val += getX(${getCoords(i,"coords")});\n }\n setOutput(val);\n }\n `}getCustomSetupFunc(e){return(t,n)=>{null==this.index&&(this.index=t.getUniformLocation(n,"index")),t.gl.uniform1f(this.index,e)}}}function getCoords(e,t){if(1===e)return`${t}`;if(2===e)return`${t}.x, ${t}.y`;if(3===e)return`${t}.x, ${t}.y, ${t}.z`;if(4===e)return`${t}.x, ${t}.y, ${t}.z, ${t}.w`;throw Error(`Cumulative sum for rank ${e} is not yet supported`)}function getFinalCoord(e,t){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw Error(`Cumulative sum for rank ${e} is not yet supported`)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function cumsum(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,exclusive:a,reverse:s}=i,l=r.shape.length,c=getAxesPermutation([o],l);let h=r;null!=c&&(h=transpose({inputs:{x:r},backend:n,attrs:{perm:c}}));const u=getInnerMostAxes(1,l)[0];if(u!==l-1)throw new Error(`WebGL cumsum shader expects an inner-most axis=${r.shape.length-1} but got axis=${o}`);const d=h.shape[u];let p=identity$2({inputs:{x:h},backend:n});for(let e=0;e<=Math.ceil(Math.log2(d))-1;e++){const t=new CumSumProgram(h.shape,!1,s),i=t.getCustomSetupFunc(e),r=p;p=n.runWebGLProgram(t,[p],p.dtype,i),n.disposeIntermediateTensorInfo(r)}if(a){const e=new CumSumProgram(h.shape,a,s),t=p;p=n.runWebGLProgram(e,[p],p.dtype),n.disposeIntermediateTensorInfo(t)}if(null!=c){const e=transpose({inputs:{x:p},backend:n,attrs:{perm:getUndoAxesPermutation(c)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),e}return p}const cumsumConfig={kernelName:Cumsum,backendName:"webgl",kernelFunc:cumsum}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function denseBincount(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,weights:o}=t,{size:a,binaryOutput:s}=i;if(1===r.shape.length){const e=n.readSync(r.dataId),t=n.readSync(o.dataId),i=bincountImplCPU(e,t,o.dtype,o.shape,a);return n.makeTensorInfo([a],o.dtype,i)}if(2===r.shape.length){const e=n.bufferSync(r),t=n.bufferSync(o),i=bincountReduceImplCPU(e,t,a,s);return n.makeTensorInfo(i.shape,o.dtype,i.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}const denseBincountConfig={kernelName:DenseBincount,backendName:"webgl",kernelFunc:denseBincount}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class DepthToSpaceProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = ${this.getHeightCoordString()};\n int w = ${this.getWidthCoordString()};\n int d = ${this.getDepthCoordString()};\n\n int in_h = h / ${t};\n int offset_h = imod(h, ${t});\n int in_w = w / ${t};\n int offset_w = imod(w, ${t});\n int offset_d = (offset_h * ${t} + offset_w) *\n ${this.getOutputDepthSize()};\n int in_d = d + offset_d;\n\n float result = ${this.getInputSamplingString()};\n setOutput(result);\n }\n `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function depthToSpace(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{blockSize:o,dataFormat:a}=i;assert$1(o>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${o}`));const s=r.shape[0],l=("NHWC"===a?r.shape[1]:r.shape[2])*o,c=("NHWC"===a?r.shape[2]:r.shape[3])*o,h=("NHWC"===a?r.shape[3]:r.shape[1])/(o*o),u=new DepthToSpaceProgram("NHWC"===a?[s,l,c,h]:[s,h,l,c],o,a);return n.runWebGLProgram(u,[r],r.dtype)}const depthToSpaceConfig={kernelName:DepthToSpace,backendName:"webgl",kernelFunc:depthToSpace}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class DepthwiseConv2DProgram{constructor(e,t=!1,n=null,i=!1,r=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const o=e.inHeight,a=e.inWidth,s=e.padInfo.top,l=e.padInfo.left,c=e.strideHeight,h=e.strideWidth,u=e.dilationHeight,d=e.dilationWidth,p=e.filterHeight,m=e.filterWidth,f=e.outChannels/e.inChannels;let g="",v="";n&&(g=i?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:r?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,v="result = activation(result);");const y=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${g}\n\n const ivec2 strides = ivec2(${c}, ${h});\n const ivec2 pads = ivec2(${s}, ${l});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${f};\n int q = d2 - d1 * ${f};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${u};\n\n if (xR < 0 || xR >= ${o}) {\n continue;\n }\n\n for (int wC = 0; wC < ${m}; wC++) {\n int xC = xCCorner + wC * ${d};\n\n if (xC < 0 || xC >= ${a}) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${y}\n ${v}\n setOutput(result);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class DepthwiseConvPacked2DProgram{constructor(e,t=!1,n=null,i=!1,r=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.outShape;const o=e.outChannels/e.inChannels,a=e.inHeight,s=e.inWidth,l=e.padInfo.top,c=e.padInfo.left,h=e.strideHeight,u=e.strideWidth,d=e.dilationHeight,p=e.dilationWidth,m=e.filterHeight,f=e.filterWidth,g=f;let v="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e<f;e++)v+=`\n vec4 xTexelC${2*e};\n vec4 xC${e};`;for(let e=0;e<m;e++){for(let e=0;e<f;e++)v+=`\n xTexelC${2*e} = vec4(0.0);\n xC${e} = vec4(0.0);`;v+=`\n xR = xRCorner + ${e*d};\n if (xR >=0 && xR < ${a}) {\n `;for(let t=0;t<g/2+1;t++){const n=2*t;if(v+=`\n xC = xCCorner + ${n*p};\n `,1===u){if(n<f&&(c%2==1?(v+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < ${s}) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= ${s}) {\n xTexelC${n}.zw = vec2(0.0);\n }\n }\n `,v+=1===p&&n>0?`\n xC${n} = vec4(xTexelC${n-2}.zw, xTexelC${n}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < ${s}) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= ${s}) {\n previous.zw = vec2(0.0);\n }\n\n xC${n} = vec4(previous.zw, xTexelC${n}.xy);\n } else {\n xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n }\n `):v+=`\n if (xC >= 0 && xC < ${s}) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= ${s}) {\n xTexelC${n}.zw = vec2(0.0);\n }\n }\n\n xC${n} = xTexelC${n};\n `,n+1<f)){const e=c%2==0?nearestLargerEven(p):p;p%2==0&&c%2==1||p%2!=0&&c%2!=1?(v+=`\n xCOffset = xC + ${c%2} + ${e};\n\n if (xCOffset >= 0 && xCOffset < ${s}) {\n xTexelC${n+2} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= ${s}) {\n xTexelC${n+2}.zw = vec2(0.0);\n }\n }\n `,p>1&&(v+=`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < ${s}) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n }\n `),v+=`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+2}.xy);\n `):v+=1===e?`\n xC${n+1} = xTexelC${n};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < ${s}) {\n xTexelC${n+2} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= ${s}) {\n xTexelC${n+2}.zw = vec2(0.0);\n }\n }\n\n xC${n+1} = xTexelC${n+2};\n `}}else n<f&&(c%2==1?(v+=`\n xCOffset = xC + 1 - ${u};\n if(xCOffset >= 0 && xCOffset < ${s}) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= ${s}) {\n xTexelC${n}.zw = vec2(0.0);\n }\n }\n\n if(xC + 1 >= 0 && xC + 1 < ${s}) {\n xTexelC${n+2} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= ${s}) {\n xTexelC${n+2}.zw = vec2(0.0);\n }\n }\n\n xC${n} = vec4(xTexelC${n}.zw, xTexelC${n+2}.zw);\n `,n+1<f&&(v+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + ${u};\n if(xCOffset >= 0 && xCOffset < ${s}) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${n+1} = vec4(xTexelC${n+2}.xy, final.xy);\n `)):(v+=`\n if(xC >= 0 && xC < ${s}) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= ${s}) {\n xTexelC${n}.zw = vec2(0.0);\n }\n }\n\n xCOffset = xC + ${u};\n if(xCOffset >= 0 && xCOffset < ${s}) {\n xTexelC${n+2} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= ${s}) {\n xTexelC${n+2}.zw = vec2(0.);\n }\n }\n\n xC${n} = vec4(\n xTexelC${n}.xy, xTexelC${n+2}.xy);\n `,n+1<f&&(v+=`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+2}.zw);\n `)));n<f&&(v+=`\n wTexel = getW(${e}, ${n}, d1, q);\n dotProd += xC${n} * vec4(wTexel.xz, wTexel.xz);\n `,n+1<f&&(v+=`\n wTexel = getW(${e}, ${n+1}, d1, q);\n dotProd += xC${n+1} * vec4(wTexel.xz, wTexel.xz);\n `))}v+="\n }\n "}let y="",b="";n&&(y=i?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:r?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,b="result = activation(result);");const _=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${y}\n\n const ivec2 strides = ivec2(${h}, ${u});\n const ivec2 pads = ivec2(${l}, ${c});\n\n void main() {\n\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${o};\n int q = d2 - d1 * ${o};\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${v}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${_}\n ${b}\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function depthwiseConv2dNative(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o}=t,{strides:a,pad:s,dilations:l,dimRoundingMode:c}=i;let h=l;null==h&&(h=[1,1]),assert$1(eitherStridesOrDilationsAreOne(a,h),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${h}'`));const u=computeConv2DInfo(r.shape,o.shape,a,h,s,c,!0);let d;return d=env().getBool("WEBGL_PACK_DEPTHWISECONV")&&u.strideWidth<=2&&u.outChannels/u.inChannels==1?new DepthwiseConvPacked2DProgram(u):new DepthwiseConv2DProgram(u),n.runWebGLProgram(d,[r,o],"float32")}const depthwiseConv2dNativeConfig={kernelName:DepthwiseConv2dNative,backendName:"webgl",kernelFunc:depthwiseConv2dNative}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class DepthwiseConv2DDerFilterProgram{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * ${e.outChannels/e.inChannels} + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${e.strideHeight} - ${e.padInfo.top};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${e.strideWidth} - ${e.padInfo.left};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class DepthwiseConv2DDerInputProgram{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,i=e.outChannels/e.inChannels;this.userCode=`\n const ivec2 pads = ivec2(${t-1-e.padInfo.top}, ${n-1-e.padInfo.left});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < ${i}; dm++) {\n int d2 = d1 * ${i} + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function depthwiseConv2dNativeBackpropFilter(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,dy:o}=t,{strides:a,dilations:s,pad:l,dimRoundingMode:c,filterShape:h}=i,u=computeConv2DInfo(r.shape,h,a,s,l,c,!0),d=new DepthwiseConv2DDerFilterProgram(u);return n.runWebGLProgram(d,[r,o],"float32")}const depthwiseConv2dNativeBackpropFilterConfig={kernelName:DepthwiseConv2dNativeBackpropFilter,backendName:"webgl",kernelFunc:depthwiseConv2dNativeBackpropFilter}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function depthwiseConv2dNativeBackpropInput(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,filter:o}=t,{strides:a,dilations:s,pad:l,dimRoundingMode:c,inputShape:h}=i,u=computeConv2DInfo(h,o.shape,a,s,l,c,!0),d=new DepthwiseConv2DDerInputProgram(u);return n.runWebGLProgram(d,[r,o],"float32")}const depthwiseConv2dNativeBackpropInputConfig={kernelName:DepthwiseConv2dNativeBackpropInput,backendName:"webgl",kernelFunc:depthwiseConv2dNativeBackpropInput}; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class DiagProgram{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function diag(e){const{inputs:t,backend:n}=e,{x:i}=t,r=[...i.shape,...i.shape],o=sizeFromShape(i.shape),a=reshape({inputs:{x:i},backend:n,attrs:{shape:[o]}}),s=new DiagProgram(o),l=n.runWebGLProgram(s,[a],a.dtype),c=reshape({inputs:{x:l},backend:n,attrs:{shape:r}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(l),c}const diagConfig={kernelName:Diag,backendName:"webgl",kernelFunc:diag}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class Dilation2DProgram{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:n,padInfo:i,strideHeight:r,strideWidth:o,filterHeight:a,filterWidth:s,dilationHeight:l,dilationWidth:c}=e,{top:h,left:u}=i;this.userCode=`\n const ivec2 strides = ivec2(${r}, ${o});\n const ivec2 pads = ivec2(${h}, ${u});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${a}; h++) {\n int hIn = hBeg + h * ${l};\n\n if (hIn >= 0 && hIn < ${t}) {\n for (int w = 0; w < ${s}; w++) {\n int wIn = wBeg + w * ${c};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function dilation2D(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o}=t,{strides:a,pad:s,dilations:l}=i,c=computeDilation2DInfo(r.shape,o.shape,a,s,"NHWC",l);let h;const u=new Dilation2DProgram(c);h=n.runWebGLProgram(u,[r,o],"float32");const d=reshape({inputs:{x:h},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(h),d}const dilation2DConfig={kernelName:Dilation2D,backendName:"webgl",kernelFunc:dilation2D}; /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function einsum(e){const{inputs:t,backend:n,attrs:i}=e,{equation:r}=i,o=t,{allDims:a,summedDims:s,idDims:l}=decodeEinsumEquation(r,o.length);checkEinsumDimSizes(a.length,l,o);const{path:c,steps:h}=getEinsumComputePath(s,l),u=h.length;let d=null,p=a.length;const m=[];for(let e=0;e<u;++e){for(const t of h[e]){const{permutationIndices:e,expandDims:i}=getEinsumPermutation(p,l[t]);let r;isIdentityPermutation(e)?r=o[t]:(r=transpose({inputs:{x:o[t]},backend:n,attrs:{perm:e}}),m.push(r));const a=r.shape.slice();for(let e=0;e<i.length;++e)a.splice(i[e],0,1);arraysEqual$1(r.shape,a)||(r=reshape({inputs:{x:r},backend:n,attrs:{shape:a}}),m.push(r)),null===d?d=r:(d=multiply({inputs:{a:r,b:d},backend:n}),m.push(d))}e<u-1&&(c[e]>=0&&(d=sum({inputs:{x:d},backend:n,attrs:{axis:c[e]-(a.length-p),keepDims:!1}}),m.push(d)),p--)}for(const e of m)e!==d&&n.disposeIntermediateTensorInfo(e);return d}const einsumConfig={kernelName:Einsum,backendName:"webgl",kernelFunc:einsum},ELU="return (x >= 0.0) ? x : (exp(x) - 1.0);",ELU_PACKED="\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n",elu=unaryKernelFunc({opSnippet:ELU,packedOpSnippet:ELU_PACKED}),eluConfig={kernelName:Elu,backendName:"webgl",kernelFunc:elu},ELU_DER="return (b >= 1.0) ? a : a * (b + 1.0);",ELU_DER_PACKED="\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",eluGrad=e=>{const{inputs:t,backend:n}=e,{dy:i,y:r}=t,o=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new BinaryOpPackedProgram(ELU_DER_PACKED,i.shape,r.shape):new BinaryOpProgram(ELU_DER,i.shape,r.shape);return n.runWebGLProgram(o,[i,r],i.dtype)},eluGradConfig={kernelName:EluGrad,backendName:"webgl",kernelFunc:eluGrad},PACKED_EQUAL="\n return vec4(equal(a, b));\n",EQUAL="return float(a == b);",equal=binaryKernelFunc({opSnippet:EQUAL,packedOpSnippet:PACKED_EQUAL,dtype:"bool"}),equalConfig={kernelName:Equal,backendName:"webgl",kernelFunc:equal},ERF=`\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = ${ERF_P};\n float a1 = ${ERF_A1};\n float a2 = ${ERF_A2};\n float a3 = ${ERF_A3};\n float a4 = ${ERF_A4};\n float a5 = ${ERF_A5};\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n`,erf=unaryKernelFunc({opSnippet:ERF}),erfConfig={kernelName:Erf,backendName:"webgl",kernelFunc:erf},EXP="return exp(x);",exp=unaryKernelFunc({opSnippet:EXP,packedOpSnippet:EXP,cpuKernelImpl:expImplCPU}),expConfig={kernelName:Exp,backendName:"webgl",kernelFunc:exp}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function expandDims(e){const{inputs:t,attrs:n,backend:i}=e,{dim:r}=n,{input:o}=t,a=o.shape.length,s=o.shape.slice();let l=r;return r<0&&(assert$1(-(a+1)<=r,(()=>`Axis must be in the interval [${-(a+1)}, ${a}]`)),l=a+r+1),s.splice(l,0,1),reshape({inputs:{x:o},backend:i,attrs:{shape:s}})}const expandDimsConfig={kernelName:ExpandDims,backendName:"webgl",kernelFunc:expandDims},EXPM1="return exp(x) - 1.0;",expm1=unaryKernelFunc({opSnippet:EXPM1,packedOpSnippet:EXPM1,cpuKernelImpl:expm1ImplCPU}),expm1Config={kernelName:Expm1,backendName:"webgl",kernelFunc:expm1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class FFTProgram{constructor(e,t,n){this.variableNames=["real","imag"];const i=t[1];this.outputShape=t;const r=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,o=n?`${i}.0`:"1.0";let a;if("real"===e)a="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);a="return real * expI + imag * expR;"}this.userCode=`\n const float exponentMultiplier = ${r};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${a}\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(${i});\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ${i}; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / ${o};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fftImpl(e,t,n){const i=n.texData.get(e.dataId),r=sizeFromShape(e.shape),o=e.shape[e.shape.length-1],a=reshape({inputs:{x:e},backend:n,attrs:{shape:[r/o,o]}}),s=a.shape,l=new FFTProgram("real",s,t),c=new FFTProgram("imag",s,t),h=[{dataId:i.complexTensorInfos.real.dataId,dtype:i.complexTensorInfos.real.dtype,shape:s},{dataId:i.complexTensorInfos.imag.dataId,dtype:i.complexTensorInfos.imag.dtype,shape:s}],u=n.runWebGLProgram(l,h,"float32"),d=n.runWebGLProgram(c,h,"float32"),p=complex({inputs:{real:u,imag:d},backend:n});n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d);const m=reshape({inputs:{x:p},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(p),m} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fft(e){const{inputs:t,backend:n}=e,{input:i}=t;return fftImpl(i,!1,n)}const fftConfig={kernelName:FFT,backendName:"webgl",kernelFunc:fft}; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class FillProgram{constructor(e,t){this.outputShape=[],this.variableNames=["x"],this.outputShape=e,this.userCode="\n uniform float value;\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}getCustomSetupFunc(e){return(t,n)=>{null==this.valueLoc&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fill(e){const{backend:t,attrs:n}=e,{shape:i,value:r}=n;let{dtype:o}=n;if(o=o||inferDtype(r),"string"===o){const e=getArrayFromDType(o,sizeFromShape(i));return e.fill(r),t.makeTensorInfo(i,o,e)}{const e=new FillProgram(i,r),n=e.getCustomSetupFunc(r);return t.runWebGLProgram(e,[],o,n)}}const fillConfig={kernelName:Fill,backendName:"webgl",kernelFunc:fill}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class FlipLeftRightProgram{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${t} - x;\n float outputValue;\n if(coordX >= 0 && coordX < ${t}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const flipLeftRightConfig={kernelName:FlipLeftRight,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,i=t,r=new FlipLeftRightProgram(n.shape);return i.runWebGLProgram(r,[n],n.dtype)}},FLOOR="return floor(x);",floor=unaryKernelFunc({opSnippet:FLOOR,packedOpSnippet:FLOOR,cpuKernelImpl:floorImplCPU}),floorConfig={kernelName:Floor,backendName:"webgl",kernelFunc:floor},INT_DIV="\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n",INT_DIV_PACKED="\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n",floorDiv=binaryKernelFunc({opSnippet:INT_DIV,packedOpSnippet:INT_DIV_PACKED,dtype:"int32"}),floorDivConfig={kernelName:FloorDiv,backendName:"webgl",kernelFunc:floorDiv}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class FromPixelsProgram{constructor(e){this.variableNames=["A"];const t=getGlslDifferences(),[n,i]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${i}.0, ${n}.0);\n\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class FromPixelsPackedProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=getGlslDifferences(),[n,i]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${i}.0, ${n}.0);\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${t.output} = result;\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const fromPixelsConfig={kernelName:FromPixels,backendName:"webgl",kernelFunc:fromPixels};let fromPixels2DContext;function fromPixels(e){const{inputs:t,backend:n,attrs:i}=e;let{pixels:r}=t;const{numChannels:o}=i,a="undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement,s="undefined"!=typeof HTMLImageElement&&r instanceof HTMLImageElement,[l,c]=a?[r.videoWidth,r.videoHeight]:[r.width,r.height],h=[c,l],u=[c,l,o];(s||a)&&(null==fromPixels2DContext&&(fromPixels2DContext=document.createElement("canvas").getContext("2d")),fromPixels2DContext.canvas.width=l,fromPixels2DContext.canvas.height=c,fromPixels2DContext.drawImage(r,0,0,l,c),r=fromPixels2DContext.canvas);const d=n.makeTensorInfo(h,"int32");n.texData.get(d.dataId).usage=TextureUsage.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),r);const p=env().getBool("WEBGL_PACK")?new FromPixelsPackedProgram(u):new FromPixelsProgram(u),m=n.runWebGLProgram(p,[d],"int32");return n.disposeData(d.dataId),m} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fusedConv2d(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o,bias:a,preluActivationWeights:s}=t,{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d,activation:p,leakyreluAlpha:m}=i,f=convertConv2DDataFormat(h),g=computeConv2DInfo(r.shape,o.shape,l,u,c,d,!1,f);let v;const y=[];if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(env().getBool("WEBGL_CONV_IM2COL")&&1===r.shape[0])v=conv2dWithIm2Row({x:r,filter:o,convInfo:g,backend:n,bias:a,activation:p,preluActivationWeights:s,leakyreluAlpha:m});else{const e=null!=a,t=null!=s,i="leakyrelu"===p,l=p?mapActivationToShaderProgram(p,!1):null,c=new Conv2DProgram(g,e,l,t,i),h=[r,o];if(a&&h.push(a),s&&h.push(s),i){const e=n.makeTensorInfo([],"float32",createScalarValue(m,"float32"));h.push(e),y.push(e)}v=n.runWebGLProgram(c,h,"float32")}else v=conv2dByMatMul({x:r,filter:o,convInfo:g,backend:n,bias:a,activation:p,preluActivationWeights:s,leakyreluAlpha:m});const b=reshape({inputs:{x:v},backend:n,attrs:{shape:g.outShape}});return y.push(v),y.forEach((e=>n.disposeIntermediateTensorInfo(e))),b}const fusedConv2DConfig={kernelName:FusedConv2D,backendName:"webgl",kernelFunc:fusedConv2d}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function fusedDepthwiseConv2D(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,filter:o,bias:a,preluActivationWeights:s}=t,{strides:l,pad:c,dilations:h,dimRoundingMode:u,activation:d,leakyreluAlpha:p}=i,m=[];let f=h;null==f&&(f=[1,1]),assert$1(eitherStridesOrDilationsAreOne(l,f),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${f}'`));const g=computeConv2DInfo(r.shape,o.shape,l,f,c,u,!0),v=env().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,y=d?mapActivationToShaderProgram(d,v):null,b=[r,o],_=null!=a,x=null!=s,w="leakyrelu"===d;if(_&&b.push(a),x&&b.push(s),w){const e=n.makeTensorInfo([],"float32",createScalarValue(p,"float32"));b.push(e),m.push(e)}let S;S=v?new DepthwiseConvPacked2DProgram(g,_,y,x,w):new DepthwiseConv2DProgram(g,_,y,x,w);const C=n.runWebGLProgram(S,b,"float32");return m.forEach((e=>n.disposeIntermediateTensorInfo(e))),C}const fusedDepthwiseConv2DConfig={kernelName:FusedDepthwiseConv2D,backendName:"webgl",kernelFunc:fusedDepthwiseConv2D};class GatherNDProgram{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;const i=getCoordsDataType(t.length),r=getCoordsDataType(n.length);this.userCode=`\n ${i} strides = ${i}(${this.strides});\n void main() {\n ${r} coords = getOutputCoords();\n int flattenIndex = 0;\n for (int j = 0; j < ${this.sliceDim}; j++) {\n int index = round(getIndices(coords[0], j));\n flattenIndex += index * ${this.sliceDim>1?"strides[j]":"strides"};\n }\n setOutput(getX(flattenIndex, coords[1]));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function gatherNd(e){const{inputs:t,backend:n}=e,{params:i,indices:r}=t,o=r.shape,a=o[o.length-1],[s,l,c,h]=prepareAndValidate(i,r),u=reshape({inputs:{x:r},backend:n,attrs:{shape:[l,a]}}),d=reshape({inputs:{x:i},backend:n,attrs:{shape:[sizeFromShape(i.shape)/c,c]}}),p=new GatherNDProgram(a,h,[l,c]),m=n.runWebGLProgram(p,[d,u],d.dtype),f=reshape({inputs:{x:m},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),f}const gatherNdConfig={kernelName:GatherNd,backendName:"webgl",kernelFunc:gatherNd}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class GatherProgram{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const n=getCoordsDataType(this.rank),i=getSourceCoords$1(e);this.userCode=`\n void main() {\n ${n} resRC = getOutputCoords();\n setOutput(getA(${i}));\n }\n `}}function getSourceCoords$1(e,t){const n=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[];for(let t=0;t<e.length;t++)i.push(2===t?"int(getIndices(resRC.x, resRC.z))":`${n[t]}`);return i.join()} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function gatherV2(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,indices:o}=t,{axis:a,batchDims:s}=i,l=collectGatherOpShapeInfo(r,o,parseAxisParam(a,r.shape)[0],s),c=sizeFromShape(o.shape),h=[],u=reshape({inputs:{x:r},backend:n,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),d=reshape({inputs:{x:o},backend:n,attrs:{shape:[l.batchSize,c/l.batchSize]}});h.push(u),h.push(d);const p=[l.batchSize,l.outerSize,c/l.batchSize,l.sliceSize];if(n.shouldExecuteOnCPU([r,o])||"string"===r.dtype){const e=n.bufferSync(d),t=n.bufferSync(u),i=gatherV2ImplCPU(t,e,p);return h.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(l.outputShape,i.dtype,i.values)}const m=new GatherProgram(u.shape,p),f=n.runWebGLProgram(m,[u,d],u.dtype);h.push(f);const g=reshape({inputs:{x:f},backend:n,attrs:{shape:l.outputShape}});return h.forEach((e=>n.disposeIntermediateTensorInfo(e))),g}const gatherV2Config={kernelName:GatherV2,backendName:"webgl",kernelFunc:gatherV2},GREATER="return float(a > b);",GREATER_PACKED="\n return vec4(greaterThan(a, b));\n",greater=binaryKernelFunc({opSnippet:GREATER,packedOpSnippet:GREATER_PACKED,cpuKernelImpl:greaterImplCPU,dtype:"bool"}),greaterConfig={kernelName:Greater,backendName:"webgl",kernelFunc:greater},GREATER_EQUAL="return float(a >= b);",GREATER_EQUAL_PACKED="\n return vec4(greaterThanEqual(a, b));\n",greaterEqual=binaryKernelFunc({opSnippet:GREATER_EQUAL,packedOpSnippet:GREATER_EQUAL_PACKED,dtype:"bool"}),greaterEqualConfig={kernelName:GreaterEqual,backendName:"webgl",kernelFunc:greaterEqual}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function ifft(e){const{inputs:t,backend:n}=e,{input:i}=t;return fftImpl(i,!0,n)}const ifftConfig={kernelName:IFFT,backendName:"webgl",kernelFunc:ifft},IS_FINITE="return float(!isnan(x) && !isinf(x));",isFinite$1=unaryKernelFunc({opSnippet:IS_FINITE,dtype:"bool"}),isFiniteConfig={kernelName:IsFinite,backendName:"webgl",kernelFunc:isFinite$1},IS_INF="return float(isinf(x));",isInf=unaryKernelFunc({opSnippet:IS_INF,dtype:"bool"}),isInfConfig={kernelName:IsInf,backendName:"webgl",kernelFunc:isInf},IS_NAN="return float(isnan(x));",isNaN$1=unaryKernelFunc({opSnippet:IS_NAN,dtype:"bool"}),isNaNConfig={kernelName:IsNan,backendName:"webgl",kernelFunc:isNaN$1},LESS="return float(a < b);",LESS_PACKED="\n return vec4(lessThan(a, b));\n",less=binaryKernelFunc({opSnippet:LESS,packedOpSnippet:LESS_PACKED,cpuKernelImpl:lessImplCPU,dtype:"bool"}),lessConfig={kernelName:Less,backendName:"webgl",kernelFunc:less},LESS_EQUAL="return float(a <= b);",LESS_EQUAL_PACKED="\n return vec4(lessThanEqual(a, b));\n",lessEqual=binaryKernelFunc({opSnippet:LESS_EQUAL,packedOpSnippet:LESS_EQUAL_PACKED,dtype:"bool"}),lessEqualConfig={kernelName:LessEqual,backendName:"webgl",kernelFunc:lessEqual}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function linSpace(e){const{backend:t,attrs:n}=e,{start:i,stop:r,num:o}=n,a=linSpaceImplCPU(i,r,o);return t.makeTensorInfo([a.length],"float32",a)}const linSpaceConfig={kernelName:LinSpace,backendName:"webgl",kernelFunc:linSpace},LOG="if (x < 0.0) return NAN;\n return log(x);",LOG_PACKED="\n vec4 result = log(x);\n vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n result.r = isNaN.r == 1.0 ? NAN : result.r;\n result.g = isNaN.g == 1.0 ? NAN : result.g;\n result.b = isNaN.b == 1.0 ? NAN : result.b;\n result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n return result;\n",log=unaryKernelFunc({opSnippet:LOG,packedOpSnippet:LOG_PACKED,cpuKernelImpl:logImplCPU}),logConfig={kernelName:Log,backendName:"webgl",kernelFunc:log},LOG1P="return log(1.0 + x);",log1p=unaryKernelFunc({opSnippet:LOG1P}),log1pConfig={kernelName:Log1p,backendName:"webgl",kernelFunc:log1p},LOGICAL_AND="return float(a >= 1.0 && b >= 1.0);",LOGICAL_AND_PACKED="\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n",logicalAnd=binaryKernelFunc({opSnippet:LOGICAL_AND,packedOpSnippet:LOGICAL_AND_PACKED,dtype:"bool"}),logicalAndConfig={kernelName:LogicalAnd,backendName:"webgl",kernelFunc:logicalAnd},LOGICAL_NOT="return float(!(x >= 1.0));",logicalNot=unaryKernelFunc({opSnippet:LOGICAL_NOT}),logicalNotConfig={kernelName:LogicalNot,backendName:"webgl",kernelFunc:logicalNot},LOGICAL_OR="return float(a >= 1.0 || b >= 1.0);",LOGICAL_OR_PACKED="\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n",logicalOr=binaryKernelFunc({opSnippet:LOGICAL_OR,packedOpSnippet:LOGICAL_OR_PACKED,dtype:"bool"}),logicalOrConfig={kernelName:LogicalOr,backendName:"webgl",kernelFunc:logicalOr}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class LRNProgram{constructor(e,t,n,i,r){this.variableNames=["x"],this.outputShape=[];const o=t,a=e[3]-1;let s;this.outputShape=e;const l=`float(${n}) + float(${i}) * sum`;s=.5===r?`inversesqrt(${l})`:1===r?`1.0/(${l})`:`exp(log(${l}) * float(-${r}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -${o}; j <= ${o}; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ${a}) {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ${s};\n setOutput(val);\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class LRNPackedProgram{constructor(e,t,n,i,r){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const o=t,a=e[3]-1;let s;this.outputShape=e;const l=`float(${n}) + float(${i}) * sum`;s=.5===r?`inversesqrt(${l})`:1===r?`1.0/(${l})`:`exp(log(${l}) * float(-${r}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < ${this.outputShape[3]};\n bool hasNextRow = c < ${this.outputShape[2]};\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - ${o};\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - ${o}; j <= ${o}; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${a}));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * ${s};\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const lrn=e=>{const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{depthRadius:o,bias:a,alpha:s,beta:l}=i,c=env().getBool("WEBGL_PACK_NORMALIZATION")?new LRNPackedProgram(r.shape,o,a,s,l):new LRNProgram(r.shape,o,a,s,l);return n.runWebGLProgram(c,[r],r.dtype)},LRNConfig={kernelName:LRN,backendName:"webgl",kernelFunc:lrn}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class LRNGradProgram{constructor(e,t,n,i,r){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=i,this.beta=r,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < ${this.depth}; ++d) {\n int depthBegin = int(max(0.0, float(d - ${t})));\n int depthEnd = int(min(float(${this.depth}),\n float(d + ${t} + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = ${this.depth};\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float(${i}) * norm + float(${n});\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float(${i})\n * float(${r})\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${r});\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const lrnGrad=e=>{const{inputs:t,backend:n,attrs:i}=e,{x:r,y:o,dy:a}=t,{depthRadius:s,bias:l,alpha:c,beta:h}=i,u=new LRNGradProgram(r.shape,s,l,c,h);return n.runWebGLProgram(u,[r,o,a],r.dtype)},LRNGradConfig={kernelName:LRNGrad,backendName:"webgl",kernelFunc:lrnGrad}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function maxImpl(e,t,n,i){const r=sizeFromShape(t),o=reshape({inputs:{x:e},attrs:{shape:[sizeFromShape(e.shape)/r,r]},backend:i}),a=reduce(o,e.dtype,"max",i),s=reshape({inputs:{x:a},attrs:{shape:n},backend:i});return i.disposeIntermediateTensorInfo(o),i.disposeIntermediateTensorInfo(a),s} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function max(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{reductionIndices:o,keepDims:a}=i,s=r.shape.length,l=parseAxisParam(o,r.shape);let c=l;const h=getAxesPermutation(c,s),u=null!=h,d=n.shouldExecuteOnCPU([r]);let p=r;if(u){if(d){const e=n.texData.get(p.dataId).values,t=new Array(s);for(let e=0;e<t.length;e++)t[e]=r.shape[h[e]];const i=transposeImplCPU(e,r.shape,r.dtype,h,t);p=n.makeTensorInfo(t,r.dtype),n.texData.get(p.dataId).values=i}else p=transposeImpl(r,h,n);c=getInnerMostAxes(c.length,s)}assertAxesAreInnerMostDims("max",c,s);const[m,f]=computeOutAndReduceShapes(p.shape,c);let g,v=m;if(a&&(v=expandShapeToKeepDim(m,l)),d){const e=n.texData.get(p.dataId),t=maxImplCPU(e.values,sizeFromShape(f),v,r.dtype);g=n.makeTensorInfo(v,r.dtype),n.texData.get(g.dataId).values=t}else g=maxImpl(p,f,v,n);return u&&n.disposeIntermediateTensorInfo(p),g}const maxConfig={kernelName:Max,backendName:"webgl",kernelFunc:max},MAXIMUM=CHECK_NAN_SNIPPET$1+"\n return max(a, b);\n",MAXIMUM_PACKED="\n vec4 result = vec4(max(a, b));\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n "+CHECK_NAN_SNIPPET+"\n return result;\n",maximum=binaryKernelFunc({opSnippet:MAXIMUM,packedOpSnippet:MAXIMUM_PACKED,cpuKernelImpl:maximumImplCPU}),maximumConfig={kernelName:Maximum,backendName:"webgl",kernelFunc:maximum}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function maxPool(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t;assertNotComplex(r,"maxPool");const{filterSize:o,strides:a,pad:s,dimRoundingMode:l}=i;assert$1(eitherStridesOrDilationsAreOne(a,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const c=computePool2DInfo(r.shape,o,a,1,s,l);if(1===c.filterWidth&&1===c.filterHeight&&arraysEqual$1(c.inShape,c.outShape))return identity$2({inputs:{x:r},backend:n});const h=new Pool2DProgram(c,"max",!1);return n.runWebGLProgram(h,[r],r.dtype)}const maxPoolConfig={kernelName:MaxPool,backendName:"webgl",kernelFunc:maxPool}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPool3d(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{filterSize:o,strides:a,pad:s,dataFormat:l,dimRoundingMode:c}=i,h=computePool3DInfo(r.shape,o,a,[1,1,1],s,c,l),u=new Pool3DProgram(h,"max",!1);return n.runWebGLProgram(u,[r],r.dtype)}const maxPool3DConfig={kernelName:MaxPool3D,backendName:"webgl",kernelFunc:maxPool3d}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class MaxPool2DBackpropProgram{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.effectiveFilterHeight,n=e.effectiveFilterWidth;this.userCode=`\n const ivec2 pads = ivec2(${t-1-e.padInfo.top}, ${n-1-e.padInfo.left});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t};\n wR += ${e.dilationHeight}) {\n float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = ${t*n-1} - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * ${n} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n `}}class MaxPool3DBackpropProgram{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.effectiveFilterDepth,n=e.effectiveFilterHeight,i=e.effectiveFilterWidth;this.userCode=`\n const ivec3 pads = ivec3(${t-1-e.padInfo.front}, ${n-1-e.padInfo.top}, ${i-1-e.padInfo.left});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${t};\n wD += ${e.dilationDepth}) {\n float dyD = float(dyDCorner + wD) / ${e.strideDepth}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${n};\n wR += ${e.dilationHeight}) {\n float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${i};\n wC += ${e.dilationWidth}) {\n float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = ${t*n*i-1} -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * ${n} * ${i} +\n wR * ${i} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPool3DGrad(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,input:o}=t,a=o,{filterSize:s,strides:l,pad:c,dimRoundingMode:h}=i,u=computePool3DInfo(a.shape,s,l,[1,1,1],c,h),d=new Pool3DProgram(u,"max",!0),p=n.runWebGLProgram(d,[a],a.dtype),m=new MaxPool3DBackpropProgram(u),f=n.runWebGLProgram(m,[r,p],a.dtype);return n.disposeIntermediateTensorInfo(p),f}const maxPoolGrad3DConfig={kernelName:MaxPool3DGrad,backendName:"webgl",kernelFunc:maxPool3DGrad}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPoolGrad(e){const{inputs:t,backend:n,attrs:i}=e,{dy:r,input:o,output:a}=t,s=o;assertNotComplex([o,a],"maxPoolGrad");const{filterSize:l,strides:c,pad:h,dimRoundingMode:u}=i,d=computePool2DInfo(s.shape,l,c,1,h,u),p=new Pool2DProgram(d,"max",!0),m=n.runWebGLProgram(p,[s],s.dtype),f=new MaxPool2DBackpropProgram(d),g=n.runWebGLProgram(f,[r,m],s.dtype);return n.disposeIntermediateTensorInfo(m),g}const maxPoolGradConfig={kernelName:MaxPoolGrad,backendName:"webgl",kernelFunc:maxPoolGrad}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function maxPoolWithArgmaxImpl(e,t,n,i){let r=new Pool2DProgram(n,"max",!1);const o=i.runWebGLProgram(r,[e],"float32");return r=new Pool2DProgram(n,"max",!0,!0,t),[o,i.runWebGLProgram(r,[e],"float32")]} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const maxPoolWithArgmaxConfig={kernelName:MaxPoolWithArgmax,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:i}=e,{filterSize:r,strides:o,pad:a,includeBatchInIndex:s}=t,l=n;assert$1(4===i.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${i.shape.length}.`));const c=[1,1];assert$1(eitherStridesOrDilationsAreOne(o,c),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`));const h=computePool2DInfo(i.shape,r,o,c,a),[u,d]=maxPoolWithArgmaxImpl(i,s,h,l);return[u,d]}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function meanImpl(e,t,n,i){const r=sizeFromShape(t),o=reshape({inputs:{x:e},attrs:{shape:[sizeFromShape(e.shape)/r,r]},backend:i}),a=reduce(o,"float32","mean",i),s=reshape({inputs:{x:a},attrs:{shape:n},backend:i});return i.disposeIntermediateTensorInfo(o),i.disposeIntermediateTensorInfo(a),s} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const meanConfig={kernelName:Mean,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:i}=e,{keepDims:r,axis:o}=t,a=n,s=i.shape.length,l=parseAxisParam(o,i.shape);let c=l;const h=getAxesPermutation(c,s),u=null!=h,d=a.shouldExecuteOnCPU([i]),p=[];let m=i;if(u){if(d){const e=a.texData.get(m.dataId).values,t=new Array(s);for(let e=0;e<t.length;e++)t[e]=i.shape[h[e]];const n=transposeImplCPU(e,i.shape,i.dtype,h,t);m=a.makeTensorInfo(t,i.dtype),a.texData.get(m.dataId).values=n}else m=transposeImpl(i,h,a);p.push(m),c=getInnerMostAxes(c.length,s)}assertAxesAreInnerMostDims("sum",c,s);const[f,g]=computeOutAndReduceShapes(m.shape,c);let v=f;r&&(v=expandShapeToKeepDim(f,l));const y=meanImpl(m,g,v,a);for(const e of p)a.disposeIntermediateTensorInfo(e);return y}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function min(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i,s=r.shape.length,l=parseAxisParam(o,r.shape);let c=l;const h=getAxesPermutation(c,s);let u=r;null!=h&&(u=transpose({inputs:{x:r},backend:n,attrs:{perm:h}}),c=getInnerMostAxes(c.length,r.shape.length)),assertAxesAreInnerMostDims("min",c,s);const[d,p]=computeOutAndReduceShapes(u.shape,c),m=reshape({inputs:{x:u},backend:n,attrs:{shape:[-1,sizeFromShape(p)]}}),f=reduce(m,m.dtype,"min",n);let g;return g=reshape(a?{inputs:{x:f},backend:n,attrs:{shape:expandShapeToKeepDim(d,l)}}:{inputs:{x:f},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),null!=h&&n.disposeIntermediateTensorInfo(u),g}const minConfig={kernelName:Min,backendName:"webgl",kernelFunc:min},MINIMUM=CHECK_NAN_SNIPPET$1+"\n return min(a, b);\n",MINIMUM_PACKED="\n vec4 result = vec4(min(a, b));\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n "+CHECK_NAN_SNIPPET+"\n return result;\n",minimum=binaryKernelFunc({opSnippet:MINIMUM,packedOpSnippet:MINIMUM_PACKED,cpuKernelImpl:minimumImplCPU}),minimumConfig={kernelName:Minimum,backendName:"webgl",kernelFunc:minimum}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class MirrorPadProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const i=e.length,r=getCoordsDataType(i),o=t.map((e=>e[0])).join(","),a=t.map(((t,n)=>t[0]+e[n])).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,i),l="reflect"===n?0:1;this.userCode=1!==i?`\n ${r} start = ${r}(${o});\n ${r} end = ${r}(${a});\n\n void main() {\n ${r} outC = getOutputCoords();\n for (int i = 0; i < ${i}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${l};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${l};\n }\n }\n ${r} coords = outC - start;\n setOutput(getX(${s}));\n }\n `:`\n int start = ${o};\n int end = ${a};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${l};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${l};\n }\n setOutput(getX(outC - start));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class MirrorPadPackedProgram{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const i=e.length,r=getCoordsDataType(i),o=t.map((e=>e[0])).join(","),a=t.map(((t,n)=>t[0]+e[n])).join(","),s=getChannels("rc",i),l=getChannels("source",i),c=`${s[i-1]} < ${this.outputShape[i-1]}`,h=1===i?"source":`vec2(${l.slice(-2).join()})`,u="reflect"===n?0:1;let d="";if(1===i){const e=`\n ${r} source = rc;\n if (source < start) {\n source = start * 2 - source - ${u};\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ${u};\n }\n source -= start;\n `;d=`\n ${r} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${l.join()}), ${h});\n ${s[i-1]} += 1;\n if(${c}) {\n ${e}\n result[1] = getChannel(getX(${l.join()}), ${h});\n }\n `}else{const e=`\n ${r} source = rc;\n ${r} lt = ${r}(lessThan(source, start));\n ${r} gte = ${r}(greaterThanEqual(source, end));\n ${r} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${u}) +\n gte * ((end - 1) * 2 - source + ${u});\n source -= start;\n `;d=`\n ${r} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${l.join()}), ${h});\n ${s[i-1]} += 1;\n if(${c}) {\n ${e}\n result[1] = getChannel(getX(${l.join()}), ${h});\n }\n rc = outputLoc;\n ${s[i-2]} += 1;\n if(${s[i-2]} < ${this.outputShape[i-2]}) {\n ${e}\n result[2] = getChannel(getX(${l.join()}), ${h});\n ${s[i-1]} += 1;\n if(${c}) {\n ${e}\n result[3] = getChannel(getX(${l.join()}), ${h});\n }\n }\n `}this.userCode=`\n const ${r} start = ${r}(${o});\n const ${r} end = ${r}(${a});\n\n void main() {\n ${r} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const mirrorPadKernelFunc=({inputs:e,backend:t,attrs:n})=>{const{x:i}=e,{paddings:r,mode:o}=n,a=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new MirrorPadPackedProgram(i.shape,r,o):new MirrorPadProgram(i.shape,r,o);return t.runWebGLProgram(a,[i],i.dtype)},mirrorPadConfig={kernelName:MirrorPad,backendName:"webgl",kernelFunc:mirrorPadKernelFunc},MOD="if (b == 0.0) return NAN;\n return mod(a, b);",MOD_PACKED="\n vec4 result = mod(a, b);\n vec4 isNaN = vec4(equal(b, vec4(0.0)));\n "+CHECK_NAN_SNIPPET+"\n return result;\n",mod=binaryKernelFunc({opSnippet:MOD,packedOpSnippet:MOD_PACKED}),modConfig={kernelName:Mod,backendName:"webgl",kernelFunc:mod}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class MultinomialProgram{constructor(e,t,n){this.variableNames=["probs"],this.outputShape=[e,n],this.userCode=`\n uniform float seed;\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < ${t-1}; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float(${t-1}));\n }\n `}getCustomSetupFunc(e){return(t,n)=>{null==this.seedLoc&&(this.seedLoc=t.getUniformLocation(n,"seed")),t.gl.uniform1f(this.seedLoc,e)}}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const DIV="\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",DIV_PACKED="\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n",realDiv=binaryKernelFunc({opSnippet:DIV,packedOpSnippet:DIV_PACKED,checkOutOfBounds:!0}),realDivConfig={kernelName:RealDiv,backendName:"webgl",kernelFunc:realDiv},SUB="return a - b;",sub$1=binaryKernelFunc({opSnippet:SUB,packedOpSnippet:SUB,supportsComplex:!0,cpuKernelImpl:subImplCPU}),subConfig={kernelName:Sub,backendName:"webgl",kernelFunc:sub$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function softmax(e){const{inputs:t,backend:n,attrs:i}=e,{logits:r}=t,{dim:o}=i,a=parseAxisParam([o],r.shape),s=max({inputs:{x:r},backend:n,attrs:{reductionIndices:a,keepDims:!1}}),l=expandShapeToKeepDim(s.shape,a),c=reshape({inputs:{x:s},backend:n,attrs:{shape:l}}),h=sub$1({inputs:{a:r,b:c},backend:n}),u=exp({inputs:{x:h},backend:n}),d=sum({inputs:{x:u},backend:n,attrs:{axis:a,keepDims:!1}}),p=reshape({inputs:{x:d},backend:n,attrs:{shape:l}}),m=realDiv({inputs:{a:u,b:p},backend:n});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),m}const softmaxConfig={kernelName:Softmax,backendName:"webgl",kernelFunc:softmax}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function multinomial(e){const{inputs:t,backend:n,attrs:i}=e,{logits:r}=t,{numSamples:o,seed:a,normalized:s}=i,l=s?r:softmax({inputs:{logits:r},backend:n,attrs:{dim:r.shape.length-1}}),c=new MultinomialProgram(l.shape[0],l.shape[1],o),h=c.getCustomSetupFunc(a),u=n.runWebGLProgram(c,[l],"int32",h);return s||n.disposeIntermediateTensorInfo(l),u}const multinomialConfig={kernelName:Multinomial,backendName:"webgl",kernelFunc:multinomial},NEG="return -x;"; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function neg(e){const{inputs:t,backend:n}=e,{x:i}=t;if(n.shouldExecuteOnCPU([i])){const e=n.texData.get(i.dataId),[t,r]=negImplCPU(e.values,i.shape,i.dtype);return n.makeTensorInfo(r,i.dtype,t)}let r;return r=env().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new UnaryOpPackedProgram(i.shape,NEG):new UnaryOpProgram(i.shape,NEG),n.runWebGLProgram(r,[i],i.dtype)}const negConfig={kernelName:Neg,backendName:"webgl",kernelFunc:neg},nonMaxSuppressionV3Impl=nonMaxSuppressionV3Impl$2; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function nonMaxSuppressionV3(e){warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:i}=e,{boxes:r,scores:o}=t,{maxOutputSize:a,iouThreshold:s,scoreThreshold:l}=i,c=n.readSync(r.dataId),h=n.readSync(o.dataId),{selectedIndices:u}=nonMaxSuppressionV3Impl(c,h,a,s,l);return n.makeTensorInfo([u.length],"int32",new Int32Array(u))}const nonMaxSuppressionV3Config={kernelName:NonMaxSuppressionV3,backendName:"webgl",kernelFunc:nonMaxSuppressionV3},nonMaxSuppressionV4Impl=nonMaxSuppressionV4Impl$2; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function nonMaxSuppressionV4(e){warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:i}=e,{boxes:r,scores:o}=t,{maxOutputSize:a,iouThreshold:s,scoreThreshold:l,padToMaxOutputSize:c}=i,h=n.readSync(r.dataId),u=n.readSync(o.dataId),{selectedIndices:d,validOutputs:p}=nonMaxSuppressionV4Impl(h,u,a,s,l,c);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([p]))]}const nonMaxSuppressionV4Config={kernelName:NonMaxSuppressionV4,backendName:"webgl",kernelFunc:nonMaxSuppressionV4},nonMaxSuppressionV5Impl=nonMaxSuppressionV5Impl$2; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function nonMaxSuppressionV5(e){warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:i}=e,{boxes:r,scores:o}=t,{maxOutputSize:a,iouThreshold:s,scoreThreshold:l,softNmsSigma:c}=i,h=n.readSync(r.dataId),u=n.readSync(o.dataId),d=a,p=s,m=l,f=c,{selectedIndices:g,selectedScores:v}=nonMaxSuppressionV5Impl(h,u,d,p,m,f);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([v.length],"float32",new Float32Array(v))]}const nonMaxSuppressionV5Config={kernelName:NonMaxSuppressionV5,backendName:"webgl",kernelFunc:nonMaxSuppressionV5}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class OneHotProgram{constructor(e,t,n,i){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(${i}), float(${n}),\n float(index == coords.y)));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const oneHot=e=>{const{inputs:t,backend:n,attrs:i}=e,{indices:r}=t,{depth:o,onValue:a,offValue:s}=i,l=sizeFromShape(r.shape),c=new OneHotProgram(l,o,a,s),h=reshape({inputs:{x:r},backend:n,attrs:{shape:[l]}}),u=n.runWebGLProgram(c,[h],r.dtype);n.disposeIntermediateTensorInfo(h);const d=reshape({inputs:{x:u},backend:n,attrs:{shape:[...r.shape,o]}});return n.disposeIntermediateTensorInfo(u),d},oneHotConfig={kernelName:OneHot,backendName:"webgl",kernelFunc:oneHot}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function zerosLike(e){const{inputs:t,backend:n}=e,{x:i}=t;if("complex64"===i.dtype){const e=real({inputs:{input:i},backend:n}),t=zerosLike({inputs:{x:e},backend:n}),r=imag({inputs:{input:i},backend:n}),o=zerosLike({inputs:{x:r},backend:n}),a=complex({inputs:{real:t,imag:o},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),a}return fill({attrs:{shape:i.shape,dtype:i.dtype,value:"string"===i.dtype?"":0},backend:n})}const zerosLikeConfig={kernelName:ZerosLike,backendName:"webgl",kernelFunc:zerosLike}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function onesLike(e){const{inputs:t,backend:n}=e,{x:i}=t;if("string"===i.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===i.dtype){const e=real({inputs:{input:i},backend:n}),t=onesLike({inputs:{x:e},backend:n}),r=imag({inputs:{input:i},backend:n}),o=zerosLike({inputs:{x:r},backend:n}),a=complex({inputs:{real:t,imag:o},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),a}return fill({attrs:{shape:i.shape,dtype:i.dtype,value:1},backend:n})}const onesLikeConfig={kernelName:OnesLike,backendName:"webgl",kernelFunc:onesLike}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function pack(e){const{inputs:t,backend:n,attrs:i}=e,{axis:r}=i;if(1===t.length)return expandDims({inputs:{input:t[0]},backend:n,attrs:{dim:r}});const o=t[0].shape,a=t[0].dtype;t.forEach((e=>{assertShapesMatch(o,e.shape,"All tensors passed to stack must have matching shapes"),assert$1(a===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const s=[],l=concat({inputs:t.map((e=>{const t=expandDims({inputs:{input:e},backend:n,attrs:{dim:r}});return s.push(t),t})),backend:n,attrs:{axis:r}});return s.forEach((e=>n.disposeIntermediateTensorInfo(e))),l}const packConfig={kernelName:Pack,backendName:"webgl",kernelFunc:pack}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class PadProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const i=e.length,r=getCoordsDataType(i),o=t.map((e=>e[0])).join(","),a=t.map(((t,n)=>t[0]+e[n])).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,i);this.userCode=1!==i?`\n ${r} start = ${r}(${o});\n ${r} end = ${r}(${a});\n uniform float value;\n\n void main() {\n ${r} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${r} coords = outC - start;\n setOutput(getX(${s}));\n }\n }\n `:`\n int start = ${o};\n int end = ${a};\n uniform float value;\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}getCustomSetupFunc(e){return(t,n)=>{null==this.valueLoc&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class PadPackedProgram{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const i=e.length,r=getCoordsDataType(i),o=t.map((e=>e[0])).join(","),a=t.map(((t,n)=>t[0]+e[n])).join(","),s=getChannels("rc",i),l=getChannels("source",i),c=`${s[i-1]} < ${this.outputShape[i-1]}`,h=1===i?"source":`vec2(${l.slice(-2).join()})`,u=[`${r} rc = outputLoc;`,`${s[i-1]} += 1;\n if(${c}) {\n `,1===i?"":`}\n rc = outputLoc;\n ${s[i-2]} += 1;\n if(${s[i-2]} < ${this.outputShape[i-2]}) {`,1===i?"":` ${s[i-1]} += 1;\n if(${c}) {`],d=1===i?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let p="";for(let e=0,t=1===i?2:4;e<t;e++)p+=`\n ${u[e]}\n if (${d}) {\n result[${e}] = float(value);\n } else {\n ${r} source = rc - start;\n result[${e}] = getChannel(getX(${l.join()}), ${h});\n }\n `;p+=1===i?"} ":"}}",this.userCode=`\n const ${r} start = ${r}(${o});\n const ${r} end = ${r}(${a});\n uniform float value;\n\n void main() {\n ${r} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${p}\n setOutput(result);\n }\n `}getCustomSetupFunc(e){return(t,n)=>{null==this.valueLoc&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const padV2=e=>{const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{paddings:o,constantValue:a}=i,s=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new PadPackedProgram(r.shape,o,a):new PadProgram(r.shape,o,a),l=s.getCustomSetupFunc(a);return n.runWebGLProgram(s,[r],r.dtype,l)},padV2Config={kernelName:PadV2,backendName:"webgl",kernelFunc:padV2},POW="\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",POW_PACKED="\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n "+CHECK_NAN_SNIPPET+"\n return result;\n",pow$1=binaryKernelFunc({opSnippet:POW,packedOpSnippet:POW_PACKED}),powConfig={kernelName:Pow,backendName:"webgl",kernelFunc:pow$1}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function prod(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{axis:o,keepDims:a}=i,s=r.shape.length,l=[],c=parseAxisParam(o,r.shape);let h=c;const u=getAxesPermutation(h,s);let d,p=r;if(null!=u&&(p=transpose({inputs:{x:r},backend:n,attrs:{perm:u}}),h=getInnerMostAxes(h.length,s),l.push(p)),assertAxesAreInnerMostDims("prod",h,s),n.shouldExecuteOnCPU([p])){const e=n.texData.get(p.dataId).values,{outVals:t,outShape:i,outDtype:r}=prodImplCPU(p.shape,p.dtype,e,h);d=n.makeTensorInfo(i,r,t)}else{const[e,t]=computeOutAndReduceShapes(p.shape,h),i=sizeFromShape(t),o=reshape({inputs:{x:p},backend:n,attrs:{shape:[-1,i]}}),a=reduce(o,sumOutType(r.dtype),"prod",n);d=reshape({inputs:{x:a},backend:n,attrs:{shape:e}}),l.push(o),l.push(a)}if(a){l.push(d);const e=expandShapeToKeepDim(d.shape,c);d=reshape({inputs:{x:d},backend:n,attrs:{shape:e}})}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}const prodConfig={kernelName:Prod,backendName:"webgl",kernelFunc:prod},range$1=e=>{const{backend:t,attrs:n}=e,{start:i,stop:r,step:o,dtype:a}=n,s=rangeImplCPU(i,r,o,a);return t.makeTensorInfo([s.length],a,s)},rangeConfig={kernelName:Range,backendName:"webgl",kernelFunc:range$1},RECIPROCAL="return 1.0 / x;",reciprocal=unaryKernelFunc({opSnippet:RECIPROCAL}),reciprocalConfig={kernelName:Reciprocal,backendName:"webgl",kernelFunc:reciprocal},RELU=CHECK_NAN_SNIPPET$2+"\n return (x < 0.0) ? 0.0 : x;\n",RELU_PACKED="\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",relu=unaryKernelFunc({opSnippet:RELU,packedOpSnippet:RELU_PACKED}),reluConfig={kernelName:Relu,backendName:"webgl",kernelFunc:relu},RELU6=CHECK_NAN_SNIPPET$2+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",RELU6_PACKED="\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",relu6=unaryKernelFunc({opSnippet:RELU6,packedOpSnippet:RELU6_PACKED}),relu6Config={kernelName:Relu6,backendName:"webgl",kernelFunc:relu6}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class ResizeBilinearProgram{constructor(e,t,n,i,r){this.variableNames=["A"],this.outputShape=[];const[o,a,s,l]=e;this.outputShape=[o,t,n,l];const c=[i&&t>1?a-1:a,i&&n>1?s-1:s],h=[i&&t>1?t-1:t,i&&n>1?n-1:n];let u;u=r?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${c[0]/h[0]},\n ${c[1]/h[1]});\n const vec2 inputShapeRC = vec2(${a}.0, ${s}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${u};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ResizeBilinearPackedProgram{constructor(e,t,n,i,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,a,s,l]=e;this.outputShape=[o,t,n,l];const c=[i&&t>1?a-1:a,i&&n>1?s-1:s],h=[i&&t>1?t-1:t,i&&n>1?n-1:n];let u;u=r?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${c[0]/h[0]},\n ${c[1]/h[1]},\n ${c[1]/h[1]});\n const vec3 inputShapeRC = vec3(${a}.0, ${s}.0,\n ${s}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${u};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${l-1};\n bool hasNextRow = coords.z < ${n-1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function resizeBilinear(e){const{inputs:t,backend:n,attrs:i}=e,{images:r}=t,{alignCorners:o,halfPixelCenters:a,size:s}=i,[l,c]=s,h=env().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new ResizeBilinearPackedProgram(r.shape,l,c,o,a):new ResizeBilinearProgram(r.shape,l,c,o,a);return n.runWebGLProgram(h,[r],"float32")}const resizeBilinearConfig={kernelName:ResizeBilinear,backendName:"webgl",kernelFunc:resizeBilinear}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ResizeBilinearBackpropProgram{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,i,r]=t,[,o,a]=e,s=[n&&o>1?i-1:i,n&&a>1?r-1:r],l=[n&&o>1?o-1:o,n&&a>1?a-1:a],c=s[0]/l[0],h=s[1]/l[1],u=1/c,d=1/h,p=2*Math.ceil(u)+2,m=2*Math.ceil(d)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${c});\n const float widthScale = float(${h});\n\n const float invHeightScale = float(${u});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${p});\n const int winWidth = int(${m});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${o}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${a}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${i-1}.0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), ${r-1}.0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function resizeBilinearGrad(e){const{inputs:t,backend:n,attrs:i}=e,{images:r,dy:o}=t,{alignCorners:a}=i,s=new ResizeBilinearBackpropProgram(o.shape,r.shape,a);return n.runWebGLProgram(s,[o],o.dtype)}const resizeBilinearGradConfig={kernelName:ResizeBilinearGrad,backendName:"webgl",kernelFunc:resizeBilinearGrad}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ResizeNearestNeighborProgram{constructor(e,t,n,i,r){this.variableNames=["A"],this.outputShape=[];const[o,a,s,l]=e;this.outputShape=[o,t,n,l];const c=[i&&t>1?a-1:a,i&&n>1?s-1:s],h=[i&&t>1?t-1:t,i&&n>1?n-1:n];let u;u=r?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${c[0]/h[0]},\n ${c[1]/h[1]});\n const vec2 inputShapeRC = vec2(${a}.0, ${s}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${u};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${i?"0.5":"0.0"})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function resizeNearestNeighbor(e){const{inputs:t,backend:n,attrs:i}=e,{images:r}=t,{alignCorners:o,halfPixelCenters:a,size:s}=i,[l,c]=s,h=new ResizeNearestNeighborProgram(r.shape,l,c,o,a);return n.runWebGLProgram(h,[r],r.dtype)}const resizeNearestNeighborConfig={kernelName:ResizeNearestNeighbor,backendName:"webgl",kernelFunc:resizeNearestNeighbor}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ResizeNearestNeigborBackpropProgram{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,i,r]=t,[,o,a]=e,s=[n&&o>1?i-1:i,n&&a>1?r-1:r],l=[n&&o>1?o-1:o,n&&a>1?a-1:a],c=s[0]/l[0],h=s[1]/l[1],u=1/c,d=1/h,p=2*Math.ceil(u)+2,m=2*Math.ceil(d)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${c});\n const float widthScale = float(${h});\n\n const float invHeightScale = float(${u});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${p});\n const int winWidth = int(${m});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${o}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${a}) {\n continue;\n }\n\n float sourceFracRow =\n float(${s[0]}) *\n (float(dyR) / float(${l[0]}));\n\n float sourceFracCol =\n float(${s[1]}) *\n (float(dyC) / float(${l[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${i}) - 1),\n ${n} ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(${r}) - 1),\n ${n} ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function resizeNearestNeighborGrad(e){const{inputs:t,backend:n,attrs:i}=e,{images:r,dy:o}=t,{alignCorners:a}=i,s=new ResizeNearestNeigborBackpropProgram(o.shape,r.shape,a);return n.runWebGLProgram(s,[o],o.dtype)}const resizeNearestNeighborGradConfig={kernelName:ResizeNearestNeighborGrad,backendName:"webgl",kernelFunc:resizeNearestNeighborGrad}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ReverseProgram{constructor(e,t){this.variableNames=["x"];const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=e,1===n)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `);const i=e.map(((n,i)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(i))).join(","),r=getCoordsDataType(n);this.userCode=`\n void main() {\n ${r} coords = getOutputCoords();\n setOutput(getX(${i}));\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class ReversePackedProgram{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const i=getChannels("rc",n),r=`${i[n-1]} + 1 < ${this.outputShape[n-1]}`,o=`${i[n-2]} + 1 < ${this.outputShape[n-2]}`,a=getCoordsDataType(n);function s(n){const i=e.map(((i,r)=>(function o(n,i){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${i[n]} - 1`:`${i[n]}`})(r,n)));return`getChannel(getX(${i.join(",")}), vec2(${i.slice(-2).join(",")}))`}this.userCode=1===n?`\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${e[0]} - rc - 1),\n ${e[0]} - rc - 1);\n if(${r}){\n result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),\n ${e[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n `:`\n void main() {\n ${a} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${(function l(e){return s(e)})(i.slice())};\n if(${r}){\n result.g = ${(function c(e){return e[n-1]="("+e[n-1]+" + 1)",s(e)})(i.slice())};\n }\n if(${o}) {\n result.b = ${(function h(e){return e[n-2]="("+e[n-2]+" + 1)",s(e)})(i.slice())};\n if(${r}) {\n result.a = ${(function u(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",s(e)})(i.slice())};\n }\n }\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function reverse(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{dims:o}=i,a=r.shape.length,s=parseAxisParam(o,r.shape);if(0===a)return identity$2({inputs:{x:r},backend:n});const l=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new ReversePackedProgram(r.shape,s):new ReverseProgram(r.shape,s);return n.runWebGLProgram(l,[r],r.dtype)}const reverseConfig={kernelName:Reverse,backendName:"webgl",kernelFunc:reverse}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class RotateProgram{constructor(e,t){this.variableNames=["Image"],this.outputShape=[];const n=e[1],i=e[2];this.outputShape=e;let r="";r="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:`\n vec3 fill = vec3(${t.join(",")});\n float outputValue = fill[coords[3]];`,this.userCode=`\n uniform vec4 params;\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${r}\n if(coordX >= 0 && coordX < ${i} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n `}getCustomSetupFunc(e,t,n,i){return(r,o)=>{null==this.paramsLoc&&(this.paramsLoc=r.getUniformLocationNoThrow(o,"params")),r.gl.uniform4f(this.paramsLoc,e,t,n,i)}}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const rotateWithOffsetConfig={kernelName:RotateWithOffset,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:i}=e,{radians:r,fillValue:o,center:a}=t,s=n,l=new RotateProgram(i.shape,o),[c,h]=getImageCenter(a,i.shape[1],i.shape[2]),u=l.getCustomSetupFunc(c,h,Math.sin(r),Math.cos(r));return s.runWebGLProgram(l,[i],i.dtype,u)}},ROUND="\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n",round=unaryKernelFunc({opSnippet:ROUND}),roundConfig={kernelName:Round,backendName:"webgl",kernelFunc:round},RSQRT="return inversesqrt(x);",rsqrt=unaryKernelFunc({opSnippet:RSQRT,cpuKernelImpl:rsqrtImplCPU}),rsqrtConfig={kernelName:Rsqrt,backendName:"webgl",kernelFunc:rsqrt}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class ScatterProgram{constructor(e,t,n,i,r,o,a=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=o;const s=getCoordsDataType(r.length),l=getCoordsDataType(o.length);let c="";1===n?c="i":2===n&&(c="i, j");let h="";1===i?h="i":2===i&&(h="i, coords[1]"),this.userCode=`\n ${s} strides = ${s}(${r});\n\n void main() {\n ${l} coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ${e}; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ${t}; j++) {\n int index = round(getIndices(${c}));\n flattenedIndex += index * ${t>1?"strides[j]":"strides"};\n }\n if (flattenedIndex == coords[0]) {\n sum += getUpdates(${h});\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function scatterNd(e){const{inputs:t,backend:n,attrs:i}=e,{indices:r,updates:o}=t,{shape:a}=i,{sliceRank:s,numUpdates:l,sliceSize:c,strides:h,outputSize:u}=calculateShapes(o,r,a),d=[u/c,c];if(0===u)return n.makeTensorInfo(a,r.dtype);const p=reshape({inputs:{x:r},backend:n,attrs:{shape:[l,s]}}),m=reshape({inputs:{x:o},backend:n,attrs:{shape:[l,c]}}),f=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new ScatterProgram(l,s,p.shape.length,m.shape.length,h,d),v=n.runWebGLProgram(g,[m,p,f],m.dtype),y=reshape({inputs:{x:v},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),n.disposeIntermediateTensorInfo(f),y}const scatterNdConfig={kernelName:ScatterNd,backendName:"webgl",kernelFunc:scatterNd}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class SelectProgram{constructor(e,t,n){let i,r;if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)r="resRC",i="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],a=[];for(let i=0;i<t.length;i++)a.push(`${n[i]}`),i<e&&o.push(`${n[i]}`);i=o.join(),r=a.join()}const o=getCoordsDataType(n);this.userCode=`\n void main() {\n ${o} resRC = getOutputCoords();\n float cVal = getC(${i});\n if (cVal >= 1.0) {\n setOutput(getA(${r}));\n } else {\n setOutput(getB(${r}));\n }\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function select(e){const{inputs:t,backend:n}=e,{condition:i,t:r,e:o}=t,a=new SelectProgram(i.shape.length,r.shape,r.shape.length);return n.runWebGLProgram(a,[i,r,o],upcastType(r.dtype,o.dtype))}const selectConfig={kernelName:Select,backendName:"webgl",kernelFunc:select},SELU=`\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${SELU_SCALEALPHA};\n float scale = ${SELU_SCALE};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`,selu=unaryKernelFunc({opSnippet:SELU}),seluConfig={kernelName:Selu,backendName:"webgl",kernelFunc:selu},SIGMOID="return 1.0 / (1.0 + exp(-1.0 * x));",sigmoid=unaryKernelFunc({opSnippet:SIGMOID}),sigmoidConfig={kernelName:Sigmoid,backendName:"webgl",kernelFunc:sigmoid},SIGN="\n if (isnan(x)) { return 0.0; }\n return sign(x);\n",sign$1=unaryKernelFunc({opSnippet:SIGN}),signConfig={kernelName:Sign,backendName:"webgl",kernelFunc:sign$1},SIN=CHECK_NAN_SNIPPET_UNARY+"\n return sin(x);\n",sin=unaryKernelFunc({opSnippet:SIN}),sinConfig={kernelName:Sin,backendName:"webgl",kernelFunc:sin},SINH="\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n",sinh=unaryKernelFunc({opSnippet:SINH}),sinhConfig={kernelName:Sinh,backendName:"webgl",kernelFunc:sinh},SOFTPLUS="\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n",softplus=unaryKernelFunc({opSnippet:SOFTPLUS}),softplusConfig={kernelName:Softplus,backendName:"webgl",kernelFunc:softplus},spaceToBatchND=e=>{const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{blockShape:o,paddings:a}=i;assert$1(r.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const s=o.reduce(((e,t)=>e*t)),l=[[0,0]];l.push(...a);for(let e=1+o.length;e<r.shape.length;++e)l.push([0,0]);const c=[],h=padV2({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),u=getReshaped(h.shape,o,s,!1),d=getPermuted(u.length,o.length,!1),p=getReshapedPermuted(h.shape,o,s,!1),m=reshape({inputs:{x:h},backend:n,attrs:{shape:u}}),f=transpose({inputs:{x:m},backend:n,attrs:{perm:d}}),g=reshape({inputs:{x:f},backend:n,attrs:{shape:p}});return c.push(h),c.push(m),c.push(f),c.forEach((e=>n.disposeIntermediateTensorInfo(e))),g},spaceToBatchNDConfig={kernelName:SpaceToBatchND,backendName:"webgl",kernelFunc:spaceToBatchND}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function sparseToDense(e){const{inputs:t,backend:n,attrs:i}=e,{sparseIndices:r,sparseValues:o,defaultValue:a}=t,{outputShape:s}=i,{sliceRank:l,numUpdates:c,strides:h,outputSize:u}=calculateShapes(o,r,s),d=new ScatterProgram(c,l,r.shape.length,o.shape.length,h,[u,1],!1),p=n.runWebGLProgram(d,[o,r,a],o.dtype),m=reshape({inputs:{x:p},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(p),m}const sparseToDenseConfig={kernelName:SparseToDense,backendName:"webgl",kernelFunc:sparseToDense}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function splitV(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{numOrSizeSplits:o,axis:a}=i,s=parseAxisParam(a,r.shape)[0],l=prepareSplitSize(r,o,s),c=new Array(r.shape.length).fill(0),h=r.shape.slice();return l.map((e=>{const t=[...h];t[s]=e;const i=slice$1({inputs:{x:r},backend:n,attrs:{begin:c,size:t}});return c[s]+=e,i}))}const splitVConfig={kernelName:SplitV,backendName:"webgl",kernelFunc:splitV},SQRT="return sqrt(x);",sqrt=unaryKernelFunc({opSnippet:SQRT}),sqrtConfig={kernelName:Sqrt,backendName:"webgl",kernelFunc:sqrt},SQUARE="return x * x;",square=unaryKernelFunc({opSnippet:SQUARE}),squareConfig={kernelName:Square,backendName:"webgl",kernelFunc:square},SQUARED_DIFFERENCE="return (a - b) * (a - b);",squaredDifference=binaryKernelFunc({opSnippet:SQUARED_DIFFERENCE,packedOpSnippet:SQUARED_DIFFERENCE}),squaredDifferenceConfig={kernelName:SquaredDifference,backendName:"webgl",kernelFunc:squaredDifference}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function step({inputs:e,attrs:t,backend:n}){const{x:i}=e,r=new UnaryOpProgram(i.shape,CHECK_NAN_SNIPPET$2+`\n return x > 0.0 ? 1.0 : float(${t.alpha});\n `);return n.runWebGLProgram(r,[i],i.dtype)}const stepConfig={kernelName:Step,backendName:"webgl",kernelFunc:step}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class StridedSliceProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const i=n.length,r=getCoordsDataType(n.length),o=getCoordsDataType(n.length);let a="";if(1===i)a="coords * strides + begin";else{let e=0;a=n.map(((t,i)=>(e++,1===n.length?`coords * strides[${i}] + begin[${i}]`:`coords[${e-1}] * strides[${i}] + begin[${i}]`))).join(",")}this.userCode=`\n ${r} begin = ${r}(${e});\n ${r} strides = ${r}(${t});\n\n void main() {\n ${o} coords = getOutputCoords();\n setOutput(getX(${a}));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function stridedSlice(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{begin:o,end:a,strides:s,beginMask:l,endMask:c,ellipsisMask:h,newAxisMask:u,shrinkAxisMask:d}=i,{nonStrided:p,$begin:m,$strides:f,size:g,newShape:v,outShape:y}=sliceInfo(r.shape,o,a,s,l,c,h,u,d),b=reshape({inputs:{x:r},backend:n,attrs:{shape:v}});let _;if(p){const e=slice$1({inputs:{x:b},backend:n,attrs:{begin:m,size:g}});_=reshape({inputs:{x:e},backend:n,attrs:{shape:y}}),n.disposeIntermediateTensorInfo(e)}else if(y.some((e=>0===e)))_=n.makeTensorInfo(y,r.dtype,[]);else if(n.shouldExecuteOnCPU([b])){const e=n.texData.get(b.dataId),t=buffer(b.shape,b.dtype,e.values),i=stridedSliceImplCPU(y,t,f,m);_=n.makeTensorInfo(y,b.dtype,i.values)}else{const e=new StridedSliceProgram(m,f,y);_=n.runWebGLProgram(e,[b],b.dtype)}const x=reshape({inputs:{x:_},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(b),n.disposeIntermediateTensorInfo(_),x}const stridedSliceConfig={kernelName:StridedSlice,backendName:"webgl",kernelFunc:stridedSlice},TAN="return tan(x);",tan=unaryKernelFunc({opSnippet:TAN}),tanConfig={kernelName:Tan,backendName:"webgl",kernelFunc:tan},TANH="\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n",tanh=unaryKernelFunc({opSnippet:TANH}),tanhConfig={kernelName:Tanh,backendName:"webgl",kernelFunc:tanh}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class TileProgram{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let i=0;i<n.length;i++)n[i]=e[i]*t[i];this.outputShape=n,this.rank=n.length;const i=getCoordsDataType(this.rank),r=getSourceCoords(e);this.userCode=`\n void main() {\n ${i} resRC = getOutputCoords();\n setOutput(getA(${r}));\n }\n `}}function getSourceCoords(e){const t=e.length;if(t>5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],i=[];for(let t=0;t<e.length;t++)i.push(`imod(${n[t]}, ${e[t]})`);return i.join()} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function tile(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{reps:o}=i;if("string"===r.dtype){const e=n.readSync(r.dataId).map((e=>decodeString(e))),t=buffer(r.shape,r.dtype,e),i=tileImplCPU(t,o);return n.makeTensorInfo(i.shape,i.dtype,i.values)}const a=new TileProgram(r.shape,o);return n.runWebGLProgram(a,[r],r.dtype)}const tileConfig={kernelName:Tile,backendName:"webgl",kernelFunc:tile}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function topK(e){const{inputs:t,backend:n,attrs:i}=e,{x:r}=t,{k:o,sorted:a}=i,s=n.readSync(r.dataId),[l,c]=topKImplCPU(s,r.shape,r.dtype,o,a);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(c.shape,c.dtype,c.values)]}const topKConfig={kernelName:TopK,backendName:"webgl",kernelFunc:topK}; /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class TransformProgram{constructor(e,t,n,i,r,o){this.variableNames=["Image","Transforms"],this.outputShape=o;const a="nearest"===n?1:2;let s;switch(i){case"constant":s=1;break;case"reflect":s=2;break;case"wrap":s=3;break;case"nearest":s=4;break;default:s=1}this.userCode=`\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${s} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${s} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${s} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${r});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${r});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${t}));\n float mapY = mapCoord(inY, float(${e}));\n\n if (${a} == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n `}} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function transform(e){const{inputs:t,backend:n,attrs:i}=e,{image:r,transforms:o}=t,{interpolation:a,fillMode:s,fillValue:l,outputShape:c}=i,[h,u,d,p]=r.shape,[m,f]=null!=c?c:[u,d],g=new TransformProgram(u,d,a,s,l,[h,m,f,p]);return n.runWebGLProgram(g,[r,o],"float32")}const transformConfig={kernelName:Transform,backendName:"webgl",kernelFunc:transform}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function unique(e){const{inputs:t,attrs:n,backend:i}=e,{axis:r}=n,{x:o}=t;assertNotComplex(o,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const a=i.readSync(o.dataId),{outputValues:s,outputShape:l,indices:c}=uniqueImplCPU(a,r,o.shape,o.dtype);return[i.makeTensorInfo(l,o.dtype,s),i.makeTensorInfo([c.length],"int32",c)]}const uniqueConfig={kernelName:Unique,backendName:"webgl",kernelFunc:unique}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function unpack(e){const{inputs:t,backend:n,attrs:i}=e,{value:r}=t;let{axis:o}=i;o<0&&(o+=r.shape.length);const a=r,s=a.shape.length,l=r.shape[o],c=new Array(s-1);let h=0;for(let e=0;e<s;e++)e!==o&&(c[h++]=a.shape[e]);const u=[],d=new Array(s).fill(0),p=a.shape.slice();p[o]=1;const m=new Array(l);for(let e=0;e<m.length;e++){d[o]=e;const t=slice$1({inputs:{x:a},backend:n,attrs:{begin:d,size:p}}),i=reshape({inputs:{x:t},backend:n,attrs:{shape:c}});m[e]=i,u.push(t)}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),m}const unpackConfig={kernelName:Unpack,backendName:"webgl",kernelFunc:unpack}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class SegmentOpProgram{constructor(e,t){this.variableNames=["x","segmentIds"];const n=e.windowSize,i=e.batchSize,r=e.inSize,o=e.numSegments,a=o*Math.ceil(r/n);this.outputShape=[i,a];const s=4*Math.floor(n/4),l=n%4,c="\n sumValue += dot(values, segFilter);\n ";let h="";r%n>0&&(h=`\n if (inIdx < 0 || inIdx >= ${r}) {\n return initializationValue;\n }\n `);let u="";r%n>0&&(u=`\n if (inIdx < 0 || inIdx >= ${r}) {\n return -1.0;\n }\n `),this.userCode=`\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${h}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${u}\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n ${o})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${o})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${s}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n ${c}\n }\n\n int inIdx = inOffset + ${s};\n if (${1===l}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n ${c}\n } else if (${2===l}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n ${c}\n } else if (${3===l}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n ${c}\n }\n setOutput(sumValue);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function unsortedSegmentSum(e){const{inputs:t,backend:n,attrs:i}=e,{x:r,segmentIds:o}=t,{numSegments:a}=i,s=r.shape.length,l=[];let c=0;const h=getAxesPermutation([c],s);let u=r;null!=h&&(u=transpose({inputs:{x:r},backend:n,attrs:{perm:h}}),l.push(u),c=getInnerMostAxes(1,s)[0]);const d=computeOutShape(u.shape,c,a),p=sizeFromShape([u.shape[c]]),m=reshape({inputs:{x:u},backend:n,attrs:{shape:[-1,p]}});l.push(m);const f=sumOutType(r.dtype),g=(e,t,i,r,o)=>{const a=e.shape[0],s=e.shape[1],c=segOpComputeOptimalWindowSize(s,o),h=new SegmentOpProgram({windowSize:c,inSize:s,batchSize:a,numSegments:o},t),u=n.compileAndRun(h,[e,i],r);if(l.push(u),u.shape[1]===o)return u;const d=range$1({backend:n,attrs:{start:0,stop:o,step:1,dtype:"float32"}}),p=tile({inputs:{x:d},backend:n,attrs:{reps:[s/c]}});return l.push(d),l.push(p),g(u,t,p,r,o)},v=reshape({inputs:{x:g(m,"unsortedSegmentSum",o,f,a)},backend:n,attrs:{shape:d}});let y=v;if(null!=h){l.push(v);const e=getUndoAxesPermutation(h);y=transpose({inputs:{x:y},backend:n,attrs:{perm:e}})}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}const unsortedSegmentSumConfig={kernelName:UnsortedSegmentSum,backendName:"webgl",kernelFunc:unsortedSegmentSum},kernelConfigs=[LRNConfig,LRNGradConfig,_fusedMatMulConfig,absConfig,acosConfig,acoshConfig,addConfig,addNConfig,allConfig,anyConfig,argMaxConfig,argMinConfig,asinConfig,asinhConfig,atan2Config,atanConfig,atanhConfig,avgPool3DConfig,avgPoolConfig,avgPoolGrad3DConfig,avgPoolGradConfig,batchMatMulConfig,batchNormConfig,batchToSpaceNDConfig,bincountConfig,castConfig,ceilConfig,clipByValueConfig,complexAbsConfig,complexConfig,concatConfig,conv2DBackpropFilterConfig,conv2DBackpropInputConfig,conv2DConfig,conv3DBackpropFilterV2Config,conv3DBackpropInputConfig,conv3DConfig,cosConfig,coshConfig,cropAndResizeConfig,cumsumConfig,denseBincountConfig,depthToSpaceConfig,depthwiseConv2dNativeBackpropFilterConfig,depthwiseConv2dNativeBackpropInputConfig,depthwiseConv2dNativeConfig,diagConfig,dilation2DConfig,einsumConfig,eluConfig,eluGradConfig,equalConfig,erfConfig,expConfig,expandDimsConfig,expm1Config,fftConfig,fillConfig,flipLeftRightConfig,floorConfig,floorDivConfig,fromPixelsConfig,fusedConv2DConfig,fusedDepthwiseConv2DConfig,gatherNdConfig,gatherV2Config,greaterConfig,greaterEqualConfig,identityConfig,ifftConfig,imagConfig,isFiniteConfig,isInfConfig,isNaNConfig,leakyReluConfig,lessConfig,lessEqualConfig,linSpaceConfig,log1pConfig,logConfig,logicalAndConfig,logicalNotConfig,logicalOrConfig,maxConfig,maxPool3DConfig,maxPoolConfig,maxPoolGrad3DConfig,maxPoolGradConfig,maxPoolWithArgmaxConfig,maximumConfig,meanConfig,minConfig,minimumConfig,mirrorPadConfig,modConfig,multinomialConfig,multiplyConfig,negConfig,nonMaxSuppressionV3Config,nonMaxSuppressionV4Config,nonMaxSuppressionV5Config,notEqualConfig,oneHotConfig,onesLikeConfig,packConfig,padV2Config,powConfig,preluConfig,prodConfig,rangeConfig,realConfig,realDivConfig,reciprocalConfig,relu6Config,reluConfig,reshapeConfig,resizeBilinearConfig,resizeBilinearGradConfig,resizeNearestNeighborConfig,resizeNearestNeighborGradConfig,reverseConfig,rotateWithOffsetConfig,roundConfig,rsqrtConfig,scatterNdConfig,selectConfig,seluConfig,sigmoidConfig,signConfig,sinConfig,sinhConfig,sliceConfig,softmaxConfig,softplusConfig,spaceToBatchNDConfig,sparseToDenseConfig,splitVConfig,sqrtConfig,squareConfig,squaredDifferenceConfig,stepConfig,stridedSliceConfig,subConfig,sumConfig,tanConfig,tanhConfig,tileConfig,topKConfig,transformConfig,transposeConfig,uniqueConfig,unpackConfig,unsortedSegmentSumConfig,zerosLikeConfig]; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */for(const e of kernelConfigs)registerKernel(e);class MinHeap{constructor(){this.arr=[]}push(e,t){this.arr.push({key:e,value:t}),this.bubbleUp(this.arr.length-1)}pop(){if(0===this.arr.length)throw new Error("pop() called on empty binary heap");let e=this.arr[0],t=this.arr.length-1;return this.arr[0]=this.arr[t],this.arr.pop(),t>0&&this.bubbleDown(0),e}peek(){return this.arr[0]}popPush(e,t){if(0===this.arr.length)throw new Error("pop() called on empty binary heap");let n=this.arr[0];return this.arr[0]={key:e,value:t},this.arr.length>0&&this.bubbleDown(0),n}size(){return this.arr.length}items(){return this.arr}swap(e,t){let n=this.arr[e];this.arr[e]=this.arr[t],this.arr[t]=n}bubbleDown(e){let t=1+(e<<1),n=t+1,i=e;t<this.arr.length&&this.arr[t].key<this.arr[i].key&&(i=t),n<this.arr.length&&this.arr[n].key<this.arr[i].key&&(i=n),i!==e&&(this.swap(i,e),this.bubbleDown(i))}bubbleUp(e){if(e<=0)return;let t=e-1>>1;this.arr[e].key<this.arr[t].key&&(this.swap(e,t),this.bubbleUp(t))}}class KMin{constructor(e){this.maxHeap=new MinHeap,this.k=e}add(e,t){this.maxHeap.size()<this.k?this.maxHeap.push(-e,t):e<-this.maxHeap.peek().key&&this.maxHeap.popPush(-e,t)}getMinKItems(){let e=this.maxHeap.items();return e.sort(((e,t)=>t.key-e.key)),e.map((e=>e.value))}getSize(){return this.maxHeap.size()}getLargestKey(){return 0===this.maxHeap.size()?null:-this.maxHeap.peek().key}}function ascending(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function bisector(e){return 1===e.length&&(e=ascendingComparator(e)),{left:function(t,n,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i<r;){var o=i+r>>>1;e(t[o],n)<0?i=o+1:r=o}return i},right:function(t,n,i,r){for(null==i&&(i=0),null==r&&(r=t.length);i<r;){var o=i+r>>>1;e(t[o],n)>0?r=o:i=o+1}return i}}}function ascendingComparator(e){return function(t,n){return ascending(e(t),n)}}var ascendingBisect=bisector(ascending),bisectRight=ascendingBisect.right;function extent(e,t){var n,i,r,o=e.length,a=-1;if(null==t){for(;++a<o;)if(null!=(n=e[a])&&n>=n)for(i=r=n;++a<o;)null!=(n=e[a])&&(i>n&&(i=n),r<n&&(r=n))}else for(;++a<o;)if(null!=(n=t(e[a],a,e))&&n>=n)for(i=r=n;++a<o;)null!=(n=t(e[a],a,e))&&(i>n&&(i=n),r<n&&(r=n));return[i,r]}var e10=Math.sqrt(50),e5=Math.sqrt(10),e2=Math.sqrt(2);function ticks(e,t,n){var i,r,o,a,s=-1;if(n=+n,(e=+e)==(t=+t)&&n>0)return[e];if((i=t<e)&&(r=e,e=t,t=r),0===(a=tickIncrement(e,t,n))||!isFinite(a))return[];if(a>0)for(e=Math.ceil(e/a),t=Math.floor(t/a),o=new Array(r=Math.ceil(t-e+1));++s<r;)o[s]=(e+s)*a;else for(e=Math.floor(e*a),t=Math.ceil(t*a),o=new Array(r=Math.ceil(e-t+1));++s<r;)o[s]=(e-s)/a;return i&&o.reverse(),o}function tickIncrement(e,t,n){var i=(t-e)/Math.max(0,n),r=Math.floor(Math.log(i)/Math.LN10),o=i/Math.pow(10,r);return r>=0?(o>=e10?10:o>=e5?5:o>=e2?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=e10?10:o>=e5?5:o>=e2?2:1)}function tickStep(e,t,n){var i=Math.abs(t-e)/Math.max(0,n),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=i/r;return o>=e10?r*=10:o>=e5?r*=5:o>=e2&&(r*=2),t<e?-r:r}var noop={value:function(){}};function dispatch(){for(var e,t=0,n=arguments.length,i={};t<n;++t){if(!(e=arguments[t]+"")||e in i||/[\s.]/.test(e))throw new Error("illegal type: "+e);i[e]=[]}return new Dispatch(i)}function Dispatch(e){this._=e}function parseTypenames(e,t){return e.trim().split(/^|\s+/).map((function(e){var n="",i=e.indexOf(".");if(i>=0&&(n=e.slice(i+1),e=e.slice(0,i)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}}))}function get(e,t){for(var n,i=0,r=e.length;i<r;++i)if((n=e[i]).name===t)return n.value}function set(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=noop,e=e.slice(0,i).concat(e.slice(i+1));break}return null!=n&&e.push({name:t,value:n}),e}function define(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function extend(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Color$1(){}Dispatch.prototype=dispatch.prototype={constructor:Dispatch,on:function(e,t){var n,i=this._,r=parseTypenames(e+"",i),o=-1,a=r.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++o<a;)if(n=(e=r[o]).type)i[n]=set(i[n],e.name,t);else if(null==t)for(n in i)i[n]=set(i[n],e.name,null);return this}for(;++o<a;)if((n=(e=r[o]).type)&&(n=get(i[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Dispatch(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,i,r=new Array(n),o=0;o<n;++o)r[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=0,n=(i=this._[e]).length;o<n;++o)i[o].value.apply(t,r)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)}};var darker=.7,brighter=1/darker,reI="\\s*([+-]?\\d+)\\s*",reN="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",reP="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",reHex=/^#([0-9a-f]{3,8})$/,reRgbInteger=new RegExp("^rgb\\("+[reI,reI,reI]+"\\)$"),reRgbPercent=new RegExp("^rgb\\("+[reP,reP,reP]+"\\)$"),reRgbaInteger=new RegExp("^rgba\\("+[reI,reI,reI,reN]+"\\)$"),reRgbaPercent=new RegExp("^rgba\\("+[reP,reP,reP,reN]+"\\)$"),reHslPercent=new RegExp("^hsl\\("+[reN,reP,reP]+"\\)$"),reHslaPercent=new RegExp("^hsla\\("+[reN,reP,reP,reN]+"\\)$"),named={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function color_formatHex(){return this.rgb().formatHex()}function color_formatHsl(){return hslConvert(this).formatHsl()}function color_formatRgb(){return this.rgb().formatRgb()}function color(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=reHex.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?rgbn(t):3===n?new Rgb(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?rgba(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?rgba(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=reRgbInteger.exec(e))?new Rgb(t[1],t[2],t[3],1):(t=reRgbPercent.exec(e))?new Rgb(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=reRgbaInteger.exec(e))?rgba(t[1],t[2],t[3],t[4]):(t=reRgbaPercent.exec(e))?rgba(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=reHslPercent.exec(e))?hsla(t[1],t[2]/100,t[3]/100,1):(t=reHslaPercent.exec(e))?hsla(t[1],t[2]/100,t[3]/100,t[4]):named.hasOwnProperty(e)?rgbn(named[e]):"transparent"===e?new Rgb(NaN,NaN,NaN,0):null}function rgbn(e){return new Rgb(e>>16&255,e>>8&255,255&e,1)}function rgba(e,t,n,i){return i<=0&&(e=t=n=NaN),new Rgb(e,t,n,i)}function rgbConvert(e){return e instanceof Color$1||(e=color(e)),e?new Rgb((e=e.rgb()).r,e.g,e.b,e.opacity):new Rgb}function rgb(e,t,n,i){return 1===arguments.length?rgbConvert(e):new Rgb(e,t,n,null==i?1:i)}function Rgb(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}function rgb_formatHex(){return"#"+hex(this.r)+hex(this.g)+hex(this.b)}function rgb_formatRgb(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===e?")":", "+e+")")}function hex(e){return((e=Math.max(0,Math.min(255,Math.round(e)||0)))<16?"0":"")+e.toString(16)}function hsla(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Hsl(e,t,n,i)}function hslConvert(e){if(e instanceof Hsl)return new Hsl(e.h,e.s,e.l,e.opacity);if(e instanceof Color$1||(e=color(e)),!e)return new Hsl;if(e instanceof Hsl)return e;var t=(e=e.rgb()).r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),o=Math.max(t,n,i),a=NaN,s=o-r,l=(o+r)/2;return s?(a=t===o?(n-i)/s+6*(n<i):n===o?(i-t)/s+2:(t-n)/s+4,s/=l<.5?o+r:2-o-r,a*=60):s=l>0&&l<1?0:a,new Hsl(a,s,l,e.opacity)}function hsl(e,t,n,i){return 1===arguments.length?hslConvert(e):new Hsl(e,t,n,null==i?1:i)}function Hsl(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}function hsl2rgb(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}function constant$1(e){return function(){return e}}function linear$1(e,t){return function(n){return e+n*t}}function exponential(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function gamma(e){return 1==(e=+e)?nogamma:function(t,n){return n-t?exponential(t,n,e):constant$1(isNaN(t)?n:t)}}function nogamma(e,t){var n=t-e;return n?linear$1(e,n):constant$1(isNaN(e)?t:e)}define(Color$1,color,{copy:function(e){return Object.assign(new this.constructor,this,e)},displayable:function(){return this.rgb().displayable()},hex:color_formatHex,formatHex:color_formatHex,formatHsl:color_formatHsl,formatRgb:color_formatRgb,toString:color_formatRgb}),define(Rgb,rgb,extend(Color$1,{brighter:function(e){return e=null==e?brighter:Math.pow(brighter,e),new Rgb(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=null==e?darker:Math.pow(darker,e),new Rgb(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rgb_formatHex,formatHex:rgb_formatHex,formatRgb:rgb_formatRgb,toString:rgb_formatRgb})),define(Hsl,hsl,extend(Color$1,{brighter:function(e){return e=null==e?brighter:Math.pow(brighter,e),new Hsl(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=null==e?darker:Math.pow(darker,e),new Hsl(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new Rgb(hsl2rgb(e>=240?e-240:e+120,r,i),hsl2rgb(e,r,i),hsl2rgb(e<120?e+240:e-120,r,i),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===e?")":", "+e+")")}}));var interpolateRgb=(function e(t){var n=gamma(t);function i(e,t){var i=n((e=rgb(e)).r,(t=rgb(t)).r),r=n(e.g,t.g),o=n(e.b,t.b),a=nogamma(e.opacity,t.opacity);return function(t){return e.r=i(t),e.g=r(t),e.b=o(t),e.opacity=a(t),e+""}}return i.gamma=e,i})(1);function numberArray(e,t){t||(t=[]);var n,i=e?Math.min(t.length,e.length):0,r=t.slice();return function(o){for(n=0;n<i;++n)r[n]=e[n]*(1-o)+t[n]*o;return r}}function isNumberArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function genericArray(e,t){var n,i=t?t.length:0,r=e?Math.min(i,e.length):0,o=new Array(r),a=new Array(i);for(n=0;n<r;++n)o[n]=interpolateValue(e[n],t[n]);for(;n<i;++n)a[n]=t[n];return function(e){for(n=0;n<r;++n)a[n]=o[n](e);return a}}function date(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function interpolateNumber(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function object(e,t){var n,i={},r={};for(n in null!==e&&"object"==typeof e||(e={}),null!==t&&"object"==typeof t||(t={}),t)n in e?i[n]=interpolateValue(e[n],t[n]):r[n]=t[n];return function(e){for(n in i)r[n]=i[n](e);return r}}var reA=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB=new RegExp(reA.source,"g");function zero(e){return function(){return e}}function one(e){return function(t){return e(t)+""}}function interpolateString(e,t){var n,i,r,o=reA.lastIndex=reB.lastIndex=0,a=-1,s=[],l=[];for(e+="",t+="";(n=reA.exec(e))&&(i=reB.exec(t));)(r=i.index)>o&&(r=t.slice(o,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,l.push({i:a,x:interpolateNumber(n,i)})),o=reB.lastIndex;return o<t.length&&(r=t.slice(o),s[a]?s[a]+=r:s[++a]=r),s.length<2?l[0]?one(l[0].x):zero(t):(t=l.length,function(e){for(var n,i=0;i<t;++i)s[(n=l[i]).i]=n.x(e);return s.join("")})}function interpolateValue(e,t){var n,i=typeof t;return null==t||"boolean"===i?constant$1(t):("number"===i?interpolateNumber:"string"===i?(n=color(t))?(t=n,interpolateRgb):interpolateString:t instanceof color?interpolateRgb:t instanceof Date?date:isNumberArray(t)?numberArray:Array.isArray(t)?genericArray:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?object:interpolateNumber)(e,t)}function interpolateRound(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}dispatch("start","end","cancel","interrupt");var prefix="$";function Map$1(){}function map$2(e,t){var n=new Map$1;if(e instanceof Map$1)e.each((function(e,t){n.set(t,e)}));else if(Array.isArray(e)){var i,r=-1,o=e.length;if(null==t)for(;++r<o;)n.set(r,e[r]);else for(;++r<o;)n.set(t(i=e[r],r,e),i)}else if(e)for(var a in e)n.set(a,e[a]);return n}function Set$1(){}Map$1.prototype=map$2.prototype={constructor:Map$1,has:function(e){return prefix+e in this},get:function(e){return this[prefix+e]},set:function(e,t){return this[prefix+e]=t,this},remove:function(e){var t=prefix+e;return t in this&&delete this[t]},clear:function(){for(var e in this)e[0]===prefix&&delete this[e]},keys:function(){var e=[];for(var t in this)t[0]===prefix&&e.push(t.slice(1));return e},values:function(){var e=[];for(var t in this)t[0]===prefix&&e.push(this[t]);return e},entries:function(){var e=[];for(var t in this)t[0]===prefix&&e.push({key:t.slice(1),value:this[t]});return e},size:function(){var e=0;for(var t in this)t[0]===prefix&&++e;return e},empty:function(){for(var e in this)if(e[0]===prefix)return!1;return!0},each:function(e){for(var t in this)t[0]===prefix&&e(this[t],t.slice(1),this)}};var proto=map$2.prototype;function formatDecimal(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function formatDecimalParts(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function exponent(e){return(e=formatDecimalParts(Math.abs(e)))?e[1]:NaN}function formatGroup(e,t){return function(n,i){for(var r=n.length,o=[],a=0,s=e[0],l=0;r>0&&s>0&&(l+s+1>i&&(s=Math.max(1,i-l)),o.push(n.substring(r-=s,r+s)),!((l+=s+1)>i));)s=e[a=(a+1)%e.length];return o.reverse().join(t)}}function formatNumerals(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}Set$1.prototype={constructor:Set$1,has:proto.has,add:function(e){return this[prefix+(e+="")]=e,this},remove:proto.remove,clear:proto.clear,values:proto.keys,size:proto.size,empty:proto.empty,each:proto.each};var re=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i,prefixExponent;function formatSpecifier(e){if(!(t=re.exec(e)))throw new Error("invalid format: "+e);var t;return new FormatSpecifier({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function FormatSpecifier(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function formatTrim(e){e:for(var t,n=e.length,i=1,r=-1;i<n;++i)switch(e[i]){case".":r=t=i;break;case"0":0===r&&(r=i),t=i;break;default:if(!+e[i])break e;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(t+1):e}function formatPrefixAuto(e,t){var n=formatDecimalParts(e,t);if(!n)return e+"";var i=n[0],r=n[1],o=r-(prefixExponent=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,a=i.length;return o===a?i:o>a?i+new Array(o-a+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+formatDecimalParts(e,Math.max(0,t+o-1))[0]}function formatRounded(e,t){var n=formatDecimalParts(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}formatSpecifier.prototype=FormatSpecifier.prototype,FormatSpecifier.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var formatTypes={"%":function(e,t){return(100*e).toFixed(t)},b:function(e){return Math.round(e).toString(2)},c:function(e){return e+""},d:formatDecimal,e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},g:function(e,t){return e.toPrecision(t)},o:function(e){return Math.round(e).toString(8)},p:function(e,t){return formatRounded(100*e,t)},r:formatRounded,s:formatPrefixAuto,X:function(e){return Math.round(e).toString(16).toUpperCase()},x:function(e){return Math.round(e).toString(16)}};function identity$1(e){return e}var map$1=Array.prototype.map,prefixes=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],locale,format,formatPrefix;function formatLocale(e){var t=void 0===e.grouping||void 0===e.thousands?identity$1:formatGroup(map$1.call(e.grouping,Number),e.thousands+""),n=void 0===e.currency?"":e.currency[0]+"",i=void 0===e.currency?"":e.currency[1]+"",r=void 0===e.decimal?".":e.decimal+"",o=void 0===e.numerals?identity$1:formatNumerals(map$1.call(e.numerals,String)),a=void 0===e.percent?"%":e.percent+"",s=void 0===e.minus?"-":e.minus+"",l=void 0===e.nan?"NaN":e.nan+"";function c(e){var c=(e=formatSpecifier(e)).fill,h=e.align,u=e.sign,d=e.symbol,p=e.zero,m=e.width,f=e.comma,g=e.precision,v=e.trim,y=e.type;"n"===y?(f=!0,y="g"):formatTypes[y]||(void 0===g&&(g=12),v=!0,y="g"),(p||"0"===c&&"="===h)&&(p=!0,c="0",h="=");var b="$"===d?n:"#"===d&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",_="$"===d?i:/[%p]/.test(y)?a:"",x=formatTypes[y],w=/[defgprs%]/.test(y);function S(e){var n,i,a,d=b,S=_;if("c"===y)S=x(e)+S,e="";else{var C=(e=+e)<0||1/e<0;if(e=isNaN(e)?l:x(Math.abs(e),g),v&&(e=formatTrim(e)),C&&0==+e&&"+"!==u&&(C=!1),d=(C?"("===u?u:s:"-"===u||"("===u?"":u)+d,S=("s"===y?prefixes[8+prefixExponent/3]:"")+S+(C&&"("===u?")":""),w)for(n=-1,i=e.length;++n<i;)if(48>(a=e.charCodeAt(n))||a>57){S=(46===a?r+e.slice(n+1):e.slice(n))+S,e=e.slice(0,n);break}}f&&!p&&(e=t(e,1/0));var M=d.length+e.length+S.length,E=M<m?new Array(m-M+1).join(c):"";switch(f&&p&&(e=t(E+e,E.length?m-S.length:1/0),E=""),h){case"<":e=d+e+S+E;break;case"=":e=d+E+e+S;break;case"^":e=E.slice(0,M=E.length>>1)+d+e+S+E.slice(M);break;default:e=E+d+e+S}return o(e)}return g=void 0===g?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),S.toString=function(){return e+""},S}return{format:c,formatPrefix:function h(e,t){var n=c(((e=formatSpecifier(e)).type="f",e)),i=3*Math.max(-8,Math.min(8,Math.floor(exponent(t)/3))),r=Math.pow(10,-i),o=prefixes[8+i/3];return function(e){return n(r*e)+o}}}}function defaultLocale(e){return locale=formatLocale(e),format=locale.format,formatPrefix=locale.formatPrefix,locale}function precisionFixed(e){return Math.max(0,-exponent(Math.abs(e)))}function precisionPrefix(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(exponent(t)/3)))-exponent(Math.abs(e)))}function precisionRound(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,exponent(t)-exponent(e))+1}function defaultSource(){return Math.random()}defaultLocale({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"});var normal=(function e(t){function n(e,n){var i,r;return e=null==e?0:+e,n=null==n?1:+n,function(){var o;if(null!=i)o=i,i=null;else do{i=2*t()-1,o=2*t()-1,r=i*i+o*o}while(!r||r>1);return e+n*o*Math.sqrt(-2*Math.log(r)/r)}}return n.source=e,n})(defaultSource);function initRange(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}var array=Array.prototype,map=array.map,slice=array.slice,implicit={name:"implicit"};function ordinal(){var e=map$2(),t=[],n=[],i=implicit;function r(r){var o=r+"",a=e.get(o);if(!a){if(i!==implicit)return i;e.set(o,a=t.push(r))}return n[(a-1)%n.length]}return r.domain=function(n){if(!arguments.length)return t.slice();t=[],e=map$2();for(var i,o,a=-1,s=n.length;++a<s;)e.has(o=(i=n[a])+"")||e.set(o,t.push(i));return r},r.range=function(e){return arguments.length?(n=slice.call(e),r):n.slice()},r.unknown=function(e){return arguments.length?(i=e,r):i},r.copy=function(){return ordinal(t,n).unknown(i)},initRange.apply(r,arguments),r}function constant(e){return function(){return e}}function number(e){return+e}var unit$1=[0,1];function identity(e){return e}function normalize(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:constant(isNaN(t)?NaN:.5)}function clamper(e){var t,n=e[0],i=e[e.length-1];return n>i&&(t=n,n=i,i=t),function(e){return Math.max(n,Math.min(i,e))}}function bimap(e,t,n){var i=e[0],r=e[1],o=t[0],a=t[1];return r<i?(i=normalize(r,i),o=n(a,o)):(i=normalize(i,r),o=n(o,a)),function(e){return o(i(e))}}function polymap(e,t,n){var i=Math.min(e.length,t.length)-1,r=new Array(i),o=new Array(i),a=-1;for(e[i]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++a<i;)r[a]=normalize(e[a],e[a+1]),o[a]=n(t[a],t[a+1]);return function(t){var n=bisectRight(e,t,1,i)-1;return o[n](r[n](t))}}function copy(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function transformer(){var e,t,n,i,r,o,a=unit$1,s=unit$1,l=interpolateValue,c=identity;function h(){return i=Math.min(a.length,s.length)>2?polymap:bimap,r=o=null,u}function u(t){return isNaN(t=+t)?n:(r||(r=i(a.map(e),s,l)))(e(c(t)))}return u.invert=function(n){return c(t((o||(o=i(s,a.map(e),interpolateNumber)))(n)))},u.domain=function(e){return arguments.length?(a=map.call(e,number),c===identity||(c=clamper(a)),h()):a.slice()},u.range=function(e){return arguments.length?(s=slice.call(e),h()):s.slice()},u.rangeRound=function(e){return s=slice.call(e),l=interpolateRound,h()},u.clamp=function(e){return arguments.length?(c=e?clamper(a):identity,u):c!==identity},u.interpolate=function(e){return arguments.length?(l=e,h()):l},u.unknown=function(e){return arguments.length?(n=e,u):n},function(n,i){return e=n,t=i,h()}}function continuous(e,t){return transformer()(e,t)}function tickFormat(e,t,n,i){var r,o=tickStep(e,t,n);switch((i=formatSpecifier(null==i?",f":i)).type){case"s":var a=Math.max(Math.abs(e),Math.abs(t));return null!=i.precision||isNaN(r=precisionPrefix(o,a))||(i.precision=r),formatPrefix(i,a);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(r=precisionRound(o,Math.max(Math.abs(e),Math.abs(t))))||(i.precision=r-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(r=precisionFixed(o))||(i.precision=r-2*("%"===i.type))}return format(i)}function linearish(e){var t=e.domain;return e.ticks=function(e){var n=t();return ticks(n[0],n[n.length-1],null==e?10:e)},e.tickFormat=function(e,n){var i=t();return tickFormat(i[0],i[i.length-1],null==e?10:e,n)},e.nice=function(n){null==n&&(n=10);var i,r=t(),o=0,a=r.length-1,s=r[o],l=r[a];return l<s&&(i=s,s=l,l=i,i=o,o=a,a=i),(i=tickIncrement(s,l,n))>0?i=tickIncrement(s=Math.floor(s/i)*i,l=Math.ceil(l/i)*i,n):i<0&&(i=tickIncrement(s=Math.ceil(s*i)/i,l=Math.floor(l*i)/i,n)),i>0?(r[o]=Math.floor(s/i)*i,r[a]=Math.ceil(l/i)*i,t(r)):i<0&&(r[o]=Math.ceil(s*i)/i,r[a]=Math.floor(l*i)/i,t(r)),e},e}function linear(){var e=continuous(identity,identity);return e.copy=function(){return copy(e,linear())},initRange.apply(e,arguments),linearish(e)}function transformPow(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function transformSqrt(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function transformSquare(e){return e<0?-e*e:e*e}function powish(e){var t=e(identity,identity),n=1;function i(){return 1===n?e(identity,identity):.5===n?e(transformSqrt,transformSquare):e(transformPow(n),transformPow(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,i()):n},linearish(t)}function pow(){var e=powish(transformer());return e.copy=function(){return copy(e,pow()).exponent(e.exponent())},initRange.apply(e,arguments),e}function colors(e){for(var t=e.length/6|0,n=new Array(t),i=0;i<t;)n[i]="#"+e.slice(6*i,6*++i);return n}var category10=colors("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf");const REVISION="125",MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},CullFaceNone=0,CullFaceBack=1,CullFaceFront=2,PCFShadowMap=1,PCFSoftShadowMap=2,VSMShadowMap=3,FrontSide=0,BackSide=1,DoubleSide=2,FlatShading=1,NoBlending=0,NormalBlending=1,AdditiveBlending=2,SubtractiveBlending=3,MultiplyBlending=4,CustomBlending=5,AddEquation=100,SubtractEquation=101,ReverseSubtractEquation=102,MinEquation=103,MaxEquation=104,ZeroFactor=200,OneFactor=201,SrcColorFactor=202,OneMinusSrcColorFactor=203,SrcAlphaFactor=204,OneMinusSrcAlphaFactor=205,DstAlphaFactor=206,OneMinusDstAlphaFactor=207,DstColorFactor=208,OneMinusDstColorFactor=209,SrcAlphaSaturateFactor=210,NeverDepth=0,AlwaysDepth=1,LessDepth=2,LessEqualDepth=3,EqualDepth=4,GreaterEqualDepth=5,GreaterDepth=6,NotEqualDepth=7,MultiplyOperation=0,MixOperation=1,AddOperation=2,NoToneMapping=0,LinearToneMapping=1,ReinhardToneMapping=2,CineonToneMapping=3,ACESFilmicToneMapping=4,CustomToneMapping=5,UVMapping=300,CubeReflectionMapping=301,CubeRefractionMapping=302,EquirectangularReflectionMapping=303,EquirectangularRefractionMapping=304,CubeUVReflectionMapping=306,CubeUVRefractionMapping=307,RepeatWrapping=1e3,ClampToEdgeWrapping=1001,MirroredRepeatWrapping=1002,NearestFilter=1003,NearestMipmapNearestFilter=1004,NearestMipmapLinearFilter=1005,LinearFilter=1006,LinearMipmapNearestFilter=1007,LinearMipmapLinearFilter=1008,UnsignedByteType=1009,ByteType=1010,ShortType=1011,UnsignedShortType=1012,IntType=1013,UnsignedIntType=1014,FloatType=1015,HalfFloatType=1016,UnsignedShort4444Type=1017,UnsignedShort5551Type=1018,UnsignedShort565Type=1019,UnsignedInt248Type=1020,AlphaFormat=1021,RGBFormat=1022,RGBAFormat=1023,LuminanceFormat=1024,LuminanceAlphaFormat=1025,DepthFormat=1026,DepthStencilFormat=1027,RedFormat=1028,RedIntegerFormat=1029,RGFormat=1030,RGIntegerFormat=1031,RGBIntegerFormat=1032,RGBAIntegerFormat=1033,RGB_S3TC_DXT1_Format=33776,RGBA_S3TC_DXT1_Format=33777,RGBA_S3TC_DXT3_Format=33778,RGBA_S3TC_DXT5_Format=33779,RGB_PVRTC_4BPPV1_Format=35840,RGB_PVRTC_2BPPV1_Format=35841,RGBA_PVRTC_4BPPV1_Format=35842,RGBA_PVRTC_2BPPV1_Format=35843,RGB_ETC1_Format=36196,RGB_ETC2_Format=37492,RGBA_ETC2_EAC_Format=37496,RGBA_ASTC_4x4_Format=37808,RGBA_ASTC_5x4_Format=37809,RGBA_ASTC_5x5_Format=37810,RGBA_ASTC_6x5_Format=37811,RGBA_ASTC_6x6_Format=37812,RGBA_ASTC_8x5_Format=37813,RGBA_ASTC_8x6_Format=37814,RGBA_ASTC_8x8_Format=37815,RGBA_ASTC_10x5_Format=37816,RGBA_ASTC_10x6_Format=37817,RGBA_ASTC_10x8_Format=37818,RGBA_ASTC_10x10_Format=37819,RGBA_ASTC_12x10_Format=37820,RGBA_ASTC_12x12_Format=37821,RGBA_BPTC_Format=36492,SRGB8_ALPHA8_ASTC_4x4_Format=37840,SRGB8_ALPHA8_ASTC_5x4_Format=37841,SRGB8_ALPHA8_ASTC_5x5_Format=37842,SRGB8_ALPHA8_ASTC_6x5_Format=37843,SRGB8_ALPHA8_ASTC_6x6_Format=37844,SRGB8_ALPHA8_ASTC_8x5_Format=37845,SRGB8_ALPHA8_ASTC_8x6_Format=37846,SRGB8_ALPHA8_ASTC_8x8_Format=37847,SRGB8_ALPHA8_ASTC_10x5_Format=37848,SRGB8_ALPHA8_ASTC_10x6_Format=37849,SRGB8_ALPHA8_ASTC_10x8_Format=37850,SRGB8_ALPHA8_ASTC_10x10_Format=37851,SRGB8_ALPHA8_ASTC_12x10_Format=37852,SRGB8_ALPHA8_ASTC_12x12_Format=37853,LoopOnce=2200,LoopRepeat=2201,LoopPingPong=2202,InterpolateDiscrete=2300,InterpolateLinear=2301,InterpolateSmooth=2302,ZeroCurvatureEnding=2400,ZeroSlopeEnding=2401,WrapAroundEnding=2402,NormalAnimationBlendMode=2500,AdditiveAnimationBlendMode=2501,TrianglesDrawMode=0,LinearEncoding=3e3,sRGBEncoding=3001,GammaEncoding=3007,RGBEEncoding=3002,LogLuvEncoding=3003,RGBM7Encoding=3004,RGBM16Encoding=3005,RGBDEncoding=3006,BasicDepthPacking=3200,RGBADepthPacking=3201,TangentSpaceNormalMap=0,ObjectSpaceNormalMap=1,KeepStencilOp=7680,AlwaysStencilFunc=519,StaticDrawUsage=35044,DynamicDrawUsage=35048,GLSL3="300 es";function EventDispatcher(){}Object.assign(EventDispatcher.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)},removeEventListener:function(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}},dispatchEvent:function(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t<i;t++)n[t].call(this,e)}}});const _lut=[];for(let e=0;e<256;e++)_lut[e]=(e<16?"0":"")+e.toString(16);let _seed=1234567;const MathUtils={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(_lut[255&e]+_lut[e>>8&255]+_lut[e>>16&255]+_lut[e>>24&255]+"-"+_lut[255&t]+_lut[t>>8&255]+"-"+_lut[t>>16&15|64]+_lut[t>>24&255]+"-"+_lut[63&n|128]+_lut[n>>8&255]+"-"+_lut[n>>16&255]+_lut[n>>24&255]+_lut[255&i]+_lut[i>>8&255]+_lut[i>>16&255]+_lut[i>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},damp:function(e,t,n,i){return MathUtils.lerp(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(MathUtils.euclideanModulo(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(_seed=e%2147483647),_seed=16807*_seed%2147483647,(_seed-1)/2147483646},degToRad:function(e){return e*MathUtils.DEG2RAD},radToDeg:function(e){return e*MathUtils.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,i,r){const o=Math.cos,a=Math.sin,s=o(n/2),l=a(n/2),c=o((t+i)/2),h=a((t+i)/2),u=o((t-i)/2),d=a((t-i)/2),p=o((i-t)/2),m=a((i-t)/2);switch(r){case"XYX":e.set(s*h,l*u,l*d,s*c);break;case"YZY":e.set(l*d,s*h,l*u,s*c);break;case"ZXZ":e.set(l*u,l*d,s*h,s*c);break;case"XZX":e.set(s*h,l*m,l*p,s*c);break;case"YXY":e.set(l*p,s*h,l*m,s*c);break;case"ZYZ":e.set(l*m,l*p,s*h,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class Vector2{constructor(e=0,t=0){Object.defineProperty(this,"isVector2",{value:!0}),this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}class Matrix3{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,r,o,a,s,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=r,c[5]=s,c[6]=n,c[7]=o,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return(new this.constructor).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],s=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],m=i[0],f=i[3],g=i[6],v=i[1],y=i[4],b=i[7],_=i[2],x=i[5],w=i[8];return r[0]=o*m+a*v+s*_,r[3]=o*f+a*y+s*x,r[6]=o*g+a*b+s*w,r[1]=l*m+c*v+h*_,r[4]=l*f+c*y+h*x,r[7]=l*g+c*b+h*w,r[2]=u*m+d*v+p*_,r[5]=u*f+d*y+p*x,r[8]=u*g+d*b+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8];return t*o*c-t*a*l-n*r*c+n*a*s+i*r*l-i*o*s}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],h=c*o-a*l,u=a*s-c*r,d=l*r-o*s,p=t*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(i*l-c*n)*m,e[2]=(a*n-i*o)*m,e[3]=u*m,e[4]=(c*t-i*s)*m,e[5]=(i*r-a*t)*m,e[6]=d*m,e[7]=(n*s-l*t)*m,e[8]=(o*t-n*r)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).copy(this).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,o,a){const s=Math.cos(r),l=Math.sin(r);return this.set(n*s,n*l,-n*(s*o+l*a)+o+e,-i*l,i*s,-i*(-l*o+s*a)+a+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,r=i[0],o=i[3],a=i[6],s=i[1],l=i[4],c=i[7];return i[0]=t*r+n*s,i[3]=t*o+n*l,i[6]=t*a+n*c,i[1]=-n*r+t*s,i[4]=-n*o+t*l,i[7]=-n*a+t*c,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}}let _canvas;const ImageUtils={getDataURL:function(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===_canvas&&(_canvas=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),_canvas.width=e.width,_canvas.height=e.height;const n=_canvas.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=_canvas}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}};let textureId=0;function Texture(e=Texture.DEFAULT_IMAGE,t=Texture.DEFAULT_MAPPING,n=ClampToEdgeWrapping,i=ClampToEdgeWrapping,r=LinearFilter,o=LinearMipmapLinearFilter,a=RGBAFormat,s=UnsignedByteType,l=1,c=LinearEncoding){Object.defineProperty(this,"id",{value:textureId++}),this.uuid=MathUtils.generateUUID(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=s,this.offset=new Vector2(0,0),this.repeat=new Vector2(1,1),this.center=new Vector2(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Matrix3,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null}function serializeImage(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ImageUtils.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}Texture.DEFAULT_IMAGE=void 0,Texture.DEFAULT_MAPPING=UVMapping,Texture.prototype=Object.assign(Object.create(EventDispatcher.prototype),{constructor:Texture,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const i=this.image;if(void 0===i.uuid&&(i.uuid=MathUtils.generateUUID()),!t&&void 0===e.images[i.uuid]){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)t.push(serializeImage(i[e].isDataTexture?i[e].image:i[e]))}else t=serializeImage(i);e.images[i.uuid]={uuid:i.uuid,url:t}}n.image=i.uuid}return t||(e.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping!==UVMapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case RepeatWrapping:e.x=e.x-Math.floor(e.x);break;case ClampToEdgeWrapping:e.x=e.x<0?0:1;break;case MirroredRepeatWrapping:e.x=1===Math.abs(Math.floor(e.x)%2)?Math.ceil(e.x)-e.x:e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case RepeatWrapping:e.y=e.y-Math.floor(e.y);break;case ClampToEdgeWrapping:e.y=e.y<0?0:1;break;case MirroredRepeatWrapping:e.y=1===Math.abs(Math.floor(e.y)%2)?Math.ceil(e.y)-e.y:e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(Texture.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}});class Vector4{constructor(e=0,t=0,n=0,i=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const o=.01,a=.1,s=e.elements,l=s[0],c=s[4],h=s[8],u=s[1],d=s[5],p=s[9],m=s[2],f=s[6],g=s[10];if(Math.abs(c-u)<o&&Math.abs(h-m)<o&&Math.abs(p-f)<o){if(Math.abs(c+u)<a&&Math.abs(h+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,s=(d+1)/2,v=(g+1)/2,y=(c+u)/4,b=(h+m)/4,_=(p+f)/4;return e>s&&e>v?e<o?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(e),i=y/n,r=b/n):s>v?s<o?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(s),n=y/i,r=_/i):v<o?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=b/r,i=_/r),this.set(n,i,r,t),this}let v=Math.sqrt((f-p)*(f-p)+(h-m)*(h-m)+(u-c)*(u-c));return Math.abs(v)<.001&&(v=1),this.x=(f-p)/v,this.y=(h-m)/v,this.z=(u-c)/v,this.w=Math.acos((l+d+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}class WebGLRenderTarget extends EventDispatcher{constructor(e,t,n){super(),Object.defineProperty(this,"isWebGLRenderTarget",{value:!0}),this.width=e,this.height=t,this.scissor=new Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new Vector4(0,0,e,t),this.texture=new Texture(void 0,(n=n||{}).mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:LinearFilter,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}setSize(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.texture.image.width=e,this.texture.image.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Quaternion{constructor(e=0,t=0,n=0,i=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=e,this._y=t,this._z=n,this._w=i}static slerp(e,t,n,i){return n.copy(e).slerp(t,i)}static slerpFlat(e,t,n,i,r,o,a){let s=n[i+0],l=n[i+1],c=n[i+2],h=n[i+3];const u=r[o+0],d=r[o+1],p=r[o+2],m=r[o+3];if(h!==m||s!==u||l!==d||c!==p){let e=1-a;const t=s*u+l*d+c*p+h*m,n=t>=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),o=Math.atan2(r,t*n);e=Math.sin(e*o)/r,a=Math.sin(a*o)/r}const r=a*n;if(s=s*e+u*r,l=l*e+d*r,c=c*e+p*r,h=h*e+m*r,e===1-a){const e=1/Math.sqrt(s*s+l*l+c*c+h*h);s*=e,l*=e,c*=e,h*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],s=n[i+1],l=n[i+2],c=n[i+3],h=r[o],u=r[o+1],d=r[o+2],p=r[o+3];return e[t]=a*p+c*h+s*d-l*u,e[t+1]=s*p+c*u+l*h-a*d,e[t+2]=l*p+c*d+a*u-s*h,e[t+3]=c*p-a*h-s*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=s(n/2),d=s(i/2),p=s(r/2);switch(o){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],s=t[9],l=t[2],c=t[6],h=t[10],u=n+a+h;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-s)*e,this._y=(r-l)*e,this._z=(o-i)*e}else if(n>a&&n>h){const e=2*Math.sqrt(1+n-a-h);this._w=(c-s)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(r+l)/e}else if(a>h){const e=2*Math.sqrt(1+a-n-h);this._w=(r-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+h-n-a);this._w=(o-i)/e,this._x=(r+l)/e,this._y=(s+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-6?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(MathUtils.clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+o*a+i*l-r*s,this._y=i*c+o*s+r*a-n*l,this._z=r*c+o*l+n*s-i*a,this._w=o*c-n*a-i*s-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const s=1-a*a;if(s<=Number.EPSILON){const e=1-t;return this._w=e*o+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,a),h=Math.sin((1-t)*c)/l,u=Math.sin(t*c)/l;return this._w=o*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}class Vector3{constructor(e=0,t=0,n=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(_quaternion.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_quaternion.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,s=e.w,l=s*t+o*i-a*n,c=s*n+a*t-r*i,h=s*i+r*n-o*t,u=-r*t-o*n-a*i;return this.x=l*s+u*-r+c*-a-h*-o,this.y=c*s+u*-o+h*-r-l*-a,this.z=h*s+u*-a+l*-o-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,s=t.z;return this.x=i*s-r*a,this.y=r*o-n*s,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return _vector.copy(this).projectOnVector(e),this.sub(_vector)}reflect(e){return this.sub(_vector.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(MathUtils.clamp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}const _vector=new Vector3,_quaternion=new Quaternion;class Box3{constructor(e,t){Object.defineProperty(this,"isBox3",{value:!0}),this.min=void 0!==e?e:new Vector3(1/0,1/0,1/0),this.max=void 0!==t?t:new Vector3(-1/0,-1/0,-1/0)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0;for(let s=0,l=e.length;s<l;s+=3){const l=e[s],c=e[s+1],h=e[s+2];l<t&&(t=l),c<n&&(n=c),h<i&&(i=h),l>r&&(r=l),c>o&&(o=c),h>a&&(a=h)}return this.min.set(t,n,i),this.max.set(r,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0;for(let s=0,l=e.count;s<l;s++){const l=e.getX(s),c=e.getY(s),h=e.getZ(s);l<t&&(t=l),c<n&&(n=c),h<i&&(i=h),l>r&&(r=l),c>o&&(o=c),h>a&&(a=h)}return this.min.set(t,n,i),this.max.set(r,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=_vector$1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return void 0===e&&(console.warn("THREE.Box3: .getCenter() target is now required"),e=new Vector3),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return void 0===e&&(console.warn("THREE.Box3: .getSize() target is now required"),e=new Vector3),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){e.updateWorldMatrix(!1,!1);const t=e.geometry;void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),_box.copy(t.boundingBox),_box.applyMatrix4(e.matrixWorld),this.union(_box));const n=e.children;for(let e=0,t=n.length;e<t;e++)this.expandByObject(n[e]);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new Vector3),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,_vector$1),_vector$1.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_center),_extents.subVectors(this.max,_center),_v0.subVectors(e.a,_center),_v1.subVectors(e.b,_center),_v2.subVectors(e.c,_center),_f0.subVectors(_v1,_v0),_f1.subVectors(_v2,_v1),_f2.subVectors(_v0,_v2);let t=[0,-_f0.z,_f0.y,0,-_f1.z,_f1.y,0,-_f2.z,_f2.y,_f0.z,0,-_f0.x,_f1.z,0,-_f1.x,_f2.z,0,-_f2.x,-_f0.y,_f0.x,0,-_f1.y,_f1.x,0,-_f2.y,_f2.x,0];return!!satForAxes(t,_v0,_v1,_v2,_extents)&&(t=[1,0,0,0,1,0,0,0,1],!!satForAxes(t,_v0,_v1,_v2,_extents)&&(_triangleNormal.crossVectors(_f0,_f1),t=[_triangleNormal.x,_triangleNormal.y,_triangleNormal.z],satForAxes(t,_v0,_v1,_v2,_extents)))}clampPoint(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new Vector3),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return _vector$1.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return void 0===e&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(_vector$1).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(_points[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_points[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_points[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_points[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_points[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_points[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_points[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_points[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_points)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}function satForAxes(e,t,n,i,r){for(let o=0,a=e.length-3;o<=a;o+=3){_testAxis.fromArray(e,o);const a=r.x*Math.abs(_testAxis.x)+r.y*Math.abs(_testAxis.y)+r.z*Math.abs(_testAxis.z),s=t.dot(_testAxis),l=n.dot(_testAxis),c=i.dot(_testAxis);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>a)return!1}return!0}const _points=[new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3],_vector$1=new Vector3,_box=new Box3,_v0=new Vector3,_v1=new Vector3,_v2=new Vector3,_f0=new Vector3,_f1=new Vector3,_f2=new Vector3,_center=new Vector3,_extents=new Vector3,_triangleNormal=new Vector3,_testAxis=new Vector3,_box$1=new Box3;class Sphere{constructor(e,t){this.center=void 0!==e?e:new Vector3,this.radius=void 0!==t?t:-1}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):_box$1.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;t<r;t++)i=Math.max(i,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return void 0===t&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),t=new Vector3),t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Box3),this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}}const _vector$2=new Vector3,_segCenter=new Vector3,_segDir=new Vector3,_diff=new Vector3,_edge1=new Vector3,_edge2=new Vector3,_normal=new Vector3;class Ray{constructor(e,t){this.origin=void 0!==e?e:new Vector3,this.direction=void 0!==t?t:new Vector3(0,0,-1)}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new Vector3),t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_vector$2)),this}closestPointToPoint(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new Vector3),t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=_vector$2.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_vector$2.copy(this.direction).multiplyScalar(t).add(this.origin),_vector$2.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){_segCenter.copy(e).add(t).multiplyScalar(.5),_segDir.copy(t).sub(e).normalize(),_diff.copy(this.origin).sub(_segCenter);const r=.5*e.distanceTo(t),o=-this.direction.dot(_segDir),a=_diff.dot(this.direction),s=-_diff.dot(_segDir),l=_diff.lengthSq(),c=Math.abs(1-o*o);let h,u,d,p;if(c>0)if(h=o*s-a,u=o*a-s,p=r*c,h>=0)if(u>=-p)if(u<=p){const e=1/c;h*=e,u*=e,d=h*(h+o*u+2*a)+u*(o*h+u+2*s)+l}else u=r,h=Math.max(0,-(o*u+a)),d=-h*h+u*(u+2*s)+l;else u=-r,h=Math.max(0,-(o*u+a)),d=-h*h+u*(u+2*s)+l;else u<=-p?(h=Math.max(0,-(-o*r+a)),u=h>0?-r:Math.min(Math.max(-r,-s),r),d=-h*h+u*(u+2*s)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-s),r),d=u*(u+2*s)+l):(h=Math.max(0,-(o*r+a)),u=h>0?r:Math.min(Math.max(-r,-s),r),d=-h*h+u*(u+2*s)+l);else u=o>0?-r:r,h=Math.max(0,-(o*u+a)),d=-h*h+u*(u+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(_segDir).multiplyScalar(u).add(_segCenter),d}intersectSphere(e,t){_vector$2.subVectors(e.center,this.origin);const n=_vector$2.dot(this.direction),i=_vector$2.dot(_vector$2)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,s=n+o;return a<0&&s<0?null:this.at(a<0?s:a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,s;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),c>=0?(r=(e.min.y-u.y)*c,o=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,o=(e.min.y-u.y)*c),n>o||r>i?null:((r>n||n!=n)&&(n=r),(o<i||i!=i)&&(i=o),h>=0?(a=(e.min.z-u.z)*h,s=(e.max.z-u.z)*h):(a=(e.max.z-u.z)*h,s=(e.min.z-u.z)*h),n>s||a>i?null:((a>n||n!=n)&&(n=a),(s<i||i!=i)&&(i=s),i<0?null:this.at(n>=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,_vector$2)}intersectTriangle(e,t,n,i,r){_edge1.subVectors(t,e),_edge2.subVectors(n,e),_normal.crossVectors(_edge1,_edge2);let o,a=this.direction.dot(_normal);if(a>0){if(i)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}_diff.subVectors(this.origin,e);const s=o*this.direction.dot(_edge2.crossVectors(_diff,_edge2));if(s<0)return null;const l=o*this.direction.dot(_edge1.cross(_diff));if(l<0)return null;if(s+l>a)return null;const c=-o*_diff.dot(_normal);return c<0?null:this.at(c/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}class Matrix4{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,r,o,a,s,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Matrix4).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/_v1$1.setFromMatrixColumn(e,0).length(),r=1/_v1$1.setFromMatrixColumn(e,1).length(),o=1/_v1$1.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=o*c,n=o*h,i=a*c,r=a*h;t[0]=s*c,t[4]=-s*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-a*s,t[2]=r-e*l,t[6]=i+n*l,t[10]=o*s}else if("YXZ"===e.order){const e=s*c,n=s*h,i=l*c,r=l*h;t[0]=e+r*a,t[4]=i*a-n,t[8]=o*l,t[1]=o*h,t[5]=o*c,t[9]=-a,t[2]=n*a-i,t[6]=r+e*a,t[10]=o*s}else if("ZXY"===e.order){const e=s*c,n=s*h,i=l*c,r=l*h;t[0]=e-r*a,t[4]=-o*h,t[8]=i+n*a,t[1]=n+i*a,t[5]=o*c,t[9]=r-e*a,t[2]=-o*l,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){const e=o*c,n=o*h,i=a*c,r=a*h;t[0]=s*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=s*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){const e=o*s,n=o*l,i=a*s,r=a*l;t[0]=s*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=o*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=o*s,n=o*l,i=a*s,r=a*l;t[0]=s*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=o*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=a*c,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(_zero,e,_one)}lookAt(e,t,n){const i=this.elements;return _z.subVectors(e,t),0===_z.lengthSq()&&(_z.z=1),_z.normalize(),_x.crossVectors(n,_z),0===_x.lengthSq()&&(1===Math.abs(n.z)?_z.x+=1e-4:_z.z+=1e-4,_z.normalize(),_x.crossVectors(n,_z)),_x.normalize(),_y.crossVectors(_z,_x),i[0]=_x.x,i[4]=_y.x,i[8]=_z.x,i[1]=_x.y,i[5]=_y.y,i[9]=_z.y,i[2]=_x.z,i[6]=_y.z,i[10]=_z.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],s=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],y=n[7],b=n[11],_=n[15],x=i[0],w=i[4],S=i[8],C=i[12],M=i[1],E=i[5],T=i[9],I=i[13],A=i[2],k=i[6],P=i[10],R=i[14],L=i[3],N=i[7],D=i[11],O=i[15];return r[0]=o*x+a*M+s*A+l*L,r[4]=o*w+a*E+s*k+l*N,r[8]=o*S+a*T+s*P+l*D,r[12]=o*C+a*I+s*R+l*O,r[1]=c*x+h*M+u*A+d*L,r[5]=c*w+h*E+u*k+d*N,r[9]=c*S+h*T+u*P+d*D,r[13]=c*C+h*I+u*R+d*O,r[2]=p*x+m*M+f*A+g*L,r[6]=p*w+m*E+f*k+g*N,r[10]=p*S+m*T+f*P+g*D,r[14]=p*C+m*I+f*R+g*O,r[3]=v*x+y*M+b*A+_*L,r[7]=v*w+y*E+b*k+_*N,r[11]=v*S+y*T+b*P+_*D,r[15]=v*C+y*I+b*R+_*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],s=e[9],l=e[13],c=e[2],h=e[6],u=e[10],d=e[14];return e[3]*(+r*s*h-i*l*h-r*a*u+n*l*u+i*a*d-n*s*d)+e[7]*(+t*s*d-t*l*u+r*o*u-i*o*d+i*l*c-r*s*c)+e[11]*(+t*l*h-t*a*d-r*o*h+n*o*d+r*a*c-n*l*c)+e[15]*(-i*a*c-t*s*h+t*a*u+i*o*h-n*o*u+n*s*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],m=e[13],f=e[14],g=e[15],v=h*f*l-m*u*l+m*s*d-a*f*d-h*s*g+a*u*g,y=p*u*l-c*f*l-p*s*d+o*f*d+c*s*g-o*u*g,b=c*m*l-p*h*l+p*a*d-o*m*d-c*a*g+o*h*g,_=p*h*s-c*m*s-p*a*u+o*m*u+c*a*f-o*h*f,x=t*v+n*y+i*b+r*_;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return e[0]=v*w,e[1]=(m*u*r-h*f*r-m*i*d+n*f*d+h*i*g-n*u*g)*w,e[2]=(a*f*r-m*s*r+m*i*l-n*f*l-a*i*g+n*s*g)*w,e[3]=(h*s*r-a*u*r-h*i*l+n*u*l+a*i*d-n*s*d)*w,e[4]=y*w,e[5]=(c*f*r-p*u*r+p*i*d-t*f*d-c*i*g+t*u*g)*w,e[6]=(p*s*r-o*f*r-p*i*l+t*f*l+o*i*g-t*s*g)*w,e[7]=(o*u*r-c*s*r+c*i*l-t*u*l-o*i*d+t*s*d)*w,e[8]=b*w,e[9]=(p*h*r-c*m*r-p*n*d+t*m*d+c*n*g-t*h*g)*w,e[10]=(o*m*r-p*a*r+p*n*l-t*m*l-o*n*g+t*a*g)*w,e[11]=(c*a*r-o*h*r-c*n*l+t*h*l+o*n*d-t*a*d)*w,e[12]=_*w,e[13]=(c*m*i-p*h*i+p*n*u-t*m*u-c*n*f+t*h*f)*w,e[14]=(p*a*i-o*m*i-p*n*s+t*m*s+o*n*f-t*a*f)*w,e[15]=(o*h*i-c*a*i+c*n*s-t*h*s-o*n*u+t*a*u)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10]))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,s=e.z,l=r*o,c=r*a;return this.set(l*o+n,l*a-i*s,l*s+i*a,0,l*a+i*s,c*a+n,c*s-i*o,0,l*s-i*a,c*s+i*o,r*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n){return this.set(1,t,n,0,e,1,n,0,e,t,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,s=t._w,l=r+r,c=o+o,h=a+a,u=r*l,d=r*c,p=r*h,m=o*c,f=o*h,g=a*h,v=s*l,y=s*c,b=s*h,_=n.x,x=n.y,w=n.z;return i[0]=(1-(m+g))*_,i[1]=(d+b)*_,i[2]=(p-y)*_,i[3]=0,i[4]=(d-b)*x,i[5]=(1-(u+g))*x,i[6]=(f+v)*x,i[7]=0,i[8]=(p+y)*w,i[9]=(f-v)*w,i[10]=(1-(u+m))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=_v1$1.set(i[0],i[1],i[2]).length();const o=_v1$1.set(i[4],i[5],i[6]).length(),a=_v1$1.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],_m1.copy(this);const s=1/r,l=1/o,c=1/a;return _m1.elements[0]*=s,_m1.elements[1]*=s,_m1.elements[2]*=s,_m1.elements[4]*=l,_m1.elements[5]*=l,_m1.elements[6]*=l,_m1.elements[8]*=c,_m1.elements[9]*=c,_m1.elements[10]*=c,t.setFromRotationMatrix(_m1),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,s=2*r/(n-i),l=(t+e)/(t-e),c=(n+i)/(n-i),h=-(o+r)/(o-r),u=-2*o*r/(o-r);return a[0]=2*r/(t-e),a[4]=0,a[8]=l,a[12]=0,a[1]=0,a[5]=s,a[9]=c,a[13]=0,a[2]=0,a[6]=0,a[10]=h,a[14]=u,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,r,o){const a=this.elements,s=1/(t-e),l=1/(n-i),c=1/(o-r),h=(t+e)*s,u=(n+i)*l,d=(o+r)*c;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const _v1$1=new Vector3,_m1=new Matrix4,_zero=new Vector3(0,0,0),_one=new Vector3(1,1,1),_x=new Vector3,_y=new Vector3,_z=new Vector3;class Euler{constructor(e=0,t=0,n=0,i=Euler.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._order=i||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t,n){const i=MathUtils.clamp,r=e.elements,o=r[0],a=r[4],s=r[8],l=r[1],c=r[5],h=r[9],u=r[2],d=r[6],p=r[10];switch(t=t||this._order){case"XYZ":this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-i(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,o),this._z=0);break;case"ZXY":this._x=Math.asin(i(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,o));break;case"ZYX":this._y=Math.asin(-i(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(i(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,o)):(this._x=0,this._y=Math.atan2(s,p));break;case"XZY":this._z=Math.asin(-i(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!1!==n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return _matrix.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_matrix,t,n)}setFromVector3(e,t){return this.set(e.x,e.y,e.z,t||this._order)}reorder(e){return _quaternion$1.setFromEuler(this),this.setFromQuaternion(_quaternion$1,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new Vector3(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Euler.DefaultOrder="XYZ",Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];const _matrix=new Matrix4,_quaternion$1=new Quaternion;class Layers{constructor(){this.mask=1}set(e){this.mask=1<<e|0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}}let _object3DId=0;const _v1$2=new Vector3,_q1=new Quaternion,_m1$1=new Matrix4,_target=new Vector3,_position=new Vector3,_scale=new Vector3,_quaternion$2=new Quaternion,_xAxis=new Vector3(1,0,0),_yAxis=new Vector3(0,1,0),_zAxis=new Vector3(0,0,1),_addedEvent={type:"added"},_removedEvent={type:"removed"};function Object3D(){Object.defineProperty(this,"id",{value:_object3DId++}),this.uuid=MathUtils.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Object3D.DefaultUp.clone();const e=new Vector3,t=new Euler,n=new Quaternion,i=new Vector3(1,1,1);t._onChange((function r(){n.setFromEuler(t,!1)})),n._onChange((function o(){t.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Matrix4},normalMatrix:{value:new Matrix3}}),this.matrix=new Matrix4,this.matrixWorld=new Matrix4,this.matrixAutoUpdate=Object3D.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}Object3D.DefaultUp=new Vector3(0,1,0),Object3D.DefaultMatrixAutoUpdate=!0,Object3D.prototype=Object.assign(Object.create(EventDispatcher.prototype),{constructor:Object3D,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(e,t){return _q1.setFromAxisAngle(e,t),this.quaternion.multiply(_q1),this},rotateOnWorldAxis:function(e,t){return _q1.setFromAxisAngle(e,t),this.quaternion.premultiply(_q1),this},rotateX:function(e){return this.rotateOnAxis(_xAxis,e)},rotateY:function(e){return this.rotateOnAxis(_yAxis,e)},rotateZ:function(e){return this.rotateOnAxis(_zAxis,e)},translateOnAxis:function(e,t){return _v1$2.copy(e).applyQuaternion(this.quaternion),this.position.add(_v1$2.multiplyScalar(t)),this},translateX:function(e){return this.translateOnAxis(_xAxis,e)},translateY:function(e){return this.translateOnAxis(_yAxis,e)},translateZ:function(e){return this.translateOnAxis(_zAxis,e)},localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(e){return e.applyMatrix4(_m1$1.copy(this.matrixWorld).invert())},lookAt:function(e,t,n){e.isVector3?_target.copy(e):_target.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),_position.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_m1$1.lookAt(_position,_target,this.up):_m1$1.lookAt(_target,_position,this.up),this.quaternion.setFromRotationMatrix(_m1$1),i&&(_m1$1.extractRotation(i.matrixWorld),_q1.setFromRotationMatrix(_m1$1),this.quaternion.premultiply(_q1.invert()))},add:function(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(_addedEvent)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)},remove:function(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(_removedEvent)),this},clear:function(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(_removedEvent)}return this.children.length=0,this},attach:function(e){return this.updateWorldMatrix(!0,!1),_m1$1.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),_m1$1.multiply(e.parent.matrixWorld)),e.applyMatrix4(_m1$1),e.updateWorldMatrix(!1,!1),this.add(e),this},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}},getWorldPosition:function(e){return void 0===e&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),e=new Vector3),this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(e){return void 0===e&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),e=new Quaternion),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position,e,_scale),e},getWorldScale:function(e){return void 0===e&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),e=new Vector3),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position,_quaternion$2,e),e},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),e=new Vector3),this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()},raycast:function(){},traverse:function(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)},traverseVisible:function(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)},traverseAncestors:function(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)},updateWorldMatrix:function(e,t){const n=this.parent;if(!0===e&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}},toJSON:function(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const i={};function r(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON()),this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t<i;t++)r(e.shapes,n[t]);else r(e.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,i=this.material.length;n<i;n++)t.push(r(e.materials,this.material[n]));i.material=t}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++)i.animations.push(r(e.animations,this.animations[t]))}if(t){const t=o(e.geometries),i=o(e.materials),r=o(e.textures),a=o(e.images),s=o(e.shapes),l=o(e.skeletons),c=o(e.animations);t.length>0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c)}return n.object=i,n;function o(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++)this.add(e.children[t].clone());return this}});const _vector1=new Vector3,_vector2=new Vector3,_normalMatrix=new Matrix3;class Plane{constructor(e,t){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=void 0!==e?e:new Vector3(1,0,0),this.constant=void 0!==t?t:0}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=_vector1.subVectors(n,t).cross(_vector2.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new Vector3),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){void 0===t&&(console.warn("THREE.Plane: .intersectLine() target is now required"),t=new Vector3);const n=e.delta(_vector1),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):void 0;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?void 0:t.copy(n).multiplyScalar(r).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new Vector3),e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||_normalMatrix.getNormalMatrix(e),i=this.coplanarPoint(_vector1).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}const _v0$1=new Vector3,_v1$3=new Vector3,_v2$1=new Vector3,_v3=new Vector3,_vab=new Vector3,_vac=new Vector3,_vbc=new Vector3,_vap=new Vector3,_vbp=new Vector3,_vcp=new Vector3;class Triangle{constructor(e,t,n){this.a=void 0!==e?e:new Vector3,this.b=void 0!==t?t:new Vector3,this.c=void 0!==n?n:new Vector3}static getNormal(e,t,n,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new Vector3),i.subVectors(n,t),_v0$1.subVectors(e,t),i.cross(_v0$1);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){_v0$1.subVectors(i,t),_v1$3.subVectors(n,t),_v2$1.subVectors(e,t);const o=_v0$1.dot(_v0$1),a=_v0$1.dot(_v1$3),s=_v0$1.dot(_v2$1),l=_v1$3.dot(_v1$3),c=_v1$3.dot(_v2$1),h=o*l-a*a;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new Vector3),0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*s-a*c)*u,p=(o*c-a*s)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,_v3),_v3.x>=0&&_v3.y>=0&&_v3.x+_v3.y<=1}static getUV(e,t,n,i,r,o,a,s){return this.getBarycoord(e,t,n,i,_v3),s.set(0,0),s.addScaledVector(r,_v3.x),s.addScaledVector(o,_v3.y),s.addScaledVector(a,_v3.z),s}static isFrontFacing(e,t,n,i){return _v0$1.subVectors(n,t),_v1$3.subVectors(e,t),_v0$1.cross(_v1$3).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return _v0$1.subVectors(this.c,this.b),_v1$3.subVectors(this.a,this.b),.5*_v0$1.cross(_v1$3).length()}getMidpoint(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new Vector3),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Triangle.getNormal(this.a,this.b,this.c,e)}getPlane(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new Plane),e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Triangle.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return Triangle.getUV(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Triangle.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Triangle.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){void 0===t&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new Vector3);const n=this.a,i=this.b,r=this.c;let o,a;_vab.subVectors(i,n),_vac.subVectors(r,n),_vap.subVectors(e,n);const s=_vab.dot(_vap),l=_vac.dot(_vap);if(s<=0&&l<=0)return t.copy(n);_vbp.subVectors(e,i);const c=_vab.dot(_vbp),h=_vac.dot(_vbp);if(c>=0&&h<=c)return t.copy(i);const u=s*h-c*l;if(u<=0&&s>=0&&c<=0)return o=s/(s-c),t.copy(n).addScaledVector(_vab,o);_vcp.subVectors(e,r);const d=_vab.dot(_vcp),p=_vac.dot(_vcp);if(p>=0&&d<=p)return t.copy(r);const m=d*l-s*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(_vac,a);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return _vbc.subVectors(r,i),a=(h-c)/(h-c+(d-p)),t.copy(i).addScaledVector(_vbc,a);const g=1/(f+m+u);return o=m*g,a=u*g,t.copy(n).addScaledVector(_vab,o).addScaledVector(_vac,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const _colorKeywords={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},_hslA={h:0,s:0,l:0},_hslB={h:0,s:0,l:0};function hue2rgb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function LinearToSRGB(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class Color{constructor(e,t,n){return Object.defineProperty(this,"isColor",{value:!0}),void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=MathUtils.euclideanModulo(e,1),t=MathUtils.clamp(t,0,1),n=MathUtils.clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=hue2rgb(r,i,e+1/3),this.g=hue2rgb(r,i,e),this.b=hue2rgb(r,i,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const i=n[2];switch(n[1]){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const n=parseFloat(e[1])/360,i=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(n,i,r)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=n[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=_colorKeywords[e];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){const n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=SRGBToLinear(e.r),this.g=SRGBToLinear(e.g),this.b=SRGBToLinear(e.b),this}copyLinearToSRGB(e){return this.r=LinearToSRGB(e.r),this.g=LinearToSRGB(e.g),this.b=LinearToSRGB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});const t=this.r,n=this.g,i=this.b,r=Math.max(t,n,i),o=Math.min(t,n,i);let a,s;const l=(o+r)/2;if(o===r)a=0,s=0;else{const e=r-o;switch(s=l<=.5?e/(r+o):e/(2-r-o),r){case t:a=(n-i)/e+(n<i?6:0);break;case n:a=(i-t)/e+2;break;case i:a=(t-n)/e+4}a/=6}return e.h=a,e.s=s,e.l=l,e}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(e,t,n){return this.getHSL(_hslA),_hslA.h+=e,_hslA.s+=t,_hslA.l+=n,this.setHSL(_hslA.h,_hslA.s,_hslA.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(_hslA),e.getHSL(_hslB);const n=MathUtils.lerp(_hslA.h,_hslB.h,t),i=MathUtils.lerp(_hslA.s,_hslB.s,t),r=MathUtils.lerp(_hslA.l,_hslB.l,t);return this.setHSL(n,i,r),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}Color.NAMES=_colorKeywords,Color.prototype.r=1,Color.prototype.g=1,Color.prototype.b=1;class Face3{constructor(e,t,n,i,r,o=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new Vector3,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new Color,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=o}clone(){return(new this.constructor).copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}}let materialId=0;function Material(){Object.defineProperty(this,"id",{value:materialId++}),this.uuid=MathUtils.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=NormalBlending,this.side=FrontSide,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=SrcAlphaFactor,this.blendDst=OneMinusSrcAlphaFactor,this.blendEquation=AddEquation,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=LessEqualDepth,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AlwaysStencilFunc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=KeepStencilOp,this.stencilZFail=KeepStencilOp,this.stencilZPass=KeepStencilOp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}function MeshBasicMaterial(e){Material.call(this),this.type="MeshBasicMaterial",this.color=new Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(e)}Material.prototype=Object.assign(Object.create(EventDispatcher.prototype),{constructor:Material,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===FlatShading;continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}},toJSON:function(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==NormalBlending&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==FrontSide&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Material.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),MeshBasicMaterial.prototype=Object.create(Material.prototype),MeshBasicMaterial.prototype.constructor=MeshBasicMaterial,MeshBasicMaterial.prototype.isMeshBasicMaterial=!0,MeshBasicMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this};const _vector$3=new Vector3,_vector2$1=new Vector2;function BufferAttribute(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=StaticDrawUsage,this.updateRange={offset:0,count:-1},this.version=0}function Int8BufferAttribute(e,t,n){BufferAttribute.call(this,new Int8Array(e),t,n)}function Uint8BufferAttribute(e,t,n){BufferAttribute.call(this,new Uint8Array(e),t,n)}function Uint8ClampedBufferAttribute(e,t,n){BufferAttribute.call(this,new Uint8ClampedArray(e),t,n)}function Int16BufferAttribute(e,t,n){BufferAttribute.call(this,new Int16Array(e),t,n)}function Uint16BufferAttribute(e,t,n){BufferAttribute.call(this,new Uint16Array(e),t,n)}function Int32BufferAttribute(e,t,n){BufferAttribute.call(this,new Int32Array(e),t,n)}function Uint32BufferAttribute(e,t,n){BufferAttribute.call(this,new Uint32Array(e),t,n)}function Float16BufferAttribute(e,t,n){BufferAttribute.call(this,new Uint16Array(e),t,n)}function Float32BufferAttribute(e,t,n){BufferAttribute.call(this,new Float32Array(e),t,n)}function Float64BufferAttribute(e,t,n){BufferAttribute.call(this,new Float64Array(e),t,n)}function arrayMax(e){if(0===e.length)return-1/0;let t=e[0];for(let n=1,i=e.length;n<i;++n)e[n]>t&&(t=e[n]);return t}Object.defineProperty(BufferAttribute.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(BufferAttribute.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){const t=this.array;let n=0;for(let i=0,r=e.length;i<r;i++){let r=e[i];void 0===r&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),r=new Color),t[n++]=r.r,t[n++]=r.g,t[n++]=r.b}return this},copyVector2sArray:function(e){const t=this.array;let n=0;for(let i=0,r=e.length;i<r;i++){let r=e[i];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),r=new Vector2),t[n++]=r.x,t[n++]=r.y}return this},copyVector3sArray:function(e){const t=this.array;let n=0;for(let i=0,r=e.length;i<r;i++){let r=e[i];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),r=new Vector3),t[n++]=r.x,t[n++]=r.y,t[n++]=r.z}return this},copyVector4sArray:function(e){const t=this.array;let n=0;for(let i=0,r=e.length;i<r;i++){let r=e[i];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),r=new Vector4),t[n++]=r.x,t[n++]=r.y,t[n++]=r.z,t[n++]=r.w}return this},applyMatrix3:function(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)_vector2$1.fromBufferAttribute(this,t),_vector2$1.applyMatrix3(e),this.setXY(t,_vector2$1.x,_vector2$1.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)_vector$3.fromBufferAttribute(this,t),_vector$3.applyMatrix3(e),this.setXYZ(t,_vector$3.x,_vector$3.y,_vector$3.z);return this},applyMatrix4:function(e){for(let t=0,n=this.count;t<n;t++)_vector$3.x=this.getX(t),_vector$3.y=this.getY(t),_vector$3.z=this.getZ(t),_vector$3.applyMatrix4(e),this.setXYZ(t,_vector$3.x,_vector$3.y,_vector$3.z);return this},applyNormalMatrix:function(e){for(let t=0,n=this.count;t<n;t++)_vector$3.x=this.getX(t),_vector$3.y=this.getY(t),_vector$3.z=this.getZ(t),_vector$3.applyNormalMatrix(e),this.setXYZ(t,_vector$3.x,_vector$3.y,_vector$3.z);return this},transformDirection:function(e){for(let t=0,n=this.count;t<n;t++)_vector$3.x=this.getX(t),_vector$3.y=this.getY(t),_vector$3.z=this.getZ(t),_vector$3.transformDirection(e),this.setXYZ(t,_vector$3.x,_vector$3.y,_vector$3.z);return this},set:function(e,t=0){return this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,n){return this.array[0+(e*=this.itemSize)]=t,this.array[e+1]=n,this},setXYZ:function(e,t,n,i){return this.array[0+(e*=this.itemSize)]=t,this.array[e+1]=n,this.array[e+2]=i,this},setXYZW:function(e,t,n,i,r){return this.array[0+(e*=this.itemSize)]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}}),Int8BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Int8BufferAttribute.prototype.constructor=Int8BufferAttribute,Uint8BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Uint8BufferAttribute.prototype.constructor=Uint8BufferAttribute,Uint8ClampedBufferAttribute.prototype=Object.create(BufferAttribute.prototype),Uint8ClampedBufferAttribute.prototype.constructor=Uint8ClampedBufferAttribute,Int16BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Int16BufferAttribute.prototype.constructor=Int16BufferAttribute,Uint16BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Uint16BufferAttribute.prototype.constructor=Uint16BufferAttribute,Int32BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Int32BufferAttribute.prototype.constructor=Int32BufferAttribute,Uint32BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Uint32BufferAttribute.prototype.constructor=Uint32BufferAttribute,Float16BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Float16BufferAttribute.prototype.constructor=Float16BufferAttribute,Float16BufferAttribute.prototype.isFloat16BufferAttribute=!0,Float32BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Float32BufferAttribute.prototype.constructor=Float32BufferAttribute,Float64BufferAttribute.prototype=Object.create(BufferAttribute.prototype),Float64BufferAttribute.prototype.constructor=Float64BufferAttribute;const TYPED_ARRAYS={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function getTypedArray(e,t){return new TYPED_ARRAYS[e](t)}let _id=0;const _m1$2=new Matrix4,_obj=new Object3D,_offset=new Vector3,_box$2=new Box3,_boxMorphTargets=new Box3,_vector$4=new Vector3;function BufferGeometry(){Object.defineProperty(this,"id",{value:_id++}),this.uuid=MathUtils.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}BufferGeometry.prototype=Object.assign(Object.create(EventDispatcher.prototype),{constructor:BufferGeometry,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){return this.index=Array.isArray(e)?new(arrayMax(e)>65535?Uint32BufferAttribute:Uint16BufferAttribute)(e,1):e,this},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},hasAttribute:function(e){return void 0!==this.attributes[e]},addGroup:function(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new Matrix3).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(e){return _m1$2.makeRotationX(e),this.applyMatrix4(_m1$2),this},rotateY:function(e){return _m1$2.makeRotationY(e),this.applyMatrix4(_m1$2),this},rotateZ:function(e){return _m1$2.makeRotationZ(e),this.applyMatrix4(_m1$2),this},translate:function(e,t,n){return _m1$2.makeTranslation(e,t,n),this.applyMatrix4(_m1$2),this},scale:function(e,t,n){return _m1$2.makeScale(e,t,n),this.applyMatrix4(_m1$2),this},lookAt:function(e){return _obj.lookAt(e),_obj.updateMatrix(),this.applyMatrix4(_obj.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(_offset).negate(),this.translate(_offset.x,_offset.y,_offset.z),this},setFromPoints:function(e){const t=[];for(let n=0,i=e.length;n<i;n++){const i=e[n];t.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new Float32BufferAttribute(t,3)),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Box3);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Vector3(-1/0,-1/0,-1/0),new Vector3(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++)_box$2.setFromBufferAttribute(t[e]),this.morphTargetsRelative?(_vector$4.addVectors(this.boundingBox.min,_box$2.min),this.boundingBox.expandByPoint(_vector$4),_vector$4.addVectors(this.boundingBox.max,_box$2.max),this.boundingBox.expandByPoint(_vector$4)):(this.boundingBox.expandByPoint(_box$2.min),this.boundingBox.expandByPoint(_box$2.max))}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Sphere);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Vector3,1/0);if(e){const n=this.boundingSphere.center;if(_box$2.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++)_boxMorphTargets.setFromBufferAttribute(t[e]),this.morphTargetsRelative?(_vector$4.addVectors(_box$2.min,_boxMorphTargets.min),_box$2.expandByPoint(_vector$4),_vector$4.addVectors(_box$2.max,_boxMorphTargets.max),_box$2.expandByPoint(_vector$4)):(_box$2.expandByPoint(_boxMorphTargets.min),_box$2.expandByPoint(_boxMorphTargets.max));_box$2.getCenter(n);let i=0;for(let t=0,r=e.count;t<r;t++)_vector$4.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(_vector$4));if(t)for(let r=0,o=t.length;r<o;r++){const o=t[r],a=this.morphTargetsRelative;for(let t=0,r=o.count;t<r;t++)_vector$4.fromBufferAttribute(o,t),a&&(_offset.fromBufferAttribute(e,t),_vector$4.add(_offset)),i=Math.max(i,n.distanceToSquared(_vector$4))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeTangents:function(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.array,i=t.position.array,r=t.normal.array,o=t.uv.array,a=i.length/3;void 0===t.tangent&&this.setAttribute("tangent",new BufferAttribute(new Float32Array(4*a),4));const s=t.tangent.array,l=[],c=[];for(let e=0;e<a;e++)l[e]=new Vector3,c[e]=new Vector3;const h=new Vector3,u=new Vector3,d=new Vector3,p=new Vector2,m=new Vector2,f=new Vector2,g=new Vector3,v=new Vector3;function y(e,t,n){h.fromArray(i,3*e),u.fromArray(i,3*t),d.fromArray(i,3*n),p.fromArray(o,2*e),m.fromArray(o,2*t),f.fromArray(o,2*n),u.sub(h),d.sub(h),m.sub(p),f.sub(p);const r=1/(m.x*f.y-f.x*m.y);isFinite(r)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(r),v.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(r),l[e].add(g),l[t].add(g),l[n].add(g),c[e].add(v),c[t].add(v),c[n].add(v))}let b=this.groups;0===b.length&&(b=[{start:0,count:n.length}]);for(let e=0,t=b.length;e<t;++e){const t=b[e],i=t.start;for(let e=i,r=i+t.count;e<r;e+=3)y(n[e+0],n[e+1],n[e+2])}const _=new Vector3,x=new Vector3,w=new Vector3,S=new Vector3;function C(e){w.fromArray(r,3*e),S.copy(w);const t=l[e];_.copy(t),_.sub(w.multiplyScalar(w.dot(t))).normalize(),x.crossVectors(S,t);const n=x.dot(c[e])<0?-1:1;s[4*e]=_.x,s[4*e+1]=_.y,s[4*e+2]=_.z,s[4*e+3]=n}for(let e=0,t=b.length;e<t;++e){const t=b[e],i=t.start;for(let e=i,r=i+t.count;e<r;e+=3)C(n[e+0]),C(n[e+1]),C(n[e+2])}},computeVertexNormals:function(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new BufferAttribute(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const i=new Vector3,r=new Vector3,o=new Vector3,a=new Vector3,s=new Vector3,l=new Vector3,c=new Vector3,h=new Vector3;if(e)for(let u=0,d=e.count;u<d;u+=3){const d=e.getX(u+0),p=e.getX(u+1),m=e.getX(u+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),o.fromBufferAttribute(t,m),c.subVectors(o,r),h.subVectors(i,r),c.cross(h),a.fromBufferAttribute(n,d),s.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),a.add(c),s.add(c),l.add(c),n.setXYZ(d,a.x,a.y,a.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let e=0,a=t.count;e<a;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),o.fromBufferAttribute(t,e+2),c.subVectors(o,r),h.subVectors(i,r),c.cross(h),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}},merge:function(e,t){if(!e||!e.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const n=this.attributes;for(const i in n){if(void 0===e.attributes[i])continue;const r=n[i].array,o=e.attributes[i],a=o.array,s=o.itemSize*t,l=Math.min(a.length,r.length-s);for(let e=0,t=s;e<l;e++,t++)r[t]=a[e]}return this},normalizeNormals:function(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_vector$4.fromBufferAttribute(e,t),_vector$4.normalize(),e.setXYZ(t,_vector$4.x,_vector$4.y,_vector$4.z)},toNonIndexed:function(){function e(e,t){const n=e.array,i=e.itemSize,r=e.normalized,o=new n.constructor(t.length*i);let a=0,s=0;for(let e=0,r=t.length;e<r;e++){a=t[e]*i;for(let e=0;e<i;e++)o[s++]=n[a++]}return new BufferAttribute(o,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new BufferGeometry,n=this.index.array,i=this.attributes;for(const r in i){const o=e(i[r],n);t.setAttribute(r,o)}const r=this.morphAttributes;for(const i in r){const o=[],a=r[i];for(let t=0,i=a.length;t<i;t++){const i=e(a[t],n);o.push(i)}t.morphAttributes[i]=o}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let e=0,n=o.length;e<n;e++){const n=o[e];t.addGroup(n.start,n.count,n.materialIndex)}return t},toJSON:function(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t],r=i.toJSON(e.data);""!==i.name&&(r.name=i.name),e.data.attributes[t]=r}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],o=[];for(let t=0,i=n.length;t<i;t++){const i=n[t],r=i.toJSON(e.data);""!==i.name&&(r.name=i.name),o.push(r)}o.length>0&&(i[t]=o,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e},clone:function(){return(new BufferGeometry).copy(this)},copy:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i)this.setAttribute(e,i[e].clone(t));const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e<r;e++)n.push(i[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let e=0,t=o.length;e<t;e++){const t=o[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const s=e.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});const _inverseMatrix=new Matrix4,_ray=new Ray,_sphere=new Sphere,_vA=new Vector3,_vB=new Vector3,_vC=new Vector3,_tempA=new Vector3,_tempB=new Vector3,_tempC=new Vector3,_morphA=new Vector3,_morphB=new Vector3,_morphC=new Vector3,_uvA=new Vector2,_uvB=new Vector2,_uvC=new Vector2,_intersectionPoint=new Vector3,_intersectionPointWorld=new Vector3;function Mesh(e=new BufferGeometry,t=new MeshBasicMaterial){Object3D.call(this),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}function checkIntersection(e,t,n,i,r,o,a,s){let l;if(l=t.side===BackSide?i.intersectTriangle(a,o,r,!0,s):i.intersectTriangle(r,o,a,t.side!==DoubleSide,s),null===l)return null;_intersectionPointWorld.copy(s),_intersectionPointWorld.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(_intersectionPointWorld);return c<n.near||c>n.far?null:{distance:c,point:_intersectionPointWorld.clone(),object:e}}function checkBufferGeometryIntersection(e,t,n,i,r,o,a,s,l,c,h,u){_vA.fromBufferAttribute(r,c),_vB.fromBufferAttribute(r,h),_vC.fromBufferAttribute(r,u);const d=e.morphTargetInfluences;if(t.morphTargets&&o&&d){_morphA.set(0,0,0),_morphB.set(0,0,0),_morphC.set(0,0,0);for(let e=0,t=o.length;e<t;e++){const t=d[e],n=o[e];0!==t&&(_tempA.fromBufferAttribute(n,c),_tempB.fromBufferAttribute(n,h),_tempC.fromBufferAttribute(n,u),a?(_morphA.addScaledVector(_tempA,t),_morphB.addScaledVector(_tempB,t),_morphC.addScaledVector(_tempC,t)):(_morphA.addScaledVector(_tempA.sub(_vA),t),_morphB.addScaledVector(_tempB.sub(_vB),t),_morphC.addScaledVector(_tempC.sub(_vC),t)))}_vA.add(_morphA),_vB.add(_morphB),_vC.add(_morphC)}e.isSkinnedMesh&&(e.boneTransform(c,_vA),e.boneTransform(h,_vB),e.boneTransform(u,_vC));const p=checkIntersection(e,t,n,i,_vA,_vB,_vC,_intersectionPoint);if(p){s&&(_uvA.fromBufferAttribute(s,c),_uvB.fromBufferAttribute(s,h),_uvC.fromBufferAttribute(s,u),p.uv=Triangle.getUV(_intersectionPoint,_vA,_vB,_vC,_uvA,_uvB,_uvC,new Vector2)),l&&(_uvA.fromBufferAttribute(l,c),_uvB.fromBufferAttribute(l,h),_uvC.fromBufferAttribute(l,u),p.uv2=Triangle.getUV(_intersectionPoint,_vA,_vB,_vC,_uvA,_uvB,_uvC,new Vector2));const e=new Face3(c,h,u);Triangle.getNormal(_vA,_vB,_vC,e.normal),p.face=e}return p}Mesh.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:Mesh,isMesh:!0,copy:function(e){return Object3D.prototype.copy.call(this,e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){const n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere.copy(n.boundingSphere),_sphere.applyMatrix4(r),!1===e.ray.intersectsSphere(_sphere))return;if(_inverseMatrix.copy(r).invert(),_ray.copy(e.ray).applyMatrix4(_inverseMatrix),null!==n.boundingBox&&!1===_ray.intersectsBox(n.boundingBox))return;let o;if(n.isBufferGeometry){const r=n.index,a=n.attributes.position,s=n.morphAttributes.position,l=n.morphTargetsRelative,c=n.attributes.uv,h=n.attributes.uv2,u=n.groups,d=n.drawRange;if(null!==r)if(Array.isArray(i))for(let n=0,p=u.length;n<p;n++){const p=u[n],m=i[p.materialIndex];for(let n=Math.max(p.start,d.start),i=Math.min(p.start+p.count,d.start+d.count);n<i;n+=3){const i=r.getX(n),u=r.getX(n+1),d=r.getX(n+2);o=checkBufferGeometryIntersection(this,m,e,_ray,a,s,l,c,h,i,u,d),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=p.materialIndex,t.push(o))}}else for(let n=Math.max(0,d.start),u=Math.min(r.count,d.start+d.count);n<u;n+=3){const u=r.getX(n),d=r.getX(n+1),p=r.getX(n+2);o=checkBufferGeometryIntersection(this,i,e,_ray,a,s,l,c,h,u,d,p),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}else if(void 0!==a)if(Array.isArray(i))for(let n=0,r=u.length;n<r;n++){const r=u[n],p=i[r.materialIndex];for(let n=Math.max(r.start,d.start),i=Math.min(r.start+r.count,d.start+d.count);n<i;n+=3)o=checkBufferGeometryIntersection(this,p,e,_ray,a,s,l,c,h,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=r.materialIndex,t.push(o))}else for(let n=Math.max(0,d.start),r=Math.min(a.count,d.start+d.count);n<r;n+=3)o=checkBufferGeometryIntersection(this,i,e,_ray,a,s,l,c,h,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}else n.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}});class BoxGeometry extends BufferGeometry{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const s=[],l=[],c=[],h=[];let u=0,d=0;function p(e,t,n,i,r,o,p,m,f,g,v){const y=o/f,b=p/g,_=o/2,x=p/2,w=m/2,S=f+1,C=g+1;let M=0,E=0;const T=new Vector3;for(let o=0;o<C;o++){const a=o*b-x;for(let s=0;s<S;s++)T[e]=(s*y-_)*i,T[t]=a*r,T[n]=w,l.push(T.x,T.y,T.z),T[e]=0,T[t]=0,T[n]=m>0?1:-1,c.push(T.x,T.y,T.z),h.push(s/f),h.push(1-o/g),M+=1}for(let e=0;e<g;e++)for(let t=0;t<f;t++){const n=u+t+S*(e+1),i=u+(t+1)+S*(e+1),r=u+(t+1)+S*e;s.push(u+t+S*e,n,r),s.push(n,i,r),E+=6}a.addGroup(d,E,v),d+=E,u+=M}p("z","y","x",-1,-1,n,t,e,o,r,0),p("z","y","x",1,-1,n,t,-e,o,r,1),p("x","z","y",1,1,e,n,t,i,o,2),p("x","z","y",1,-1,e,n,-t,i,o,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(s),this.setAttribute("position",new Float32BufferAttribute(l,3)),this.setAttribute("normal",new Float32BufferAttribute(c,3)),this.setAttribute("uv",new Float32BufferAttribute(h,2))}}function cloneUniforms(e){const t={};for(const n in e){t[n]={};for(const i in e[n]){const r=e[n][i];t[n][i]=r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?r.clone():Array.isArray(r)?r.slice():r}}return t}function mergeUniforms(e){const t={};for(let n=0;n<e.length;n++){const i=cloneUniforms(e[n]);for(const e in i)t[e]=i[e]}return t}const UniformsUtils={clone:cloneUniforms,merge:mergeUniforms};var default_vertex="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",default_fragment="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";function ShaderMaterial(e){Material.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=default_vertex,this.fragmentShader=default_fragment,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}function Camera(){Object3D.call(this),this.type="Camera",this.matrixWorldInverse=new Matrix4,this.projectionMatrix=new Matrix4,this.projectionMatrixInverse=new Matrix4}function PerspectiveCamera(e=50,t=1,n=.1,i=2e3){Camera.call(this),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}ShaderMaterial.prototype=Object.create(Material.prototype),ShaderMaterial.prototype.constructor=ShaderMaterial,ShaderMaterial.prototype.isShaderMaterial=!0,ShaderMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=cloneUniforms(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this},ShaderMaterial.prototype.toJSON=function(e){const t=Material.prototype.toJSON.call(this,e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;t.uniforms[n]=i&&i.isTexture?{type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?{type:"c",value:i.getHex()}:i&&i.isVector2?{type:"v2",value:i.toArray()}:i&&i.isVector3?{type:"v3",value:i.toArray()}:i&&i.isVector4?{type:"v4",value:i.toArray()}:i&&i.isMatrix3?{type:"m3",value:i.toArray()}:i&&i.isMatrix4?{type:"m4",value:i.toArray()}:{value:i}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t},Camera.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:Camera,isCamera:!0,copy:function(e,t){return Object3D.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new Vector3),this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){Object3D.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(e,t){Object3D.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return(new this.constructor).copy(this)}}),PerspectiveCamera.prototype=Object.assign(Object.create(Camera.prototype),{constructor:PerspectiveCamera,isPerspectiveCamera:!0,copy:function(e,t){return Camera.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){const t=.5*this.getFilmHeight()/e;this.fov=2*MathUtils.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){const e=Math.tan(.5*MathUtils.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*MathUtils.RAD2DEG*Math.atan(Math.tan(.5*MathUtils.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,n,i,r,o){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const e=this.near;let t=e*Math.tan(.5*MathUtils.DEG2RAD*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(null!==this.view&&this.view.enabled){const e=o.fullWidth,a=o.fullHeight;r+=o.offsetX*i/e,t-=o.offsetY*n/a,i*=o.width/e,n*=o.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){const t=Object3D.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});const fov=90,aspect=1;function CubeCamera(e,t,n){if(Object3D.call(this),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const i=new PerspectiveCamera(fov,aspect,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Vector3(1,0,0)),this.add(i);const r=new PerspectiveCamera(fov,aspect,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Vector3(-1,0,0)),this.add(r);const o=new PerspectiveCamera(fov,aspect,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new Vector3(0,1,0)),this.add(o);const a=new PerspectiveCamera(fov,aspect,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new Vector3(0,-1,0)),this.add(a);const s=new PerspectiveCamera(fov,aspect,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new Vector3(0,0,1)),this.add(s);const l=new PerspectiveCamera(fov,aspect,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Vector3(0,0,-1)),this.add(l),this.update=function(e,t){null===this.parent&&this.updateMatrixWorld();const c=e.xr.enabled,h=e.getRenderTarget();e.xr.enabled=!1;const u=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=u,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(h),e.xr.enabled=c}}function CubeTexture(e,t,n,i,r,o,a,s,l,c){Texture.call(this,e=void 0!==e?e:[],t=void 0!==t?t:CubeReflectionMapping,n,i,r,o,a=void 0!==a?a:RGBFormat,s,l,c),this.flipY=!1,this._needsFlipEnvMap=!0}CubeCamera.prototype=Object.create(Object3D.prototype),CubeCamera.prototype.constructor=CubeCamera,CubeTexture.prototype=Object.create(Texture.prototype),CubeTexture.prototype.constructor=CubeTexture,CubeTexture.prototype.isCubeTexture=!0,Object.defineProperty(CubeTexture.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});class WebGLCubeRenderTarget extends WebGLRenderTarget{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),super(e,e,t),Object.defineProperty(this,"isWebGLCubeRenderTarget",{value:!0}),this.texture=new CubeTexture(void 0,(t=t||{}).mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=RGBAFormat,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new BoxGeometry(5,5,5),i=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:BackSide,blending:NoBlending});i.uniforms.tEquirect.value=t;const r=new Mesh(n,i),o=t.minFilter;return t.minFilter===LinearMipmapLinearFilter&&(t.minFilter=LinearFilter),new CubeCamera(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}function DataTexture(e,t,n,i,r,o,a,s,l,c,h,u){Texture.call(this,null,o,a,s,l,c,i,r,h,u),this.image={data:e||null,width:t||1,height:n||1},this.magFilter=void 0!==l?l:NearestFilter,this.minFilter=void 0!==c?c:NearestFilter,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}DataTexture.prototype=Object.create(Texture.prototype),DataTexture.prototype.constructor=DataTexture,DataTexture.prototype.isDataTexture=!0;const _sphere$1=new Sphere,_vector$5=new Vector3;class Frustum{constructor(e,t,n,i,r,o){this.planes=[void 0!==e?e:new Plane,void 0!==t?t:new Plane,void 0!==n?n:new Plane,void 0!==i?i:new Plane,void 0!==r?r:new Plane,void 0!==o?o:new Plane]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}clone(){return(new this.constructor).copy(this)}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],r=n[1],o=n[2],a=n[3],s=n[4],l=n[5],c=n[6],h=n[7],u=n[8],d=n[9],p=n[10],m=n[11],f=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(a-i,h-s,m-u,y-f).normalize(),t[1].setComponents(a+i,h+s,m+u,y+f).normalize(),t[2].setComponents(a+r,h+l,m+d,y+g).normalize(),t[3].setComponents(a-r,h-l,m-d,y-g).normalize(),t[4].setComponents(a-o,h-c,m-p,y-v).normalize(),t[5].setComponents(a+o,h+c,m+p,y+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),_sphere$1.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(_sphere$1)}intersectsSprite(e){return _sphere$1.center.set(0,0,0),_sphere$1.radius=.7071067811865476,_sphere$1.applyMatrix4(e.matrixWorld),this.intersectsSphere(_sphere$1)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(_vector$5.x=i.normal.x>0?e.max.x:e.min.x,_vector$5.y=i.normal.y>0?e.max.y:e.min.y,_vector$5.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(_vector$5)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}}function WebGLAnimation(){let e=null,t=!1,n=null,i=null;function r(t,o){n(t,o),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function WebGLAttributes(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function r(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function o(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function a(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version<t.version)&&i.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const o=i.get(t);void 0===o?i.set(t,(function a(t,i){const r=t.array,o=t.usage,a=e.createBuffer();e.bindBuffer(i,a),e.bufferData(i,r,o),t.onUploadCallback();let s=5126;return r instanceof Float32Array?s=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?t.isFloat16BufferAttribute?n?s=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):s=5123:r instanceof Int16Array?s=5122:r instanceof Uint32Array?s=5125:r instanceof Int32Array?s=5124:r instanceof Int8Array?s=5120:r instanceof Uint8Array&&(s=5121),{buffer:a,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}})(t,r)):o.version<t.version&&((function s(t,i,r){const o=i.array,a=i.updateRange;e.bindBuffer(r,t),-1===a.count?e.bufferSubData(r,0,o):(n?e.bufferSubData(r,a.offset*o.BYTES_PER_ELEMENT,o,a.offset,a.count):e.bufferSubData(r,a.offset*o.BYTES_PER_ELEMENT,o.subarray(a.offset,a.offset+a.count)),a.count=-1)})(o.buffer,t,r),o.version=t.version)}}}class PlaneGeometry extends BufferGeometry{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,o=t/2,a=Math.floor(n),s=Math.floor(i),l=a+1,c=s+1,h=e/a,u=t/s,d=[],p=[],m=[],f=[];for(let e=0;e<c;e++){const t=e*u-o;for(let n=0;n<l;n++)p.push(n*h-r,-t,0),m.push(0,0,1),f.push(n/a),f.push(1-e/s)}for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=t+l*(e+1),i=t+1+l*(e+1),r=t+1+l*e;d.push(t+l*e,n,r),d.push(n,i,r)}this.setIndex(d),this.setAttribute("position",new Float32BufferAttribute(p,3)),this.setAttribute("normal",new Float32BufferAttribute(m,3)),this.setAttribute("uv",new Float32BufferAttribute(f,2))}}var alphamap_fragment="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment="#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment="#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex="vec3 transformed = vec3( position );",beginnormal_vertex="vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs="vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment="#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex="#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment="#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex="#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex="#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor.xyz *= color.xyz;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common="#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment="#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex="vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment="gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment="\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment="#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment="#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment="#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_vertex="#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex="#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex="#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment="#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment="#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment="#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin="uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",envmap_physical_pars_fragment="#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",lights_toon_fragment="ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment="varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment="varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment="struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps="#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end="#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment="#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment="#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment="#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin="#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps="#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin="#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps="#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_pars_fragment="#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing="vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex="vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment="#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment="#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment="#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment="#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment="#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment="#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment="#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex="#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex="#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex="#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag="uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",background_vert="varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag="#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert="#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert="#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag="uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert="#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag="uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert="#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag="#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert="#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag="#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert="#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert="#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag="#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n\tuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <transmissionmap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\n\t#endif\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <transmissionmap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert="#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",normal_frag="#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert="#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert="uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag="uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert="#include <common>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert="uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";const ShaderChunk={alphamap_fragment:alphamap_fragment,alphamap_pars_fragment:alphamap_pars_fragment,alphatest_fragment:alphatest_fragment,aomap_fragment:aomap_fragment,aomap_pars_fragment:aomap_pars_fragment,begin_vertex:begin_vertex,beginnormal_vertex:beginnormal_vertex,bsdfs:bsdfs,bumpmap_pars_fragment:bumpmap_pars_fragment,clipping_planes_fragment:clipping_planes_fragment,clipping_planes_pars_fragment:clipping_planes_pars_fragment,clipping_planes_pars_vertex:clipping_planes_pars_vertex,clipping_planes_vertex:clipping_planes_vertex,color_fragment:color_fragment,color_pars_fragment:color_pars_fragment,color_pars_vertex:color_pars_vertex,color_vertex:color_vertex,common:common,cube_uv_reflection_fragment:cube_uv_reflection_fragment,defaultnormal_vertex:defaultnormal_vertex,displacementmap_pars_vertex:displacementmap_pars_vertex,displacementmap_vertex:displacementmap_vertex,emissivemap_fragment:emissivemap_fragment,emissivemap_pars_fragment:emissivemap_pars_fragment,encodings_fragment:encodings_fragment,encodings_pars_fragment:encodings_pars_fragment,envmap_fragment:envmap_fragment,envmap_common_pars_fragment:envmap_common_pars_fragment,envmap_pars_fragment:envmap_pars_fragment,envmap_pars_vertex:envmap_pars_vertex,envmap_physical_pars_fragment:envmap_physical_pars_fragment,envmap_vertex:envmap_vertex,fog_vertex:fog_vertex,fog_pars_vertex:fog_pars_vertex,fog_fragment:fog_fragment,fog_pars_fragment:fog_pars_fragment,gradientmap_pars_fragment:gradientmap_pars_fragment,lightmap_fragment:lightmap_fragment,lightmap_pars_fragment:lightmap_pars_fragment,lights_lambert_vertex:lights_lambert_vertex,lights_pars_begin:lights_pars_begin,lights_toon_fragment:lights_toon_fragment,lights_toon_pars_fragment:lights_toon_pars_fragment,lights_phong_fragment:lights_phong_fragment,lights_phong_pars_fragment:lights_phong_pars_fragment,lights_physical_fragment:lights_physical_fragment,lights_physical_pars_fragment:lights_physical_pars_fragment,lights_fragment_begin:lights_fragment_begin,lights_fragment_maps:lights_fragment_maps,lights_fragment_end:lights_fragment_end,logdepthbuf_fragment:logdepthbuf_fragment,logdepthbuf_pars_fragment:logdepthbuf_pars_fragment,logdepthbuf_pars_vertex:logdepthbuf_pars_vertex,logdepthbuf_vertex:logdepthbuf_vertex,map_fragment:map_fragment,map_pars_fragment:map_pars_fragment,map_particle_fragment:map_particle_fragment,map_particle_pars_fragment:map_particle_pars_fragment,metalnessmap_fragment:metalnessmap_fragment,metalnessmap_pars_fragment:metalnessmap_pars_fragment,morphnormal_vertex:morphnormal_vertex,morphtarget_pars_vertex:morphtarget_pars_vertex,morphtarget_vertex:morphtarget_vertex,normal_fragment_begin:normal_fragment_begin,normal_fragment_maps:normal_fragment_maps,normalmap_pars_fragment:normalmap_pars_fragment,clearcoat_normal_fragment_begin:clearcoat_normal_fragment_begin,clearcoat_normal_fragment_maps:clearcoat_normal_fragment_maps,clearcoat_pars_fragment:clearcoat_pars_fragment,packing:packing,premultiplied_alpha_fragment:premultiplied_alpha_fragment,project_vertex:project_vertex,dithering_fragment:dithering_fragment,dithering_pars_fragment:dithering_pars_fragment,roughnessmap_fragment:roughnessmap_fragment,roughnessmap_pars_fragment:roughnessmap_pars_fragment,shadowmap_pars_fragment:shadowmap_pars_fragment,shadowmap_pars_vertex:shadowmap_pars_vertex,shadowmap_vertex:shadowmap_vertex,shadowmask_pars_fragment:shadowmask_pars_fragment,skinbase_vertex:skinbase_vertex,skinning_pars_vertex:skinning_pars_vertex,skinning_vertex:skinning_vertex,skinnormal_vertex:skinnormal_vertex,specularmap_fragment:specularmap_fragment,specularmap_pars_fragment:specularmap_pars_fragment,tonemapping_fragment:tonemapping_fragment,tonemapping_pars_fragment:tonemapping_pars_fragment,transmissionmap_fragment:transmissionmap_fragment,transmissionmap_pars_fragment:transmissionmap_pars_fragment,uv_pars_fragment:uv_pars_fragment,uv_pars_vertex:uv_pars_vertex,uv_vertex:uv_vertex,uv2_pars_fragment:uv2_pars_fragment,uv2_pars_vertex:uv2_pars_vertex,uv2_vertex:uv2_vertex,worldpos_vertex:worldpos_vertex,background_frag:background_frag,background_vert:background_vert,cube_frag:cube_frag,cube_vert:cube_vert,depth_frag:depth_frag,depth_vert:depth_vert,distanceRGBA_frag:distanceRGBA_frag,distanceRGBA_vert:distanceRGBA_vert,equirect_frag:equirect_frag,equirect_vert:equirect_vert,linedashed_frag:linedashed_frag,linedashed_vert:linedashed_vert,meshbasic_frag:meshbasic_frag,meshbasic_vert:meshbasic_vert,meshlambert_frag:meshlambert_frag,meshlambert_vert:meshlambert_vert,meshmatcap_frag:meshmatcap_frag,meshmatcap_vert:meshmatcap_vert,meshtoon_frag:meshtoon_frag,meshtoon_vert:meshtoon_vert,meshphong_frag:meshphong_frag,meshphong_vert:meshphong_vert,meshphysical_frag:meshphysical_frag,meshphysical_vert:meshphysical_vert,normal_frag:normal_frag,normal_vert:normal_vert,points_frag:points_frag,points_vert:points_vert,shadow_frag:shadow_frag,shadow_vert:shadow_vert,sprite_frag:sprite_frag,sprite_vert:sprite_vert},UniformsLib={common:{diffuse:{value:new Color(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Matrix3},uv2Transform:{value:new Matrix3},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Vector2(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Color(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Color(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Matrix3}},sprite:{diffuse:{value:new Color(15658734)},opacity:{value:1},center:{value:new Vector2(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Matrix3}}},ShaderLib={basic:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.fog]),vertexShader:ShaderChunk.meshbasic_vert,fragmentShader:ShaderChunk.meshbasic_frag},lambert:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)}}]),vertexShader:ShaderChunk.meshlambert_vert,fragmentShader:ShaderChunk.meshlambert_frag},phong:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)},specular:{value:new Color(1118481)},shininess:{value:30}}]),vertexShader:ShaderChunk.meshphong_vert,fragmentShader:ShaderChunk.meshphong_frag},standard:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.roughnessmap,UniformsLib.metalnessmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ShaderChunk.meshphysical_vert,fragmentShader:ShaderChunk.meshphysical_frag},toon:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.gradientmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color(0)}}]),vertexShader:ShaderChunk.meshtoon_vert,fragmentShader:ShaderChunk.meshtoon_frag},matcap:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,{matcap:{value:null}}]),vertexShader:ShaderChunk.meshmatcap_vert,fragmentShader:ShaderChunk.meshmatcap_frag},points:{uniforms:mergeUniforms([UniformsLib.points,UniformsLib.fog]),vertexShader:ShaderChunk.points_vert,fragmentShader:ShaderChunk.points_frag},dashed:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ShaderChunk.linedashed_vert,fragmentShader:ShaderChunk.linedashed_frag},depth:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.displacementmap]),vertexShader:ShaderChunk.depth_vert,fragmentShader:ShaderChunk.depth_frag},normal:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,{opacity:{value:1}}]),vertexShader:ShaderChunk.normal_vert,fragmentShader:ShaderChunk.normal_frag},sprite:{uniforms:mergeUniforms([UniformsLib.sprite,UniformsLib.fog]),vertexShader:ShaderChunk.sprite_vert,fragmentShader:ShaderChunk.sprite_frag},background:{uniforms:{uvTransform:{value:new Matrix3},t2D:{value:null}},vertexShader:ShaderChunk.background_vert,fragmentShader:ShaderChunk.background_frag},cube:{uniforms:mergeUniforms([UniformsLib.envmap,{opacity:{value:1}}]),vertexShader:ShaderChunk.cube_vert,fragmentShader:ShaderChunk.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ShaderChunk.equirect_vert,fragmentShader:ShaderChunk.equirect_frag},distanceRGBA:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.displacementmap,{referencePosition:{value:new Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ShaderChunk.distanceRGBA_vert,fragmentShader:ShaderChunk.distanceRGBA_frag},shadow:{uniforms:mergeUniforms([UniformsLib.lights,UniformsLib.fog,{color:{value:new Color(0)},opacity:{value:1}}]),vertexShader:ShaderChunk.shadow_vert,fragmentShader:ShaderChunk.shadow_frag}};function WebGLBackground(e,t,n,i,r){const o=new Color(0);let a,s,l=0,c=null,h=0,u=null;function d(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),l=t,d(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(e){l=e,d(o,l)},render:function p(n,r,m,f){let g=!0===r.isScene?r.background:null;g&&g.isTexture&&(g=t.get(g));const v=e.xr,y=v.getSession&&v.getSession();y&&"additive"===y.environmentBlendMode&&(g=null),null===g?d(o,l):g&&g.isColor&&(d(g,1),f=!0),(e.autoClear||f)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),g&&(g.isCubeTexture||g.isWebGLCubeRenderTarget||g.mapping===CubeUVReflectionMapping)?(void 0===s&&(s=new Mesh(new BoxGeometry(1,1,1),new ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:cloneUniforms(ShaderLib.cube.uniforms),vertexShader:ShaderLib.cube.vertexShader,fragmentShader:ShaderLib.cube.fragmentShader,side:BackSide,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s)),g.isWebGLCubeRenderTarget&&(g=g.texture),s.material.uniforms.envMap.value=g,s.material.uniforms.flipEnvMap.value=g.isCubeTexture&&g._needsFlipEnvMap?-1:1,c===g&&h===g.version&&u===e.toneMapping||(s.material.needsUpdate=!0,c=g,h=g.version,u=e.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null)):g&&g.isTexture&&(void 0===a&&(a=new Mesh(new PlaneGeometry(2,2),new ShaderMaterial({name:"BackgroundMaterial",uniforms:cloneUniforms(ShaderLib.background.uniforms),vertexShader:ShaderLib.background.vertexShader,fragmentShader:ShaderLib.background.fragmentShader,side:FrontSide,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(a)),a.material.uniforms.t2D.value=g,!0===g.matrixAutoUpdate&&g.updateMatrix(),a.material.uniforms.uvTransform.value.copy(g.matrix),c===g&&h===g.version&&u===e.toneMapping||(a.material.needsUpdate=!0,c=g,h=g.version,u=e.toneMapping),n.unshift(a,a.geometry,a.material,0,0,null))}}}function WebGLBindingStates(e,t,n,i){const r=e.getParameter(34921),o=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==o,s={},l=d(null);let c=l;function h(t){return i.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function u(t){return i.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function d(e){const t=[],n=[],i=[];for(let e=0;e<r;e++)t[e]=0,n[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:i,object:e,attributes:{},index:null}}function p(){const e=c.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function m(e){f(e,0)}function f(n,r){const o=c.enabledAttributes,a=c.attributeDivisors;c.newAttributes[n]=1,0===o[n]&&(e.enableVertexAttribArray(n),o[n]=1),a[n]!==r&&((i.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,r),a[n]=r)}function g(){const t=c.newAttributes,n=c.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function v(t,n,r,o,a,s){!0!==i.isWebGL2||5124!==r&&5125!==r?e.vertexAttribPointer(t,n,r,o,a,s):e.vertexAttribIPointer(t,n,r,a,s)}function y(){b(),c!==l&&(c=l,h(c.object))}function b(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function _(r,l,u,y,b){let _=!1;if(a){const t=(function x(t,n,r){const a=!0===r.wireframe;let l=s[t.id];void 0===l&&(l={},s[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let h=c[a];return void 0===h&&(h=d((function u(){return i.isWebGL2?e.createVertexArray():o.createVertexArrayOES()})()),c[a]=h),h})(y,u,l);c!==t&&(c=t,h(c.object)),_=(function w(e,t){const n=c.attributes,i=e.attributes;let r=0;for(const e in i){const t=n[e],o=i[e];if(void 0===t)return!0;if(t.attribute!==o)return!0;if(t.data!==o.data)return!0;r++}return c.attributesNum!==r||c.index!==t})(y,b),_&&(function S(e,t){const n={},i=e.attributes;let r=0;for(const e in i){const t=i[e],o={};o.attribute=t,t.data&&(o.data=t.data),n[e]=o,r++}c.attributes=n,c.attributesNum=r,c.index=t})(y,b)}else{const e=!0===l.wireframe;c.geometry===y.id&&c.program===u.id&&c.wireframe===e||(c.geometry=y.id,c.program=u.id,c.wireframe=e,_=!0)}!0===r.isInstancedMesh&&(_=!0),null!==b&&n.update(b,34963),_&&((function C(r,o,a,s){if(!1===i.isWebGL2&&(r.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;p();const l=s.attributes,c=a.getAttributes(),h=o.defaultAttributeValues;for(const t in c){const i=c[t];if(i>=0){const o=l[t];if(void 0!==o){const t=o.normalized,r=o.itemSize,a=n.get(o);if(void 0===a)continue;const l=a.buffer,c=a.type,h=a.bytesPerElement;if(o.isInterleavedBufferAttribute){const n=o.data,a=n.stride,u=o.offset;n&&n.isInstancedInterleavedBuffer?(f(i,n.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)):m(i),e.bindBuffer(34962,l),v(i,r,c,t,a*h,u*h)}else o.isInstancedBufferAttribute?(f(i,o.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)):m(i),e.bindBuffer(34962,l),v(i,r,c,t,0,0)}else if("instanceMatrix"===t){const t=n.get(r.instanceMatrix);if(void 0===t)continue;const o=t.buffer,a=t.type;f(i+0,1),f(i+1,1),f(i+2,1),f(i+3,1),e.bindBuffer(34962,o),e.vertexAttribPointer(i+0,4,a,!1,64,0),e.vertexAttribPointer(i+1,4,a,!1,64,16),e.vertexAttribPointer(i+2,4,a,!1,64,32),e.vertexAttribPointer(i+3,4,a,!1,64,48)}else if("instanceColor"===t){const t=n.get(r.instanceColor);if(void 0===t)continue;const o=t.buffer,a=t.type;f(i,1),e.bindBuffer(34962,o),e.vertexAttribPointer(i,3,a,!1,12,0)}else if(void 0!==h){const n=h[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(i,n);break;case 3:e.vertexAttrib3fv(i,n);break;case 4:e.vertexAttrib4fv(i,n);break;default:e.vertexAttrib1fv(i,n)}}}}g()})(r,l,u,y),null!==b&&e.bindBuffer(34963,n.get(b).buffer))},reset:y,resetDefaultState:b,dispose:function x(){y();for(const e in s){const t=s[e];for(const e in t){const n=t[e];for(const e in n)u(n[e].object),delete n[e];delete t[e]}delete s[e]}},releaseStatesOfGeometry:function w(e){if(void 0===s[e.id])return;const t=s[e.id];for(const e in t){const n=t[e];for(const e in n)u(n[e].object),delete n[e];delete t[e]}delete s[e.id]},releaseStatesOfProgram:function S(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const i=n[e.id];for(const e in i)u(i[e].object),delete i[e];delete n[e.id]}},initAttributes:p,enableAttribute:m,disableUnusedAttributes:g}}function WebGLBufferRenderer(e,t,n,i){const r=i.isWebGL2;let o;this.setMode=function a(e){o=e},this.render=function s(t,i){e.drawArrays(o,t,i),n.update(i,o,1)},this.renderInstances=function l(i,a,s){if(0===s)return;let l,c;if(r)l=e,c="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](o,i,a,s),n.update(a,o,s)}}function WebGLCapabilities(e,t,n){let i;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=r(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=!0===n.logarithmicDepthBuffer,c=e.getParameter(34930),h=e.getParameter(35660),u=e.getParameter(3379),d=e.getParameter(34076),p=e.getParameter(34921),m=e.getParameter(36347),f=e.getParameter(36348),g=e.getParameter(36349),v=h>0,y=o||!!t.get("OES_texture_float");return{isWebGL2:o,getMaxAnisotropy:function b(){if(void 0!==i)return i;const n=t.get("EXT_texture_filter_anisotropic");return i=null!==n?e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,i},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:h,maxTextureSize:u,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:m,maxVaryings:f,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:o?e.getParameter(36183):0}}function WebGLClipping(e){const t=this;let n=null,i=0,r=!1,o=!1;const a=new Plane,s=new Matrix3,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function h(e,n,i,r){const o=null!==e?e.length:0;let c=null;if(0!==o){if(c=l.value,!0!==r||null===c){const t=i+4*o,r=n.matrixWorldInverse;s.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==o;++t,n+=4)a.copy(e[t]).applyMatrix4(r,s),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=o,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,o){const a=0!==e.length||t||0!==i||r;return r=t,n=h(e,o,0),i=e.length,a},this.beginShadows=function(){o=!0,h(null)},this.endShadows=function(){o=!1,c()},this.setState=function(t,a,s){const u=t.clippingPlanes,d=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!r||null===u||0===u.length||o&&!p)o?h(null):c();else{const e=o?0:i,t=4*e;let r=m.clippingState||null;l.value=r,r=h(u,a,t,s);for(let e=0;e!==t;++e)r[e]=n[e];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function WebGLCubeMaps(e){let t=new WeakMap;function n(e,t){return t===EquirectangularReflectionMapping?e.mapping=CubeReflectionMapping:t===EquirectangularRefractionMapping&&(e.mapping=CubeRefractionMapping),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function r(o){if(o&&o.isTexture){const r=o.mapping;if(r===EquirectangularReflectionMapping||r===EquirectangularRefractionMapping){if(t.has(o))return n(t.get(o).texture,o.mapping);{const r=o.image;if(r&&r.height>0){const a=e.getRenderList(),s=e.getRenderTarget(),l=new WebGLCubeRenderTarget(r.height/2);return l.fromEquirectangularTexture(e,o),t.set(o,l),e.setRenderTarget(s),e.setRenderList(a),o.addEventListener("dispose",i),n(l.texture,o.mapping)}return null}}}return o},dispose:function o(){t=new WeakMap}}}function WebGLExtensions(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function WebGLGeometries(e,t,n,i){const r={},o=new WeakMap;function a(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",a),delete r[s.id];const l=o.get(s);l&&(t.remove(l),o.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],i=e.index,r=e.attributes.position;let a=0;if(null!==i){const e=i.array;a=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],r=e[t+1],o=e[t+2];n.push(i,r,r,o,o,i)}}else{a=r.version;for(let e=0,t=r.array.length/3-1;e<t;e+=3){const t=e+0,i=e+1,r=e+2;n.push(t,i,i,r,r,t)}}const s=new(arrayMax(n)>65535?Uint32BufferAttribute:Uint16BufferAttribute)(n,1);s.version=a;const l=o.get(e);l&&t.remove(l),o.set(e,s)}return{get:function l(e,t){return!0===r[t.id]||(t.addEventListener("dispose",a),r[t.id]=!0,n.memory.geometries++),t},update:function c(e){const n=e.attributes;for(const e in n)t.update(n[e],34962);const i=e.morphAttributes;for(const e in i){const n=i[e];for(let e=0,i=n.length;e<i;e++)t.update(n[e],34962)}},getWireframeAttribute:function h(e){const t=o.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return o.get(e)}}}function WebGLIndexedBufferRenderer(e,t,n,i){const r=i.isWebGL2;let o,a,s;this.setMode=function l(e){o=e},this.setIndex=function c(e){a=e.type,s=e.bytesPerElement},this.render=function h(t,i){e.drawElements(o,i,a,t*s),n.update(i,o,1)},this.renderInstances=function u(i,l,c){if(0===c)return;let h,u;if(r)h=e,u="drawElementsInstanced";else if(h=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===h)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[u](o,l,a,i*s,c),n.update(l,o,c)}}function WebGLInfo(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function n(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function i(e,n,r){switch(t.calls++,n){case 4:t.triangles+=r*(e/3);break;case 1:t.lines+=r*(e/2);break;case 3:t.lines+=r*(e-1);break;case 2:t.lines+=r*e;break;case 0:t.points+=r*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function numericalSort(e,t){return e[0]-t[0]}function absNumericalSort(e,t){return Math.abs(t[1])-Math.abs(e[1])}function WebGLMorphtargets(e){const t={},n=new Float32Array(8),i=[];for(let e=0;e<8;e++)i[e]=[e,0];return{update:function r(o,a,s,l){const c=o.morphTargetInfluences,h=void 0===c?0:c.length;let u=t[a.id];if(void 0===u){u=[];for(let e=0;e<h;e++)u[e]=[e,0];t[a.id]=u}for(let e=0;e<h;e++){const t=u[e];t[0]=e,t[1]=c[e]}u.sort(absNumericalSort);for(let e=0;e<8;e++)e<h&&u[e][1]?(i[e][0]=u[e][0],i[e][1]=u[e][1]):(i[e][0]=Number.MAX_SAFE_INTEGER,i[e][1]=0);i.sort(numericalSort);const d=s.morphTargets&&a.morphAttributes.position,p=s.morphNormals&&a.morphAttributes.normal;let m=0;for(let e=0;e<8;e++){const t=i[e],r=t[0],o=t[1];r!==Number.MAX_SAFE_INTEGER&&o?(d&&a.getAttribute("morphTarget"+e)!==d[r]&&a.setAttribute("morphTarget"+e,d[r]),p&&a.getAttribute("morphNormal"+e)!==p[r]&&a.setAttribute("morphNormal"+e,p[r]),n[e]=o,m+=o):(d&&!0===a.hasAttribute("morphTarget"+e)&&a.deleteAttribute("morphTarget"+e),p&&!0===a.hasAttribute("morphNormal"+e)&&a.deleteAttribute("morphNormal"+e),n[e]=0)}const f=a.morphTargetsRelative?1:1-m;l.getUniforms().setValue(e,"morphTargetBaseInfluence",f),l.getUniforms().setValue(e,"morphTargetInfluences",n)}}}function WebGLObjects(e,t,n,i){let r=new WeakMap;function o(e){const t=e.target;t.removeEventListener("dispose",o),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function a(e){const a=i.render.frame,s=t.get(e,e.geometry);return r.get(s)!==a&&(t.update(s),r.set(s,a)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",o)&&e.addEventListener("dispose",o),n.update(e.instanceMatrix,34962),null!==e.instanceColor&&n.update(e.instanceColor,34962)),s},dispose:function s(){r=new WeakMap}}}function DataTexture2DArray(e=null,t=1,n=1,i=1){Texture.call(this,null),this.image={data:e,width:t,height:n,depth:i},this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.wrapR=ClampToEdgeWrapping,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function DataTexture3D(e=null,t=1,n=1,i=1){Texture.call(this,null),this.image={data:e,width:t,height:n,depth:i},this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.wrapR=ClampToEdgeWrapping,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}ShaderLib.physical={uniforms:mergeUniforms([ShaderLib.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Vector2(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new Color(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:ShaderChunk.meshphysical_vert,fragmentShader:ShaderChunk.meshphysical_frag},DataTexture2DArray.prototype=Object.create(Texture.prototype),DataTexture2DArray.prototype.constructor=DataTexture2DArray,DataTexture2DArray.prototype.isDataTexture2DArray=!0,DataTexture3D.prototype=Object.create(Texture.prototype),DataTexture3D.prototype.constructor=DataTexture3D,DataTexture3D.prototype.isDataTexture3D=!0;const emptyTexture=new Texture,emptyTexture2dArray=new DataTexture2DArray,emptyTexture3d=new DataTexture3D,emptyCubeTexture=new CubeTexture,arrayCacheF32=[],arrayCacheI32=[],mat4array=new Float32Array(16),mat3array=new Float32Array(9),mat2array=new Float32Array(4);function flatten(e,t,n){const i=e[0];if(i<=0||i>0)return e;const r=t*n;let o=arrayCacheF32[r];if(void 0===o&&(o=new Float32Array(r),arrayCacheF32[r]=o),0!==t){i.toArray(o,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(o,r)}return o}function arraysEqual(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function copyArray(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function allocTexUnits(e,t){let n=arrayCacheI32[t];void 0===n&&(n=new Int32Array(t),arrayCacheI32[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function setValueV1f(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function setValueV2f(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(arraysEqual(n,t))return;e.uniform2fv(this.addr,t),copyArray(n,t)}}function setValueV3f(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(arraysEqual(n,t))return;e.uniform3fv(this.addr,t),copyArray(n,t)}}function setValueV4f(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(arraysEqual(n,t))return;e.uniform4fv(this.addr,t),copyArray(n,t)}}function setValueM2(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(arraysEqual(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),copyArray(n,t)}else{if(arraysEqual(n,i))return;mat2array.set(i),e.uniformMatrix2fv(this.addr,!1,mat2array),copyArray(n,i)}}function setValueM3(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(arraysEqual(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),copyArray(n,t)}else{if(arraysEqual(n,i))return;mat3array.set(i),e.uniformMatrix3fv(this.addr,!1,mat3array),copyArray(n,i)}}function setValueM4(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(arraysEqual(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),copyArray(n,t)}else{if(arraysEqual(n,i))return;mat4array.set(i),e.uniformMatrix4fv(this.addr,!1,mat4array),copyArray(n,i)}}function setValueT1(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.safeSetTexture2D(t||emptyTexture,r)}function setValueT2DArray1(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||emptyTexture2dArray,r)}function setValueT3D1(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||emptyTexture3d,r)}function setValueT6(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.safeSetTextureCube(t||emptyCubeTexture,r)}function setValueV1i(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function setValueV2i(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform2iv(this.addr,t),copyArray(n,t))}function setValueV3i(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform3iv(this.addr,t),copyArray(n,t))}function setValueV4i(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform4iv(this.addr,t),copyArray(n,t))}function setValueV1ui(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function getSingularSetter(e){switch(e){case 5126:return setValueV1f;case 35664:return setValueV2f;case 35665:return setValueV3f;case 35666:return setValueV4f;case 35674:return setValueM2;case 35675:return setValueM3;case 35676:return setValueM4;case 5124:case 35670:return setValueV1i;case 35667:case 35671:return setValueV2i;case 35668:case 35672:return setValueV3i;case 35669:case 35673:return setValueV4i;case 5125:return setValueV1ui;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1;case 35679:case 36299:case 36307:return setValueT3D1;case 35680:case 36300:case 36308:case 36293:return setValueT6;case 36289:case 36303:case 36311:case 36292:return setValueT2DArray1}}function setValueV1fArray(e,t){e.uniform1fv(this.addr,t)}function setValueV1iArray(e,t){e.uniform1iv(this.addr,t)}function setValueV2iArray(e,t){e.uniform2iv(this.addr,t)}function setValueV3iArray(e,t){e.uniform3iv(this.addr,t)}function setValueV4iArray(e,t){e.uniform4iv(this.addr,t)}function setValueV2fArray(e,t){const n=flatten(t,this.size,2);e.uniform2fv(this.addr,n)}function setValueV3fArray(e,t){const n=flatten(t,this.size,3);e.uniform3fv(this.addr,n)}function setValueV4fArray(e,t){const n=flatten(t,this.size,4);e.uniform4fv(this.addr,n)}function setValueM2Array(e,t){const n=flatten(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function setValueM3Array(e,t){const n=flatten(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function setValueM4Array(e,t){const n=flatten(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function setValueT1Array(e,t,n){const i=t.length,r=allocTexUnits(n,i);e.uniform1iv(this.addr,r);for(let e=0;e!==i;++e)n.safeSetTexture2D(t[e]||emptyTexture,r[e])}function setValueT6Array(e,t,n){const i=t.length,r=allocTexUnits(n,i);e.uniform1iv(this.addr,r);for(let e=0;e!==i;++e)n.safeSetTextureCube(t[e]||emptyCubeTexture,r[e])}function getPureArraySetter(e){switch(e){case 5126:return setValueV1fArray;case 35664:return setValueV2fArray;case 35665:return setValueV3fArray;case 35666:return setValueV4fArray;case 35674:return setValueM2Array;case 35675:return setValueM3Array;case 35676:return setValueM4Array;case 5124:case 35670:return setValueV1iArray;case 35667:case 35671:return setValueV2iArray;case 35668:case 35672:return setValueV3iArray;case 35669:case 35673:return setValueV4iArray;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1Array;case 35680:case 36300:case 36308:case 36293:return setValueT6Array}}function SingleUniform(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=getSingularSetter(t.type)}function PureArrayUniform(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=getPureArraySetter(t.type)}function StructuredUniform(e){this.id=e,this.seq=[],this.map={}}PureArrayUniform.prototype.updateCache=function(e){const t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),copyArray(t,e)},StructuredUniform.prototype.setValue=function(e,t,n){const i=this.seq;for(let r=0,o=i.length;r!==o;++r){const o=i[r];o.setValue(e,t[o.id],n)}};const RePathPart=/(\w+)(\])?(\[|\.)?/g;function addUniform(e,t){e.seq.push(t),e.map[t.id]=t}function parseUniform(e,t,n){const i=e.name,r=i.length;for(RePathPart.lastIndex=0;;){const o=RePathPart.exec(i),a=RePathPart.lastIndex;let s=o[1];const l=o[3];if("]"===o[2]&&(s|=0),void 0===l||"["===l&&a+2===r){addUniform(n,void 0===l?new SingleUniform(s,e,t):new PureArrayUniform(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new StructuredUniform(s),addUniform(n,e)),n=e}}}function WebGLUniforms(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,35718);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);parseUniform(n,e.getUniformLocation(t,n.name),this)}}function WebGLShader(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}WebGLUniforms.prototype.setValue=function(e,t,n,i){const r=this.map[t];void 0!==r&&r.setValue(e,n,i)},WebGLUniforms.prototype.setOptional=function(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)},WebGLUniforms.upload=function(e,t,n,i){for(let r=0,o=t.length;r!==o;++r){const o=t[r],a=n[o.id];!1!==a.needsUpdate&&o.setValue(e,a.value,i)}},WebGLUniforms.seqWithValue=function(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const r=e[i];r.id in t&&n.push(r)}return n};let programIdCount=0;function addLineNumbers(e){const t=e.split("\n");for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join("\n")}function getEncodingComponents(e){switch(e){case LinearEncoding:return["Linear","( value )"];case sRGBEncoding:return["sRGB","( value )"];case RGBEEncoding:return["RGBE","( value )"];case RGBM7Encoding:return["RGBM","( value, 7.0 )"];case RGBM16Encoding:return["RGBM","( value, 16.0 )"];case RGBDEncoding:return["RGBD","( value, 256.0 )"];case GammaEncoding:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case LogLuvEncoding:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function getShaderErrors(e,t,n){const i=e.getShaderParameter(t,35713),r=e.getShaderInfoLog(t).trim();return i&&""===r?"":"THREE.WebGLShader: gl.getShaderInfoLog() "+n+"\n"+r+addLineNumbers(e.getShaderSource(t))}function getTexelDecodingFunction(e,t){const n=getEncodingComponents(t);return"vec4 "+e+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function getTexelEncodingFunction(e,t){const n=getEncodingComponents(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function getToneMappingFunction(e,t){let n;switch(t){case LinearToneMapping:n="Linear";break;case ReinhardToneMapping:n="Reinhard";break;case CineonToneMapping:n="OptimizedCineon";break;case ACESFilmicToneMapping:n="ACESFilmic";break;case CustomToneMapping:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function generateExtensions(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(filterEmptyLine).join("\n")}function generateDefines(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}function fetchAttributeLocations(e,t){const n={},i=e.getProgramParameter(t,35721);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r).name;n[i]=e.getAttribLocation(t,i)}return n}function filterEmptyLine(e){return""!==e}function replaceLightNums(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function replaceClippingPlaneNums(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const includePattern=/^[ \t]*#include +<([\w\d./]+)>/gm;function resolveIncludes(e){return e.replace(includePattern,includeReplacer)}function includeReplacer(e,t){const n=ShaderChunk[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return resolveIncludes(n)}const deprecatedUnrollLoopPattern=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,unrollLoopPattern=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function unrollLoops(e){return e.replace(unrollLoopPattern,loopReplacer).replace(deprecatedUnrollLoopPattern,deprecatedLoopReplacer)}function deprecatedLoopReplacer(e,t,n,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),loopReplacer(e,t,n,i)}function loopReplacer(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function generatePrecision(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function generateShadowMapTypeDefine(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===PCFShadowMap?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===PCFSoftShadowMap?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===VSMShadowMap&&(t="SHADOWMAP_TYPE_VSM"),t}function generateEnvMapTypeDefine(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case CubeReflectionMapping:case CubeRefractionMapping:t="ENVMAP_TYPE_CUBE";break;case CubeUVReflectionMapping:case CubeUVRefractionMapping:t="ENVMAP_TYPE_CUBE_UV"}return t}function generateEnvMapModeDefine(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case CubeRefractionMapping:case CubeUVRefractionMapping:t="ENVMAP_MODE_REFRACTION"}return t}function generateEnvMapBlendingDefine(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case MultiplyOperation:t="ENVMAP_BLENDING_MULTIPLY";break;case MixOperation:t="ENVMAP_BLENDING_MIX";break;case AddOperation:t="ENVMAP_BLENDING_ADD"}return t}function WebGLProgram(e,t,n,i){const r=e.getContext(),o=n.defines;let a=n.vertexShader,s=n.fragmentShader;const l=generateShadowMapTypeDefine(n),c=generateEnvMapTypeDefine(n),h=generateEnvMapModeDefine(n),u=generateEnvMapBlendingDefine(n),d=e.gammaFactor>0?e.gammaFactor:1,p=n.isWebGL2?"":generateExtensions(n),m=generateDefines(o),f=r.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=[m].filter(filterEmptyLine).join("\n"),g.length>0&&(g+="\n"),v=[p,m].filter(filterEmptyLine).join("\n"),v.length>0&&(v+="\n")):(g=[generatePrecision(n),"#define SHADER_NAME "+n.shaderName,m,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(filterEmptyLine).join("\n"),v=[p,generatePrecision(n),"#define SHADER_NAME "+n.shaderName,m,n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==NoToneMapping?"#define TONE_MAPPING":"",n.toneMapping!==NoToneMapping?ShaderChunk.tonemapping_pars_fragment:"",n.toneMapping!==NoToneMapping?getToneMappingFunction("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",ShaderChunk.encodings_pars_fragment,n.map?getTexelDecodingFunction("mapTexelToLinear",n.mapEncoding):"",n.matcap?getTexelDecodingFunction("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?getTexelDecodingFunction("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?getTexelDecodingFunction("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?getTexelDecodingFunction("lightMapTexelToLinear",n.lightMapEncoding):"",getTexelEncodingFunction("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(filterEmptyLine).join("\n")),a=resolveIncludes(a),a=replaceLightNums(a,n),a=replaceClippingPlaneNums(a,n),s=resolveIncludes(s),s=replaceLightNums(s,n),s=replaceClippingPlaneNums(s,n),a=unrollLoops(a),s=unrollLoops(s),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===GLSL3?"":"out highp vec4 pc_fragColor;",n.glslVersion===GLSL3?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const b=y+v+s,_=WebGLShader(r,35633,y+g+a),x=WebGLShader(r,35632,b);if(r.attachShader(f,_),r.attachShader(f,x),void 0!==n.index0AttributeName?r.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),e.debug.checkShaderErrors){const e=r.getProgramInfoLog(f).trim(),t=r.getShaderInfoLog(_).trim(),n=r.getShaderInfoLog(x).trim();let i=!0,o=!0;if(!1===r.getProgramParameter(f,35714)){i=!1;const t=getShaderErrors(r,_,"vertex"),n=getShaderErrors(r,x,"fragment");console.error("THREE.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(f,35715),"gl.getProgramInfoLog",e,t,n)}else""!==e?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",e):""!==t&&""!==n||(o=!1);o&&(this.diagnostics={runnable:i,programLog:e,vertexShader:{log:t,prefix:g},fragmentShader:{log:n,prefix:v}})}let w,S;return r.deleteShader(_),r.deleteShader(x),this.getUniforms=function(){return void 0===w&&(w=new WebGLUniforms(r,f)),w},this.getAttributes=function(){return void 0===S&&(S=fetchAttributeLocations(r,f)),S},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.name=n.shaderName,this.id=programIdCount++,this.cacheKey=t,this.usedTimes=1,this.program=f,this.vertexShader=_,this.fragmentShader=x,this}function WebGLPrograms(e,t,n,i,r,o){const a=[],s=i.isWebGL2,l=i.logarithmicDepthBuffer,c=i.floatVertexTextures,h=i.maxVertexUniforms,u=i.vertexTextures;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},m=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function f(e){let t;return e&&e.isTexture?t=e.encoding:e&&e.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),t=e.texture.encoding):t=LinearEncoding,t}return{getParameters:function g(r,a,m,v,y){const b=v.fog,_=t.get(r.envMap||(r.isMeshStandardMaterial?v.environment:null)),x=p[r.type],w=y.isSkinnedMesh?(function S(e){const t=e.skeleton.bones;if(c)return 1024;{const e=Math.floor((h-20)/4),n=Math.min(e,t.length);return n<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+n+"."),0):n}})(y):0;let C,M;if(null!==r.precision&&(d=i.getMaxPrecision(r.precision),d!==r.precision&&console.warn("THREE.WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead.")),x){const e=ShaderLib[x];C=e.vertexShader,M=e.fragmentShader}else C=r.vertexShader,M=r.fragmentShader;const E=e.getRenderTarget();return{isWebGL2:s,shaderID:x,shaderName:r.type,vertexShader:C,fragmentShader:M,defines:r.defines,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,instancing:!0===y.isInstancedMesh,instancingColor:!0===y.isInstancedMesh&&null!==y.instanceColor,supportsVertexTextures:u,outputEncoding:null!==E?f(E.texture):e.outputEncoding,map:!!r.map,mapEncoding:f(r.map),matcap:!!r.matcap,matcapEncoding:f(r.matcap),envMap:!!_,envMapMode:_&&_.mapping,envMapEncoding:f(_),envMapCubeUV:!!_&&(_.mapping===CubeUVReflectionMapping||_.mapping===CubeUVRefractionMapping),lightMap:!!r.lightMap,lightMapEncoding:f(r.lightMap),aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,emissiveMapEncoding:f(r.emissiveMap),bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:r.normalMapType===ObjectSpaceNormalMap,tangentSpaceNormalMap:r.normalMapType===TangentSpaceNormalMap,clearcoatMap:!!r.clearcoatMap,clearcoatRoughnessMap:!!r.clearcoatRoughnessMap,clearcoatNormalMap:!!r.clearcoatNormalMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,alphaMap:!!r.alphaMap,gradientMap:!!r.gradientMap,sheen:!!r.sheen,transmissionMap:!!r.transmissionMap,combine:r.combine,vertexTangents:r.normalMap&&r.vertexTangents,vertexColors:r.vertexColors,vertexUvs:!!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatMap||r.clearcoatRoughnessMap||r.clearcoatNormalMap||r.displacementMap||r.transmissionMap),uvsVertexOnly:!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatNormalMap||r.transmissionMap||!r.displacementMap),fog:!!b,useFog:r.fog,fogExp2:b&&b.isFogExp2,flatShading:r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:l,skinning:r.skinning&&w>0,maxBones:w,useVertexTexture:c,morphTargets:r.morphTargets,morphNormals:r.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&m.length>0,shadowMapType:e.shadowMap.type,toneMapping:r.toneMapped?e.toneMapping:NoToneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:r.side===DoubleSide,flipSided:r.side===BackSide,depthPacking:void 0!==r.depthPacking&&r.depthPacking,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:s||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:s||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:s||n.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function v(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.fragmentShader),n.push(t.vertexShader)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);if(!1===t.isRawShaderMaterial){for(let e=0;e<m.length;e++)n.push(t[m[e]]);n.push(e.outputEncoding),n.push(e.gammaFactor)}return n.push(t.customProgramCacheKey),n.join()},getUniforms:function y(e){const t=p[e.type];let n;return n=t?UniformsUtils.clone(ShaderLib[t].uniforms):e.uniforms,n},acquireProgram:function b(t,n){let i;for(let e=0,t=a.length;e<t;e++){const t=a[e];if(t.cacheKey===n){i=t,++i.usedTimes;break}}return void 0===i&&(i=new WebGLProgram(e,n,t,r),a.push(i)),i},releaseProgram:function _(e){if(0==--e.usedTimes){const t=a.indexOf(e);a[t]=a[a.length-1],a.pop(),e.destroy()}},programs:a}}function WebGLProperties(){let e=new WeakMap;return{get:function t(n){let i=e.get(n);return void 0===i&&(i={},e.set(n,i)),i},remove:function n(t){e.delete(t)},update:function i(t,n,r){e.get(t)[n]=r},dispose:function r(){e=new WeakMap}}}function painterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function reversePainterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function WebGLRenderList(e){const t=[];let n=0;const i=[],r=[],o={id:-1};function a(i,r,a,s,l,c){let h=t[n];const u=e.get(a);return void 0===h?(h={id:i.id,object:i,geometry:r,material:a,program:u.program||o,groupOrder:s,renderOrder:i.renderOrder,z:l,group:c},t[n]=h):(h.id=i.id,h.object=i,h.geometry=r,h.material=a,h.program=u.program||o,h.groupOrder=s,h.renderOrder=i.renderOrder,h.z=l,h.group=c),n++,h}return{opaque:i,transparent:r,init:function s(){n=0,i.length=0,r.length=0},push:function l(e,t,n,o,s,c){const h=a(e,t,n,o,s,c);(!0===n.transparent?r:i).push(h)},unshift:function c(e,t,n,o,s,l){const c=a(e,t,n,o,s,l);(!0===n.transparent?r:i).unshift(c)},finish:function h(){for(let e=n,i=t.length;e<i;e++){const n=t[e];if(null===n.id)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.program=null,n.group=null}},sort:function u(e,t){i.length>1&&i.sort(e||painterSortStable),r.length>1&&r.sort(t||reversePainterSortStable)}}}function WebGLRenderLists(e){let t=new WeakMap;return{get:function n(i,r){const o=t.get(i);let a;return void 0===o?(a=new WebGLRenderList(e),t.set(i,new WeakMap),t.get(i).set(r,a)):(a=o.get(r),void 0===a&&(a=new WebGLRenderList(e),o.set(r,a))),a},dispose:function i(){t=new WeakMap}}}function UniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Vector3,color:new Color};break;case"SpotLight":n={position:new Vector3,direction:new Vector3,color:new Color,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Vector3,color:new Color,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Vector3,skyColor:new Color,groundColor:new Color};break;case"RectAreaLight":n={color:new Color,position:new Vector3,halfWidth:new Vector3,halfHeight:new Vector3}}return e[t.id]=n,n}}}function ShadowUniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}let nextVersion=0;function shadowCastingLightsFirst(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function WebGLLights(e,t){const n=new UniformsCache,i=ShadowUniformsCache(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)r.probe.push(new Vector3);const o=new Vector3,a=new Matrix4,s=new Matrix4;return{setup:function l(o){let a=0,s=0,l=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,h=0,u=0,d=0,p=0,m=0,f=0,g=0;o.sort(shadowCastingLightsFirst);for(let e=0,t=o.length;e<t;e++){const t=o[e],v=t.color,y=t.intensity,b=t.distance,_=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)a+=v.r*y,s+=v.g*y,l+=v.b*y;else if(t.isLightProbe)for(let e=0;e<9;e++)r.probe[e].addScaledVector(t.sh.coefficients[e],y);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity),t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,r.directionalShadow[c]=n,r.directionalShadowMap[c]=_,r.directionalShadowMatrix[c]=t.shadow.matrix,m++}r.directional[c]=e,c++}else if(t.isSpotLight){const e=n.get(t);if(e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(v).multiplyScalar(y),e.distance=b,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,r.spotShadow[u]=n,r.spotShadowMap[u]=_,r.spotShadowMatrix[u]=t.shadow.matrix,g++}r.spot[u]=e,u++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(v).multiplyScalar(y),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),r.rectArea[d]=e,d++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,r.pointShadow[h]=n,r.pointShadowMap[h]=_,r.pointShadowMatrix[h]=t.shadow.matrix,f++}r.point[h]=e,h++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(y),e.groundColor.copy(t.groundColor).multiplyScalar(y),r.hemi[p]=e,p++}}d>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=UniformsLib.LTC_FLOAT_1,r.rectAreaLTC2=UniformsLib.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=UniformsLib.LTC_HALF_1,r.rectAreaLTC2=UniformsLib.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=a,r.ambient[1]=s,r.ambient[2]=l;const v=r.hash;v.directionalLength===c&&v.pointLength===h&&v.spotLength===u&&v.rectAreaLength===d&&v.hemiLength===p&&v.numDirectionalShadows===m&&v.numPointShadows===f&&v.numSpotShadows===g||(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=h,r.hemi.length=p,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=f,r.pointShadowMap.length=f,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=f,r.spotShadowMatrix.length=g,v.directionalLength=c,v.pointLength=h,v.spotLength=u,v.rectAreaLength=d,v.hemiLength=p,v.numDirectionalShadows=m,v.numPointShadows=f,v.numSpotShadows=g,r.version=nextVersion++)},setupView:function c(e,t){let n=0,i=0,l=0,c=0,h=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){const d=e[t];if(d.isDirectionalLight){const e=r.directional[n];e.direction.setFromMatrixPosition(d.matrixWorld),o.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(u),n++}else if(d.isSpotLight){const e=r.spot[l];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(d.matrixWorld),o.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(u),l++}else if(d.isRectAreaLight){const e=r.rectArea[c];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),s.identity(),a.copy(d.matrixWorld),a.premultiply(u),s.extractRotation(a),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),c++}else if(d.isPointLight){const e=r.point[i];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),i++}else if(d.isHemisphereLight){const e=r.hemi[h];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(u),e.direction.normalize(),h++}}},state:r}}function WebGLRenderState(e,t){const n=new WebGLLights(e,t),i=[],r=[];return{init:function o(){i.length=0,r.length=0},state:{lightsArray:i,shadowsArray:r,lights:n},setupLights:function a(){n.setup(i)},setupLightsView:function s(e){n.setupView(i,e)},pushLight:function l(e){i.push(e)},pushShadow:function c(e){r.push(e)}}}function WebGLRenderStates(e,t){let n=new WeakMap;return{get:function i(r,o=0){let a;return!1===n.has(r)?(a=new WebGLRenderState(e,t),n.set(r,[]),n.get(r).push(a)):o>=n.get(r).length?(a=new WebGLRenderState(e,t),n.get(r).push(a)):a=n.get(r)[o],a},dispose:function r(){n=new WeakMap}}}function MeshDepthMaterial(e){Material.call(this),this.type="MeshDepthMaterial",this.depthPacking=BasicDepthPacking,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}function MeshDistanceMaterial(e){Material.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new Vector3,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}MeshDepthMaterial.prototype=Object.create(Material.prototype),MeshDepthMaterial.prototype.constructor=MeshDepthMaterial,MeshDepthMaterial.prototype.isMeshDepthMaterial=!0,MeshDepthMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},MeshDistanceMaterial.prototype=Object.create(Material.prototype),MeshDistanceMaterial.prototype.constructor=MeshDistanceMaterial,MeshDistanceMaterial.prototype.isMeshDistanceMaterial=!0,MeshDistanceMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this};var vsm_frag="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}",vsm_vert="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";function WebGLShadowMap(e,t,n){let i=new Frustum;const r=new Vector2,o=new Vector2,a=new Vector4,s=[],l=[],c={},h={0:BackSide,1:FrontSide,2:DoubleSide},u=new ShaderMaterial({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Vector2},radius:{value:4}},vertexShader:vsm_vert,fragmentShader:vsm_frag}),d=u.clone();d.defines.HORIZONTAL_PASS=1;const p=new BufferGeometry;p.setAttribute("position",new BufferAttribute(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Mesh(p,u),f=this;function g(n,i){const r=t.update(m);u.uniforms.shadow_pass.value=n.map.texture,u.uniforms.resolution.value=n.mapSize,u.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,u,m,null),d.uniforms.shadow_pass.value=n.mapPass.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,d,m,null)}function v(e,t,n){const i=e<<0|t<<1|n<<2;let r=s[i];return void 0===r&&(r=new MeshDepthMaterial({depthPacking:RGBADepthPacking,morphTargets:e,skinning:t}),s[i]=r),r}function y(e,t,n){const i=e<<0|t<<1|n<<2;let r=l[i];return void 0===r&&(r=new MeshDistanceMaterial({morphTargets:e,skinning:t}),l[i]=r),r}function b(t,n,i,r,o,a,s){let l=null,u=v,d=t.customDepthMaterial;if(!0===r.isPointLight&&(u=y,d=t.customDistanceMaterial),void 0===d){let e=!1;!0===i.morphTargets&&(e=n.morphAttributes&&n.morphAttributes.position&&n.morphAttributes.position.length>0);let r=!1;!0===t.isSkinnedMesh&&(!0===i.skinning?r=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t)),l=u(e,r,!0===t.isInstancedMesh)}else l=d;if(e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){const e=l.uuid,t=i.uuid;let n=c[e];void 0===n&&(n={},c[e]=n);let r=n[t];void 0===r&&(r=l.clone(),n[t]=r),l=r}return l.visible=i.visible,l.wireframe=i.wireframe,l.side=s===VSMShadowMap?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:h[i.side],l.clipShadows=i.clipShadows,l.clippingPlanes=i.clippingPlanes,l.clipIntersection=i.clipIntersection,l.wireframeLinewidth=i.wireframeLinewidth,l.linewidth=i.linewidth,!0===r.isPointLight&&!0===l.isMeshDistanceMaterial&&(l.referencePosition.setFromMatrixPosition(r.matrixWorld),l.nearDistance=o,l.farDistance=a),l}function _(n,r,o,a,s){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===VSMShadowMap)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;l<c;l++){const c=t[l],h=r[c.materialIndex];if(h&&h.visible){const t=b(n,i,h,a,o.near,o.far,s);e.renderBufferDirect(o,null,i,t,n,c)}}}else if(r.visible){const t=b(n,i,r,a,o.near,o.far,s);e.renderBufferDirect(o,null,i,t,n,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)_(l[e],r,o,a,s)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=PCFShadowMap,this.render=function(t,s,l){if(!1===f.enabled)return;if(!1===f.autoUpdate&&!1===f.needsUpdate)return;if(0===t.length)return;const c=e.getRenderTarget(),h=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),d=e.state;d.setBlending(NoBlending),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(let c=0,h=t.length;c<h;c++){const h=t[c],u=h.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",h,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const p=u.getFrameExtents();if(r.multiply(p),o.copy(u.mapSize),(r.x>n||r.y>n)&&(r.x>n&&(o.x=Math.floor(n/p.x),r.x=o.x*p.x,u.mapSize.x=o.x),r.y>n&&(o.y=Math.floor(n/p.y),r.y=o.y*p.y,u.mapSize.y=o.y)),null===u.map&&!u.isPointLightShadow&&this.type===VSMShadowMap){const e={minFilter:LinearFilter,magFilter:LinearFilter,format:RGBAFormat};u.map=new WebGLRenderTarget(r.x,r.y,e),u.map.texture.name=h.name+".shadowMap",u.mapPass=new WebGLRenderTarget(r.x,r.y,e),u.camera.updateProjectionMatrix()}null===u.map&&(u.map=new WebGLRenderTarget(r.x,r.y,{minFilter:NearestFilter,magFilter:NearestFilter,format:RGBAFormat}),u.map.texture.name=h.name+".shadowMap",u.camera.updateProjectionMatrix()),e.setRenderTarget(u.map),e.clear();const m=u.getViewportCount();for(let e=0;e<m;e++){const t=u.getViewport(e);a.set(o.x*t.x,o.y*t.y,o.x*t.z,o.y*t.w),d.viewport(a),u.updateMatrices(h,e),i=u.getFrustum(),_(s,l,u.camera,h,this.type)}u.isPointLightShadow||this.type!==VSMShadowMap||g(u,l),u.needsUpdate=!1}f.needsUpdate=!1,e.setRenderTarget(c,h,u)}}function WebGLState(e,t,n){const i=n.isWebGL2,r=new(function o(){let t=!1;const n=new Vector4;let i=null;const r=new Vector4(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,o,a,s){!0===s&&(t*=a,i*=a,o*=a),n.set(t,i,o,a),!1===r.equals(n)&&(e.clearColor(t,i,o,a),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}}),a=new(function s(){let t=!1,n=null,i=null,r=null;return{setTest:function(e){e?O(2929):z(2929)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){if(t)switch(t){case NeverDepth:e.depthFunc(512);break;case AlwaysDepth:e.depthFunc(519);break;case LessDepth:e.depthFunc(513);break;case LessEqualDepth:e.depthFunc(515);break;case EqualDepth:e.depthFunc(514);break;case GreaterEqualDepth:e.depthFunc(518);break;case GreaterDepth:e.depthFunc(516);break;case NotEqualDepth:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}}),l=new(function c(){let t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?O(2960):z(2960))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&r===n&&o===a||(e.stencilFunc(t,n,a),i=t,r=n,o=a)},setOp:function(t,n,i){a===t&&s===n&&l===i||(e.stencilOp(t,n,i),a=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,c=null}}});let h={},u=null,d=null,p=null,m=null,f=null,g=null,v=null,y=null,b=null,_=!1,x=null,w=null,S=null,C=null,M=null;const E=e.getParameter(35661);let T=!1,I=0;const A=e.getParameter(7938);-1!==A.indexOf("WebGL")?(I=parseFloat(/^WebGL (\d)/.exec(A)[1]),T=I>=1):-1!==A.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(A)[1]),T=I>=2);let k=null,P={};const R=new Vector4,L=new Vector4;function N(t,n,i){const r=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<i;t++)e.texImage2D(n+t,0,6408,1,1,0,6408,5121,r);return o}const D={};function O(t){!0!==h[t]&&(e.enable(t),h[t]=!0)}function z(t){!1!==h[t]&&(e.disable(t),h[t]=!1)}D[3553]=N(3553,3553,1),D[34067]=N(34067,34069,6),r.setClear(0,0,0,1),a.setClear(1),l.setClear(0),O(2929),a.setFunc(LessEqualDepth),V(!1),H(CullFaceBack),O(2884),B(NoBlending);const F={[AddEquation]:32774,[SubtractEquation]:32778,[ReverseSubtractEquation]:32779};if(i)F[MinEquation]=32775,F[MaxEquation]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(F[MinEquation]=e.MIN_EXT,F[MaxEquation]=e.MAX_EXT)}const $={[ZeroFactor]:0,[OneFactor]:1,[SrcColorFactor]:768,[SrcAlphaFactor]:770,[SrcAlphaSaturateFactor]:776,[DstColorFactor]:774,[DstAlphaFactor]:772,[OneMinusSrcColorFactor]:769,[OneMinusSrcAlphaFactor]:771,[OneMinusDstColorFactor]:775,[OneMinusDstAlphaFactor]:773};function B(t,n,i,r,o,a,s,l){if(t!==NoBlending){if(d||(O(3042),d=!0),t===CustomBlending)o=o||n,a=a||i,s=s||r,n===m&&o===v||(e.blendEquationSeparate(F[n],F[o]),m=n,v=o),i===f&&r===g&&a===y&&s===b||(e.blendFuncSeparate($[i],$[r],$[a],$[s]),f=i,g=r,y=a,b=s),p=t,_=null;else if(t!==p||l!==_){if(m===AddEquation&&v===AddEquation||(e.blendEquation(32774),m=AddEquation,v=AddEquation),l)switch(t){case NormalBlending:e.blendFuncSeparate(1,771,1,771);break;case AdditiveBlending:e.blendFunc(1,1);break;case SubtractiveBlending:e.blendFuncSeparate(0,0,769,771);break;case MultiplyBlending:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case NormalBlending:e.blendFuncSeparate(770,771,1,771);break;case AdditiveBlending:e.blendFunc(770,1);break;case SubtractiveBlending:e.blendFunc(0,769);break;case MultiplyBlending:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}f=null,g=null,y=null,b=null,p=t,_=l}}else d&&(z(3042),d=!1)}function V(t){x!==t&&(e.frontFace(t?2304:2305),x=t)}function H(t){t!==CullFaceNone?(O(2884),t!==w&&e.cullFace(t===CullFaceBack?1029:t===CullFaceFront?1028:1032)):z(2884),w=t}function U(t,n,i){t?(O(32823),C===n&&M===i||(e.polygonOffset(n,i),C=n,M=i)):z(32823)}function G(t){void 0===t&&(t=33984+E-1),k!==t&&(e.activeTexture(t),k=t)}return{buffers:{color:r,depth:a,stencil:l},enable:O,disable:z,useProgram:function j(t){return u!==t&&(e.useProgram(t),u=t,!0)},setBlending:B,setMaterial:function W(e,t){e.side===DoubleSide?z(2884):O(2884);let n=e.side===BackSide;t&&(n=!n),V(n),e.blending===NormalBlending&&!1===e.transparent?B(NoBlending):B(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),a.setFunc(e.depthFunc),a.setTest(e.depthTest),a.setMask(e.depthWrite),r.setMask(e.colorWrite);const i=e.stencilWrite;l.setTest(i),i&&(l.setMask(e.stencilWriteMask),l.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),l.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),U(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)},setFlipSided:V,setCullFace:H,setLineWidth:function q(t){t!==S&&(T&&e.lineWidth(t),S=t)},setPolygonOffset:U,setScissorTest:function X(e){e?O(3089):z(3089)},activeTexture:G,bindTexture:function K(t,n){null===k&&G();let i=P[k];void 0===i&&(i={type:void 0,texture:void 0},P[k]=i),i.type===t&&i.texture===n||(e.bindTexture(t,n||D[t]),i.type=t,i.texture=n)},unbindTexture:function Y(){const t=P[k];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function Z(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function J(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function Q(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function ee(t){!1===R.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),R.copy(t))},viewport:function te(t){!1===L.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),L.copy(t))},reset:function ne(){h={},k=null,P={},u=null,d=null,p=null,m=null,f=null,g=null,v=null,y=null,b=null,_=!1,x=null,w=null,S=null,C=null,M=null,r.reset(),a.reset(),l.reset()}}}function WebGLTextures(e,t,n,i,r,o,a){const s=r.isWebGL2,l=r.maxTextures,c=r.maxCubemapSize,h=r.maxTextureSize,u=r.maxSamples,d=new WeakMap;let p,m=!1;try{m="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function f(e,t){return m?new OffscreenCanvas(e,t):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function g(e,t,n,i){let r=1;if((e.width>i||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?MathUtils.floorPowerOfTwo:Math.floor,o=i(r*e.width),a=i(r*e.height);void 0===p&&(p=f(o,a));const s=n?f(o,a):p;return s.width=o,s.height=a,s.getContext("2d").drawImage(e,0,0,o,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+a+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function v(e){return MathUtils.isPowerOfTwo(e.width)&&MathUtils.isPowerOfTwo(e.height)}function y(e,t){return e.generateMipmaps&&t&&e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter}function b(t,n,r,o){e.generateMipmap(t),i.get(n).__maxMipLevel=Math.log(Math.max(r,o))*Math.LOG2E}function _(n,i,r){if(!1===s)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;return 6403===i&&(5126===r&&(o=33326),5131===r&&(o=33325),5121===r&&(o=33321)),6407===i&&(5126===r&&(o=34837),5131===r&&(o=34843),5121===r&&(o=32849)),6408===i&&(5126===r&&(o=34836),5131===r&&(o=34842),5121===r&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||t.get("EXT_color_buffer_float"),o}function x(e){return e===NearestFilter||e===NearestMipmapNearestFilter||e===NearestMipmapLinearFilter?9728:9729}function w(t){const n=t.target;n.removeEventListener("dispose",w),(function r(t){const n=i.get(t);void 0!==n.__webglInit&&(e.deleteTexture(n.__webglTexture),i.remove(t))})(n),n.isVideoTexture&&d.delete(n),a.memory.textures--}function S(t){const n=t.target;n.removeEventListener("dispose",S),(function r(t){const n=i.get(t),r=i.get(t.texture);if(t){if(void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer&&e.deleteRenderbuffer(n.__webglColorRenderbuffer),n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer);i.remove(t.texture),i.remove(t)}})(n),a.memory.textures--}let C=0;function M(e,t){const r=i.get(e);if(e.isVideoTexture&&(function o(e){const t=a.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())})(e),e.version>0&&r.__version!==e.version){const n=e.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void P(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,r.__webglTexture)}function E(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?(function l(t,i,r){if(6!==i.image.length)return;k(t,i),n.activeTexture(33984+r),n.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment);const a=i&&(i.isCompressedTexture||i.image[0].isCompressedTexture),l=i.image[0]&&i.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=a||l?l?i.image[e].image:i.image[e]:g(i.image[e],!1,!0,c);const u=h[0],d=v(u)||s,p=o.convert(i.format),m=o.convert(i.type),f=_(i.internalFormat,p,m);let x;if(A(34067,i,d),a){for(let e=0;e<6;e++){x=h[e].mipmaps;for(let t=0;t<x.length;t++){const r=x[t];i.format!==RGBAFormat&&i.format!==RGBFormat?null!==p?n.compressedTexImage2D(34069+e,t,f,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(34069+e,t,f,r.width,r.height,0,p,m,r.data)}}t.__maxMipLevel=x.length-1}else{x=i.mipmaps;for(let e=0;e<6;e++)if(l){n.texImage2D(34069+e,0,f,h[e].width,h[e].height,0,p,m,h[e].data);for(let t=0;t<x.length;t++){const i=x[t].image[e].image;n.texImage2D(34069+e,t+1,f,i.width,i.height,0,p,m,i.data)}}else{n.texImage2D(34069+e,0,f,p,m,h[e]);for(let t=0;t<x.length;t++)n.texImage2D(34069+e,t+1,f,p,m,x[t].image[e])}t.__maxMipLevel=x.length}y(i,d)&&b(34067,i,u.width,u.height),t.__version=i.version,i.onUpdate&&i.onUpdate(i)})(a,t,r):(n.activeTexture(33984+r),n.bindTexture(34067,a.__webglTexture))}const T={[RepeatWrapping]:10497,[ClampToEdgeWrapping]:33071,[MirroredRepeatWrapping]:33648},I={[NearestFilter]:9728,[NearestMipmapNearestFilter]:9984,[NearestMipmapLinearFilter]:9986,[LinearFilter]:9729,[LinearMipmapNearestFilter]:9985,[LinearMipmapLinearFilter]:9987};function A(n,o,a){a?(e.texParameteri(n,10242,T[o.wrapS]),e.texParameteri(n,10243,T[o.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,T[o.wrapR]),e.texParameteri(n,10240,I[o.magFilter]),e.texParameteri(n,10241,I[o.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),o.wrapS===ClampToEdgeWrapping&&o.wrapT===ClampToEdgeWrapping||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,10240,x(o.magFilter)),e.texParameteri(n,10241,x(o.minFilter)),o.minFilter!==NearestFilter&&o.minFilter!==LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));const l=t.get("EXT_texture_filter_anisotropic");if(l){if(o.type===FloatType&&null===t.get("OES_texture_float_linear"))return;if(o.type===HalfFloatType&&null===(s||t.get("OES_texture_half_float_linear")))return;(o.anisotropy>1||i.get(o).__currentAnisotropy)&&(e.texParameterf(n,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function k(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",w),t.__webglTexture=e.createTexture(),a.memory.textures++)}function P(t,i,r){let a=3553;i.isDataTexture2DArray&&(a=35866),i.isDataTexture3D&&(a=32879),k(t,i),n.activeTexture(33984+r),n.bindTexture(a,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment);const l=(function c(e){return!s&&(e.wrapS!==ClampToEdgeWrapping||e.wrapT!==ClampToEdgeWrapping||e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter)})(i)&&!1===v(i.image),u=g(i.image,l,!1,h),d=v(u)||s,p=o.convert(i.format);let m,f=o.convert(i.type),x=_(i.internalFormat,p,f);A(a,i,d);const w=i.mipmaps;if(i.isDepthTexture)x=6402,s?x=i.type===FloatType?36012:i.type===UnsignedIntType?33190:i.type===UnsignedInt248Type?35056:33189:i.type===FloatType&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===DepthFormat&&6402===x&&i.type!==UnsignedShortType&&i.type!==UnsignedIntType&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=UnsignedShortType,f=o.convert(i.type)),i.format===DepthStencilFormat&&6402===x&&(x=34041,i.type!==UnsignedInt248Type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=UnsignedInt248Type,f=o.convert(i.type))),n.texImage2D(3553,0,x,u.width,u.height,0,p,f,null);else if(i.isDataTexture)if(w.length>0&&d){for(let e=0,t=w.length;e<t;e++)m=w[e],n.texImage2D(3553,e,x,m.width,m.height,0,p,f,m.data);i.generateMipmaps=!1,t.__maxMipLevel=w.length-1}else n.texImage2D(3553,0,x,u.width,u.height,0,p,f,u.data),t.__maxMipLevel=0;else if(i.isCompressedTexture){for(let e=0,t=w.length;e<t;e++)m=w[e],i.format!==RGBAFormat&&i.format!==RGBFormat?null!==p?n.compressedTexImage2D(3553,e,x,m.width,m.height,0,m.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(3553,e,x,m.width,m.height,0,p,f,m.data);t.__maxMipLevel=w.length-1}else if(i.isDataTexture2DArray)n.texImage3D(35866,0,x,u.width,u.height,u.depth,0,p,f,u.data),t.__maxMipLevel=0;else if(i.isDataTexture3D)n.texImage3D(32879,0,x,u.width,u.height,u.depth,0,p,f,u.data),t.__maxMipLevel=0;else if(w.length>0&&d){for(let e=0,t=w.length;e<t;e++)m=w[e],n.texImage2D(3553,e,x,p,f,m);i.generateMipmaps=!1,t.__maxMipLevel=w.length-1}else n.texImage2D(3553,0,x,p,f,u),t.__maxMipLevel=0;y(i,d)&&b(a,i,u.width,u.height),t.__version=i.version,i.onUpdate&&i.onUpdate(i)}function R(t,r,a,s){const l=o.convert(r.texture.format),c=o.convert(r.texture.type),h=_(r.texture.internalFormat,l,c);n.texImage2D(s,0,h,r.width,r.height,0,l,c,null),e.bindFramebuffer(36160,t),e.framebufferTexture2D(36160,a,s,i.get(r.texture).__webglTexture,0),e.bindFramebuffer(36160,null)}function L(t,n,i){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let r=33189;if(i){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===FloatType?r=36012:t.type===UnsignedIntType&&(r=33190));const i=N(n);e.renderbufferStorageMultisample(36161,i,r,n.width,n.height)}else e.renderbufferStorage(36161,r,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){if(i){const t=N(n);e.renderbufferStorageMultisample(36161,t,35056,n.width,n.height)}else e.renderbufferStorage(36161,34041,n.width,n.height);e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=o.convert(n.texture.format),r=o.convert(n.texture.type),a=_(n.texture.internalFormat,t,r);if(i){const t=N(n);e.renderbufferStorageMultisample(36161,t,a,n.width,n.height)}else e.renderbufferStorage(36161,a,n.width,n.height)}e.bindRenderbuffer(36161,null)}function N(e){return s&&e.isWebGLMultisampleRenderTarget?Math.min(u,e.samples):0}let D=!1,O=!1;this.allocateTextureUnit=function z(){const e=C;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),C+=1,e},this.resetTextureUnits=function F(){C=0},this.setTexture2D=M,this.setTexture2DArray=function $(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?P(r,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function B(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?P(r,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,r.__webglTexture))},this.setTextureCube=E,this.setupRenderTarget=function V(t){const r=i.get(t),l=i.get(t.texture);t.addEventListener("dispose",S),l.__webglTexture=e.createTexture(),a.memory.textures++;const c=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultisampleRenderTarget,u=v(t)||s;if(!s||t.texture.format!==RGBFormat||t.texture.type!==FloatType&&t.texture.type!==HalfFloatType||(t.texture.format=RGBAFormat,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),c){r.__webglFramebuffer=[];for(let t=0;t<6;t++)r.__webglFramebuffer[t]=e.createFramebuffer()}else if(r.__webglFramebuffer=e.createFramebuffer(),h)if(s){r.__webglMultisampledFramebuffer=e.createFramebuffer(),r.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,r.__webglColorRenderbuffer);const n=o.convert(t.texture.format),i=o.convert(t.texture.type),a=_(t.texture.internalFormat,n,i),s=N(t);e.renderbufferStorageMultisample(36161,s,a,t.width,t.height),e.bindFramebuffer(36160,r.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,r.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(r.__webglDepthRenderbuffer=e.createRenderbuffer(),L(r.__webglDepthRenderbuffer,t,!0)),e.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(c){n.bindTexture(34067,l.__webglTexture),A(34067,t.texture,u);for(let e=0;e<6;e++)R(r.__webglFramebuffer[e],t,36064,34069+e);y(t.texture,u)&&b(34067,t.texture,t.width,t.height),n.bindTexture(34067,null)}else n.bindTexture(3553,l.__webglTexture),A(3553,t.texture,u),R(r.__webglFramebuffer,t,36064,3553),y(t.texture,u)&&b(3553,t.texture,t.width,t.height),n.bindTexture(3553,null);t.depthBuffer&&(function d(t){const n=i.get(t),r=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!(function o(t,n){if(n&&n.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,t),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(n.depthTexture).__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),M(n.depthTexture,0);const r=i.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===DepthFormat)e.framebufferTexture2D(36160,36096,3553,r,0);else{if(n.depthTexture.format!==DepthStencilFormat)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(36160,33306,3553,r,0)}})(n.__webglFramebuffer,t)}else if(r){n.__webglDepthbuffer=[];for(let i=0;i<6;i++)e.bindFramebuffer(36160,n.__webglFramebuffer[i]),n.__webglDepthbuffer[i]=e.createRenderbuffer(),L(n.__webglDepthbuffer[i],t,!1)}else e.bindFramebuffer(36160,n.__webglFramebuffer),n.__webglDepthbuffer=e.createRenderbuffer(),L(n.__webglDepthbuffer,t,!1);e.bindFramebuffer(36160,null)})(t)},this.updateRenderTargetMipmap=function H(e){const t=e.texture;if(y(t,v(e)||s)){const r=e.isWebGLCubeRenderTarget?34067:3553,o=i.get(t).__webglTexture;n.bindTexture(r,o),b(r,t,e.width,e.height),n.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function U(t){if(t.isWebGLMultisampleRenderTarget)if(s){const n=i.get(t);e.bindFramebuffer(36008,n.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,n.__webglFramebuffer);const r=t.width,o=t.height;let a=16384;t.depthBuffer&&(a|=256),t.stencilBuffer&&(a|=1024),e.blitFramebuffer(0,0,r,o,0,0,r,o,a,9728),e.bindFramebuffer(36160,n.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function G(e,t){e&&e.isWebGLRenderTarget&&(!1===D&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),D=!0),e=e.texture),M(e,t)},this.safeSetTextureCube=function j(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===O&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),O=!0),e=e.texture),E(e,t)}}function WebGLUtils(e,t,n){const i=n.isWebGL2;return{convert:function r(e){let n;if(e===UnsignedByteType)return 5121;if(e===UnsignedShort4444Type)return 32819;if(e===UnsignedShort5551Type)return 32820;if(e===UnsignedShort565Type)return 33635;if(e===ByteType)return 5120;if(e===ShortType)return 5122;if(e===UnsignedShortType)return 5123;if(e===IntType)return 5124;if(e===UnsignedIntType)return 5125;if(e===FloatType)return 5126;if(e===HalfFloatType)return i?5131:(n=t.get("OES_texture_half_float"),null!==n?n.HALF_FLOAT_OES:null);if(e===AlphaFormat)return 6406;if(e===RGBFormat)return 6407;if(e===RGBAFormat)return 6408;if(e===LuminanceFormat)return 6409;if(e===LuminanceAlphaFormat)return 6410;if(e===DepthFormat)return 6402;if(e===DepthStencilFormat)return 34041;if(e===RedFormat)return 6403;if(e===RedIntegerFormat)return 36244;if(e===RGFormat)return 33319;if(e===RGIntegerFormat)return 33320;if(e===RGBIntegerFormat)return 36248;if(e===RGBAIntegerFormat)return 36249;if(e===RGB_S3TC_DXT1_Format||e===RGBA_S3TC_DXT1_Format||e===RGBA_S3TC_DXT3_Format||e===RGBA_S3TC_DXT5_Format){if(n=t.get("WEBGL_compressed_texture_s3tc"),null===n)return null;if(e===RGB_S3TC_DXT1_Format)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT1_Format)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT3_Format)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===RGBA_S3TC_DXT5_Format)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===RGB_PVRTC_4BPPV1_Format||e===RGB_PVRTC_2BPPV1_Format||e===RGBA_PVRTC_4BPPV1_Format||e===RGBA_PVRTC_2BPPV1_Format){if(n=t.get("WEBGL_compressed_texture_pvrtc"),null===n)return null;if(e===RGB_PVRTC_4BPPV1_Format)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===RGB_PVRTC_2BPPV1_Format)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===RGBA_PVRTC_4BPPV1_Format)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===RGBA_PVRTC_2BPPV1_Format)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===RGB_ETC1_Format)return n=t.get("WEBGL_compressed_texture_etc1"),null!==n?n.COMPRESSED_RGB_ETC1_WEBGL:null;if((e===RGB_ETC2_Format||e===RGBA_ETC2_EAC_Format)&&(n=t.get("WEBGL_compressed_texture_etc"),null!==n)){if(e===RGB_ETC2_Format)return n.COMPRESSED_RGB8_ETC2;if(e===RGBA_ETC2_EAC_Format)return n.COMPRESSED_RGBA8_ETC2_EAC}return e===RGBA_ASTC_4x4_Format||e===RGBA_ASTC_5x4_Format||e===RGBA_ASTC_5x5_Format||e===RGBA_ASTC_6x5_Format||e===RGBA_ASTC_6x6_Format||e===RGBA_ASTC_8x5_Format||e===RGBA_ASTC_8x6_Format||e===RGBA_ASTC_8x8_Format||e===RGBA_ASTC_10x5_Format||e===RGBA_ASTC_10x6_Format||e===RGBA_ASTC_10x8_Format||e===RGBA_ASTC_10x10_Format||e===RGBA_ASTC_12x10_Format||e===RGBA_ASTC_12x12_Format||e===SRGB8_ALPHA8_ASTC_4x4_Format||e===SRGB8_ALPHA8_ASTC_5x4_Format||e===SRGB8_ALPHA8_ASTC_5x5_Format||e===SRGB8_ALPHA8_ASTC_6x5_Format||e===SRGB8_ALPHA8_ASTC_6x6_Format||e===SRGB8_ALPHA8_ASTC_8x5_Format||e===SRGB8_ALPHA8_ASTC_8x6_Format||e===SRGB8_ALPHA8_ASTC_8x8_Format||e===SRGB8_ALPHA8_ASTC_10x5_Format||e===SRGB8_ALPHA8_ASTC_10x6_Format||e===SRGB8_ALPHA8_ASTC_10x8_Format||e===SRGB8_ALPHA8_ASTC_10x10_Format||e===SRGB8_ALPHA8_ASTC_12x10_Format||e===SRGB8_ALPHA8_ASTC_12x12_Format?(n=t.get("WEBGL_compressed_texture_astc"),null!==n?e:null):e===RGBA_BPTC_Format?(n=t.get("EXT_texture_compression_bptc"),null!==n?e:null):e===UnsignedInt248Type?i?34042:(n=t.get("WEBGL_depth_texture"),null!==n?n.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}function ArrayCamera(e=[]){PerspectiveCamera.call(this),this.cameras=e}function Group(){Object3D.call(this),this.type="Group"}function WebXRController(){this._targetRay=null,this._grip=null,this._hand=null}function WebXRManager(e,t){const n=this;let i=null,r=1,o=null,a="local-floor",s=null;const l=[],c=new Map,h=new PerspectiveCamera;h.layers.enable(1),h.viewport=new Vector4;const u=new PerspectiveCamera;u.layers.enable(2),u.viewport=new Vector4;const d=[h,u],p=new ArrayCamera;p.layers.enable(1),p.layers.enable(2);let m=null,f=null;function g(e){const t=c.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function v(){c.forEach((function(e,t){e.disconnect(t)})),c.clear(),m=null,f=null,e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),S.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function y(e){const t=i.inputSources;for(let e=0;e<l.length;e++)c.set(t[e],l[e]);for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=c.get(n);i&&(i.dispatchEvent({type:"disconnected",data:n}),c.delete(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t],i=c.get(n);i&&i.dispatchEvent({type:"connected",data:n})}}this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=l[e];return void 0===t&&(t=new WebXRController,l[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=l[e];return void 0===t&&(t=new WebXRController,l[e]=t),t.getGripSpace()},this.getHand=function(e){let t=l[e];return void 0===t&&(t=new WebXRController,l[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getSession=function(){return i},this.setSession=async function(e){if(i=e,null!==i){i.addEventListener("select",g),i.addEventListener("selectstart",g),i.addEventListener("selectend",g),i.addEventListener("squeeze",g),i.addEventListener("squeezestart",g),i.addEventListener("squeezeend",g),i.addEventListener("end",v),i.addEventListener("inputsourceschange",y);const e=t.getContextAttributes();!0!==e.xrCompatible&&await t.makeXRCompatible();const s=new XRWebGLLayer(i,t,{antialias:e.antialias,alpha:e.alpha,depth:e.depth,stencil:e.stencil,framebufferScaleFactor:r});i.updateRenderState({baseLayer:s}),o=await i.requestReferenceSpace(a),S.setContext(i),S.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const b=new Vector3,_=new Vector3;function x(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.getCamera=function(e){p.near=u.near=h.near=e.near,p.far=u.far=h.far=e.far,m===p.near&&f===p.far||(i.updateRenderState({depthNear:p.near,depthFar:p.far}),m=p.near,f=p.far);const t=e.parent,n=p.cameras;x(p,t);for(let e=0;e<n.length;e++)x(n[e],t);e.matrixWorld.copy(p.matrixWorld),e.matrix.copy(p.matrix),e.matrix.decompose(e.position,e.quaternion,e.scale);const r=e.children;for(let e=0,t=r.length;e<t;e++)r[e].updateMatrixWorld(!0);return 2===n.length?(function o(e,t,n){b.setFromMatrixPosition(t.matrixWorld),_.setFromMatrixPosition(n.matrixWorld);const i=b.distanceTo(_),r=t.projectionMatrix.elements,o=n.projectionMatrix.elements,a=r[14]/(r[10]-1),s=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],h=(r[8]-1)/r[0],u=(o[8]+1)/o[0],d=a*h,p=a*u,m=i/(-h+u),f=m*-h;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(f),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=a+m,v=s+m;e.projectionMatrix.makePerspective(d-f,p+(i-f),l*s/v*g,c*s/v*g,g,v)})(p,h,u):p.projectionMatrix.copy(h.projectionMatrix),p};let w=null;const S=new WebGLAnimation;S.setAnimationLoop((function C(t,n){if(s=n.getViewerPose(o),null!==s){const t=s.views,n=i.renderState.baseLayer;e.setFramebuffer(n.framebuffer);let r=!1;t.length!==p.cameras.length&&(p.cameras.length=0,r=!0);for(let e=0;e<t.length;e++){const i=t[e],o=n.getViewport(i),a=d[e];a.matrix.fromArray(i.transform.matrix),a.projectionMatrix.fromArray(i.projectionMatrix),a.viewport.set(o.x,o.y,o.width,o.height),0===e&&p.matrix.copy(a.matrix),!0===r&&p.cameras.push(a)}}const r=i.inputSources;for(let e=0;e<l.length;e++)l[e].update(r[e],n,o);w&&w(t,n)})),this.setAnimationLoop=function(e){w=e},this.dispose=function(){}}function WebGLMaterials(e){function t(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map),n.alphaMap&&(t.alphaMap.value=n.alphaMap),n.specularMap&&(t.specularMap.value=n.specularMap);const i=e.get(n).envMap;if(i){t.envMap.value=i,t.flipEnvMap.value=i.isCubeTexture&&i._needsFlipEnvMap?-1:1,t.reflectivity.value=n.reflectivity,t.refractionRatio.value=n.refractionRatio;const r=e.get(i).__maxMipLevel;void 0!==r&&(t.maxMipLevel.value=r)}let r,o;n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity),n.map?r=n.map:n.specularMap?r=n.specularMap:n.displacementMap?r=n.displacementMap:n.normalMap?r=n.normalMap:n.bumpMap?r=n.bumpMap:n.roughnessMap?r=n.roughnessMap:n.metalnessMap?r=n.metalnessMap:n.alphaMap?r=n.alphaMap:n.emissiveMap?r=n.emissiveMap:n.clearcoatMap?r=n.clearcoatMap:n.clearcoatNormalMap?r=n.clearcoatNormalMap:n.clearcoatRoughnessMap&&(r=n.clearcoatRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix)),n.aoMap?o=n.aoMap:n.lightMap&&(o=n.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),t.uv2Transform.value.copy(o.matrix))}function n(t,n){t.roughness.value=n.roughness,t.metalness.value=n.metalness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap),n.bumpMap&&(t.bumpMap.value=n.bumpMap,t.bumpScale.value=n.bumpScale,n.side===BackSide&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,t.normalScale.value.copy(n.normalScale),n.side===BackSide&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function i(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function r(e,i,o,a){i.isMeshBasicMaterial?t(e,i):i.isMeshLambertMaterial?(t(e,i),(function s(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)})(e,i)):i.isMeshToonMaterial?(t(e,i),(function l(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===BackSide&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===BackSide&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,i)):i.isMeshPhongMaterial?(t(e,i),(function c(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===BackSide&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===BackSide&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,i)):i.isMeshStandardMaterial?(t(e,i),i.isMeshPhysicalMaterial?(function h(e,t){n(e,t),e.reflectivity.value=t.reflectivity,e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.sheen&&e.sheen.value.copy(t.sheen),t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,t.side===BackSide&&e.clearcoatNormalScale.value.negate()),e.transmission.value=t.transmission,t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap)})(e,i):n(e,i)):i.isMeshMatcapMaterial?(t(e,i),(function u(e,t){t.matcap&&(e.matcap.value=t.matcap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===BackSide&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===BackSide&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,i)):i.isMeshDepthMaterial?(t(e,i),(function d(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,i)):i.isMeshDistanceMaterial?(t(e,i),(function p(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance})(e,i)):i.isMeshNormalMaterial?(t(e,i),(function m(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===BackSide&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===BackSide&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,i)):i.isLineBasicMaterial?((function f(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity})(e,i),i.isLineDashedMaterial&&(function g(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale})(e,i)):i.isPointsMaterial?(function v(e,t,n,i){let r;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*i,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.map?r=t.map:t.alphaMap&&(r=t.alphaMap),void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))})(e,i,o,a):i.isSpriteMaterial?(function y(e,t){let n;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.map?n=t.map:t.alphaMap&&(n=t.alphaMap),void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))})(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function createCanvasElement(){const e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.style.display="block",e}function WebGLRenderer(e){const t=void 0!==(e=e||{}).canvas?e.canvas:createCanvasElement(),n=void 0!==e.context?e.context:null,i=void 0!==e.alpha&&e.alpha,r=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,a=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,l=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,c=void 0!==e.powerPreference?e.powerPreference:"default",h=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let u=null,d=null;const p=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=LinearEncoding,this.physicallyCorrectLights=!1,this.toneMapping=NoToneMapping,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;const m=this;let f=!1,g=null,v=0,y=0,b=null,_=null,x=-1,w=null;const S=new Vector4,C=new Vector4;let M=null,E=t.width,T=t.height,I=1,A=null,k=null;const P=new Vector4(0,0,E,T),R=new Vector4(0,0,E,T);let L=!1;const N=new Frustum;let D=!1,O=!1;const z=new Matrix4,F=new Vector3,$={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function B(){return null===b?I:1}let V,H,U,G,j,W,q,X,K,Y,Z,J,Q,ee,te,ne,ie,re,oe,ae,se,le=n;function ce(e,n){for(let i=0;i<e.length;i++){const r=t.getContext(e[i],n);if(null!==r)return r}return null}try{const e={alpha:i,depth:r,stencil:o,antialias:a,premultipliedAlpha:s,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:h};if(t.addEventListener("webglcontextlost",pe,!1),t.addEventListener("webglcontextrestored",me,!1),null===le){const t=["webgl2","webgl","experimental-webgl"];if(!0===m.isWebGL1Renderer&&t.shift(),le=ce(t,e),null===le)throw ce(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===le.getShaderPrecisionFormat&&(le.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function he(){V=new WebGLExtensions(le),H=new WebGLCapabilities(le,V,e),V.init(H),ae=new WebGLUtils(le,V,H),U=new WebGLState(le,V,H),U.scissor(C.copy(R).multiplyScalar(I).floor()),U.viewport(S.copy(P).multiplyScalar(I).floor()),G=new WebGLInfo(le),j=new WebGLProperties,W=new WebGLTextures(le,V,U,j,H,ae,G),q=new WebGLCubeMaps(m),X=new WebGLAttributes(le,H),se=new WebGLBindingStates(le,V,X,H),K=new WebGLGeometries(le,X,G,se),Y=new WebGLObjects(le,K,X,G),ie=new WebGLMorphtargets(le),te=new WebGLClipping(j),Z=new WebGLPrograms(m,q,V,H,se,te),J=new WebGLMaterials(j),Q=new WebGLRenderLists(j),ee=new WebGLRenderStates(V,H),ne=new WebGLBackground(m,q,U,Y,s),re=new WebGLBufferRenderer(le,V,G,H),oe=new WebGLIndexedBufferRenderer(le,V,G,H),G.programs=Z.programs,m.capabilities=H,m.extensions=V,m.properties=j,m.renderLists=Q,m.state=U,m.info=G}he();const ue=new WebXRManager(m,le);this.xr=ue;const de=new WebGLShadowMap(m,Y,H.maxTextureSize);function pe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),f=!0}function me(){console.log("THREE.WebGLRenderer: Context Restored."),f=!1,he()}function fe(e){const t=e.target;t.removeEventListener("dispose",fe),(function n(e){ge(e),j.remove(e)})(t)}function ge(e){const t=j.get(e).program;void 0!==t&&Z.releaseProgram(t)}this.shadowMap=de,this.getContext=function(){return le},this.getContextAttributes=function(){return le.getContextAttributes()},this.forceContextLoss=function(){const e=V.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=V.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(e){void 0!==e&&(I=e,this.setSize(E,T,!1))},this.getSize=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),e=new Vector2),e.set(E,T)},this.setSize=function(e,n,i){ue.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(E=e,T=n,t.width=Math.floor(e*I),t.height=Math.floor(n*I),!1!==i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),e=new Vector2),e.set(E*I,T*I).floor()},this.setDrawingBufferSize=function(e,n,i){E=e,T=n,I=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),e=new Vector4),e.copy(S)},this.getViewport=function(e){return e.copy(P)},this.setViewport=function(e,t,n,i){e.isVector4?P.set(e.x,e.y,e.z,e.w):P.set(e,t,n,i),U.viewport(S.copy(P).multiplyScalar(I).floor())},this.getScissor=function(e){return e.copy(R)},this.setScissor=function(e,t,n,i){e.isVector4?R.set(e.x,e.y,e.z,e.w):R.set(e,t,n,i),U.scissor(C.copy(R).multiplyScalar(I).floor())},this.getScissorTest=function(){return L},this.setScissorTest=function(e){U.setScissorTest(L=e)},this.setOpaqueSort=function(e){A=e},this.setTransparentSort=function(e){k=e},this.getClearColor=function(e){return void 0===e&&(console.warn("WebGLRenderer: .getClearColor() now requires a Color as an argument"),e=new Color),e.copy(ne.getClearColor())},this.setClearColor=function(){ne.setClearColor.apply(ne,arguments)},this.getClearAlpha=function(){return ne.getClearAlpha()},this.setClearAlpha=function(){ne.setClearAlpha.apply(ne,arguments)},this.clear=function(e,t,n){let i=0;(void 0===e||e)&&(i|=16384),(void 0===t||t)&&(i|=256),(void 0===n||n)&&(i|=1024),le.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",pe,!1),t.removeEventListener("webglcontextrestored",me,!1),Q.dispose(),ee.dispose(),j.dispose(),q.dispose(),Y.dispose(),se.dispose(),ue.dispose(),ye.stop()},this.renderBufferImmediate=function(e,t){se.initAttributes();const n=j.get(e);e.hasPositions&&!n.position&&(n.position=le.createBuffer()),e.hasNormals&&!n.normal&&(n.normal=le.createBuffer()),e.hasUvs&&!n.uv&&(n.uv=le.createBuffer()),e.hasColors&&!n.color&&(n.color=le.createBuffer());const i=t.getAttributes();e.hasPositions&&(le.bindBuffer(34962,n.position),le.bufferData(34962,e.positionArray,35048),se.enableAttribute(i.position),le.vertexAttribPointer(i.position,3,5126,!1,0,0)),e.hasNormals&&(le.bindBuffer(34962,n.normal),le.bufferData(34962,e.normalArray,35048),se.enableAttribute(i.normal),le.vertexAttribPointer(i.normal,3,5126,!1,0,0)),e.hasUvs&&(le.bindBuffer(34962,n.uv),le.bufferData(34962,e.uvArray,35048),se.enableAttribute(i.uv),le.vertexAttribPointer(i.uv,2,5126,!1,0,0)),e.hasColors&&(le.bindBuffer(34962,n.color),le.bufferData(34962,e.colorArray,35048),se.enableAttribute(i.color),le.vertexAttribPointer(i.color,3,5126,!1,0,0)),se.disableUnusedAttributes(),le.drawArrays(4,0,e.count),e.count=0},this.renderBufferDirect=function(e,t,n,i,r,o){null===t&&(t=$);const a=r.isMesh&&r.matrixWorld.determinant()<0,s=Se(e,t,i,r);U.setMaterial(i,a);let l=n.index;const c=n.attributes.position;if(null===l){if(void 0===c||0===c.count)return}else if(0===l.count)return;let h,u=1;!0===i.wireframe&&(l=K.getWireframeAttribute(n),u=2),(i.morphTargets||i.morphNormals)&&ie.update(r,n,i,s),se.setup(r,i,s,n,l);let d=re;null!==l&&(h=X.get(l),d=oe,d.setIndex(h));const p=null!==l?l.count:c.count,m=n.drawRange.start*u,f=n.drawRange.count*u,g=null!==o?o.start*u:0,v=null!==o?o.count*u:1/0,y=Math.max(m,g),b=Math.min(p,m+f,g+v)-1,_=Math.max(0,b-y+1);if(0!==_){if(r.isMesh)!0===i.wireframe?(U.setLineWidth(i.wireframeLinewidth*B()),d.setMode(1)):d.setMode(4);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),U.setLineWidth(e*B()),d.setMode(r.isLineSegments?1:r.isLineLoop?2:3)}else r.isPoints?d.setMode(0):r.isSprite&&d.setMode(4);if(r.isInstancedMesh)d.renderInstances(y,_,r.count);else if(n.isInstancedBufferGeometry){const e=Math.min(n.instanceCount,n._maxInstanceCount);d.renderInstances(y,_,e)}else d.render(y,_)}},this.compile=function(e,t){d=ee.get(e),d.init(),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(d.pushLight(e),e.castShadow&&d.pushShadow(e))})),d.setupLights();const n=new WeakMap;e.traverse((function(t){const i=t.material;if(i)if(Array.isArray(i))for(let r=0;r<i.length;r++){const o=i[r];!1===n.has(o)&&(we(o,e,t),n.set(o))}else!1===n.has(i)&&(we(i,e,t),n.set(i))}))};let ve=null;const ye=new WebGLAnimation;function be(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)d.pushLight(e),e.castShadow&&d.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||N.intersectsSprite(e)){i&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z);const t=Y.update(e),r=e.material;r.visible&&u.push(e,t,r,n,F.z,null)}}else if(e.isImmediateRenderObject)i&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z),u.push(e,null,e.material,n,F.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==G.render.frame&&(e.skeleton.update(),e.skeleton.frame=G.render.frame),!e.frustumCulled||N.intersectsObject(e))){i&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z);const t=Y.update(e),r=e.material;if(Array.isArray(r)){const i=t.groups;for(let o=0,a=i.length;o<a;o++){const a=i[o],s=r[a.materialIndex];s&&s.visible&&u.push(e,t,s,n,F.z,a)}}else r.visible&&u.push(e,t,r,n,F.z,null)}const r=e.children;for(let e=0,o=r.length;e<o;e++)be(r[e],t,n,i)}function _e(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,o=e.length;r<o;r++){const o=e[r],a=o.object,s=o.geometry,l=null===i?o.material:i,c=o.group;if(n.isArrayCamera){const e=n.cameras;for(let n=0,i=e.length;n<i;n++){const i=e[n];a.layers.test(i.layers)&&(U.viewport(S.copy(i.viewport)),d.setupLightsView(i),xe(a,t,i,s,l,c))}}else xe(a,t,n,s,l,c)}}function xe(e,t,n,i,r,o){if(e.onBeforeRender(m,t,n,i,r,o),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject){const i=Se(n,t,r,e);U.setMaterial(r),se.reset(),(function a(e,t){e.render((function(e){m.renderBufferImmediate(e,t)}))})(e,i)}else m.renderBufferDirect(n,t,i,r,e,o);e.onAfterRender(m,t,n,i,r,o)}function we(e,t,n){!0!==t.isScene&&(t=$);const i=j.get(e),r=d.state.lights,o=r.state.version,a=Z.getParameters(e,r.state,d.state.shadowsArray,t,n),s=Z.getProgramCacheKey(a);let l=i.program,c=!0;if(i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=q.get(e.envMap||i.environment),void 0===l)e.addEventListener("dispose",fe);else if(l.cacheKey!==s)ge(e);else if(i.lightsStateVersion!==o)c=!1;else{if(void 0!==a.shaderID)return;c=!1}c&&(a.uniforms=Z.getUniforms(e),e.onBeforeCompile(a,m),l=Z.acquireProgram(a,s),i.program=l,i.uniforms=a.uniforms,i.outputEncoding=a.outputEncoding);const h=i.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=te.numPlanes,i.numIntersection=te.numIntersection,h.clippingPlanes=te.uniform),i.needsLights=(function u(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights})(e),i.lightsStateVersion=o,i.needsLights&&(h.ambientLightColor.value=r.state.ambient,h.lightProbe.value=r.state.probe,h.directionalLights.value=r.state.directional,h.directionalLightShadows.value=r.state.directionalShadow,h.spotLights.value=r.state.spot,h.spotLightShadows.value=r.state.spotShadow,h.rectAreaLights.value=r.state.rectArea,h.ltc_1.value=r.state.rectAreaLTC1,h.ltc_2.value=r.state.rectAreaLTC2,h.pointLights.value=r.state.point,h.pointLightShadows.value=r.state.pointShadow,h.hemisphereLights.value=r.state.hemi,h.directionalShadowMap.value=r.state.directionalShadowMap,h.directionalShadowMatrix.value=r.state.directionalShadowMatrix,h.spotShadowMap.value=r.state.spotShadowMap,h.spotShadowMatrix.value=r.state.spotShadowMatrix,h.pointShadowMap.value=r.state.pointShadowMap,h.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=i.program.getUniforms(),f=WebGLUniforms.seqWithValue(p.seq,h);i.uniformsList=f}function Se(e,t,n,i){!0!==t.isScene&&(t=$),W.resetTextureUnits();const r=t.fog,o=n.isMeshStandardMaterial?t.environment:null,a=null===b?m.outputEncoding:b.texture.encoding,s=q.get(n.envMap||o),l=j.get(n),c=d.state.lights;!0!==D||!0!==O&&e===w||te.setState(n,e,e===w&&n.id===x),n.version===l.__version?n.fog&&l.fog!==r||l.environment!==o||l.needsLights&&l.lightsStateVersion!==c.state.version?we(n,t,i):void 0===l.numClippingPlanes||l.numClippingPlanes===te.numPlanes&&l.numIntersection===te.numIntersection?(l.outputEncoding!==a||l.envMap!==s)&&we(n,t,i):we(n,t,i):(we(n,t,i),l.__version=n.version);let h=!1,u=!1,p=!1;const f=l.program,g=f.getUniforms(),v=l.uniforms;if(U.useProgram(f.program)&&(h=!0,u=!0,p=!0),n.id!==x&&(x=n.id,u=!0),h||w!==e){if(g.setValue(le,"projectionMatrix",e.projectionMatrix),H.logarithmicDepthBuffer&&g.setValue(le,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),w!==e&&(w=e,u=!0,p=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){const t=g.map.cameraPosition;void 0!==t&&t.setValue(le,F.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&g.setValue(le,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||n.skinning)&&g.setValue(le,"viewMatrix",e.matrixWorldInverse)}if(n.skinning){g.setOptional(le,i,"bindMatrix"),g.setOptional(le,i,"bindMatrixInverse");const e=i.skeleton;if(e){const t=e.bones;if(H.floatVertexTextures){if(null===e.boneTexture){let n=Math.sqrt(4*t.length);n=MathUtils.ceilPowerOfTwo(n),n=Math.max(n,4);const i=new Float32Array(n*n*4);i.set(e.boneMatrices);const r=new DataTexture(i,n,n,RGBAFormat,FloatType);e.boneMatrices=i,e.boneTexture=r,e.boneTextureSize=n}g.setValue(le,"boneTexture",e.boneTexture,W),g.setValue(le,"boneTextureSize",e.boneTextureSize)}else g.setOptional(le,e,"boneMatrices")}}return(u||l.receiveShadow!==i.receiveShadow)&&(l.receiveShadow=i.receiveShadow,g.setValue(le,"receiveShadow",i.receiveShadow)),u&&(g.setValue(le,"toneMappingExposure",m.toneMappingExposure),l.needsLights&&(function y(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t})(v,p),r&&n.fog&&J.refreshFogUniforms(v,r),J.refreshMaterialUniforms(v,n,I,T),WebGLUniforms.upload(le,l.uniformsList,v,W)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(WebGLUniforms.upload(le,l.uniformsList,v,W),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&g.setValue(le,"center",i.center),g.setValue(le,"modelViewMatrix",i.modelViewMatrix),g.setValue(le,"normalMatrix",i.normalMatrix),g.setValue(le,"modelMatrix",i.matrixWorld),f}ye.setAnimationLoop((function Ce(e){ue.isPresenting||ve&&ve(e)})),"undefined"!=typeof window&&ye.setContext(window),this.setAnimationLoop=function(e){ve=e,ue.setAnimationLoop(e),null===e?ye.stop():ye.start()},this.render=function(e,t){let n,i;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),i=arguments[3]),void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===f)return;se.resetDefaultState(),x=-1,w=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===ue.enabled&&!0===ue.isPresenting&&(t=ue.getCamera(t)),!0===e.isScene&&e.onBeforeRender(m,e,t,n||b),d=ee.get(e,p.length),d.init(),p.push(d),z.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),N.setFromProjectionMatrix(z),O=this.localClippingEnabled,D=te.init(this.clippingPlanes,O,t),u=Q.get(e,t),u.init(),be(e,t,0,m.sortObjects),u.finish(),!0===m.sortObjects&&u.sort(A,k),!0===D&&te.beginShadows();const r=d.state.shadowsArray;de.render(r,e,t),d.setupLights(),d.setupLightsView(t),!0===D&&te.endShadows(),!0===this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),ne.render(u,e,t,i);const o=u.opaque,a=u.transparent;o.length>0&&_e(o,e,t),a.length>0&&_e(a,e,t),!0===e.isScene&&e.onAfterRender(m,e,t),null!==b&&(W.updateRenderTargetMipmap(b),W.updateMultisampleRenderTarget(b)),U.buffers.depth.setTest(!0),U.buffers.depth.setMask(!0),U.buffers.color.setMask(!0),U.setPolygonOffset(!1),p.pop(),d=p.length>0?p[p.length-1]:null,u=null},this.setFramebuffer=function(e){g!==e&&null===b&&le.bindFramebuffer(36160,e),g=e},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderList=function(){return u},this.setRenderList=function(e){u=e},this.getRenderTarget=function(){return b},this.setRenderTarget=function(e,t=0,n=0){b=e,v=t,y=n,e&&void 0===j.get(e).__webglFramebuffer&&W.setupRenderTarget(e);let i=g,r=!1;if(e){const n=j.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=n[t],r=!0):i=e.isWebGLMultisampleRenderTarget?j.get(e).__webglMultisampledFramebuffer:n,S.copy(e.viewport),C.copy(e.scissor),M=e.scissorTest}else S.copy(P).multiplyScalar(I).floor(),C.copy(R).multiplyScalar(I).floor(),M=L;if(_!==i&&(le.bindFramebuffer(36160,i),_=i),U.viewport(S),U.scissor(C),U.setScissorTest(M),r){const i=j.get(e.texture);le.framebufferTexture2D(36160,36064,34069+t,i.__webglTexture,n)}},this.readRenderTargetPixels=function(e,t,n,i,r,o,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=j.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){let a=!1;s!==_&&(le.bindFramebuffer(36160,s),a=!0);try{const s=e.texture,l=s.format,c=s.type;if(l!==RGBAFormat&&ae.convert(l)!==le.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const h=c===HalfFloatType&&(V.has("EXT_color_buffer_half_float")||H.isWebGL2&&V.has("EXT_color_buffer_float"));if(!(c===UnsignedByteType||ae.convert(c)===le.getParameter(35738)||c===FloatType&&(H.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float"))||h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===le.checkFramebufferStatus(36160)?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&le.readPixels(t,n,i,r,ae.convert(l),ae.convert(c),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{a&&le.bindFramebuffer(36160,_)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),o=Math.floor(t.image.height*i),a=ae.convert(t.format);W.setTexture2D(t,0),le.copyTexImage2D(3553,n,a,e.x,e.y,r,o,0),U.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,o=t.image.height,a=ae.convert(n.format),s=ae.convert(n.type);W.setTexture2D(n,0),le.pixelStorei(37440,n.flipY),le.pixelStorei(37441,n.premultiplyAlpha),le.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?le.texSubImage2D(3553,i,e.x,e.y,r,o,a,s,t.image.data):t.isCompressedTexture?le.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):le.texSubImage2D(3553,i,e.x,e.y,a,s,t.image),0===i&&n.generateMipmaps&&le.generateMipmap(3553),U.unbindTexture()},this.initTexture=function(e){W.setTexture2D(e,0),U.unbindTexture()},this.resetState=function(){U.reset(),se.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function WebGL1Renderer(e){WebGLRenderer.call(this,e)}ArrayCamera.prototype=Object.assign(Object.create(PerspectiveCamera.prototype),{constructor:ArrayCamera,isArrayCamera:!0}),Group.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:Group,isGroup:!0}),Object.assign(WebXRController.prototype,{constructor:WebXRController,getHandSpace:function(){return null===this._hand&&(this._hand=new Group,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this},disconnect:function(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this},update:function(e,t,n){let i=null,r=null,o=null;const a=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(l&&e.hand){o=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,n);if(void 0===l.joints[i.jointName]){const e=new Group;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[i.jointName]=e,l.add(e)}const r=l.joints[i.jointName];null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=e.radius),r.visible=null!==e}const i=l.joints["index-finger-tip"].position.distanceTo(l.joints["thumb-tip"].position),r=.02,a=.005;l.inputState.pinching&&i>r+a?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&i<=r-a&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==a&&(i=t.getPose(e.targetRaySpace,n),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale))),null!==s&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale)));return null!==a&&(a.visible=null!==i),null!==s&&(s.visible=null!==r),null!==l&&(l.visible=null!==o),this}}),Object.assign(WebXRManager.prototype,EventDispatcher.prototype),WebGL1Renderer.prototype=Object.assign(Object.create(WebGLRenderer.prototype),{constructor:WebGL1Renderer,isWebGL1Renderer:!0});class Fog{constructor(e,t,n){Object.defineProperty(this,"isFog",{value:!0}),this.name="",this.color=new Color(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}clone(){return new Fog(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Scene extends Object3D{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.background&&(t.object.background=this.background.toJSON(e)),null!==this.environment&&(t.object.environment=this.environment.toJSON(e)),null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}function InterleavedBuffer(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=StaticDrawUsage,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=MathUtils.generateUUID()}Object.defineProperty(InterleavedBuffer.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(InterleavedBuffer.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this},set:function(e,t=0){return this.array.set(e,t),this},clone:function(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=MathUtils.generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new InterleavedBuffer(new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),this.stride);return t.setUsage(this.usage),t},onUpload:function(e){return this.onUploadCallback=e,this},toJSON:function(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=MathUtils.generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});const _vector$6=new Vector3;function InterleavedBufferAttribute(e,t,n,i){this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===i}function SpriteMaterial(e){Material.call(this),this.type="SpriteMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}let _geometry;Object.defineProperties(InterleavedBufferAttribute.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(e){this.data.needsUpdate=e}}}),Object.assign(InterleavedBufferAttribute.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(e){for(let t=0,n=this.data.count;t<n;t++)_vector$6.x=this.getX(t),_vector$6.y=this.getY(t),_vector$6.z=this.getZ(t),_vector$6.applyMatrix4(e),this.setXYZ(t,_vector$6.x,_vector$6.y,_vector$6.z);return this},setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,n){return this.data.array[(e=e*this.data.stride+this.offset)+0]=t,this.data.array[e+1]=n,this},setXYZ:function(e,t,n,i){return this.data.array[(e=e*this.data.stride+this.offset)+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this},setXYZW:function(e,t,n,i,r){return this.data.array[(e=e*this.data.stride+this.offset)+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this},clone:function(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new BufferAttribute(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new InterleavedBufferAttribute(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}),SpriteMaterial.prototype=Object.create(Material.prototype),SpriteMaterial.prototype.constructor=SpriteMaterial,SpriteMaterial.prototype.isSpriteMaterial=!0,SpriteMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this};const _intersectPoint=new Vector3,_worldScale=new Vector3,_mvPosition=new Vector3,_alignedPosition=new Vector2,_rotatedPosition=new Vector2,_viewWorldMatrix=new Matrix4,_vA$1=new Vector3,_vB$1=new Vector3,_vC$1=new Vector3,_uvA$1=new Vector2,_uvB$1=new Vector2,_uvC$1=new Vector2;function Sprite(e){if(Object3D.call(this),this.type="Sprite",void 0===_geometry){_geometry=new BufferGeometry;const e=new InterleavedBuffer(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);_geometry.setIndex([0,1,2,0,2,3]),_geometry.setAttribute("position",new InterleavedBufferAttribute(e,3,0,!1)),_geometry.setAttribute("uv",new InterleavedBufferAttribute(e,2,3,!1))}this.geometry=_geometry,this.material=void 0!==e?e:new SpriteMaterial,this.center=new Vector2(.5,.5)}function transformVertex(e,t,n,i,r,o){_alignedPosition.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(_rotatedPosition.x=o*_alignedPosition.x-r*_alignedPosition.y,_rotatedPosition.y=r*_alignedPosition.x+o*_alignedPosition.y):_rotatedPosition.copy(_alignedPosition),e.copy(t),e.x+=_rotatedPosition.x,e.y+=_rotatedPosition.y,e.applyMatrix4(_viewWorldMatrix)}Sprite.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:Sprite,isSprite:!0,raycast:function(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),_worldScale.setFromMatrixScale(this.matrixWorld),_viewWorldMatrix.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),_mvPosition.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&_worldScale.multiplyScalar(-_mvPosition.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const o=this.center;transformVertex(_vA$1.set(-.5,-.5,0),_mvPosition,o,_worldScale,i,r),transformVertex(_vB$1.set(.5,-.5,0),_mvPosition,o,_worldScale,i,r),transformVertex(_vC$1.set(.5,.5,0),_mvPosition,o,_worldScale,i,r),_uvA$1.set(0,0),_uvB$1.set(1,0),_uvC$1.set(1,1);let a=e.ray.intersectTriangle(_vA$1,_vB$1,_vC$1,!1,_intersectPoint);if(null===a&&(transformVertex(_vB$1.set(-.5,.5,0),_mvPosition,o,_worldScale,i,r),_uvB$1.set(0,1),a=e.ray.intersectTriangle(_vA$1,_vC$1,_vB$1,!1,_intersectPoint),null===a))return;const s=e.ray.origin.distanceTo(_intersectPoint);s<e.near||s>e.far||t.push({distance:s,point:_intersectPoint.clone(),uv:Triangle.getUV(_intersectPoint,_vA$1,_vB$1,_vC$1,_uvA$1,_uvB$1,_uvC$1,new Vector2),face:null,object:this})},copy:function(e){return Object3D.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}});const _v1$4=new Vector3,_v2$2=new Vector3;function LOD(){Object3D.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}LOD.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:LOD,isLOD:!0,copy:function(e){Object3D.prototype.copy.call(this,e,!1);const t=e.levels;for(let e=0,n=t.length;e<n;e++){const n=t[e];this.addLevel(n.object.clone(),n.distance)}return this.autoUpdate=e.autoUpdate,this},addLevel:function(e,t=0){t=Math.abs(t);const n=this.levels;let i;for(i=0;i<n.length&&!(t<n[i].distance);i++);return n.splice(i,0,{distance:t,object:e}),this.add(e),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i&&!(e<t[n].distance);n++);return t[n-1].object}return null},raycast:function(e,t){if(this.levels.length>0){_v1$4.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(_v1$4);this.getObjectForDistance(n).raycast(e,t)}},update:function(e){const t=this.levels;if(t.length>1){_v1$4.setFromMatrixPosition(e.matrixWorld),_v2$2.setFromMatrixPosition(this.matrixWorld);const n=_v1$4.distanceTo(_v2$2)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i<r&&n>=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;i<r;i++)t[i].object.visible=!1}},toJSON:function(e){const t=Object3D.prototype.toJSON.call(this,e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let e=0,i=n.length;e<i;e++){const i=n[e];t.object.levels.push({object:i.object.uuid,distance:i.distance})}return t}});const _basePosition=new Vector3,_skinIndex=new Vector4,_skinWeight=new Vector4,_vector$7=new Vector3,_matrix$1=new Matrix4;function SkinnedMesh(e,t){e&&e.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Mesh.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Matrix4,this.bindMatrixInverse=new Matrix4}function Bone(){Object3D.call(this),this.type="Bone"}SkinnedMesh.prototype=Object.assign(Object.create(Mesh.prototype),{constructor:SkinnedMesh,isSkinnedMesh:!0,copy:function(e){return Mesh.prototype.copy.call(this,e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this},bind:function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){const e=new Vector4,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.x=t.getX(n),e.y=t.getY(n),e.z=t.getZ(n),e.w=t.getW(n);const i=1/e.manhattanLength();i!==1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}},updateMatrixWorld:function(e){Mesh.prototype.updateMatrixWorld.call(this,e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(e,t){const n=this.skeleton,i=this.geometry;_skinIndex.fromBufferAttribute(i.attributes.skinIndex,e),_skinWeight.fromBufferAttribute(i.attributes.skinWeight,e),_basePosition.fromBufferAttribute(i.attributes.position,e).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const i=_skinWeight.getComponent(e);if(0!==i){const r=_skinIndex.getComponent(e);_matrix$1.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),t.addScaledVector(_vector$7.copy(_basePosition).applyMatrix4(_matrix$1),i)}}return t.applyMatrix4(this.bindMatrixInverse)}}),Bone.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:Bone,isBone:!0});const _offsetMatrix=new Matrix4,_identityMatrix=new Matrix4;function Skeleton(e=[],t=[]){this.uuid=MathUtils.generateUUID(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}Object.assign(Skeleton.prototype,{init:function(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Matrix4)}},calculateInverses:function(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new Matrix4;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}},pose:function(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}},update:function(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,r=e.length;i<r;i++)_offsetMatrix.multiplyMatrices(e[i]?e[i].matrixWorld:_identityMatrix,t[i]),_offsetMatrix.toArray(n,16*i);null!==i&&(i.needsUpdate=!0)},clone:function(){return new Skeleton(this.bones,this.boneInverses)},getBoneByName:function(e){for(let t=0,n=this.bones.length;t<n;t++){const n=this.bones[t];if(n.name===e)return n}},dispose:function(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)},fromJSON:function(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const i=e.bones[n];let r=t[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new Bone),this.bones.push(r),this.boneInverses.push((new Matrix4).fromArray(e.boneInverses[n]))}return this.init(),this},toJSON:function(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++)e.bones.push(t[i].uuid),e.boneInverses.push(n[i].toArray());return e}});const _instanceLocalMatrix=new Matrix4,_instanceWorldMatrix=new Matrix4,_instanceIntersects=[],_mesh=new Mesh;function InstancedMesh(e,t,n){Mesh.call(this,e,t),this.instanceMatrix=new BufferAttribute(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}function LineBasicMaterial(e){Material.call(this),this.type="LineBasicMaterial",this.color=new Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(e)}InstancedMesh.prototype=Object.assign(Object.create(Mesh.prototype),{constructor:InstancedMesh,isInstancedMesh:!0,copy:function(e){return Mesh.prototype.copy.call(this,e),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this},getColorAt:function(e,t){t.fromArray(this.instanceColor.array,3*e)},getMatrixAt:function(e,t){t.fromArray(this.instanceMatrix.array,16*e)},raycast:function(e,t){const n=this.matrixWorld,i=this.count;if(_mesh.geometry=this.geometry,_mesh.material=this.material,void 0!==_mesh.material)for(let r=0;r<i;r++){this.getMatrixAt(r,_instanceLocalMatrix),_instanceWorldMatrix.multiplyMatrices(n,_instanceLocalMatrix),_mesh.matrixWorld=_instanceWorldMatrix,_mesh.raycast(e,_instanceIntersects);for(let e=0,n=_instanceIntersects.length;e<n;e++){const n=_instanceIntersects[e];n.instanceId=r,n.object=this,t.push(n)}_instanceIntersects.length=0}},setColorAt:function(e,t){null===this.instanceColor&&(this.instanceColor=new BufferAttribute(new Float32Array(3*this.count),3)),t.toArray(this.instanceColor.array,3*e)},setMatrixAt:function(e,t){t.toArray(this.instanceMatrix.array,16*e)},updateMorphTargets:function(){},dispose:function(){this.dispatchEvent({type:"dispose"})}}),LineBasicMaterial.prototype=Object.create(Material.prototype),LineBasicMaterial.prototype.constructor=LineBasicMaterial,LineBasicMaterial.prototype.isLineBasicMaterial=!0,LineBasicMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.morphTargets=e.morphTargets,this};const _start=new Vector3,_end=new Vector3,_inverseMatrix$1=new Matrix4,_ray$1=new Ray,_sphere$2=new Sphere;function Line(e=new BufferGeometry,t=new LineBasicMaterial){Object3D.call(this),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}Line.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:Line,isLine:!0,copy:function(e){return Object3D.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,i=t.count;e<i;e++)_start.fromBufferAttribute(t,e-1),_end.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=_start.distanceTo(_end);e.setAttribute("lineDistance",new Float32BufferAttribute(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this},raycast:function(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold;if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere$2.copy(n.boundingSphere),_sphere$2.applyMatrix4(i),_sphere$2.radius+=r,!1===e.ray.intersectsSphere(_sphere$2))return;_inverseMatrix$1.copy(i).invert(),_ray$1.copy(e.ray).applyMatrix4(_inverseMatrix$1);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,s=new Vector3,l=new Vector3,c=new Vector3,h=new Vector3,u=this.isLineSegments?2:1;if(n.isBufferGeometry){const i=n.index,r=n.attributes.position;if(null!==i){const n=i.array;for(let i=0,o=n.length-1;i<o;i+=u){const o=n[i+1];if(s.fromBufferAttribute(r,n[i]),l.fromBufferAttribute(r,o),_ray$1.distanceSqToSegment(s,l,h,c)>a)continue;h.applyMatrix4(this.matrixWorld);const u=e.ray.origin.distanceTo(h);u<e.near||u>e.far||t.push({distance:u,point:c.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else for(let n=0,i=r.count-1;n<i;n+=u){if(s.fromBufferAttribute(r,n),l.fromBufferAttribute(r,n+1),_ray$1.distanceSqToSegment(s,l,h,c)>a)continue;h.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(h);i<e.near||i>e.far||t.push({distance:i,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){const n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const _start$1=new Vector3,_end$1=new Vector3;function LineSegments(e,t){Line.call(this,e,t),this.type="LineSegments"}function LineLoop(e,t){Line.call(this,e,t),this.type="LineLoop"}function PointsMaterial(e){Material.call(this),this.type="PointsMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}LineSegments.prototype=Object.assign(Object.create(Line.prototype),{constructor:LineSegments,isLineSegments:!0,computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e<i;e+=2)_start$1.fromBufferAttribute(t,e),_end$1.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+_start$1.distanceTo(_end$1);e.setAttribute("lineDistance",new Float32BufferAttribute(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}),LineLoop.prototype=Object.assign(Object.create(Line.prototype),{constructor:LineLoop,isLineLoop:!0}),PointsMaterial.prototype=Object.create(Material.prototype),PointsMaterial.prototype.constructor=PointsMaterial,PointsMaterial.prototype.isPointsMaterial=!0,PointsMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this};const _inverseMatrix$2=new Matrix4,_ray$2=new Ray,_sphere$3=new Sphere,_position$1=new Vector3;function Points(e=new BufferGeometry,t=new PointsMaterial){Object3D.call(this),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}function testPoint(e,t,n,i,r,o,a){const s=_ray$2.distanceSqToPoint(e);if(s<n){const n=new Vector3;_ray$2.closestPointToPoint(e,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;o.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}function VideoTexture(e,t,n,i,r,o,a,s,l){Texture.call(this,e,t,n,i,r,o,a,s,l),this.format=void 0!==a?a:RGBFormat,this.minFilter=void 0!==o?o:LinearFilter,this.magFilter=void 0!==r?r:LinearFilter,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}function CompressedTexture(e,t,n,i,r,o,a,s,l,c,h,u){Texture.call(this,null,o,a,s,l,c,i,r,h,u),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function CanvasTexture(e,t,n,i,r,o,a,s,l){Texture.call(this,e,t,n,i,r,o,a,s,l),this.needsUpdate=!0}function DepthTexture(e,t,n,i,r,o,a,s,l,c){if((c=void 0!==c?c:DepthFormat)!==DepthFormat&&c!==DepthStencilFormat)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===DepthFormat&&(n=UnsignedShortType),void 0===n&&c===DepthStencilFormat&&(n=UnsignedInt248Type),Texture.call(this,null,i,r,o,a,s,c,n,l),this.image={width:e,height:t},this.magFilter=void 0!==a?a:NearestFilter,this.minFilter=void 0!==s?s:NearestFilter,this.flipY=!1,this.generateMipmaps=!1}Points.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:Points,isPoints:!0,copy:function(e){return Object3D.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},raycast:function(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold;if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere$3.copy(n.boundingSphere),_sphere$3.applyMatrix4(i),_sphere$3.radius+=r,!1===e.ray.intersectsSphere(_sphere$3))return;_inverseMatrix$2.copy(i).invert(),_ray$2.copy(e.ray).applyMatrix4(_inverseMatrix$2);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position;if(null!==r){const n=r.array;for(let r=0,s=n.length;r<s;r++){const s=n[r];_position$1.fromBufferAttribute(o,s),testPoint(_position$1,s,a,i,e,t,this)}}else for(let n=0,r=o.count;n<r;n++)_position$1.fromBufferAttribute(o,n),testPoint(_position$1,n,a,i,e,t,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){const n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}),VideoTexture.prototype=Object.assign(Object.create(Texture.prototype),{constructor:VideoTexture,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){const e=this.image;0=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),CompressedTexture.prototype=Object.create(Texture.prototype),CompressedTexture.prototype.constructor=CompressedTexture,CompressedTexture.prototype.isCompressedTexture=!0,CanvasTexture.prototype=Object.create(Texture.prototype),CanvasTexture.prototype.constructor=CanvasTexture,CanvasTexture.prototype.isCanvasTexture=!0,DepthTexture.prototype=Object.create(Texture.prototype),DepthTexture.prototype.constructor=DepthTexture,DepthTexture.prototype.isDepthTexture=!0,new Vector3,new Vector3,new Vector3,new Triangle;const Earcut={triangulate:function(e,t,n){n=n||2;const i=t&&t.length,r=i?t[0]*n:e.length;let o=linkedList(e,0,r,n,!0);const a=[];if(!o||o.next===o.prev)return a;let s,l,c,h,u,d,p;if(i&&(o=eliminateHoles(e,t,o,n)),e.length>80*n){s=c=e[0],l=h=e[1];for(let t=n;t<r;t+=n)u=e[t],d=e[t+1],u<s&&(s=u),d<l&&(l=d),u>c&&(c=u),d>h&&(h=d);p=Math.max(c-s,h-l),p=0!==p?1/p:0}return earcutLinked(o,a,n,s,l,p),a}};function linkedList(e,t,n,i,r){let o,a;if(r===signedArea(e,t,n,i)>0)for(o=t;o<n;o+=i)a=insertNode(o,e[o],e[o+1],a);else for(o=n-i;o>=t;o-=i)a=insertNode(o,e[o],e[o+1],a);return a&&equals(a,a.next)&&(removeNode(a),a=a.next),a}function filterPoints(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!equals(i,i.next)&&0!==area(i.prev,i,i.next))i=i.next;else{if(removeNode(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function earcutLinked(e,t,n,i,r,o,a){if(!e)return;!a&&o&&indexCurve(e,i,r,o);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,o?isEarHashed(e,i,r,o):isEar(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),removeNode(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?earcutLinked(e=cureLocalIntersections(filterPoints(e),t,n),t,n,i,r,o,2):2===a&&splitEarcut(e,t,n,i,r,o):earcutLinked(filterPoints(e),t,n,i,r,o,1);break}}function isEar(e){const t=e.prev,n=e,i=e.next;if(area(t,n,i)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(pointInTriangle(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&area(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function isEarHashed(e,t,n,i){const r=e.prev,o=e,a=e.next;if(area(r,o,a)>=0)return!1;const s=r.x>o.x?r.x>a.x?r.x:a.x:o.x>a.x?o.x:a.x,l=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,c=zOrder(r.x<o.x?r.x<a.x?r.x:a.x:o.x<a.x?o.x:a.x,r.y<o.y?r.y<a.y?r.y:a.y:o.y<a.y?o.y:a.y,t,n,i),h=zOrder(s,l,t,n,i);let u=e.prevZ,d=e.nextZ;for(;u&&u.z>=c&&d&&d.z<=h;){if(u!==e.prev&&u!==e.next&&pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,u.x,u.y)&&area(u.prev,u,u.next)>=0)return!1;if(u=u.prevZ,d!==e.prev&&d!==e.next&&pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;u&&u.z>=c;){if(u!==e.prev&&u!==e.next&&pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,u.x,u.y)&&area(u.prev,u,u.next)>=0)return!1;u=u.prevZ}for(;d&&d.z<=h;){if(d!==e.prev&&d!==e.next&&pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function cureLocalIntersections(e,t,n){let i=e;do{const r=i.prev,o=i.next.next;!equals(r,o)&&intersects(r,i,i.next,o)&&locallyInside(r,o)&&locallyInside(o,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(o.i/n),removeNode(i),removeNode(i.next),i=e=o),i=i.next}while(i!==e);return filterPoints(i)}function splitEarcut(e,t,n,i,r,o){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&isValidDiagonal(a,e)){let s=splitPolygon(a,e);return a=filterPoints(a,a.next),s=filterPoints(s,s.next),earcutLinked(a,t,n,i,r,o),void earcutLinked(s,t,n,i,r,o)}e=e.next}a=a.next}while(a!==e)}function eliminateHoles(e,t,n,i){const r=[];let o,a,s,l,c;for(o=0,a=t.length;o<a;o++)s=t[o]*i,l=o<a-1?t[o+1]*i:e.length,c=linkedList(e,s,l,i,!1),c===c.next&&(c.steiner=!0),r.push(getLeftmost(c));for(r.sort(compareX),o=0;o<r.length;o++)eliminateHole(r[o],n),n=filterPoints(n,n.next);return n}function compareX(e,t){return e.x-t.x}function eliminateHole(e,t){if(t=findHoleBridge(e,t)){const n=splitPolygon(t,e);filterPoints(t,t.next),filterPoints(n,n.next)}}function findHoleBridge(e,t){let n=t;const i=e.x,r=e.y;let o,a=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>a){if(a=e,e===i){if(r===n.y)return n;if(r===n.next.y)return n.next}o=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!o)return null;if(i===a)return o;const s=o,l=o.x,c=o.y;let h,u=1/0;n=o;do{i>=n.x&&n.x>=l&&i!==n.x&&pointInTriangle(r<c?i:a,r,l,c,r<c?a:i,r,n.x,n.y)&&(h=Math.abs(r-n.y)/(i-n.x),locallyInside(n,e)&&(h<u||h===u&&(n.x>o.x||n.x===o.x&§orContainsSector(o,n)))&&(o=n,u=h)),n=n.next}while(n!==s);return o}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function indexCurve(e,t,n,i){let r=e;do{null===r.z&&(r.z=zOrder(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(e){let t,n,i,r,o,a,s,l,c=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,i=n,s=0,t=0;t<c&&(s++,i=i.nextZ,i);t++);for(l=c;s>0||l>0&&i;)0!==s&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(a>1);return e}function zOrder(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function getLeftmost(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function pointInTriangle(e,t,n,i,r,o,a,s){return(r-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(i-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(r-a)*(i-s)>=0}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!intersectsPolygon(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&middleInside(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,i){const r=sign(area(e,t,n)),o=sign(area(e,t,i)),a=sign(area(n,i,e)),s=sign(area(n,i,t));return r!==o&&a!==s||!(0!==r||!onSegment(e,n,t))||!(0!==o||!onSegment(e,i,t))||!(0!==a||!onSegment(n,e,i))||!(0!==s||!onSegment(n,t,i))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function middleInside(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function splitPolygon(e,t){const n=new Node$1(e.i,e.x,e.y),i=new Node$1(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function insertNode(e,t,n,i){const r=new Node$1(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Node$1(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(e,t,n,i){let r=0;for(let o=t,a=n-i;o<n;o+=i)r+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return r}const ShapeUtils={area:function(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return.5*n},isClockWise:function(e){return ShapeUtils.area(e)<0},triangulateShape:function(e,t){const n=[],i=[],r=[];removeDupEndPts(e),addContour(n,e);let o=e.length;t.forEach(removeDupEndPts);for(let e=0;e<t.length;e++)i.push(o),o+=t[e].length,addContour(n,t[e]);const a=Earcut.triangulate(n,i);for(let e=0;e<a.length;e+=3)r.push(a.slice(e,e+3));return r}};function removeDupEndPts(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function addContour(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class ExtrudeGeometry extends BufferGeometry{constructor(e,t){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let t=0,n=e.length;t<n;t++)o(e[t]);function o(e){const o=[],a=void 0!==t.curveSegments?t.curveSegments:12,s=void 0!==t.steps?t.steps:1;let l=void 0!==t.depth?t.depth:100,c=void 0===t.bevelEnabled||t.bevelEnabled,h=void 0!==t.bevelThickness?t.bevelThickness:6,u=void 0!==t.bevelSize?t.bevelSize:h-2,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const m=t.extrudePath,f=void 0!==t.UVGenerator?t.UVGenerator:WorldUVGenerator;void 0!==t.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),l=t.amount);let g,v,y,b,_,x=!1;m&&(g=m.getSpacedPoints(s),x=!0,c=!1,v=m.computeFrenetFrames(s,!1),y=new Vector3,b=new Vector3,_=new Vector3),c||(p=0,h=0,u=0,d=0);const w=e.extractPoints(a);let S=w.shape;const C=w.holes;if(!ShapeUtils.isClockWise(S)){S=S.reverse();for(let e=0,t=C.length;e<t;e++){const t=C[e];ShapeUtils.isClockWise(t)&&(C[e]=t.reverse())}}const M=ShapeUtils.triangulateShape(S,C),E=S;for(let e=0,t=C.length;e<t;e++)S=S.concat(C[e]);function T(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}const I=S.length,A=M.length;function k(e,t,n){let i,r,o;const a=e.x-t.x,s=e.y-t.y,l=n.x-e.x,c=n.y-e.y,h=a*a+s*s;if(Math.abs(a*c-s*l)>Number.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=t.x-s/u,m=t.y+a/u,f=((n.x-c/d-p)*c-(n.y+l/d-m)*l)/(a*c-s*l);i=p+a*f-e.x,r=m+s*f-e.y;const g=i*i+r*r;if(g<=2)return new Vector2(i,r);o=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(i=-s,r=a,o=Math.sqrt(h)):(i=a,r=s,o=Math.sqrt(h/2))}return new Vector2(i/o,r/o)}const P=[];for(let e=0,t=E.length,n=t-1,i=e+1;e<t;e++,n++,i++)n===t&&(n=0),i===t&&(i=0),P[e]=k(E[e],E[n],E[i]);const R=[];let L,N=P.concat();for(let e=0,t=C.length;e<t;e++){const t=C[e];L=[];for(let e=0,n=t.length,i=n-1,r=e+1;e<n;e++,i++,r++)i===n&&(i=0),r===n&&(r=0),L[e]=k(t[e],t[i],t[r]);R.push(L),N=N.concat(L)}for(let e=0;e<p;e++){const t=e/p,n=h*Math.cos(t*Math.PI/2),i=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=E.length;e<t;e++){const t=T(E[e],P[e],i);z(t.x,t.y,-n)}for(let e=0,t=C.length;e<t;e++){const t=C[e];L=R[e];for(let e=0,r=t.length;e<r;e++){const r=T(t[e],L[e],i);z(r.x,r.y,-n)}}}const D=u+d;for(let e=0;e<I;e++){const t=c?T(S[e],N[e],D):S[e];x?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),_.copy(g[0]).add(b).add(y),z(_.x,_.y,_.z)):z(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<I;t++){const n=c?T(S[t],N[t],D):S[t];x?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),_.copy(g[e]).add(b).add(y),z(_.x,_.y,_.z)):z(n.x,n.y,l/s*e)}for(let e=p-1;e>=0;e--){const t=e/p,n=h*Math.cos(t*Math.PI/2),i=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=E.length;e<t;e++){const t=T(E[e],P[e],i);z(t.x,t.y,l+n)}for(let e=0,t=C.length;e<t;e++){const t=C[e];L=R[e];for(let e=0,r=t.length;e<r;e++){const r=T(t[e],L[e],i);x?z(r.x,r.y+g[s-1].y,g[s-1].x+n):z(r.x,r.y,l+n)}}}function O(e,t){let n=e.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=s+2*p;e<n;e++){const n=I*e,o=I*(e+1);$(t+i+n,t+r+n,t+r+o,t+i+o)}}}function z(e,t,n){o.push(e),o.push(t),o.push(n)}function F(e,t,r){B(e),B(t),B(r);const o=i.length/3,a=f.generateTopUV(n,i,o-3,o-2,o-1);V(a[0]),V(a[1]),V(a[2])}function $(e,t,r,o){B(e),B(t),B(o),B(t),B(r),B(o);const a=i.length/3,s=f.generateSideWallUV(n,i,a-6,a-3,a-2,a-1);V(s[0]),V(s[1]),V(s[3]),V(s[1]),V(s[2]),V(s[3])}function B(e){i.push(o[3*e+0]),i.push(o[3*e+1]),i.push(o[3*e+2])}function V(e){r.push(e.x),r.push(e.y)}!(function H(){const e=i.length/3;if(c){let e=0,t=I*e;for(let e=0;e<A;e++){const n=M[e];F(n[2]+t,n[1]+t,n[0]+t)}e=s+2*p,t=I*e;for(let e=0;e<A;e++){const n=M[e];F(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<A;e++){const t=M[e];F(t[2],t[1],t[0])}for(let e=0;e<A;e++){const t=M[e];F(t[0]+I*s,t[1]+I*s,t[2]+I*s)}}n.addGroup(e,i.length/3-e,0)})(),(function U(){const e=i.length/3;let t=0;O(E,t),t+=E.length;for(let e=0,n=C.length;e<n;e++){const n=C[e];O(n,t),t+=n.length}n.addGroup(e,i.length/3-e,1)})()}this.setAttribute("position",new Float32BufferAttribute(i,3)),this.setAttribute("uv",new Float32BufferAttribute(r,2)),this.computeVertexNormals()}toJSON(){const e=BufferGeometry.prototype.toJSON.call(this);return toJSON(this.parameters.shapes,this.parameters.options,e)}}const WorldUVGenerator={generateTopUV:function(e,t,n,i,r){const o=t[3*i],a=t[3*i+1],s=t[3*r],l=t[3*r+1];return[new Vector2(t[3*n],t[3*n+1]),new Vector2(o,a),new Vector2(s,l)]},generateSideWallUV:function(e,t,n,i,r,o){const a=t[3*n],s=t[3*n+1],l=t[3*n+2],c=t[3*i],h=t[3*i+1],u=t[3*i+2],d=t[3*r],p=t[3*r+1],m=t[3*r+2],f=t[3*o],g=t[3*o+1],v=t[3*o+2];return Math.abs(s-h)<.01?[new Vector2(a,1-l),new Vector2(c,1-u),new Vector2(d,1-m),new Vector2(f,1-v)]:[new Vector2(s,1-l),new Vector2(h,1-u),new Vector2(p,1-m),new Vector2(g,1-v)]}};function toJSON(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,i=e.length;t<i;t++)n.shapes.push(e[t].uuid);else n.shapes.push(e.uuid);return void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON()),n}function ParametricGeometry(e,t,n){BufferGeometry.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:n};const i=[],r=[],o=[],a=[],s=1e-5,l=new Vector3,c=new Vector3,h=new Vector3,u=new Vector3,d=new Vector3;e.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const p=t+1;for(let i=0;i<=n;i++){const p=i/n;for(let n=0;n<=t;n++){const i=n/t;e(i,p,c),r.push(c.x,c.y,c.z),i-s>=0?(e(i-s,p,h),u.subVectors(c,h)):(e(i+s,p,h),u.subVectors(h,c)),p-s>=0?(e(i,p-s,h),d.subVectors(c,h)):(e(i,p+s,h),d.subVectors(h,c)),l.crossVectors(u,d).normalize(),o.push(l.x,l.y,l.z),a.push(i,p)}}for(let e=0;e<n;e++)for(let n=0;n<t;n++){const t=e*p+n+1,r=(e+1)*p+n+1,o=(e+1)*p+n;i.push(e*p+n,t,o),i.push(t,r,o)}this.setIndex(i),this.setAttribute("position",new Float32BufferAttribute(r,3)),this.setAttribute("normal",new Float32BufferAttribute(o,3)),this.setAttribute("uv",new Float32BufferAttribute(a,2))}ParametricGeometry.prototype=Object.create(BufferGeometry.prototype),ParametricGeometry.prototype.constructor=ParametricGeometry;class ShapeGeometry extends BufferGeometry{constructor(e,t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],o=[];let a=0,s=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(a,s,t),a+=s,s=0;function l(e){const a=i.length/3,l=e.extractPoints(t);let c=l.shape;const h=l.holes;!1===ShapeUtils.isClockWise(c)&&(c=c.reverse());for(let e=0,t=h.length;e<t;e++){const t=h[e];!0===ShapeUtils.isClockWise(t)&&(h[e]=t.reverse())}const u=ShapeUtils.triangulateShape(c,h);for(let e=0,t=h.length;e<t;e++)c=c.concat(h[e]);for(let e=0,t=c.length;e<t;e++){const t=c[e];i.push(t.x,t.y,0),r.push(0,0,1),o.push(t.x,t.y)}for(let e=0,t=u.length;e<t;e++){const t=u[e];n.push(t[0]+a,t[1]+a,t[2]+a),s+=3}}this.setIndex(n),this.setAttribute("position",new Float32BufferAttribute(i,3)),this.setAttribute("normal",new Float32BufferAttribute(r,3)),this.setAttribute("uv",new Float32BufferAttribute(o,2))}toJSON(){const e=BufferGeometry.prototype.toJSON.call(this);return toJSON$1(this.parameters.shapes,e)}}function toJSON$1(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,i=e.length;n<i;n++)t.shapes.push(e[n].uuid);else t.shapes.push(e.uuid);return t}function ShadowMaterial(e){Material.call(this),this.type="ShadowMaterial",this.color=new Color(0),this.transparent=!0,this.setValues(e)}function RawShaderMaterial(e){ShaderMaterial.call(this,e),this.type="RawShaderMaterial"}function MeshStandardMaterial(e){Material.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Color(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(e)}function MeshPhysicalMaterial(e){MeshStandardMaterial.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Vector2(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(e){this.reflectivity=MathUtils.clamp(2.5*(e-1)/(e+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(e)}function MeshPhongMaterial(e){Material.call(this),this.type="MeshPhongMaterial",this.color=new Color(16777215),this.specular=new Color(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function MeshToonMaterial(e){Material.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Color(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function MeshNormalMaterial(e){Material.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function MeshLambertMaterial(e){Material.call(this),this.type="MeshLambertMaterial",this.color=new Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function MeshMatcapMaterial(e){Material.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Color(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function LineDashedMaterial(e){LineBasicMaterial.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}ShadowMaterial.prototype=Object.create(Material.prototype),ShadowMaterial.prototype.constructor=ShadowMaterial,ShadowMaterial.prototype.isShadowMaterial=!0,ShadowMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.color.copy(e.color),this},RawShaderMaterial.prototype=Object.create(ShaderMaterial.prototype),RawShaderMaterial.prototype.constructor=RawShaderMaterial,RawShaderMaterial.prototype.isRawShaderMaterial=!0,MeshStandardMaterial.prototype=Object.create(Material.prototype),MeshStandardMaterial.prototype.constructor=MeshStandardMaterial,MeshStandardMaterial.prototype.isMeshStandardMaterial=!0,MeshStandardMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.vertexTangents=e.vertexTangents,this},MeshPhysicalMaterial.prototype=Object.create(MeshStandardMaterial.prototype),MeshPhysicalMaterial.prototype.constructor=MeshPhysicalMaterial,MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial=!0,MeshPhysicalMaterial.prototype.copy=function(e){return MeshStandardMaterial.prototype.copy.call(this,e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.reflectivity=e.reflectivity,this.sheen=e.sheen?(this.sheen||new Color).copy(e.sheen):null,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this},MeshPhongMaterial.prototype=Object.create(Material.prototype),MeshPhongMaterial.prototype.constructor=MeshPhongMaterial,MeshPhongMaterial.prototype.isMeshPhongMaterial=!0,MeshPhongMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},MeshToonMaterial.prototype=Object.create(Material.prototype),MeshToonMaterial.prototype.constructor=MeshToonMaterial,MeshToonMaterial.prototype.isMeshToonMaterial=!0,MeshToonMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},MeshNormalMaterial.prototype=Object.create(Material.prototype),MeshNormalMaterial.prototype.constructor=MeshNormalMaterial,MeshNormalMaterial.prototype.isMeshNormalMaterial=!0,MeshNormalMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},MeshLambertMaterial.prototype=Object.create(Material.prototype),MeshLambertMaterial.prototype.constructor=MeshLambertMaterial,MeshLambertMaterial.prototype.isMeshLambertMaterial=!0,MeshLambertMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},MeshMatcapMaterial.prototype=Object.create(Material.prototype),MeshMatcapMaterial.prototype.constructor=MeshMatcapMaterial,MeshMatcapMaterial.prototype.isMeshMatcapMaterial=!0,MeshMatcapMaterial.prototype.copy=function(e){return Material.prototype.copy.call(this,e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},LineDashedMaterial.prototype=Object.create(LineBasicMaterial.prototype),LineDashedMaterial.prototype.constructor=LineDashedMaterial,LineDashedMaterial.prototype.isLineDashedMaterial=!0,LineDashedMaterial.prototype.copy=function(e){return LineBasicMaterial.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this};var Materials=Object.freeze({__proto__:null,ShadowMaterial:ShadowMaterial,SpriteMaterial:SpriteMaterial,RawShaderMaterial:RawShaderMaterial,ShaderMaterial:ShaderMaterial,PointsMaterial:PointsMaterial,MeshPhysicalMaterial:MeshPhysicalMaterial,MeshStandardMaterial:MeshStandardMaterial,MeshPhongMaterial:MeshPhongMaterial,MeshToonMaterial:MeshToonMaterial,MeshNormalMaterial:MeshNormalMaterial,MeshLambertMaterial:MeshLambertMaterial,MeshDepthMaterial:MeshDepthMaterial,MeshDistanceMaterial:MeshDistanceMaterial,MeshBasicMaterial:MeshBasicMaterial,MeshMatcapMaterial:MeshMatcapMaterial,LineDashedMaterial:LineDashedMaterial,LineBasicMaterial:LineBasicMaterial,Material:Material});const AnimationUtils={arraySlice:function(e,t,n){return AnimationUtils.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function i(t,n){return e[t]-e[n]})),n},sortedArray:function(e,t,n){const i=e.length,r=new e.constructor(i);for(let o=0,a=0;a!==i;++o){const i=n[o]*t;for(let n=0;n!==t;++n)r[a++]=e[i+n]}return r},flattenJSON:function(e,t,n,i){let r=1,o=e[0];for(;void 0!==o&&void 0===o[i];)o=e[r++];if(void 0===o)return;let a=o[i];if(void 0!==a)if(Array.isArray(a))do{a=o[i],void 0!==a&&(t.push(o.time),n.push.apply(n,a)),o=e[r++]}while(void 0!==o);else if(void 0!==a.toArray)do{a=o[i],void 0!==a&&(t.push(o.time),a.toArray(n,n.length)),o=e[r++]}while(void 0!==o);else do{a=o[i],void 0!==a&&(t.push(o.time),n.push(a)),o=e[r++]}while(void 0!==o)},subclip:function(e,t,n,i,r=30){const o=e.clone();o.name=t;const a=[];for(let e=0;e<o.tracks.length;++e){const t=o.tracks[e],s=t.getValueSize(),l=[],c=[];for(let e=0;e<t.times.length;++e){const o=t.times[e]*r;if(!(o<n||o>=i)){l.push(t.times[e]);for(let n=0;n<s;++n)c.push(t.values[e*s+n])}}0!==l.length&&(t.times=AnimationUtils.convertArray(l,t.times.constructor),t.values=AnimationUtils.convertArray(c,t.values.constructor),a.push(t))}o.tracks=a;let s=1/0;for(let e=0;e<o.tracks.length;++e)s>o.tracks[e].times[0]&&(s=o.tracks[e].times[0]);for(let e=0;e<o.tracks.length;++e)o.tracks[e].shift(-1*s);return o.resetDuration(),o},makeClipAdditive:function(e,t=0,n=e,i=30){i<=0&&(i=30);const r=n.tracks.length,o=t/i;for(let t=0;t<r;++t){const i=n.tracks[t],r=i.ValueTypeName;if("bool"===r||"string"===r)continue;const a=e.tracks.find((function(e){return e.name===i.name&&e.ValueTypeName===r}));if(void 0===a)continue;let s=0;const l=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=l/3);let c=0;const h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);const u=i.times.length-1;let d;if(o<=i.times[0])d=AnimationUtils.arraySlice(i.values,s,l-s);else if(o>=i.times[u]){const e=u*l+s;d=AnimationUtils.arraySlice(i.values,e,e+l-s)}else{const e=i.createInterpolant(),t=s,n=l-s;e.evaluate(o),d=AnimationUtils.arraySlice(e.resultBuffer,t,n)}"quaternion"===r&&(new Quaternion).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let e=0;e<p;++e){const t=e*h+c;if("quaternion"===r)Quaternion.multiplyQuaternionsFlat(a.values,t,d,0,a.values,t);else{const e=h-2*c;for(let n=0;n<e;++n)a.values[t+n]-=d[n]}}}return e.blendMode=AdditiveAnimationBlendMode,e}};function Interpolant(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n}function CubicInterpolant(e,t,n,i){Interpolant.call(this,e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function LinearInterpolant(e,t,n,i){Interpolant.call(this,e,t,n,i)}function DiscreteInterpolant(e,t,n,i){Interpolant.call(this,e,t,n,i)}function KeyframeTrack(e,t,n,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=AnimationUtils.convertArray(t,this.TimeBufferType),this.values=AnimationUtils.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}function BooleanKeyframeTrack(e,t,n){KeyframeTrack.call(this,e,t,n)}function ColorKeyframeTrack(e,t,n,i){KeyframeTrack.call(this,e,t,n,i)}function NumberKeyframeTrack(e,t,n,i){KeyframeTrack.call(this,e,t,n,i)}function QuaternionLinearInterpolant(e,t,n,i){Interpolant.call(this,e,t,n,i)}function QuaternionKeyframeTrack(e,t,n,i){KeyframeTrack.call(this,e,t,n,i)}function StringKeyframeTrack(e,t,n,i){KeyframeTrack.call(this,e,t,n,i)}function VectorKeyframeTrack(e,t,n,i){KeyframeTrack.call(this,e,t,n,i)}function AnimationClip(e,t=-1,n,i=NormalAnimationBlendMode){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=MathUtils.generateUUID(),this.duration<0&&this.resetDuration()}function getTrackTypeForValueTypeName(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return VectorKeyframeTrack;case"color":return ColorKeyframeTrack;case"quaternion":return QuaternionKeyframeTrack;case"bool":case"boolean":return BooleanKeyframeTrack;case"string":return StringKeyframeTrack}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function parseKeyframeTrack(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=getTrackTypeForValueTypeName(e.type);if(void 0===e.times){const t=[],n=[];AnimationUtils.flattenJSON(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}Object.assign(Interpolant.prototype,{evaluate:function(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let o=n+2;;){if(void 0===i){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,e,r)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}o=t.length;break n}if(e>=r)break e;{const a=t[1];e<a&&(n=2,r=a);for(let o=n-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,e,i);if(n===o)break;if(i=r,r=t[--n-1],e>=r)break t}o=n,n=0}}for(;n<o;){const i=n+o>>>1;e<t[i]?o=i:n=i+1}if(i=t[n],r=t[n-1],void 0===r)return this._cachedIndex=0,this.beforeStart_(0,e,i);if(void 0===i)return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,r,e)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let e=0;e!==i;++e)t[e]=n[r+e];return t},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Interpolant.prototype,{beforeStart_:Interpolant.prototype.copySampleValue_,afterEnd_:Interpolant.prototype.copySampleValue_}),CubicInterpolant.prototype=Object.assign(Object.create(Interpolant.prototype),{constructor:CubicInterpolant,DefaultSettings_:{endingStart:ZeroCurvatureEnding,endingEnd:ZeroCurvatureEnding},intervalChanged_:function(e,t,n){const i=this.parameterPositions;let r=e-2,o=e+1,a=i[r],s=i[o];if(void 0===a)switch(this.getSettings_().endingStart){case ZeroSlopeEnding:r=e,a=2*t-n;break;case WrapAroundEnding:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(void 0===s)switch(this.getSettings_().endingEnd){case ZeroSlopeEnding:o=e,s=2*n-t;break;case WrapAroundEnding:o=1,s=n+i[1]-i[0];break;default:o=e-1,s=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(s-n),this._offsetPrev=r*c,this._offsetNext=o*c},interpolate_:function(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,v=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,y=(-1-d)*f+(1.5+d)*m+.5*p,b=d*f-d*m;for(let e=0;e!==a;++e)r[e]=g*o[c+e]+v*o[l+e]+y*o[s+e]+b*o[h+e];return r}}),LinearInterpolant.prototype=Object.assign(Object.create(Interpolant.prototype),{constructor:LinearInterpolant,interpolate_:function(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=(n-t)/(i-t),h=1-c;for(let e=0;e!==a;++e)r[e]=o[l+e]*h+o[s+e]*c;return r}}),DiscreteInterpolant.prototype=Object.assign(Object.create(Interpolant.prototype),{constructor:DiscreteInterpolant,interpolate_:function(e){return this.copySampleValue_(e-1)}}),Object.assign(KeyframeTrack,{toJSON:function(e){const t=e.constructor;let n;if(void 0!==t.toJSON)n=t.toJSON(e);else{n={name:e.name,times:AnimationUtils.convertArray(e.times,Array),values:AnimationUtils.convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}}),Object.assign(KeyframeTrack.prototype,{constructor:KeyframeTrack,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:InterpolateLinear,InterpolantFactoryMethodDiscrete:function(e){return new DiscreteInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new LinearInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new CubicInterpolant(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){let t;switch(e){case InterpolateDiscrete:t=this.InterpolantFactoryMethodDiscrete;break;case InterpolateLinear:t=this.InterpolantFactoryMethodLinear;break;case InterpolateSmooth:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return InterpolateDiscrete;case this.InterpolantFactoryMethodLinear:return InterpolateLinear;case this.InterpolantFactoryMethodSmooth:return InterpolateSmooth}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(0!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this},scale:function(e){if(1!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this},trim:function(e,t){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;-1!==o&&n[o]>t;)--o;if(++o,0!==r||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const e=this.getValueSize();this.times=AnimationUtils.arraySlice(n,r,o),this.values=AnimationUtils.arraySlice(this.values,r*e,o*e)}return this},validate:function(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==o&&o>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,o),e=!1;break}o=i}if(void 0!==i&&AnimationUtils.isTypedArray(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e},optimize:function(){const e=AnimationUtils.arraySlice(this.times),t=AnimationUtils.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===InterpolateSmooth,r=e.length-1;let o=1;for(let a=1;a<r;++a){let r=!1;const s=e[a];if(s!==e[a+1]&&(1!==a||s!==e[0]))if(i)r=!0;else{const e=a*n,i=e-n,o=e+n;for(let a=0;a!==n;++a){const n=t[e+a];if(n!==t[i+a]||n!==t[o+a]){r=!0;break}}}if(r){if(a!==o){e[o]=e[a];const i=a*n,r=o*n;for(let e=0;e!==n;++e)t[r+e]=t[i+e]}++o}}if(r>0){e[o]=e[r];for(let e=r*n,i=o*n,a=0;a!==n;++a)t[i+a]=t[e+a];++o}return o!==e.length?(this.times=AnimationUtils.arraySlice(e,0,o),this.values=AnimationUtils.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this},clone:function(){const e=AnimationUtils.arraySlice(this.times,0),t=AnimationUtils.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}),BooleanKeyframeTrack.prototype=Object.assign(Object.create(KeyframeTrack.prototype),{constructor:BooleanKeyframeTrack,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ColorKeyframeTrack.prototype=Object.assign(Object.create(KeyframeTrack.prototype),{constructor:ColorKeyframeTrack,ValueTypeName:"color"}),NumberKeyframeTrack.prototype=Object.assign(Object.create(KeyframeTrack.prototype),{constructor:NumberKeyframeTrack,ValueTypeName:"number"}),QuaternionLinearInterpolant.prototype=Object.assign(Object.create(Interpolant.prototype),{constructor:QuaternionLinearInterpolant,interpolate_:function(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Quaternion.slerpFlat(r,0,o,l-a,o,l,s);return r}}),QuaternionKeyframeTrack.prototype=Object.assign(Object.create(KeyframeTrack.prototype),{constructor:QuaternionKeyframeTrack,ValueTypeName:"quaternion",DefaultInterpolation:InterpolateLinear,InterpolantFactoryMethodLinear:function(e){return new QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),StringKeyframeTrack.prototype=Object.assign(Object.create(KeyframeTrack.prototype),{constructor:StringKeyframeTrack,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),VectorKeyframeTrack.prototype=Object.assign(Object.create(KeyframeTrack.prototype),{constructor:VectorKeyframeTrack,ValueTypeName:"vector"}),Object.assign(AnimationClip,{parse:function(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(parseKeyframeTrack(n[e]).scale(i));const r=new AnimationClip(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r},toJSON:function(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(KeyframeTrack.toJSON(n[e]));return i},CreateFromMorphTargetSequence:function(e,t,n,i){const r=t.length,o=[];for(let e=0;e<r;e++){let a=[],s=[];a.push((e+r-1)%r,e,(e+1)%r),s.push(0,1,0);const l=AnimationUtils.getKeyframeOrder(a);a=AnimationUtils.sortedArray(a,1,l),s=AnimationUtils.sortedArray(s,1,l),i||0!==a[0]||(a.push(r),s.push(s[0])),o.push(new NumberKeyframeTrack(".morphTargetInfluences["+t[e].name+"]",a,s).scale(1/n))}return new AnimationClip(e,-1,o)},findByName:function(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null},CreateClipsFromMorphTargetSequences:function(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],o=n.name.match(r);if(o&&o.length>1){const e=o[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const o=[];for(const e in i)o.push(AnimationClip.CreateFromMorphTargetSequence(e,i[e],t,n));return o},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const o=[],a=[];AnimationUtils.flattenJSON(n,o,a,i),0!==o.length&&r.push(new e(t,o,a))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const r=l[e].keys;if(r&&0!==r.length)if(r[0].morphTargets){const e={};let t;for(t=0;t<r.length;t++)if(r[t].morphTargets)for(let n=0;n<r[t].morphTargets.length;n++)e[r[t].morphTargets[n]]=-1;for(const n in e){const e=[],o=[];for(let i=0;i!==r[t].morphTargets.length;++i){const i=r[t];e.push(i.time),o.push(i.morphTarget===n?1:0)}i.push(new NumberKeyframeTrack(".morphTargetInfluence["+n+"]",e,o))}s=e.length*(o||1)}else{const o=".bones["+t[e].name+"]";n(VectorKeyframeTrack,o+".position",r,"pos",i),n(QuaternionKeyframeTrack,o+".quaternion",r,"rot",i),n(VectorKeyframeTrack,o+".scale",r,"scl",i)}}return 0===i.length?null:new AnimationClip(r,s,i,a)}}),Object.assign(AnimationClip.prototype,{resetDuration:function(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this},trim:function(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},validate:function(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e},optimize:function(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this},clone:function(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new AnimationClip(this.name,this.duration,e,this.blendMode)},toJSON:function(){return AnimationClip.toJSON(this)}});const Cache={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function LoadingManager(e,t,n){const i=this;let r,o=!1,a=0,s=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){s++,!1===o&&void 0!==i.onStart&&i.onStart(e,a,s),o=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,s),a===s&&(o=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],i=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null}}const DefaultLoadingManager=new LoadingManager;function Loader(e){this.manager=void 0!==e?e:DefaultLoadingManager,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(Loader.prototype,{load:function(){},loadAsync:function(e,t){const n=this;return new Promise((function(i,r){n.load(e,i,t,r)}))},parse:function(){},setCrossOrigin:function(e){return this.crossOrigin=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}});const loading={};function FileLoader(e){Loader.call(this,e)}function AnimationLoader(e){Loader.call(this,e)}function CompressedTextureLoader(e){Loader.call(this,e)}function ImageLoader(e){Loader.call(this,e)}function CubeTextureLoader(e){Loader.call(this,e)}function DataTextureLoader(e){Loader.call(this,e)}function TextureLoader(e){Loader.call(this,e)}function Curve(){this.type="Curve",this.arcLengthDivisions=200}function EllipseCurve(e,t,n,i,r,o,a,s){Curve.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=n||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=a||!1,this.aRotation=s||0}function ArcCurve(e,t,n,i,r,o){EllipseCurve.call(this,e,t,n,n,i,r,o),this.type="ArcCurve"}function CubicPoly(){let e=0,t=0,n=0,i=0;function r(r,o,a,s){e=r,t=a,n=-3*r+3*o-2*a-s,i=2*r-2*o+a+s}return{initCatmullRom:function(e,t,n,i,o){r(t,n,o*(n-e),o*(i-t))},initNonuniformCatmullRom:function(e,t,n,i,o,a,s){let l=(t-e)/o-(n-e)/(o+a)+(n-t)/a,c=(n-t)/a-(i-t)/(a+s)+(i-n)/s;l*=a,c*=a,r(t,n,l,c)},calc:function(r){const o=r*r;return e+t*r+n*o+i*(o*r)}}}FileLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:FileLoader,load:function(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Cache.get(e);if(void 0!==o)return r.manager.itemStart(e),setTimeout((function(){t&&t(o),r.manager.itemEnd(e)}),0),o;if(void 0!==loading[e])return void loading[e].push({onLoad:t,onProgress:n,onError:i});const a=e.match(/^data:(.*?)(;base64)?,(.*)$/);let s;if(a){const n=a[1],o=!!a[2];let s=a[3];s=decodeURIComponent(s),o&&(s=atob(s));try{let i;const o=(this.responseType||"").toLowerCase();switch(o){case"arraybuffer":case"blob":const e=new Uint8Array(s.length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);i="blob"===o?new Blob([e.buffer],{type:n}):e.buffer;break;case"document":const t=new DOMParser;i=t.parseFromString(s,n);break;case"json":i=JSON.parse(s);break;default:i=s}setTimeout((function(){t&&t(i),r.manager.itemEnd(e)}),0)}catch(t){setTimeout((function(){i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}),0)}}else{loading[e]=[],loading[e].push({onLoad:t,onProgress:n,onError:i}),s=new XMLHttpRequest,s.open("GET",e,!0),s.addEventListener("load",(function(t){const n=this.response,i=loading[e];if(delete loading[e],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Cache.add(e,n);for(let e=0,t=i.length;e<t;e++){const t=i[e];t.onLoad&&t.onLoad(n)}r.manager.itemEnd(e)}else{for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onError&&n.onError(t)}r.manager.itemError(e),r.manager.itemEnd(e)}}),!1),s.addEventListener("progress",(function(t){const n=loading[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onProgress&&i.onProgress(t)}}),!1),s.addEventListener("error",(function(t){const n=loading[e];delete loading[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onError&&i.onError(t)}r.manager.itemError(e),r.manager.itemEnd(e)}),!1),s.addEventListener("abort",(function(t){const n=loading[e];delete loading[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onError&&i.onError(t)}r.manager.itemError(e),r.manager.itemEnd(e)}),!1),void 0!==this.responseType&&(s.responseType=this.responseType),void 0!==this.withCredentials&&(s.withCredentials=this.withCredentials),s.overrideMimeType&&s.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(const e in this.requestHeader)s.setRequestHeader(e,this.requestHeader[e]);s.send(null)}return r.manager.itemStart(e),s},setResponseType:function(e){return this.responseType=e,this},setMimeType:function(e){return this.mimeType=e,this}}),AnimationLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:AnimationLoader,load:function(e,t,n,i){const r=this,o=new FileLoader(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)},parse:function(e){const t=[];for(let n=0;n<e.length;n++){const i=AnimationClip.parse(e[n]);t.push(i)}return t}}),CompressedTextureLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:CompressedTextureLoader,load:function(e,t,n,i){const r=this,o=[],a=new CompressedTexture,s=new FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(r.withCredentials);let l=0;function c(c){s.load(e[c],(function(e){const n=r.parse(e,!0);o[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=LinearFilter),a.image=o,a.format=n.format,a.needsUpdate=!0,t&&t(a))}),n,i)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)c(t);else s.load(e,(function(e){const n=r.parse(e,!0);if(n.isCubemap){const e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){o[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)o[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),o[t].format=n.format,o[t].width=n.width,o[t].height=n.height}a.image=o}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=LinearFilter),a.format=n.format,a.needsUpdate=!0,t&&t(a)}),n,i);return a}}),ImageLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:ImageLoader,load:function(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Cache.get(e);if(void 0!==o)return r.manager.itemStart(e),setTimeout((function(){t&&t(o),r.manager.itemEnd(e)}),0),o;const a=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){a.removeEventListener("load",s,!1),a.removeEventListener("error",l,!1),Cache.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){a.removeEventListener("load",s,!1),a.removeEventListener("error",l,!1),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}return a.addEventListener("load",s,!1),a.addEventListener("error",l,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}),CubeTextureLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:CubeTextureLoader,load:function(e,t,n,i){const r=new CubeTexture,o=new ImageLoader(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function s(n){o.load(e[n],(function(e){r.images[n]=e,a++,6===a&&(r.needsUpdate=!0,t&&t(r))}),void 0,i)}for(let t=0;t<e.length;++t)s(t);return r}}),DataTextureLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:DataTextureLoader,load:function(e,t,n,i){const r=this,o=new DataTexture,a=new FileLoader(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,(function(e){const n=r.parse(e);n&&(void 0!==n.image?o.image=n.image:void 0!==n.data&&(o.image.width=n.width,o.image.height=n.height,o.image.data=n.data),o.wrapS=void 0!==n.wrapS?n.wrapS:ClampToEdgeWrapping,o.wrapT=void 0!==n.wrapT?n.wrapT:ClampToEdgeWrapping,o.magFilter=void 0!==n.magFilter?n.magFilter:LinearFilter,o.minFilter=void 0!==n.minFilter?n.minFilter:LinearFilter,o.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.encoding&&(o.encoding=n.encoding),void 0!==n.flipY&&(o.flipY=n.flipY),void 0!==n.format&&(o.format=n.format),void 0!==n.type&&(o.type=n.type),void 0!==n.mipmaps&&(o.mipmaps=n.mipmaps,o.minFilter=LinearMipmapLinearFilter),1===n.mipmapCount&&(o.minFilter=LinearFilter),o.needsUpdate=!0,t&&t(o,n))}),n,i),o}}),TextureLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:TextureLoader,load:function(e,t,n,i){const r=new Texture,o=new ImageLoader(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,(function(n){r.image=n;const i=e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/);r.format=i?RGBFormat:RGBAFormat,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}),Object.assign(Curve.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){const e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){const n=this.getLengths();let i=0;const r=n.length;let o;o=t||e*n[r-1];let a,s=0,l=r-1;for(;s<=l;)if(i=Math.floor(s+(l-s)/2),a=n[i]-o,a<0)s=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===o)return i/(r-1);const c=n[i];return(i+(o-c)/(n[i+1]-c))/(r-1)},getTangent:function(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),s=t||(o.isVector2?new Vector2:new Vector3);return s.copy(a).sub(o).normalize(),s},getTangentAt:function(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)},computeFrenetFrames:function(e,t){const n=new Vector3,i=[],r=[],o=[],a=new Vector3,s=new Matrix4;for(let t=0;t<=e;t++)i[t]=this.getTangentAt(t/e,new Vector3),i[t].normalize();r[0]=new Vector3,o[0]=new Vector3;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),o[t]=o[t-1].clone(),a.crossVectors(i[t-1],i[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(MathUtils.clamp(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(s.makeRotationAxis(a,e))}o[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(MathUtils.clamp(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(s.makeRotationAxis(i[n],t*n)),o[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:o}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),EllipseCurve.prototype=Object.create(Curve.prototype),EllipseCurve.prototype.constructor=EllipseCurve,EllipseCurve.prototype.isEllipseCurve=!0,EllipseCurve.prototype.getPoint=function(e,t){const n=t||new Vector2,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=o?0:i),!0!==this.aClockwise||o||(r===i?r=-i:r-=i);const a=this.aStartAngle+e*r;let s=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,i=l-this.aY;s=n*e-i*t+this.aX,l=n*t+i*e+this.aY}return n.set(s,l)},EllipseCurve.prototype.copy=function(e){return Curve.prototype.copy.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},EllipseCurve.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e},EllipseCurve.prototype.fromJSON=function(e){return Curve.prototype.fromJSON.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},ArcCurve.prototype=Object.create(EllipseCurve.prototype),ArcCurve.prototype.constructor=ArcCurve,ArcCurve.prototype.isArcCurve=!0;const tmp=new Vector3,px=new CubicPoly,py=new CubicPoly,pz=new CubicPoly;function CatmullRomCurve3(e=[],t=!1,n="centripetal",i=.5){Curve.call(this),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}function CatmullRom(e,t,n,i,r){const o=.5*(i-t),a=.5*(r-n),s=e*e;return(2*n-2*i+o+a)*(e*s)+(-3*n+3*i-2*o-a)*s+o*e+n}function QuadraticBezierP0(e,t){const n=1-e;return n*n*t}function QuadraticBezierP1(e,t){return 2*(1-e)*e*t}function QuadraticBezierP2(e,t){return e*e*t}function QuadraticBezier(e,t,n,i){return QuadraticBezierP0(e,t)+QuadraticBezierP1(e,n)+QuadraticBezierP2(e,i)}function CubicBezierP0(e,t){const n=1-e;return n*n*n*t}function CubicBezierP1(e,t){const n=1-e;return 3*n*n*e*t}function CubicBezierP2(e,t){return 3*(1-e)*e*e*t}function CubicBezierP3(e,t){return e*e*e*t}function CubicBezier(e,t,n,i,r){return CubicBezierP0(e,t)+CubicBezierP1(e,n)+CubicBezierP2(e,i)+CubicBezierP3(e,r)}function CubicBezierCurve(e=new Vector2,t=new Vector2,n=new Vector2,i=new Vector2){Curve.call(this),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}function CubicBezierCurve3(e=new Vector3,t=new Vector3,n=new Vector3,i=new Vector3){Curve.call(this),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}function LineCurve(e=new Vector2,t=new Vector2){Curve.call(this),this.type="LineCurve",this.v1=e,this.v2=t}function LineCurve3(e=new Vector3,t=new Vector3){Curve.call(this),this.type="LineCurve3",this.v1=e,this.v2=t}function QuadraticBezierCurve(e=new Vector2,t=new Vector2,n=new Vector2){Curve.call(this),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}function QuadraticBezierCurve3(e=new Vector3,t=new Vector3,n=new Vector3){Curve.call(this),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}function SplineCurve(e=[]){Curve.call(this),this.type="SplineCurve",this.points=e}CatmullRomCurve3.prototype=Object.create(Curve.prototype),CatmullRomCurve3.prototype.constructor=CatmullRomCurve3,CatmullRomCurve3.prototype.isCatmullRomCurve3=!0,CatmullRomCurve3.prototype.getPoint=function(e,t=new Vector3){const n=t,i=this.points,r=i.length,o=(r-(this.closed?0:1))*e;let a,s,l=Math.floor(o),c=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(tmp.subVectors(i[0],i[1]).add(i[0]),a=tmp);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2<r?s=i[(l+2)%r]:(tmp.subVectors(i[r-1],i[r-2]).add(i[r-1]),s=tmp),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(a.distanceToSquared(h),e),n=Math.pow(h.distanceToSquared(u),e),i=Math.pow(u.distanceToSquared(s),e);n<1e-4&&(n=1),t<1e-4&&(t=n),i<1e-4&&(i=n),px.initNonuniformCatmullRom(a.x,h.x,u.x,s.x,t,n,i),py.initNonuniformCatmullRom(a.y,h.y,u.y,s.y,t,n,i),pz.initNonuniformCatmullRom(a.z,h.z,u.z,s.z,t,n,i)}else"catmullrom"===this.curveType&&(px.initCatmullRom(a.x,h.x,u.x,s.x,this.tension),py.initCatmullRom(a.y,h.y,u.y,s.y,this.tension),pz.initCatmullRom(a.z,h.z,u.z,s.z,this.tension));return n.set(px.calc(c),py.calc(c),pz.calc(c)),n},CatmullRomCurve3.prototype.copy=function(e){Curve.prototype.copy.call(this,e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},CatmullRomCurve3.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);e.points=[];for(let t=0,n=this.points.length;t<n;t++)e.points.push(this.points[t].toArray());return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e},CatmullRomCurve3.prototype.fromJSON=function(e){Curve.prototype.fromJSON.call(this,e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Vector3).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},CubicBezierCurve.prototype=Object.create(Curve.prototype),CubicBezierCurve.prototype.constructor=CubicBezierCurve,CubicBezierCurve.prototype.isCubicBezierCurve=!0,CubicBezierCurve.prototype.getPoint=function(e,t=new Vector2){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(CubicBezier(e,i.x,r.x,o.x,a.x),CubicBezier(e,i.y,r.y,o.y,a.y)),n},CubicBezierCurve.prototype.copy=function(e){return Curve.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},CubicBezierCurve.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},CubicBezierCurve.prototype.fromJSON=function(e){return Curve.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},CubicBezierCurve3.prototype=Object.create(Curve.prototype),CubicBezierCurve3.prototype.constructor=CubicBezierCurve3,CubicBezierCurve3.prototype.isCubicBezierCurve3=!0,CubicBezierCurve3.prototype.getPoint=function(e,t=new Vector3){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(CubicBezier(e,i.x,r.x,o.x,a.x),CubicBezier(e,i.y,r.y,o.y,a.y),CubicBezier(e,i.z,r.z,o.z,a.z)),n},CubicBezierCurve3.prototype.copy=function(e){return Curve.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},CubicBezierCurve3.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},CubicBezierCurve3.prototype.fromJSON=function(e){return Curve.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},LineCurve.prototype=Object.create(Curve.prototype),LineCurve.prototype.constructor=LineCurve,LineCurve.prototype.isLineCurve=!0,LineCurve.prototype.getPoint=function(e,t=new Vector2){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n},LineCurve.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},LineCurve.prototype.getTangent=function(e,t){const n=t||new Vector2;return n.copy(this.v2).sub(this.v1).normalize(),n},LineCurve.prototype.copy=function(e){return Curve.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},LineCurve.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},LineCurve.prototype.fromJSON=function(e){return Curve.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},LineCurve3.prototype=Object.create(Curve.prototype),LineCurve3.prototype.constructor=LineCurve3,LineCurve3.prototype.isLineCurve3=!0,LineCurve3.prototype.getPoint=function(e,t=new Vector3){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n},LineCurve3.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},LineCurve3.prototype.copy=function(e){return Curve.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},LineCurve3.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},LineCurve3.prototype.fromJSON=function(e){return Curve.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},QuadraticBezierCurve.prototype=Object.create(Curve.prototype),QuadraticBezierCurve.prototype.constructor=QuadraticBezierCurve,QuadraticBezierCurve.prototype.isQuadraticBezierCurve=!0,QuadraticBezierCurve.prototype.getPoint=function(e,t=new Vector2){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(QuadraticBezier(e,i.x,r.x,o.x),QuadraticBezier(e,i.y,r.y,o.y)),n},QuadraticBezierCurve.prototype.copy=function(e){return Curve.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},QuadraticBezierCurve.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},QuadraticBezierCurve.prototype.fromJSON=function(e){return Curve.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},QuadraticBezierCurve3.prototype=Object.create(Curve.prototype),QuadraticBezierCurve3.prototype.constructor=QuadraticBezierCurve3,QuadraticBezierCurve3.prototype.isQuadraticBezierCurve3=!0,QuadraticBezierCurve3.prototype.getPoint=function(e,t=new Vector3){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(QuadraticBezier(e,i.x,r.x,o.x),QuadraticBezier(e,i.y,r.y,o.y),QuadraticBezier(e,i.z,r.z,o.z)),n},QuadraticBezierCurve3.prototype.copy=function(e){return Curve.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},QuadraticBezierCurve3.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},QuadraticBezierCurve3.prototype.fromJSON=function(e){return Curve.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},SplineCurve.prototype=Object.create(Curve.prototype),SplineCurve.prototype.constructor=SplineCurve,SplineCurve.prototype.isSplineCurve=!0,SplineCurve.prototype.getPoint=function(e,t=new Vector2){const n=t,i=this.points,r=(i.length-1)*e,o=Math.floor(r),a=r-o,s=i[0===o?o:o-1],l=i[o],c=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(CatmullRom(a,s.x,l.x,c.x,h.x),CatmullRom(a,s.y,l.y,c.y,h.y)),n},SplineCurve.prototype.copy=function(e){Curve.prototype.copy.call(this,e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this},SplineCurve.prototype.toJSON=function(){const e=Curve.prototype.toJSON.call(this);e.points=[];for(let t=0,n=this.points.length;t<n;t++)e.points.push(this.points[t].toArray());return e},SplineCurve.prototype.fromJSON=function(e){Curve.prototype.fromJSON.call(this,e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Vector2).fromArray(n))}return this};var Curves=Object.freeze({__proto__:null,ArcCurve:ArcCurve,CatmullRomCurve3:CatmullRomCurve3,CubicBezierCurve:CubicBezierCurve,CubicBezierCurve3:CubicBezierCurve3,EllipseCurve:EllipseCurve,LineCurve:LineCurve,LineCurve3:LineCurve3,QuadraticBezierCurve:QuadraticBezierCurve,QuadraticBezierCurve3:QuadraticBezierCurve3,SplineCurve:SplineCurve});function CurvePath(){Curve.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Path(e){CurvePath.call(this),this.type="Path",this.currentPoint=new Vector2,e&&this.setFromPoints(e)}function Shape(e){Path.call(this,e),this.uuid=MathUtils.generateUUID(),this.type="Shape",this.holes=[]}function Light(e,t=1){Object3D.call(this),this.type="Light",this.color=new Color(e),this.intensity=t}function HemisphereLight(e,t,n){Light.call(this,e,n),this.type="HemisphereLight",this.position.copy(Object3D.DefaultUp),this.updateMatrix(),this.groundColor=new Color(t)}function LightShadow(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new Vector2(512,512),this.map=null,this.mapPass=null,this.matrix=new Matrix4,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Frustum,this._frameExtents=new Vector2(1,1),this._viewportCount=1,this._viewports=[new Vector4(0,0,1,1)]}function SpotLightShadow(){LightShadow.call(this,new PerspectiveCamera(50,1,.5,500)),this.focus=1}function SpotLight(e,t,n,i,r,o){Light.call(this,e,t),this.type="SpotLight",this.position.copy(Object3D.DefaultUp),this.updateMatrix(),this.target=new Object3D,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==o?o:1,this.shadow=new SpotLightShadow}function PointLightShadow(){LightShadow.call(this,new PerspectiveCamera(90,1,.5,500)),this._frameExtents=new Vector2(4,2),this._viewportCount=6,this._viewports=[new Vector4(2,1,1,1),new Vector4(0,1,1,1),new Vector4(3,1,1,1),new Vector4(1,1,1,1),new Vector4(3,0,1,1),new Vector4(1,0,1,1)],this._cubeDirections=[new Vector3(1,0,0),new Vector3(-1,0,0),new Vector3(0,0,1),new Vector3(0,0,-1),new Vector3(0,1,0),new Vector3(0,-1,0)],this._cubeUps=[new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,0,1),new Vector3(0,0,-1)]}function PointLight(e,t,n,i){Light.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==i?i:1,this.shadow=new PointLightShadow}function OrthographicCamera(e=-1,t=1,n=1,i=-1,r=.1,o=2e3){Camera.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}function DirectionalLightShadow(){LightShadow.call(this,new OrthographicCamera(-5,5,5,-5,.5,500))}function DirectionalLight(e,t){Light.call(this,e,t),this.type="DirectionalLight",this.position.copy(Object3D.DefaultUp),this.updateMatrix(),this.target=new Object3D,this.shadow=new DirectionalLightShadow}function AmbientLight(e,t){Light.call(this,e,t),this.type="AmbientLight"}function RectAreaLight(e,t,n,i){Light.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==n?n:10,this.height=void 0!==i?i:10}CurvePath.prototype=Object.assign(Object.create(Curve.prototype),{constructor:CurvePath,add:function(e){this.curves.push(e)},closePath:function(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new LineCurve(t,e))},getPoint:function(e){const t=e*this.getLength(),n=this.getCurveLengths();let i=0;for(;i<n.length;){if(n[i]>=t){const e=n[i]-t,r=this.curves[i],o=r.getLength();return r.getPointAt(0===o?0:1-e/o)}i++}return null},getLength:function(){const e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e},getSpacedPoints:function(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t},getPoints:function(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const o=r[i],a=o.getPoints(o&&o.isEllipseCurve?2*e:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e);for(let e=0;e<a.length;e++){const i=a[e];n&&n.equals(i)||(t.push(i),n=i)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t},copy:function(e){Curve.prototype.copy.call(this,e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++)this.curves.push(e.curves[t].clone());return this.autoClose=e.autoClose,this},toJSON:function(){const e=Curve.prototype.toJSON.call(this);e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++)e.curves.push(this.curves[t].toJSON());return e},fromJSON:function(e){Curve.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new Curves[n.type]).fromJSON(n))}return this}}),Path.prototype=Object.assign(Object.create(CurvePath.prototype),{constructor:Path,setFromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this},moveTo:function(e,t){return this.currentPoint.set(e,t),this},lineTo:function(e,t){const n=new LineCurve(this.currentPoint.clone(),new Vector2(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this},quadraticCurveTo:function(e,t,n,i){const r=new QuadraticBezierCurve(this.currentPoint.clone(),new Vector2(e,t),new Vector2(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this},bezierCurveTo:function(e,t,n,i,r,o){const a=new CubicBezierCurve(this.currentPoint.clone(),new Vector2(e,t),new Vector2(n,i),new Vector2(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this},splineThru:function(e){const t=new SplineCurve([this.currentPoint.clone()].concat(e));return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this},arc:function(e,t,n,i,r,o){return this.absarc(e+this.currentPoint.x,t+this.currentPoint.y,n,i,r,o),this},absarc:function(e,t,n,i,r,o){return this.absellipse(e,t,n,n,i,r,o),this},ellipse:function(e,t,n,i,r,o,a,s){return this.absellipse(e+this.currentPoint.x,t+this.currentPoint.y,n,i,r,o,a,s),this},absellipse:function(e,t,n,i,r,o,a,s){const l=new EllipseCurve(e,t,n,i,r,o,a,s);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this},copy:function(e){return CurvePath.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){const e=CurvePath.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return CurvePath.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),Shape.prototype=Object.assign(Object.create(Path.prototype),{constructor:Shape,getPointsHoles:function(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){Path.prototype.copy.call(this,e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++)this.holes.push(e.holes[t].clone());return this},toJSON:function(){const e=Path.prototype.toJSON.call(this);e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++)e.holes.push(this.holes[t].toJSON());return e},fromJSON:function(e){Path.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new Path).fromJSON(n))}return this}}),Light.prototype=Object.assign(Object.create(Object3D.prototype),{constructor:Light,isLight:!0,copy:function(e){return Object3D.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){const t=Object3D.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),HemisphereLight.prototype=Object.assign(Object.create(Light.prototype),{constructor:HemisphereLight,isHemisphereLight:!0,copy:function(e){return Light.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(LightShadow.prototype,{_projScreenMatrix:new Matrix4,_lightPositionWorld:new Vector3,_lookTarget:new Vector3,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){const t=this.camera,n=this.matrix,i=this._projScreenMatrix,r=this._lookTarget,o=this._lightPositionWorld;o.setFromMatrixPosition(e.matrixWorld),t.position.copy(o),r.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(r),t.updateMatrixWorld(),i.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(i),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),SpotLightShadow.prototype=Object.assign(Object.create(LightShadow.prototype),{constructor:SpotLightShadow,isSpotLightShadow:!0,updateMatrices:function(e){const t=this.camera,n=2*MathUtils.RAD2DEG*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),LightShadow.prototype.updateMatrices.call(this,e)}}),SpotLight.prototype=Object.assign(Object.create(Light.prototype),{constructor:SpotLight,isSpotLight:!0,copy:function(e){return Light.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),PointLightShadow.prototype=Object.assign(Object.create(LightShadow.prototype),{constructor:PointLightShadow,isPointLightShadow:!0,updateMatrices:function(e,t=0){const n=this.camera,i=this.matrix,r=this._lightPositionWorld,o=this._lookTarget,a=this._projScreenMatrix;r.setFromMatrixPosition(e.matrixWorld),n.position.copy(r),o.copy(n.position),o.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(o),n.updateMatrixWorld(),i.makeTranslation(-r.x,-r.y,-r.z),a.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(a)}}),PointLight.prototype=Object.assign(Object.create(Light.prototype),{constructor:PointLight,isPointLight:!0,copy:function(e){return Light.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),OrthographicCamera.prototype=Object.assign(Object.create(Camera.prototype),{constructor:OrthographicCamera,isOrthographicCamera:!0,copy:function(e,t){return Camera.prototype.copy.call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this},setViewOffset:function(e,t,n,i,r,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,o=n+e,a=i+t,s=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,o=r+e*this.view.width,a-=t*this.view.offsetY,s=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){const t=Object3D.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}),DirectionalLightShadow.prototype=Object.assign(Object.create(LightShadow.prototype),{constructor:DirectionalLightShadow,isDirectionalLightShadow:!0,updateMatrices:function(e){LightShadow.prototype.updateMatrices.call(this,e)}}),DirectionalLight.prototype=Object.assign(Object.create(Light.prototype),{constructor:DirectionalLight,isDirectionalLight:!0,copy:function(e){return Light.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),AmbientLight.prototype=Object.assign(Object.create(Light.prototype),{constructor:AmbientLight,isAmbientLight:!0}),RectAreaLight.prototype=Object.assign(Object.create(Light.prototype),{constructor:RectAreaLight,isRectAreaLight:!0,copy:function(e){return Light.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){const t=Light.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}});class SphericalHarmonics3{constructor(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Vector3)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],n*i*1.092548),t.addScaledVector(o[5],i*r*1.092548),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],n*r*1.092548),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],1.023328*i),t.addScaledVector(o[2],1.023328*r),t.addScaledVector(o[3],1.023328*n),t.addScaledVector(o[4],.858086*n*i),t.addScaledVector(o[5],.858086*i*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],.858086*n*r),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}function LightProbe(e,t){Light.call(this,void 0,t),this.type="LightProbe",this.sh=void 0!==e?e:new SphericalHarmonics3}function MaterialLoader(e){Loader.call(this,e),this.textures={}}LightProbe.prototype=Object.assign(Object.create(Light.prototype),{constructor:LightProbe,isLightProbe:!0,copy:function(e){return Light.prototype.copy.call(this,e),this.sh.copy(e.sh),this},fromJSON:function(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this},toJSON:function(e){const t=Light.prototype.toJSON.call(this,e);return t.object.sh=this.sh.toArray(),t}}),MaterialLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:MaterialLoader,load:function(e,t,n,i){const r=this,o=new FileLoader(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)},parse:function(e){const t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}const i=new Materials[e.type];if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&void 0!==i.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=(new Color).setHex(e.sheen)),void 0!==e.emissive&&void 0!==i.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==i.specular&&i.specular.setHex(e.specular),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),1!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.skinning&&(i.skinning=e.skinning),void 0!==e.morphTargets&&(i.morphTargets=e.morphTargets),void 0!==e.morphNormals&&(i.morphNormals=e.morphNormals),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.vertexTangents&&(i.vertexTangents=e.vertexTangents),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.vertexColors&&(i.vertexColors="number"==typeof e.vertexColors?e.vertexColors>0:e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=(new Color).setHex(r.value);break;case"v2":i.uniforms[t].value=(new Vector2).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new Vector3).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new Vector4).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new Matrix3).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new Matrix4).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.shading&&(i.flatShading=1===e.shading),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new Vector2).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Vector2).fromArray(e.clearcoatNormalScale)),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),i},setTextures:function(e){return this.textures=e,this}});const LoaderUtils={decodeText:function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(e){return t}},extractUrlBase:function(e){const t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}};function InstancedBufferGeometry(){BufferGeometry.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}function InstancedBufferAttribute(e,t,n,i){"number"==typeof n&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),BufferAttribute.call(this,e,t,n),this.meshPerAttribute=i||1}function BufferGeometryLoader(e){Loader.call(this,e)}function ImageBitmapLoader(e){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),Loader.call(this,e),this.options={premultiplyAlpha:"none"}}function ShapePath(){this.type="ShapePath",this.color=new Color,this.subPaths=[],this.currentPath=null}InstancedBufferGeometry.prototype=Object.assign(Object.create(BufferGeometry.prototype),{constructor:InstancedBufferGeometry,isInstancedBufferGeometry:!0,copy:function(e){return BufferGeometry.prototype.copy.call(this,e),this.instanceCount=e.instanceCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const e=BufferGeometry.prototype.toJSON.call(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}),InstancedBufferAttribute.prototype=Object.assign(Object.create(BufferAttribute.prototype),{constructor:InstancedBufferAttribute,isInstancedBufferAttribute:!0,copy:function(e){return BufferAttribute.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},toJSON:function(){const e=BufferAttribute.prototype.toJSON.call(this);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}),BufferGeometryLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:BufferGeometryLoader,load:function(e,t,n,i){const r=this,o=new FileLoader(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)},parse:function(e){const t={},n={};function i(e,i){if(void 0!==t[i])return t[i];const r=e.interleavedBuffers[i],o=(function a(e,t){if(void 0!==n[t])return n[t];const i=new Uint32Array(e.arrayBuffers[t]).buffer;return n[t]=i,i})(e,r.buffer),s=new InterleavedBuffer(getTypedArray(r.type,o),r.stride);return s.uuid=r.uuid,t[i]=s,s}const r=e.isInstancedBufferGeometry?new InstancedBufferGeometry:new BufferGeometry,o=e.data.index;if(void 0!==o){const e=getTypedArray(o.type,o.array);r.setIndex(new BufferAttribute(e,1))}const a=e.data.attributes;for(const t in a){const n=a[t];let o;if(n.isInterleavedBufferAttribute)o=new InterleavedBufferAttribute(i(e.data,n.data),n.itemSize,n.offset,n.normalized);else{const e=getTypedArray(n.type,n.array);o=new(n.isInstancedBufferAttribute?InstancedBufferAttribute:BufferAttribute)(e,n.itemSize,n.normalized)}void 0!==n.name&&(o.name=n.name),r.setAttribute(t,o)}const s=e.data.morphAttributes;if(s)for(const t in s){const n=s[t],o=[];for(let t=0,r=n.length;t<r;t++){const r=n[t];let a;a=r.isInterleavedBufferAttribute?new InterleavedBufferAttribute(i(e.data,r.data),r.itemSize,r.offset,r.normalized):new BufferAttribute(getTypedArray(r.type,r.array),r.itemSize,r.normalized),void 0!==r.name&&(a.name=r.name),o.push(a)}r.morphAttributes[t]=o}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const t=l[e];r.addGroup(t.start,t.count,t.materialIndex)}const c=e.data.boundingSphere;if(void 0!==c){const e=new Vector3;void 0!==c.center&&e.fromArray(c.center),r.boundingSphere=new Sphere(e,c.radius)}return e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}}),ImageBitmapLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:ImageBitmapLoader,isImageBitmapLoader:!0,setOptions:function e(t){return this.options=t,this},load:function(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Cache.get(e);if(void 0!==o)return r.manager.itemStart(e),setTimeout((function(){t&&t(o),r.manager.itemEnd(e)}),0),o;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,r.options)})).then((function(n){Cache.add(e,n),t&&t(n),r.manager.itemEnd(e)})).catch((function(t){i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}),Object.assign(ShapePath.prototype,{moveTo:function(e,t){return this.currentPath=new Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this},lineTo:function(e,t){return this.currentPath.lineTo(e,t),this},quadraticCurveTo:function(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this},bezierCurveTo:function(e,t,n,i,r,o){return this.currentPath.bezierCurveTo(e,t,n,i,r,o),this},splineThru:function(e){return this.currentPath.splineThru(e),this},toShapes:function(e,t){function n(e){const t=[];for(let n=0,i=e.length;n<i;n++){const i=e[n],r=new Shape;r.curves=i.curves,t.push(r)}return t}function i(e,t){const n=t.length;let i=!1;for(let r=n-1,o=0;o<n;r=o++){let n=t[r],a=t[o],s=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[o],s=-s,a=t[r],l=-l),e.y<n.y||e.y>a.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return i}const r=ShapeUtils.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return n(o);let a,s,l;const c=[];if(1===o.length)return s=o[0],l=new Shape,l.curves=s.curves,c.push(l),c;let h=!r(o[0].getPoints());h=e?!h:h;const u=[],d=[];let p,m,f=[],g=0;d[g]=void 0,f[g]=[];for(let t=0,n=o.length;t<n;t++)s=o[t],p=s.getPoints(),a=r(p),a=e?!a:a,a?(!h&&d[g]&&g++,d[g]={s:new Shape,p:p},d[g].s.curves=s.curves,h&&g++,f[g]=[]):f[g].push({h:s,p:p[0]});if(!d[0])return n(o);if(d.length>1){let e=!1;const t=[];for(let e=0,t=d.length;e<t;e++)u[e]=[];for(let n=0,r=d.length;n<r;n++){const r=f[n];for(let o=0;o<r.length;o++){const a=r[o];let s=!0;for(let r=0;r<d.length;r++)i(a.p,d[r].p)&&(n!==r&&t.push({froms:n,tos:r,hole:o}),s?(s=!1,u[r].push(a)):e=!0);s&&u[n].push(a)}}t.length>0&&(e||(f=u))}for(let e=0,t=d.length;e<t;e++){l=d[e].s,c.push(l),m=f[e];for(let e=0,t=m.length;e<t;e++)l.holes.push(m[e].h)}return c}});class Font{constructor(e){Object.defineProperty(this,"isFont",{value:!0}),this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],i=createPaths(e,t,this.data);for(let e=0,t=i.length;e<t;e++)Array.prototype.push.apply(n,i[e].toShapes());return n}}function createPaths(e,t,n){const i=Array.from?Array.from(e):String(e).split(""),r=t/n.resolution,o=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,a=[];let s=0,l=0;for(let e=0;e<i.length;e++){const t=i[e];if("\n"===t)s=0,l-=o;else{const e=createPath(t,r,s,l,n);s+=e.offsetX,a.push(e.path)}}return a}function createPath(e,t,n,i,r){const o=r.glyphs[e]||r.glyphs["?"];if(!o)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+r.familyName+".");const a=new ShapePath;let s,l,c,h,u,d,p,m;if(o.o){const e=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let r=0,o=e.length;r<o;)switch(e[r++]){case"m":s=e[r++]*t+n,l=e[r++]*t+i,a.moveTo(s,l);break;case"l":s=e[r++]*t+n,l=e[r++]*t+i,a.lineTo(s,l);break;case"q":c=e[r++]*t+n,h=e[r++]*t+i,u=e[r++]*t+n,d=e[r++]*t+i,a.quadraticCurveTo(u,d,c,h);break;case"b":c=e[r++]*t+n,h=e[r++]*t+i,u=e[r++]*t+n,d=e[r++]*t+i,p=e[r++]*t+n,m=e[r++]*t+i,a.bezierCurveTo(u,d,p,m,c,h)}}return{offsetX:o.ha*t,path:a}}function FontLoader(e){Loader.call(this,e)}let _context;FontLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:FontLoader,load:function(e,t,n,i){const r=this,o=new FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(e){let n;try{n=JSON.parse(e)}catch(t){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(e.substring(65,e.length-2))}const i=r.parse(n);t&&t(i)}),n,i)},parse:function(e){return new Font(e)}});const AudioContext={getContext:function(){return void 0===_context&&(_context=new(window.AudioContext||window.webkitAudioContext)),_context},setContext:function(e){_context=e}};function AudioLoader(e){Loader.call(this,e)}function HemisphereLightProbe(e,t,n){LightProbe.call(this,void 0,n);const i=(new Color).set(e),r=(new Color).set(t),o=new Vector3(i.r,i.g,i.b),a=new Vector3(r.r,r.g,r.b),s=Math.sqrt(Math.PI),l=s*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(s),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(l)}function AmbientLightProbe(e,t){LightProbe.call(this,void 0,t);const n=(new Color).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}AudioLoader.prototype=Object.assign(Object.create(Loader.prototype),{constructor:AudioLoader,load:function(e,t,n,i){const r=this,o=new FileLoader(r.manager);o.setResponseType("arraybuffer"),o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{const e=n.slice(0);AudioContext.getContext().decodeAudioData(e,(function(e){t(e)}))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}}),HemisphereLightProbe.prototype=Object.assign(Object.create(LightProbe.prototype),{constructor:HemisphereLightProbe,isHemisphereLightProbe:!0,copy:function(e){return LightProbe.prototype.copy.call(this,e),this},toJSON:function(e){return LightProbe.prototype.toJSON.call(this,e)}}),AmbientLightProbe.prototype=Object.assign(Object.create(LightProbe.prototype),{constructor:AmbientLightProbe,isAmbientLightProbe:!0,copy:function(e){return LightProbe.prototype.copy.call(this,e),this},toJSON:function(e){return LightProbe.prototype.toJSON.call(this,e)}});const _eyeRight=new Matrix4,_eyeLeft=new Matrix4;function StereoCamera(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}Object.assign(StereoCamera.prototype,{update:function(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep;const n=e.projectionMatrix.clone(),i=t.eyeSep/2,r=i*t.near/t.focus,o=t.near*Math.tan(MathUtils.DEG2RAD*t.fov*.5)/t.zoom;let a,s;_eyeLeft.elements[12]=-i,_eyeRight.elements[12]=i,a=-o*t.aspect+r,s=o*t.aspect+r,n.elements[0]=2*t.near/(s-a),n.elements[8]=(s+a)/(s-a),this.cameraL.projectionMatrix.copy(n),a=-o*t.aspect-r,s=o*t.aspect-r,n.elements[0]=2*t.near/(s-a),n.elements[8]=(s+a)/(s-a),this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(_eyeLeft),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(_eyeRight)}});class Audio extends Object3D{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}function PropertyMixer(e,t,n){let i,r,o;switch(this.binding=e,this.valueSize=n,t){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(PropertyMixer.prototype,{accumulate:function(e,t){const n=this.buffer,i=this.valueSize,r=e*i+i;let o=this.cumulativeWeight;if(0===o){for(let e=0;e!==i;++e)n[r+e]=n[e];o=t}else o+=t,this._mixBufferRegion(n,r,0,t/o,i);this.cumulativeWeight=o},accumulateAdditive:function(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e},apply:function(e){const t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1&&this._mixBufferRegion(n,i,t*this._origIndex,1-r,t),o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){a.setValue(n,i);break}},saveOriginalState:function(){const e=this.buffer,t=this.valueSize,n=t*this._origIndex;this.binding.getValue(e,n);for(let i=t,r=n;i!==r;++i)e[i]=e[n+i%t];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_setAdditiveIdentityNumeric:function(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]},_select:function(e,t,n,i,r){if(i>=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]},_slerp:function(e,t,n,i){Quaternion.slerpFlat(e,t,e,t,e,n,i)},_slerpAdditive:function(e,t,n,i,r){const o=this._workIndex*r;Quaternion.multiplyQuaternionsFlat(e,o,e,t,e,n),Quaternion.slerpFlat(e,t,e,t,e,o,i)},_lerp:function(e,t,n,i,r){const o=1-i;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*o+e[n+a]*i}},_lerpAdditive:function(e,t,n,i,r){for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]+e[n+o]*i}}});const _RESERVED_CHARS_RE="\\[\\]\\.:\\/",_reservedRe=new RegExp("["+_RESERVED_CHARS_RE+"]","g"),_wordChar="[^"+_RESERVED_CHARS_RE+"]",_wordCharOrDot="[^"+_RESERVED_CHARS_RE.replace("\\.","")+"]",_directoryRe=/((?:WC+[\/:])*)/.source.replace("WC",_wordChar),_nodeRe=/(WCOD+)?/.source.replace("WCOD",_wordCharOrDot),_objectRe=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",_wordChar),_propertyRe=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",_wordChar),_trackRe=new RegExp("^"+_directoryRe+_nodeRe+_objectRe+_propertyRe+"$"),_supportedObjectNames=["material","materials","bones"];function Composite(e,t,n){const i=n||PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}function PropertyBinding(e,t,n){this.path=t,this.parsedPath=n||PropertyBinding.parseTrackName(t),this.node=PropertyBinding.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function AnimationObjectGroup(){this.uuid=MathUtils.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}Object.assign(Composite.prototype,{getValue:function(e,t){this.bind();const n=this._bindings[this._targetGroup.nCachedObjects_];void 0!==n&&n.getValue(e,t)},setValue:function(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)},bind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()},unbind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}),Object.assign(PropertyBinding,{Composite:Composite,create:function(e,t,n){return e&&e.isAnimationObjectGroup?new PropertyBinding.Composite(e,t,n):new PropertyBinding(e,t,n)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(_reservedRe,"")},parseTrackName:function(e){const t=_trackRe.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==_supportedObjectNames.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n},findNode:function(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i<e.length;i++){const r=e[i];if(r.name===t||r.uuid===t)return r;const o=n(r.children);if(o)return o}return null},i=n(e.children);if(i)return i}return null}}),Object.assign(PropertyBinding.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function e(t,n){t[n]=this.node[this.propertyName]},function e(t,n){const i=this.resolvedProperty;for(let e=0,r=i.length;e!==r;++e)t[n++]=i[e]},function e(t,n){t[n]=this.resolvedProperty[this.propertyIndex]},function e(t,n){this.resolvedProperty.toArray(t,n)}],SetterByBindingTypeAndVersioning:[[function e(t,n){this.targetObject[this.propertyName]=t[n]},function e(t,n){this.targetObject[this.propertyName]=t[n],this.targetObject.needsUpdate=!0},function e(t,n){this.targetObject[this.propertyName]=t[n],this.targetObject.matrixWorldNeedsUpdate=!0}],[function e(t,n){const i=this.resolvedProperty;for(let e=0,r=i.length;e!==r;++e)i[e]=t[n++]},function e(t,n){const i=this.resolvedProperty;for(let e=0,r=i.length;e!==r;++e)i[e]=t[n++];this.targetObject.needsUpdate=!0},function e(t,n){const i=this.resolvedProperty;for(let e=0,r=i.length;e!==r;++e)i[e]=t[n++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function e(t,n){this.resolvedProperty[this.propertyIndex]=t[n]},function e(t,n){this.resolvedProperty[this.propertyIndex]=t[n],this.targetObject.needsUpdate=!0},function e(t,n){this.resolvedProperty[this.propertyIndex]=t[n],this.targetObject.matrixWorldNeedsUpdate=!0}],[function e(t,n){this.resolvedProperty.fromArray(t,n)},function e(t,n){this.resolvedProperty.fromArray(t,n),this.targetObject.needsUpdate=!0},function e(t,n){this.resolvedProperty.fromArray(t,n),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function e(t,n){this.bind(),this.getValue(t,n)},setValue:function e(t,n){this.bind(),this.setValue(t,n)},bind:function(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=PropertyBinding.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let i=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===i){i=t;break}break;default:if(void 0===e[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==i){if(void 0===e[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[i]}}const o=e[i];if(void 0===o)return void console.error("THREE.PropertyBinding: Trying to update property for track: "+t.nodeName+"."+i+" but it wasn't found.",e);let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let s=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}s=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else void 0!==o.fromArray&&void 0!==o.toArray?(s=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(s=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[s],this.setValue=this.SetterByBindingTypeAndVersioning[s][a]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(PropertyBinding.prototype,{_getValue_unbound:PropertyBinding.prototype.getValue,_setValue_unbound:PropertyBinding.prototype.setValue}),Object.assign(AnimationObjectGroup.prototype,{isAnimationObjectGroup:!0,add:function(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,o=r.length;let a,s=e.length,l=this.nCachedObjects_;for(let c=0,h=arguments.length;c!==h;++c){const h=arguments[c],u=h.uuid;let d=t[u];if(void 0===d){d=s++,t[u]=d,e.push(h);for(let e=0,t=o;e!==t;++e)r[e].push(new PropertyBinding(h,n[e],i[e]))}else if(d<l){a=e[d];const s=--l,c=e[s];t[c.uuid]=d,e[d]=c,t[u]=s,e[s]=h;for(let e=0,t=o;e!==t;++e){const t=r[e];let o=t[d];t[d]=t[s],void 0===o&&(o=new PropertyBinding(h,n[e],i[e])),t[s]=o}}else e[d]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l},remove:function(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o],s=a.uuid,l=t[s];if(void 0!==l&&l>=r){const o=r++,c=e[o];t[c.uuid]=l,e[l]=c,t[s]=o,e[o]=a;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[l];t[l]=t[o],t[o]=i}}}this.nCachedObjects_=r},uncache:function(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=t[s];if(void 0!==l)if(delete t[s],l<r){const a=--r,s=e[a],c=--o,h=e[c];t[s.uuid]=l,e[l]=s,t[h.uuid]=a,e[a]=h,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[c];t[l]=t[a],t[a]=i,t.pop()}}else{const r=--o,a=e[r];r>0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r},subscribe_:function(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const o=this._paths,a=this._parsedPaths,s=this._objects,l=this.nCachedObjects_,c=new Array(s.length);i=r.length,n[e]=i,o.push(e),a.push(t),r.push(c);for(let n=l,i=s.length;n!==i;++n)c[n]=new PropertyBinding(s[n],e,t);return c},unsubscribe_:function(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];t[e[a]]=n,o[n]=s,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}});class AnimationAction{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,o=r.length,a=new Array(o),s={endingStart:ZeroCurvatureEnding,endingEnd:ZeroCurvatureEnding};for(let e=0;e!==o;++e){const t=r[e].createInterpolant(null);a[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=LoopRepeat,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,i=e._clip.duration,r=n/i;e.warp(1,i/n,t),this.warp(r,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=r,s[1]=r+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*n;if(i<0||0===n)return;this._startTime=null,t=n*i}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case AdditiveAnimationBlendMode:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(o),t[n].accumulateAdditive(a);break;case NormalAnimationBlendMode:default:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(o),t[n].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const o=n===LoopPingPong;if(0===e)return-1===r?i:o&&1==(1&r)?t-i:i;if(n===LoopOnce){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(o&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=ZeroSlopeEnding,i.endingEnd=ZeroSlopeEnding):(i.endingStart=e?this.zeroSlopeAtStart?ZeroSlopeEnding:ZeroCurvatureEnding:WrapAroundEnding,i.endingEnd=t?this.zeroSlopeAtEnd?ZeroSlopeEnding:ZeroCurvatureEnding:WrapAroundEnding)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,s=o.sampleValues;return a[0]=r,s[0]=t,a[1]=r+e,s[1]=n,this}}function AnimationMixer(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}AnimationMixer.prototype=Object.assign(Object.create(EventDispatcher.prototype),{constructor:AnimationMixer,_bindAction:function(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let e=0;e!==r;++e){const r=i[e],l=r.name;let h=c[l];if(void 0!==h)o[e]=h;else{if(h=o[e],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,s,l));continue}h=new PropertyMixer(PropertyBinding.create(n,l,t&&t._propertyBindings[e].binding.parsedPath),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,s,l),o[e]=h}a[e].resultBuffer=h.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){const t=e._cacheIndex;return null!==t&&t<this._nActiveActions},_addInactiveAction:function(e,t,n){const i=this._actions,r=this._actionsByClip;let o=r[t];if(void 0===o)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const t=o.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e},_removeInactiveAction:function(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],s=a.knownActions,l=s[s.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,s[c]=l,s.pop(),e._byClipCacheIndex=null,delete a.actionByRoot[(e._localRoot||this._root).uuid],0===s.length&&delete o[r],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.referenceCount&&this._removeInactiveBinding(n)}},_lendAction:function(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r},_takeBackAction:function(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r},_addInactiveBinding:function(e,t,n){const i=this._bindingsByRootAndName,r=this._bindings;let o=i[t];void 0===o&&(o={},i[t]=o),o[n]=e,e._cacheIndex=r.length,r.push(e)},_removeInactiveBinding:function(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete a[r],0===Object.keys(a).length&&delete o[i]},_lendBinding:function(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r},_takeBackBinding:function(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r},_lendControlInterpolant:function(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&(n=new LinearInterpolant(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),n.__cacheIndex=t,e[t]=n),n},_takeBackControlInterpolant:function(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,t,n){const i=t||this._root,r=i.uuid;let o="string"==typeof e?AnimationClip.findByName(i,e):e;const a=null!==o?o.uuid:e,s=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==o?o.blendMode:NormalAnimationBlendMode),void 0!==s){const e=s.actionByRoot[r];if(void 0!==e&&e.blendMode===n)return e;l=s.knownActions[0],null===o&&(o=l._clip)}if(null===o)return null;const c=new AnimationAction(this,o,t,n);return this._bindAction(c,l),this._addInactiveAction(c,a,r),c},existingAction:function(e,t){const n=t||this._root,i=n.uuid,r="string"==typeof e?AnimationClip.findByName(n,e):e,o=this._actionsByClip[r?r.uuid:e];return void 0!==o&&o.actionByRoot[i]||null},stopAllAction:function(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this},update:function(e){const t=this._actions,n=this._nActiveActions,i=this.time+=e*=this.timeScale,r=Math.sign(e),o=this._accuIndex^=1;for(let a=0;a!==n;++a)t[a]._update(i,e,r,o);const a=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)a[e].apply(o);return this},setTime:function(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)},getRoot:function(){return this._root},uncacheClip:function(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const e=r.knownActions;for(let n=0,i=e.length;n!==i;++n){const i=e[n];this._deactivateAction(i);const r=i._cacheIndex,o=t[t.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,o._cacheIndex=r,t[r]=o,t.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}},uncacheRoot:function(e){const t=e.uuid,n=this._actionsByClip;for(const e in n){const i=n[e].actionByRoot[t];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[t];if(void 0!==i)for(const e in i){const t=i[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}},uncacheAction:function(e,t){const n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}});class Uniform{constructor(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Uniform(void 0===this.value.clone?this.value:this.value.clone())}}function InstancedInterleavedBuffer(e,t,n){InterleavedBuffer.call(this,e,t),this.meshPerAttribute=n||1}function GLBufferAttribute(e,t,n,i,r){this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}function Raycaster(e,t,n,i){this.ray=new Ray(e,t),this.near=n||0,this.far=i||1/0,this.camera=null,this.layers=new Layers,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function ascSort(e,t){return e.distance-t.distance}function intersectObject(e,t,n,i){if(e.layers.test(t.layers)&&e.raycast(t,n),!0===i){const i=e.children;for(let e=0,r=i.length;e<r;e++)intersectObject(i[e],t,n,!0)}}InstancedInterleavedBuffer.prototype=Object.assign(Object.create(InterleavedBuffer.prototype),{constructor:InstancedInterleavedBuffer,isInstancedInterleavedBuffer:!0,copy:function(e){return InterleavedBuffer.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},clone:function(e){const t=InterleavedBuffer.prototype.clone.call(this,e);return t.meshPerAttribute=this.meshPerAttribute,t},toJSON:function(e){const t=InterleavedBuffer.prototype.toJSON.call(this,e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}),Object.defineProperty(GLBufferAttribute.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(GLBufferAttribute.prototype,{isGLBufferAttribute:!0,setBuffer:function(e){return this.buffer=e,this},setType:function(e,t){return this.type=e,this.elementSize=t,this},setItemSize:function(e){return this.itemSize=e,this},setCount:function(e){return this.count=e,this}}),Object.assign(Raycaster.prototype,{set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)},intersectObject:function(e,t,n){const i=n||[];return intersectObject(e,this,i,t),i.sort(ascSort),i},intersectObjects:function(e,t,n){const i=n||[];if(!1===Array.isArray(e))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),i;for(let n=0,r=e.length;n<r;n++)intersectObject(e[n],this,i,t);return i.sort(ascSort),i}});class Spherical{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}clone(){return(new this.constructor).copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(MathUtils.clamp(t/this.radius,-1,1))),this}}const _vector$8=new Vector2;class Box2{constructor(e,t){Object.defineProperty(this,"isBox2",{value:!0}),this.min=void 0!==e?e:new Vector2(1/0,1/0),this.max=void 0!==t?t:new Vector2(-1/0,-1/0)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=_vector$8.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return void 0===e&&(console.warn("THREE.Box2: .getCenter() target is now required"),e=new Vector2),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return void 0===e&&(console.warn("THREE.Box2: .getSize() target is now required"),e=new Vector2),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new Vector2),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new Vector2),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return _vector$8.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}function ImmediateRenderObject(e){Object3D.call(this),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}ImmediateRenderObject.prototype=Object.create(Object3D.prototype),ImmediateRenderObject.prototype.constructor=ImmediateRenderObject,ImmediateRenderObject.prototype.isImmediateRenderObject=!0;class AxesHelper extends LineSegments{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new BufferGeometry;n.setAttribute("position",new Float32BufferAttribute(t,3)),n.setAttribute("color",new Float32BufferAttribute([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new LineBasicMaterial({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}}const backgroundMaterial=new MeshBasicMaterial({side:BackSide,depthWrite:!1,depthTest:!1});function Spline(e){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),CatmullRomCurve3.call(this,e),this.type="catmullrom"}new Mesh(new BoxGeometry,backgroundMaterial),Curve.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Curve.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(Path.prototype,{fromPoints:function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)}}),Spline.prototype=Object.create(CatmullRomCurve3.prototype),Object.assign(Spline.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),Object.assign(Loader.prototype,{extractUrlBase:function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),LoaderUtils.extractUrlBase(e)}}),Loader.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(Box2.prototype,{center:function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},size:function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(Box3.prototype,{center:function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionSphere:function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},size:function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(Sphere.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}}),Frustum.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Object.assign(MathUtils,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(e){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),MathUtils.floorPowerOfTwo(e)},nextPowerOfTwo:function(e){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),MathUtils.ceilPowerOfTwo(e)}}),Object.assign(Matrix3.prototype,{flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},multiplyVector3:function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},getInverse:function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()}}),Object.assign(Matrix4.prototype,{extractPosition:function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new Vector3).setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector4:function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},crossVector:function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(e,t,n,i,r,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,i,n,r,o)},getInverse:function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()}}),Plane.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},Object.assign(Quaternion.prototype,{multiplyVector3:function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},inverse:function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()}}),Object.assign(Ray.prototype,{isIntersectionBox:function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionPlane:function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},isIntersectionSphere:function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}),Object.assign(Triangle.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},midpoint:function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},normal:function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},plane:function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)}}),Object.assign(Triangle,{barycoordFromPoint:function(e,t,n,i,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Triangle.getBarycoord(e,t,n,i,r)},normal:function(e,t,n,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Triangle.getNormal(e,t,n,i)}}),Object.assign(Shape.prototype,{extractAllPoints:function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},extrude:function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new ExtrudeGeometry(this,e)},makeGeometry:function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new ShapeGeometry(this,e)}}),Object.assign(Vector2.prototype,{fromAttribute:function(e,t,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},distanceToManhattan:function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Vector3.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},applyProjection:function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},fromAttribute:function(e,t,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},distanceToManhattan:function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Vector4.prototype,{fromAttribute:function(e,t,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Object3D.prototype,{getChildByName:function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(Object3D.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(Mesh.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(Mesh.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),TrianglesDrawMode},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(LOD.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Skeleton.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),SkinnedMesh.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Curve.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),PerspectiveCamera.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Light.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(BufferAttribute.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===DynamicDrawUsage},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(DynamicDrawUsage)}}}),Object.assign(BufferAttribute.prototype,{setDynamic:function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?DynamicDrawUsage:StaticDrawUsage),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(BufferGeometry.prototype,{addIndex:function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},addAttribute:function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new BufferAttribute(arguments[1],arguments[2])))},addDrawCall:function(e,t,n){void 0!==n&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},applyMatrix:function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(BufferGeometry.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(InstancedBufferGeometry.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(e){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=e}}}),Object.defineProperties(Raycaster.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(e){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=e}}}),Object.defineProperties(InterleavedBuffer.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===DynamicDrawUsage},set:function(e){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(e)}}}),Object.assign(InterleavedBuffer.prototype,{setDynamic:function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?DynamicDrawUsage:StaticDrawUsage),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(ExtrudeGeometry.prototype,{getArrays:function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")}}),Object.assign(Scene.prototype,{dispose:function(){console.error("THREE.Scene: .dispose() has been removed.")}}),Object.defineProperties(Uniform.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(Material.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Color}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=e===FlatShading}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(MeshPhongMaterial.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(MeshPhysicalMaterial.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(e){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=e}}}),Object.defineProperties(ShaderMaterial.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.assign(WebGLRenderer.prototype,{clearTarget:function(e,t,n,i){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,n,i)},animate:function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(WebGLRenderer.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?sRGBEncoding:LinearEncoding}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(WebGLShadowMap.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(WebGLRenderTarget.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Object.defineProperties(Audio.prototype,{load:{value:function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new AudioLoader).load(e,(function(e){t.setBuffer(e)})),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}}),CubeCamera.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},CubeCamera.prototype.clear=function(e,t,n,i){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,n,i)},ImageUtils.crossOrigin=void 0,ImageUtils.loadTexture=function(e,t,n,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new TextureLoader;r.setCrossOrigin(this.crossOrigin);const o=r.load(e,n,void 0,i);return t&&(o.mapping=t),o},ImageUtils.loadTextureCube=function(e,t,n,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new CubeTextureLoader;r.setCrossOrigin(this.crossOrigin);const o=r.load(e,n,void 0,i);return t&&(o.mapping=t),o},ImageUtils.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},ImageUtils.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:REVISION}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=REVISION);const WARNING_DURATION_MS=1e4;let dom=null,msgId=0,numActiveMessages=0;function setDomContainer(e){dom=e}function setModalMessage(e,t=null,n=null,i=!1){if(null==dom)return void console.warn("Can't show modal message before the dom is initialized");null==t&&(t=(msgId++).toString());let r=dom.shadowRoot.querySelector("#notification-dialog");r.querySelector(".close-button").style.display=i?null:"none";let o=r.querySelector(".progress");o.style.display=i?"none":null,o.active=!i||null,r.querySelector("#notification-title").textContent=n;let a=r.querySelector("#notify-msgs");if(i)a.textContent="";else{const e=a.querySelectorAll(".error");for(let t=0;t<e.length;t++)a.removeChild(e[t])}let s=`notify-msg-${t}`,l=r.querySelector("#"+s);return null==l&&(l=document.createElement("div"),l.className="notify-msg "+(i?"error":""),l.id=s,a.insertBefore(l,a.firstChild),i?numActiveMessages=0:numActiveMessages++),null==e?(numActiveMessages--,0===numActiveMessages&&r.close(),l.remove()):(l.innerText=e,r.open()),t}function setErrorMessage(e,t){setModalMessage(e,null,"Error "+(null!=t?t:""),!0)}function setWarningMessage(e){let t=dom.shadowRoot.querySelector("#toast");t.text=e,t.duration=WARNING_DURATION_MS,t.open()}const TASK_DELAY_MS=200;function shuffle(e){let t,n,i=e.length;for(;i;)n=Math.floor(Math.random()*i--),t=e[i],e[i]=e[n],e[n]=t;return e}function range(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}function classed(e,t,n){const i=e.className.split(" ");if(n){if(t in i)return;i.push(t)}else{const e=i.indexOf(t);if(-1===e)return;i.splice(e,1)}e.className=i.join(" ")}function vector3DToScreenCoords(e,t,n,i){let r=window.devicePixelRatio,o=(new Vector3).copy(i).project(e);return[(o.x+1)/2*t*r,-(o.y-1)/2*n*r]}function vector3FromPackedArray(e,t){const n=3*t;return new Vector3(e[n],e[n+1],e[n+2])}function getNearFarPoints(e,t,n){let i=1/0,r=0;const o=(new Vector3).copy(n).sub(t),a=(new Vector3).copy(o).normalize(),s=e.length/3;let l=0,c=new Vector3,h=new Vector3;for(let n=0;n<s;n++){c.x=e[l],c.y=e[l+1],c.z=e[l+2],l+=3,h.copy(c).sub(t);const n=a.dot(h);n<0||(r=n>r?n:r,i=n<i?n:i)}return[i,r]}function createTexture(e){let t=new Texture(e);return t.needsUpdate=!0,t.minFilter=LinearFilter,t.generateMipmaps=!1,t.flipY=!1,t}function assert(e,t){if(!e)throw t=t||"Assertion failed",new Error(t)}function getSearchPredicate(e,t,n){let i;if(t){let t=new RegExp(e,"i");i=e=>t.test(e.metadata[n].toString())}else e=e.toLowerCase(),i=t=>t.metadata[n].toString().toLowerCase().indexOf(e)>=0;return i}function runAsyncTask(e,t,n=null,i=TASK_DELAY_MS){let r=null==n;return n=setModalMessage(e,n),new Promise(((e,o)=>{setTimeout((()=>{try{let i=t();r&&setModalMessage(null,n),e(i)}catch(e){o(e)}return!0}),i)}))}function getURLParams(e){if(!e)return{};let t=-1!==e.indexOf("?")?e.split("?")[1]:e;t.indexOf("#")&&(t=t.split("#")[0]);const n=t.split("&");let i={};for(let e=0;e<n.length;e++){let t=n[e].split("=");i[t[0].toLowerCase()]=decodeURIComponent(t[1])}return i}const SUBSTR_GEN_TENSORS=["/Adagrad"];function tensorIsGenerated(e){for(let t=0;t<SUBSTR_GEN_TENSORS.length;t++)if(e.indexOf(SUBSTR_GEN_TENSORS[t])>=0)return!0;return!1}function xor(e,t){return(e||t)&&!(e&&t)}function hasWebGLSupport(){return __awaiter(this,void 0,void 0,(function*(){try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");return yield ready(),null!=t&&"webgl"===getBackend()}catch(e){return!1}}))}function dot(e,t){assert(e.length===t.length,"Vectors a and b must be of same length");let n=0;for(let i=0;i<e.length;++i)n+=e[i]*t[i];return n}function sub(e,t){assert(e.length===t.length,"Vectors a and b must be of same length");let n=new Float32Array(e.length);for(let i=0;i<e.length;++i)n[i]=e[i]-t[i];return n}function norm2(e){let t=0;for(let n=0;n<e.length;++n)t+=e[n]*e[n];return t}function dist(e,t){return Math.sqrt(dist2(e,t))}function dist2(e,t){assert(e.length===t.length,"Vectors a and b must be of same length");let n=0;for(let i=0;i<e.length;++i){let r=e[i]-t[i];n+=r*r}return n}function unit(e){let t=Math.sqrt(norm2(e));assert(t>=0,"Norm of the vector must be > 0");for(let n=0;n<e.length;++n)e[n]/=t}function projectRandom(e,t){let n=e[0].length,i=e.length,r=new Array(i);for(let e=0;e<i;++e)r[e]=new Float32Array(t);for(let o=0;o<t;++o){let t=rn(n);for(let n=0;n<i;++n)r[n][o]=dot(e[n],t)}return r}function centroid(e,t){if(0===e.length)return null;null==t&&(t=e=>e),assert(e.length>=0,"`vectors` must be of length >= 1");let n=new Float32Array(t(e[0]).length);for(let i=0;i<e.length;++i){let r=t(e[i]);for(let e=0;e<n.length;++e)n[e]+=r[e]}for(let t=0;t<n.length;++t)n[t]/=e.length;return n}function rn(e){const t=normal();let n=new Float32Array(e);for(let i=0;i<e;++i)n[i]=t();return n}function cosDistNorm(e,t){return 1-dot(e,t)}function cosDist(e,t){return 1-cosSim(e,t)}function cosSim(e,t){return dot(e,t)/Math.sqrt(norm2(e)*norm2(t))}function toTypedArray(e,t){let n=e.length,i=t(e[0]).length,r=new Float32Array(n*i);for(let o=0;o<n;++o){let n=t(e[o]);for(let e=0;e<i;++e)r[o*i+e]=n[e]}return r}const OPTIMAL_GPU_BLOCK_SIZE=256,KNN_GPU_MSG_ID="knn-gpu";function findKNNGPUCosDistNorm(e,t,n){const i=e.length,r=n(e[0]).length,o=new Array(i);let a=Math.ceil(i/OPTIMAL_GPU_BLOCK_SIZE);const s=Math.floor(i/a);a+=i%s?1:0;let l=0,c=0,h=1/(2*a),u=0;const d=tensor(toTypedArray(e,n),[i,r]),p=transpose$2(d),m=matMul(d,p),f=sub$3(1,m);let g=f;s*a>i&&(g=pad(f,[[0,s*a-i],[0,0]]));const v=split(g,new Array(a).fill(s),0);function y(r){runAsyncTask("Finding nearest neighbors: "+(100*c).toFixed()+"%",(()=>__awaiter(this,void 0,void 0,(function*(){const e=yield v[u].data();c+=h;for(let n=0;n<s;n++){let r=new KMin(t),a=l+n;if(a>=i)break;for(let t=0;t<i;t++){if(t===a)continue;const o=e[n*i+t];o>=0&&r.add(o,{index:t,dist:o})}o[a]=r.getMinKItems()}c+=h,l+=s,u++}))),KNN_GPU_MSG_ID).then((()=>{u<a?y(r):(setModalMessage(null,KNN_GPU_MSG_ID),d.dispose(),p.dispose(),m.dispose(),f.dispose(),v.forEach((e=>e.dispose())),r(o))}),(i=>{setModalMessage(null,KNN_GPU_MSG_ID),findKNN(e,t,n,((e,t,n)=>cosDistNorm(e,t))).then((e=>{r(e)}))}))}return new Promise((e=>y(e)))}function findKNN(e,t,n,i){return runAsyncTask("Finding nearest neighbors...",(()=>{let r=e.length,o=new Array(r),a=new Array(r);for(let e=0;e<r;e++)a[e]=new KMin(t);for(let o=0;o<r;o++){let s=n(e[o]),l=a[o];for(let c=o+1;c<r;c++){let r=a[c],h=l.getSize()===t&&l.getLargestKey()||Number.MAX_VALUE,u=r.getSize()===t&&r.getLargestKey()||Number.MAX_VALUE,d=Math.max(h,u),p=i(s,n(e[c]),d);p>=0&&(l.add(p,{index:c,dist:p}),r.add(p,{index:o,dist:p}))}}for(let e=0;e<r;e++)o[e]=a[e].getMinKItems();return o}))}function findKNNofPoint(e,t,n,i,r){let o=new KMin(n),a=i(e[t]);for(let n=0;n<e.length;++n){if(n===t)continue;let s=r(a,i(e[n]));o.add(s,{index:n,dist:s})}return o.getMinKItems()}const IS_FIREFOX=navigator.userAgent.toLowerCase().indexOf("firefox")>=0,TSNE_SAMPLE_SIZE=1e4,UMAP_SAMPLE_SIZE=5e3,PCA_SAMPLE_SIZE=5e4,PCA_SAMPLE_DIM=200,NUM_PCA_COMPONENTS$1=10,UMAP_MSG_ID="umap-optimization",SEQUENCE_METADATA_ATTRS=["__next__","__seq_next__"];function getSequenceNextPointIndex(e){let t=null;for(let n of SEQUENCE_METADATA_ATTRS)if(n in e&&""!==e[n]){t=e[n];break}return null==t?null:+t}class DataSet{constructor(e,t){this.shuffledDataIndices=[],this.projections={},this.tSNEIteration=0,this.tSNEShouldPause=!1,this.tSNEShouldStop=!0,this.superviseInput="",this.dim=[0,0],this.hasTSNERun=!1,this.hasUmapRun=!1,this.points=e,this.shuffledDataIndices=shuffle(range(this.points.length)),this.sequences=this.computeSequences(e),this.dim=[this.points.length,this.points[0].vector.length],this.spriteAndMetadataInfo=t}computeSequences(e){let t=new Int8Array(e.length),n={},i=[];for(let r=0;r<e.length;r++){if(t[r])continue;t[r]=1;let o=getSequenceNextPointIndex(e[r].metadata);if(null==o)continue;if(o in n){let e=n[o];e.pointIndices.unshift(r),n[r]=e;continue}let a={pointIndices:[]};n[r]=a,i.push(a);let s=r;for(;e[s];){a.pointIndices.push(s);let n=getSequenceNextPointIndex(e[s].metadata);null!=n?(t[n]=1,s=n):s=-1}}return i}projectionCanBeRendered(e){return"tsne"!==e||this.tSNEIteration>0}getSubset(e){let t=(null!=e&&e.length>0?e.map((e=>this.points[e])):this.points).map((e=>({metadata:e.metadata,index:e.index,vector:e.vector.slice(),projections:{}})));return new DataSet(t,this.spriteAndMetadataInfo)}normalize(){let e=centroid(this.points,(e=>e.vector));if(null==e)throw Error("centroid should not be null");for(let t=0;t<this.points.length;++t){let n=this.points[t];n.vector=sub(n.vector,e),norm2(n.vector)>0&&unit(n.vector)}}projectLinear(e,t){this.projections[t]=!0,this.points.forEach((n=>{n.projections[t]=dot(n.vector,e)}))}projectPCA(){return null!=this.projections["pca-0"]?Promise.resolve(null):runAsyncTask("Computing PCA...",(()=>{let e=this.points[0].vector.length,t=this.shuffledDataIndices.map((e=>this.points[e].vector));e>PCA_SAMPLE_DIM&&(t=projectRandom(t,PCA_SAMPLE_DIM));const n=t.slice(0,PCA_SAMPLE_SIZE),{dot:i,transpose:r,svd:o}=numeric1_2_6,a=o((0,numeric1_2_6.div)(i(r(n),n),n.length)),s=a.S;let l=0;for(let e=0;e<s.length;++e)l+=s[e];for(let e=0;e<s.length;++e)s[e]/=l;this.fracVariancesExplained=s;let c=a.U,h=t.map((e=>{let t=new Float32Array(NUM_PCA_COMPONENTS$1);for(let n=0;n<NUM_PCA_COMPONENTS$1;n++){let i=0;for(let t=0;t<e.length;t++)i+=e[t]*c[t][n];t[n]=i}return t}));for(let e=0;e<NUM_PCA_COMPONENTS$1;e++){let t="pca-"+e;this.projections[t]=!0;for(let n=0;n<h.length;n++)this.points[this.shuffledDataIndices[n]].projections[t]=h[n][e]}}))}projectTSNE(e,t,n,i){this.hasTSNERun=!0;let r=Math.floor(3*e);this.tsne=new TSNE({epsilon:t,perplexity:e,dim:n}),this.tsne.setSupervision(this.superviseLabels,this.superviseInput),this.tsne.setSuperviseFactor(this.superviseFactor),this.tSNEShouldPause=!1,this.tSNEShouldStop=!1,this.tSNEIteration=0;let o=this.shuffledDataIndices.slice(0,TSNE_SAMPLE_SIZE),a=()=>{if(this.tSNEShouldStop)return this.projections.tsne=!1,i(null),this.tsne=null,void(this.hasTSNERun=!1);if(!this.tSNEShouldPause){this.tsne.step();let e=this.tsne.getSolution();o.forEach(((t,i)=>{let r=this.points[t];r.projections["tsne-0"]=e[i*n+0],r.projections["tsne-1"]=e[i*n+1],3===n&&(r.projections["tsne-2"]=e[i*n+2])})),this.projections.tsne=!0,this.tSNEIteration++,i(this.tSNEIteration)}requestAnimationFrame(a)};const s=o.map((e=>this.points[e]));this.computeKnn(s,r).then((e=>{runAsyncTask("Initializing T-SNE...",(()=>{this.tsne.initDataDist(e)})).then(a)}))}projectUmap(e,t,n){return __awaiter(this,void 0,void 0,(function*(){this.hasUmapRun=!0,this.umap=new dist$1.UMAP({nComponents:e,nNeighbors:t});let i=0;const r=this.shuffledDataIndices.slice(0,UMAP_SAMPLE_SIZE),o=r.map((e=>this.points[e])),a=o.map((e=>Array.from(e.vector))),s=yield this.computeKnn(o,t),l=yield runAsyncTask("Initializing UMAP...",(()=>{const e=s.map((e=>e.map((e=>e.index)))),t=s.map((e=>e.map((e=>e.dist))));return this.umap.setPrecomputedKNN(e,t),this.umap.initializeFit(a)}),UMAP_MSG_ID);return new Promise(((t,o)=>{const a=()=>{const s=Math.min(10,l-i);for(let e=0;e<s;e++)i=this.umap.step();runAsyncTask(`Optimizing UMAP (epoch ${i} of ${l})`,(()=>{if(i<l)requestAnimationFrame(a);else{const o=this.umap.getEmbedding();r.forEach(((t,n)=>{const i=this.points[t];i.projections["umap-0"]=o[n][0],i.projections["umap-1"]=o[n][1],3===e&&(i.projections["umap-2"]=o[n][2])})),this.projections.umap=!0,setModalMessage(null,UMAP_MSG_ID),this.hasUmapRun=!0,n(i),t()}}),UMAP_MSG_ID,0).catch((e=>{setModalMessage(null,UMAP_MSG_ID),o(e)}))};requestAnimationFrame(a)}))}))}computeKnn(e,t){return __awaiter(this,void 0,void 0,(function*(){if(null!=this.nearest&&this.nearest.length>=e.length&&(this.nearest&&this.nearest.length?this.nearest[0].length:0)>=t)return Promise.resolve(this.nearest.slice(0,e.length).map((e=>e.slice(0,t))));{const n=(yield hasWebGLSupport())&&!IS_FIREFOX,i=yield n?findKNNGPUCosDistNorm(e,t,(e=>e.vector)):findKNN(e,t,(e=>e.vector),((e,t)=>cosDistNorm(e,t)));return this.nearest=i,Promise.resolve(i)}}))}perturbTsne(){if(this.hasTSNERun&&this.tsne){this.tsne.perturb();let e=this.tsne.getDim(),t=this.tsne.getSolution();this.shuffledDataIndices.slice(0,TSNE_SAMPLE_SIZE).forEach(((n,i)=>{let r=this.points[n];r.projections["tsne-0"]=t[i*e+0],r.projections["tsne-1"]=t[i*e+1],3===e&&(r.projections["tsne-2"]=t[i*e+2])}))}}setSupervision(e,t){null!=e&&(this.superviseLabels=this.shuffledDataIndices.slice(0,TSNE_SAMPLE_SIZE).map((t=>void 0!==this.points[t].metadata[e]?String(this.points[t].metadata[e]):`Unknown #${t}`))),null!=t&&(this.superviseInput=t),this.tsne&&this.tsne.setSupervision(this.superviseLabels,this.superviseInput)}setSuperviseFactor(e){null!=e&&(this.superviseFactor=e,this.tsne&&this.tsne.setSuperviseFactor(e))}mergeMetadata(e){if(e.pointsInfo.length!==this.points.length){let t=`Number of tensors (${this.points.length}) do not match the number of lines in metadata (${e.pointsInfo.length}).`;if(1===e.stats.length&&this.points.length+1===e.pointsInfo.length)return setErrorMessage(t+" Single column metadata should not have a header row.","merging metadata"),!1;if(e.stats.length>1&&this.points.length-1===e.pointsInfo.length)return setErrorMessage(t+" Multi-column metadata should have a header row with column labels.","merging metadata"),!1;setWarningMessage(t)}return this.spriteAndMetadataInfo=e,e.pointsInfo.slice(0,this.points.length).forEach(((e,t)=>this.points[t].metadata=e)),!0}stopTSNE(){this.tSNEShouldStop=!0}findNeighbors(e,t,n){return findKNNofPoint(this.points,e,n,(e=>e.vector),t).slice(0,n)}query(e,t,n){let i=getSearchPredicate(e,t,n),r=[];return this.points.forEach(((e,t)=>{i(e)&&r.push(t)})),r}}class Projection{constructor(e,t,n,i){this.projectionType=e,this.projectionComponents=t,this.dimensionality=n,this.dataSet=i}}class State{constructor(){this.label="",this.isSelected=!1,this.tSNEIteration=0,this.tSNEPerplexity=0,this.tSNELearningRate=0,this.tSNEis3d=!0,this.umapIs3d=!0,this.umapNeighbors=15,this.pcaComponentDimensions=[],this.projections=[],this.selectedPoints=[]}}function getProjectionComponents(e,t){if(t.length>3)throw new RangeError("components length must be <= 3");const n=[null,null,null],i="custom"===e?"linear":e;for(let e=0;e<t.length;++e)null!=t[e]&&(n[e]=i+"-"+t[e]);return n}function stateGetAccessorDimensions(e){let t;switch(e.selectedProjection){case"pca":t=e.pcaComponentDimensions.slice();break;case"tsne":t=[0,1],e.tSNEis3d&&t.push(2);break;case"umap":t=[0,1],e.umapIs3d&&t.push(2);break;case"custom":t=["x","y"];break;default:throw new Error("Unexpected fallthrough")}return t}let MetadataCard=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.hasMetadata=!1,this.isCollapsed=!1,this.collapseIcon="expand-less"}_toggleMetadataContainer(){this.$$("#metadata-container").toggle(),this.isCollapsed=!this.isCollapsed,this.set("collapseIcon",this.isCollapsed?"expand-more":"expand-less")}updateMetadata(e){if(this.pointMetadata=e,this.hasMetadata=null!=e,e){let t=[];for(let n in e)e.hasOwnProperty(n)&&t.push({key:n,value:e[n]});this.metadata=t,this.label=""+this.pointMetadata[this.labelOption]}}setLabelOption(e){this.labelOption=e,this.pointMetadata&&(this.label=""+this.pointMetadata[this.labelOption])}};MetadataCard.template=html` <style> #metadata-card { background-color: rgba(255, 255, 255, 0.9); box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2); width: 270px; } #header { background: #e9e9e9; } #icon-container { position: absolute; right: 0; top: 4px; } #metadata-label { font-weight: 400; font-size: 14px; line-height: 24px; padding: 12px 12px 8px; width: 230px; overflow-wrap: break-word; } #metadata-table { display: table; padding: 8px 12px 4px; } .metadata-row { display: table-row; } .metadata-key { font-weight: bold; } .metadata-key, .metadata-value { display: table-cell; font-size: 12px; padding: 3px 3px; } .metadata-value { word-wrap: anywhere; /* Firefox only -- word-wrap DNE in Chrome. anywhere DNE in Chrome */ word-break: break-word; /* break-word DNE in Firefox */ } </style> <template is="dom-if" if="[[hasMetadata]]"> <div id="metadata-card"> <div id="icon-container"> <paper-icon-button icon="[[collapseIcon]]" on-tap="_toggleMetadataContainer" > </paper-icon-button> </div> <div id="header"> <div id="metadata-label">[[label]]</div> </div> <iron-collapse id="metadata-container" opened> <div id="metadata-table"> <template is="dom-repeat" items="[[metadata]]"> <div class="metadata-row"> <div class="metadata-key">[[item.key]]</div> <div class="metadata-value">[[item.value]]</div> </div> </template> </div> </iron-collapse> </div> </template> `,__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],MetadataCard.prototype,"hasMetadata",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],MetadataCard.prototype,"isCollapsed",void 0),__decorate([property({type:String}),__metadata("design:type",String)],MetadataCard.prototype,"collapseIcon",void 0),__decorate([property({type:Array}),__metadata("design:type",Array)],MetadataCard.prototype,"metadata",void 0),__decorate([property({type:String}),__metadata("design:type",String)],MetadataCard.prototype,"label",void 0),MetadataCard=__decorate([customElement("vz-projector-metadata-card")],MetadataCard);const NUM_COLORS_COLOR_MAP=50,MAX_SPRITE_IMAGE_SIZE_PX=8192,METADATA_MSG_ID="metadata",TENSORS_MSG_ID="tensors";function retrieveTensorAsBytes(e,t,n,i,r,o){setModalMessage("Fetching tensor values...",TENSORS_MSG_ID);let a=new XMLHttpRequest;a.open("GET",r),a.responseType="arraybuffer",a.onprogress=e=>{e.lengthComputable&&setModalMessage("Fetching tensor values: "+(100*e.loaded/e.total).toFixed(1)+"%",TENSORS_MSG_ID)},a.onload=()=>{if(200!==a.status)return void setErrorMessage(String.fromCharCode.apply(null,new Uint8Array(a.response)),"fetching tensors");let e;try{e=new Float32Array(a.response)}catch(e){return void setErrorMessage(e,"parsing tensor bytes")}let n=t.tensorShape[1],i=e.length/n;t.tensorShape[0]>i&&setWarningMessage(`Showing the first ${i.toLocaleString()} of ${t.tensorShape[0].toLocaleString()} data points`),parseTensorsFromFloat32Array(e,n).then((e=>{o(new DataSet(e))}))},a.send()}function parseRawTensors(e,t){parseTensors(e).then((e=>{t(new DataSet(e))}))}function parseRawMetadata(e,t){parseMetadata(e).then((e=>t(e)))}function streamParse(e,t,n=1e6,i="\n"){return new Promise(((r,o)=>{let a=0,s=e.byteLength-1,l="";function c(e){a+=n;let o=e.split(i),c=l+o[0];if(1===o.length)return l=c,void h(a,n);l=o[o.length-1],t(c);for(let e=1;e<o.length-1;e++)t(o[e]);if(a>=s)return l&&t(l),void r();h(a,n)}function h(t,n){const i=e.slice(t,t+n),r=new Blob([i]),o=new FileReader;o.onload=e=>c(e.target.result),o.readAsText(r)}h(a,n)}))}function parseTensors(e,t="\t"){return setModalMessage("Parsing tensors...",TENSORS_MSG_ID),new Promise(((n,i)=>{const r=[];let o;streamParse(e,(e=>{if(""===(e=e.trim()))return;const n=e.split(t),i={metadata:{},vector:null,index:r.length,projections:null};if(isNaN(n[0])||o===n.length-1?(i.metadata.label=n[0],i.vector=new Float32Array(n.slice(1).map(Number))):i.vector=new Float32Array(n.map(Number)),r.push(i),null==o&&(o=i.vector.length),o!==i.vector.length)throw setModalMessage("Parsing failed. Vector dimensions do not match"),Error("Parsing failed");if(o<=1)throw setModalMessage("Parsing failed. Found a vector with only one dimension?"),Error("Parsing failed")})).then((()=>{setModalMessage(null,TENSORS_MSG_ID),n(r)}))}))}function parseTensorsFromFloat32Array(e,t){return runAsyncTask("Parsing tensors...",(()=>{const n=e.length/t,i=[];let r=0;for(let o=0;o<n;++o)i.push({metadata:{},vector:e.subarray(r,r+t),index:o,projections:null}),r+=t;return i}),TENSORS_MSG_ID).then((e=>(setModalMessage(null,TENSORS_MSG_ID),e)))}function analyzeMetadata(e,t){const n=e.map((e=>({name:e,isNumeric:!0,tooManyUniqueValues:!1,min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY}))),i=e.map((()=>new Object));return t.forEach((t=>{e.forEach(((e,r)=>{const o=n[r],a=i[r],s=t[e];null!=s&&(o.tooManyUniqueValues||(s in a?a[s]++:a[s]=1,Object.keys(a).length>NUM_COLORS_COLOR_MAP&&(o.tooManyUniqueValues=!0)),isNaN(s)?o.isNumeric=!1:(t[e]=+s,o.min=Math.min(o.min,+s),o.max=Math.max(o.max,+s)))}))})),n.forEach(((e,t)=>{e.uniqueEntries=Object.keys(i[t]).map((e=>({label:e,count:i[t][e]})))})),n}function parseMetadata(e){return setModalMessage("Parsing metadata...",METADATA_MSG_ID),new Promise(((t,n)=>{let i=[],r=!1,o=0,a=["label"];streamParse(e,(e=>{if(0===e.trim().length)return;if(0===o&&(r=e.indexOf("\t")>=0,r))return a=e.split("\t"),void o++;o++;let t=e.split("\t"),n={};i.push(n),a.forEach(((e,i)=>{let r=t[i];r=""===r?null:r,n[e]=r}))})).then((()=>{setModalMessage(null,METADATA_MSG_ID),t({stats:analyzeMetadata(a,i),pointsInfo:i})}))}))}function fetchImage(e){return new Promise(((t,n)=>{let i=new Image;i.onload=()=>t(i),i.onerror=e=>n(e),i.crossOrigin="",i.src=e}))}function retrieveSpriteAndMetadataInfo(e,t,n,i){let r=Promise.resolve({});e&&(r=new Promise(((t,n)=>{setModalMessage("Fetching metadata...",METADATA_MSG_ID);const i=new XMLHttpRequest;i.open("GET",e),i.responseType="arraybuffer",i.onreadystatechange=()=>{if(4===i.readyState)if(200===i.status)t(parseMetadata(i.response));else{const e=new FileReader;e.onload=()=>{setErrorMessage(e.result,"fetching metadata"),n()},e.readAsText(new Blob([i.response]))}},i.send(null)})));let o=null,a=null;t&&(o=setModalMessage("Fetching sprite image..."),a=fetchImage(t)),Promise.all([r,a]).then((e=>{o&&setModalMessage(null,o);const[t,r]=e;if(r&&(r.height>MAX_SPRITE_IMAGE_SIZE_PX||r.width>MAX_SPRITE_IMAGE_SIZE_PX))setModalMessage(`Error: Sprite image of dimensions ${r.width}px x ${r.height}px exceeds maximum dimensions ${MAX_SPRITE_IMAGE_SIZE_PX}px x ${MAX_SPRITE_IMAGE_SIZE_PX}px`);else{t.spriteImage=r,t.spriteMetadata=n;try{i(t)}catch(e){setModalMessage(String(e))}}}))}const BYTES_EXTENSION=".bytes";class DemoDataProvider{constructor(e){this.projectorConfigPath=e}getEmbeddingInfo(e){let t=this.projectorConfig.embeddings;for(let n=0;n<t.length;n++){let i=t[n];if(i.tensorName===e)return i}return null}retrieveRuns(e){e(["Demo"])}retrieveProjectorConfig(e,t){const n=setModalMessage("Fetching projector config..."),i=new XMLHttpRequest;i.open("GET",this.projectorConfigPath),i.onerror=e=>{let t=e.message;null!=i.responseText&&(t="Cannot fetch projector config, possibly a Cross-Origin request error."),setErrorMessage(t,"fetching projector config")},i.onload=()=>{const e=JSON.parse(i.responseText);setModalMessage(null,n),this.projectorConfig=e,t(e)},i.send()}retrieveTensor(e,t,n){let i=this.getEmbeddingInfo(t),r=`${i.tensorPath}`;if(i.tensorPath.substr(-1*BYTES_EXTENSION.length)===BYTES_EXTENSION)retrieveTensorAsBytes(this,this.getEmbeddingInfo(t),e,t,r,n);else{setModalMessage("Fetching tensors...",TENSORS_MSG_ID);const e=new XMLHttpRequest;e.open("GET",r),e.responseType="arraybuffer",e.onerror=()=>{setErrorMessage(e.responseText,"fetching tensors")},e.onload=()=>{parseTensors(e.response).then((e=>{n(new DataSet(e))}))},e.send()}}retrieveSpriteAndMetadata(e,t,n){let i=this.getEmbeddingInfo(t),r=null;i.sprite&&i.sprite.imagePath&&(r=i.sprite.imagePath),retrieveSpriteAndMetadataInfo(i.metadataPath,r,i.sprite,n)}getBookmarks(e,t,n){let i=this.getEmbeddingInfo(t),r=setModalMessage("Fetching bookmarks...");const o=new XMLHttpRequest;o.open("GET",i.bookmarksPath),o.onerror=e=>{setErrorMessage(o.responseText)},o.onload=()=>{const e=JSON.parse(o.responseText);setModalMessage(null,r),n(e)},o.send()}}class ProtoDataProvider{constructor(e){this.dataProto=e}retrieveRuns(e){e(["proto"])}retrieveProjectorConfig(e,t){t({modelCheckpointPath:"proto",embeddings:[{tensorName:"proto",tensorShape:this.dataProto.shape,metadataPath:"proto"}]})}retrieveTensor(e,t,n){n(this.flatArrayToDataset(this.dataProto.tensor))}retrieveSpriteAndMetadata(e,t,n){let i=this.dataProto.metadata.columns.map((e=>e.name)),r=this.dataProto.shape[0],o=new Array(r);this.dataProto.metadata.columns.forEach((e=>{let t=e.numericValues||e.stringValues;for(let n=0;n<r;n++)o[n]=o[n]||{},o[n][e.name]=t[n]}));let a=Promise.resolve(null);null!=this.dataProto.metadata.sprite&&(a=new Promise(((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=()=>t("Failed converting base64 to an image"),n.src=this.dataProto.metadata.sprite.imageBase64}))),a.then((e=>{const t={stats:analyzeMetadata(i,o),pointsInfo:o};null!=e&&(t.spriteImage=e,t.spriteMetadata={singleImageDim:this.dataProto.metadata.sprite.singleImageDim,imagePath:"proto"}),n(t)}))}getBookmarks(e,t,n){return n([])}flatArrayToDataset(e){let t=[],n=this.dataProto.shape[0],i=this.dataProto.shape[1];if(n*i!==e.length)throw"The shape doesn't match the length of the flattened array";for(let r=0;r<n;r++){let n=r*i;t.push({vector:new Float32Array(e.slice(n,n+i)),metadata:{},projections:null,index:r})}return new DataSet(t)}}const LIMIT_NUM_POINTS=1e5;class ServerDataProvider{constructor(e){this.runProjectorConfigCache={},this.routePrefix=e}getEmbeddingInfo(e,t,n){this.retrieveProjectorConfig(e,(e=>{const i=e.embeddings;for(let e=0;e<i.length;e++){const r=i[e];if(r.tensorName===t)return void n(r)}n(null)}))}retrieveRuns(e){const t=setModalMessage("Fetching runs..."),n=new XMLHttpRequest;n.open("GET",`${this.routePrefix}/runs`),n.onerror=e=>{setErrorMessage(n.responseText,"fetching runs")},n.onload=()=>{const i=JSON.parse(n.responseText);setModalMessage(null,t),e(i)},n.send()}retrieveProjectorConfig(e,t){if(e in this.runProjectorConfigCache)return void t(this.runProjectorConfigCache[e]);const n=setModalMessage("Fetching projector config..."),i=new XMLHttpRequest;i.open("GET",`${this.routePrefix}/info?run=${e}`),i.onerror=e=>{setErrorMessage(i.responseText,"fetching projector config")},i.onload=()=>{const r=JSON.parse(i.responseText);setModalMessage(null,n),this.runProjectorConfigCache[e]=r,t(r)},i.send()}retrieveTensor(e,t,n){this.getEmbeddingInfo(e,t,(i=>{retrieveTensorAsBytes(this,i,e,t,`${this.routePrefix}/tensor?run=${e}&name=${t}&num_rows=${LIMIT_NUM_POINTS}`,n)}))}retrieveSpriteAndMetadata(e,t,n){this.getEmbeddingInfo(e,t,(i=>{let r=null;i.metadataPath&&(r=`${this.routePrefix}/metadata?run=${e}&name=${t}&num_rows=${LIMIT_NUM_POINTS}`);let o=null;i.sprite&&i.sprite.imagePath&&(o=`${this.routePrefix}/sprite_image?run=${e}&name=${t}`),retrieveSpriteAndMetadataInfo(r,o,i.sprite,n)}))}getBookmarks(e,t,n){const i=setModalMessage("Fetching bookmarks..."),r=new XMLHttpRequest;r.open("GET",`${this.routePrefix}/bookmarks?run=${e}&name=${t}`),r.onerror=e=>{setErrorMessage(r.responseText,"fetching bookmarks")},r.onload=()=>{setModalMessage(null,i);const e=JSON.parse(r.responseText);n(e)},r.send()}}const template$3=html` <style include="vz-projector-styles"></style> <style> :host { transition: height 0.2s; } .ink-button { border: none; border-radius: 2px; font-size: 13px; padding: 10px; min-width: 88px; flex-shrink: 0; background: #e3e3e3; } .ink-panel-buttons { margin-bottom: 10px; } .two-way-toggle { display: flex; flex-direction: row; } .two-way-toggle span { padding-right: 7px; } .has-border { border: 1px solid rgba(0, 0, 0, 0.1); } .toggle { min-width: 0px; font-size: 12px; width: 17px; min-height: 0px; height: 21px; padding: 0; margin: 0px; } .toggle[active] { background-color: #880e4f; color: white; } .two-columns { display: flex; justify-content: space-between; } .two-columns > :first-child { margin-right: 15px; } .two-columns > div { width: 50%; } .dropdown-item { justify-content: space-between; min-height: 35px; } .tsne-supervise-factor { margin-bottom: -8px; } #z-container { display: flex; align-items: center; width: 50%; } #z-checkbox { margin: 27px 0 0 5px; width: 18px; } #z-dropdown { flex-grow: 1; } .notice { color: #880e4f; } .container { padding: 20px; } .book-icon { height: 20px; color: rgba(0, 0, 0, 0.7); } .item-details { color: gray; font-size: 12px; margin-left: 5px; } .pca-dropdown { width: 100%; } .pca-dropdown paper-listbox { width: 135px; } .dropdown-item.header { border-bottom: 1px solid #aaa; color: #333; font-weight: bold; } #total-variance { color: rgba(0, 0, 0, 0.7); } </style> <div id="main"> <div class="ink-panel-header"> <div class="ink-tab-group"> <div data-tab="umap" id="umap-tab" class="ink-tab projection-tab"> UMAP </div> <paper-tooltip for="umap-tab" position="bottom" animation-delay="0" fit-to-visible-bounds > uniform manifold approximation and projection </paper-tooltip> <div data-tab="tsne" id="tsne-tab" class="ink-tab projection-tab"> t-SNE </div> <paper-tooltip for="tsne-tab" position="bottom" animation-delay="0" fit-to-visible-bounds > t-distributed stochastic neighbor embedding </paper-tooltip> <div data-tab="pca" id="pca-tab" class="ink-tab projection-tab"> PCA </div> <paper-tooltip for="pca-tab" position="bottom" animation-delay="0" fit-to-visible-bounds > Principal component analysis </paper-tooltip> <div data-tab="custom" id="custom-tab" class="ink-tab projection-tab" title="Linear projection of two custom vectors" > Custom </div> <paper-tooltip for="custom-tab" position="bottom" animation-delay="0" fit-to-visible-bounds > Search for two vectors upon which to project all points. </paper-tooltip> </div> </div> <div class="container"> <!-- UMAP Controls --> <div data-panel="umap" class="ink-panel-content"> <div class="slider"> <label>Dimension</label> <div class="two-way-toggle"> <span>2D</span> <paper-toggle-button id="umap-toggle" checked="{{umapIs3d}}" >3D</paper-toggle-button > </div> </div> <div class="slider umap-neighbors"> <label> Neighbors <paper-icon-button icon="help" class="help-icon" ></paper-icon-button> <paper-tooltip position="right" animation-delay="0" fit-to-visible-bounds > The number of nearest neighbors used to compute the fuzzy simplicial set, which is used to approximate the overall shape of the manifold. The default value is 15. </paper-tooltip> </label> <paper-slider id="umap-neighbors-slider" value="{{umapNeighbors}}" pin min="5" max="50" ></paper-slider> <span>[[umapNeighbors]]</span> </div> <p> <button id="run-umap" class="ink-button" title="Run UMAP" on-tap="runUmap" > Run </button> </p> <p id="umap-sampling" class="notice"> For faster results, the data will be sampled down to [[getUmapSampleSizeText()]] points. </p> <p> <iron-icon icon="book" class="book-icon"></iron-icon> <a target="_blank" rel="noopener" href="https://umap-learn.readthedocs.io/en/latest/how_umap_works.html" > Learn more about UMAP. </a> </p> </div> <!-- TSNE Controls --> <div data-panel="tsne" class="ink-panel-content"> <div class="slider"> <label>Dimension</label> <div class="two-way-toggle"> <span>2D</span> <paper-toggle-button id="tsne-toggle" checked="{{tSNEis3d}}" >3D</paper-toggle-button > </div> </div> <div class="slider tsne-perplexity"> <label> Perplexity <paper-icon-button icon="help" class="help-icon" ></paper-icon-button> <paper-tooltip position="right" animation-delay="0" fit-to-visible-bounds > The most appropriate perplexity value depends on the density of the data. Loosely speaking, a larger / denser dataset requires a larger perplexity. Typical values for perplexity range between 5 and 50. </paper-tooltip> </label> <paper-slider id="perplexity-slider" pin min="2" max="100" value="30" ></paper-slider> <span></span> </div> <div class="slider tsne-learning-rate"> <label> Learning rate <paper-icon-button icon="help" class="help-icon" ></paper-icon-button> <paper-tooltip position="right" animation-delay="0" fit-to-visible-bounds > The ideal learning rate often depends on the size of the data, with smaller datasets requiring smaller learning rates. </paper-tooltip> </label> <paper-slider id="learning-rate-slider" snaps min="-3" max="2" step="1" value="1" max-markers="6" > </paper-slider> <span></span> </div> <div class="slider tsne-supervise-factor"> <label> Supervise <paper-icon-button icon="help" class="help-icon" ></paper-icon-button> <paper-tooltip position="right" animation-delay="0" fit-to-visible-bounds > The label importance used for supervision, from 0 (disabled) to 100 (full importance). </paper-tooltip> </label> <paper-slider id="supervise-factor-slider" min="0" max="100" pin value="{{superviseFactor}}" > </paper-slider> <span></span> </div> <p> <button class="run-tsne ink-button" title="Re-run t-SNE"> Run </button> <button class="pause-tsne ink-button" title="Pause t-SNE"> Pause </button> <button class="perturb-tsne ink-button" title="Perturb t-SNE"> Perturb </button> </p> <p>Iteration: <span class="run-tsne-iter">0</span></p> <p id="tsne-sampling" class="notice"> For faster results, the data will be sampled down to [[getTsneSampleSizeText()]] points. </p> <p> <iron-icon icon="book" class="book-icon"></iron-icon> <a target="_blank" href="http://distill.pub/2016/misread-tsne/" rel="noopener noreferrer" > How to use t-SNE effectively. </a> </p> </div> <!-- PCA Controls --> <div data-panel="pca" class="ink-panel-content"> <div class="two-columns"> <div> <!-- Left column --> <paper-dropdown-menu class="pca-dropdown" vertical-align="bottom" no-animations label="X" > <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{pcaX}}" slot="dropdown-content" > <paper-item disabled class="dropdown-item header"> <div>#</div> <div>Variance (%)</div> </paper-item> <template is="dom-repeat" items="[[pcaComponents]]"> <paper-item class="dropdown-item" value="[[item.id]]" label="Component #[[item.componentNumber]]" > <div>[[item.componentNumber]]</div> <div class="item-details">[[item.percVariance]]</div> </paper-item> </template> </paper-listbox> </paper-dropdown-menu> <paper-dropdown-menu class="pca-dropdown" no-animations vertical-align="bottom" label="Z" disabled="[[!hasPcaZ]]" id="z-dropdown" > <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{pcaZ}}" slot="dropdown-content" > <paper-item disabled class="dropdown-item header"> <div>#</div> <div>Variance (%)</div> </paper-item> <template is="dom-repeat" items="[[pcaComponents]]"> <paper-item class="dropdown-item" value="[[item.id]]" label="Component #[[item.componentNumber]]" > <div>[[item.componentNumber]]</div> <div class="item-details">[[item.percVariance]]</div> </paper-item> </template> </paper-listbox> </paper-dropdown-menu> </div> <div> <!-- Right column --> <paper-dropdown-menu class="pca-dropdown" vertical-align="bottom" no-animations label="Y" > <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{pcaY}}" slot="dropdown-content" > <paper-item disabled class="dropdown-item header"> <div>#</div> <div>Variance (%)</div> </paper-item> <template is="dom-repeat" items="[[pcaComponents]]"> <paper-item class="dropdown-item" value="[[item.id]]" label="Component #[[item.componentNumber]]" > <div>[[item.componentNumber]]</div> <div class="item-details">[[item.percVariance]]</div> </paper-item> </template> </paper-listbox> </paper-dropdown-menu> <paper-checkbox id="z-checkbox" checked="{{pcaIs3d}}" ></paper-checkbox> </div> </div> <p id="pca-sampling" class="notice"> PCA is approximate. <paper-icon-button icon="help" class="help-icon" ></paper-icon-button> </p> <div id="total-variance">Total variance</div> <paper-tooltip for="pca-sampling" position="top" animation-delay="0" fit-to-visible-bounds > For fast results, the data was sampled to [[getPcaSampleSizeText()]] points and randomly projected down to [[getPcaSampledDimText()]] dimensions. </paper-tooltip> </div> <!-- Custom Controls --> <div data-panel="custom" class="ink-panel-content"> <paper-dropdown-menu style="width: 100%" no-animations label="Search by" > <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{customSelectedSearchByMetadataOption}}" slot="dropdown-content" > <template is="dom-repeat" items="[[searchByMetadataOptions]]"> <paper-item class="dropdown-item" value="[[item]]" label="[[item]]" > [[item]] </paper-item> </template> </paper-listbox> </paper-dropdown-menu> <div class="two-columns"> <vz-projector-input id="xLeft" label="Left"></vz-projector-input> <vz-projector-input id="xRight" label="Right"></vz-projector-input> </div> <div class="two-columns"> <vz-projector-input id="yUp" label="Up"></vz-projector-input> <vz-projector-input id="yDown" label="Down"></vz-projector-input> </div> </div> </div> </div> </template> <script src="vz-projector-projections-panel.js"></script> </dom-module> `;let ProjectorInput=class extends(LegacyElementMixin(PolymerElement)){registerInputChangedListener(e){this.textChangedListeners.push(e)}ready(){super.ready(),this.inRegexMode=!1,this.textChangedListeners=[],this.paperInput=this.$$("paper-input"),this.inRegexModeButton=this.$$("paper-button"),this.paperInput.setAttribute("error-message","Invalid regex"),this.paperInput.addEventListener("input",(()=>{this.onTextChanged()})),this.paperInput.addEventListener("keydown",(e=>{e.stopPropagation()})),this.inRegexModeButton.addEventListener("click",(()=>this.onClickRegexModeButton())),this.updateRegexModeDisplaySlashes(),this.onTextChanged()}onClickRegexModeButton(){this.inRegexMode=this.inRegexModeButton.active,this.updateRegexModeDisplaySlashes(),this.onTextChanged()}notifyInputChanged(e,t){this.textChangedListeners.forEach((n=>n(e,t)))}onTextChanged(){try{this.inRegexMode&&new RegExp(this.paperInput.value)}catch(e){return this.paperInput.setAttribute("invalid","true"),this.message="",void this.notifyInputChanged(null,!0)}this.paperInput.removeAttribute("invalid"),this.notifyInputChanged(this.paperInput.value,this.inRegexMode)}updateRegexModeDisplaySlashes(){const e=this.paperInput.querySelectorAll(".slash"),t=this.inRegexMode?"":"none";for(let n=0;n<e.length;n++)e[n].style.display=t}getValue(){return this.paperInput.value}getInRegexMode(){return this.inRegexMode}setValue(e,t){this.inRegexModeButton.active=t,this.paperInput.value=e,this.onClickRegexModeButton()}};ProjectorInput.template=html` <style include="vz-projector-styles"></style> <style> .info { color: rgba(0, 0, 0, 0.5); display: block; font-size: 11px; } .toggle { font-size: 12px; height: 21px; margin: 0px; min-width: 0px; min-height: 0px; padding: 0; width: 17px; } .toggle[active] { background-color: #880e4f; color: white; } </style> <paper-input label="[[label]]"> <div class="slash" prefix slot="prefix">/</div> <div class="slash" suffix slot="suffix">/</div> <div suffix slot="suffix"> <paper-button id="regex" toggles class="toggle">.*</paper-button> </div> </paper-input> <paper-tooltip for="regex" position="bottom" animation-delay="0" fit-to-visible-bounds > Enable/disable regex mode. </paper-tooltip> <span class="info">[[message]]</span> `,__decorate([property({type:String}),__metadata("design:type",String)],ProjectorInput.prototype,"label",void 0),__decorate([property({type:String}),__metadata("design:type",String)],ProjectorInput.prototype,"message",void 0),ProjectorInput=__decorate([customElement("vz-projector-input")],ProjectorInput);const NUM_PCA_COMPONENTS=10;let ProjectionsPanel=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.pcaIs3d=!0,this.tSNEis3d=!0,this.superviseFactor=0,this.umapIs3d=!0,this.umapNeighbors=15,this.pcaX=0,this.pcaY=1,this.pcaZ=2}initialize(e){this.polymerChangesTriggerReprojection=!0,this.projector=e,this.perplexity=30,this.learningRate=10,this.centroidValues={xLeft:null,xRight:null,yUp:null,yDown:null},this.clearCentroids(),this.setupUIControls()}ready(){super.ready(),this.zDropdown=this.$$("#z-dropdown"),this.runTsneButton=this.$$(".run-tsne"),this.pauseTsneButton=this.$$(".pause-tsne"),this.perturbTsneButton=this.$$(".perturb-tsne"),this.perplexitySlider=this.$$("#perplexity-slider"),this.learningRateInput=this.$$("#learning-rate-slider"),this.superviseFactorInput=this.$$("#supervise-factor-slider"),this.iterationLabelTsne=this.$$(".run-tsne-iter"),this.runUmapButton=this.$$("#run-umap")}disablePolymerChangesTriggerReprojection(){this.polymerChangesTriggerReprojection=!1}enablePolymerChangesTriggerReprojection(){this.polymerChangesTriggerReprojection=!0}updateTSNEPerplexityFromSliderChange(){this.perplexitySlider&&(this.perplexity=+this.perplexitySlider.value),this.$$(".tsne-perplexity span").innerText=""+this.perplexity}updateTSNELearningRateFromUIChange(){this.learningRateInput&&(this.learningRate=Math.pow(10,+this.learningRateInput.value)),this.$$(".tsne-learning-rate span").innerText=""+this.learningRate}updateTSNESuperviseFactorFromUIChange(){this.$$(".tsne-supervise-factor span").innerText=""+this.superviseFactor,this.dataSet&&this.dataSet.setSuperviseFactor(this.superviseFactor)}setupUIControls(){{const e=this,t=this.root.querySelectorAll(".ink-tab");for(let n=0;n<t.length;n++)t[n].addEventListener("click",(function(){let t=this.getAttribute("data-tab");e.showTab(t)}))}this.runTsneButton.addEventListener("click",(()=>{this.dataSet.hasTSNERun?this.dataSet.stopTSNE():this.runTSNE()})),this.pauseTsneButton.addEventListener("click",(()=>{this.dataSet.tSNEShouldPause?(this.dataSet.tSNEShouldPause=!1,this.pauseTsneButton.innerText="Pause"):(this.dataSet.tSNEShouldPause=!0,this.pauseTsneButton.innerText="Resume")})),this.perturbTsneButton.addEventListener("mousedown",(()=>{this.dataSet&&this.projector&&(this.dataSet.perturbTsne(),this.projector.notifyProjectionPositionsUpdated(),this.perturbInterval=window.setInterval((()=>{this.dataSet.perturbTsne(),this.projector.notifyProjectionPositionsUpdated()}),100))})),this.perturbTsneButton.addEventListener("mouseup",(()=>{clearInterval(this.perturbInterval)})),this.perplexitySlider.value=this.perplexity.toString(),this.perplexitySlider.addEventListener("change",(()=>this.updateTSNEPerplexityFromSliderChange())),this.updateTSNEPerplexityFromSliderChange(),this.learningRateInput.addEventListener("change",(()=>this.updateTSNELearningRateFromUIChange())),this.updateTSNELearningRateFromUIChange(),this.superviseFactorInput.addEventListener("change",(()=>this.updateTSNESuperviseFactorFromUIChange())),this.updateTSNESuperviseFactorFromUIChange(),this.setupCustomProjectionInputFields();const e=this.root.querySelectorAll("paper-dropdown-menu paper-input input");for(let t=0;t<e.length;t++)e[t].style.fontSize="14px"}restoreUIFromBookmark(e){this.disablePolymerChangesTriggerReprojection(),this.pcaX=e.pcaComponentDimensions[0],this.pcaY=e.pcaComponentDimensions[1],3===e.pcaComponentDimensions.length&&(this.pcaZ=e.pcaComponentDimensions[2]),this.pcaIs3d=3===e.pcaComponentDimensions.length,this.perplexitySlider&&(this.perplexitySlider.value=e.tSNEPerplexity.toString()),this.learningRateInput&&(this.learningRateInput.value=e.tSNELearningRate.toString()),this.tSNEis3d=e.tSNEis3d,this.umapIs3d=e.umapIs3d,this.umapNeighbors=e.umapNeighbors,this.customSelectedSearchByMetadataOption=e.customSelectedSearchByMetadataOption,this.customProjectionXLeftInput&&this.customProjectionXLeftInput.set(e.customXLeftText,e.customXLeftRegex),this.customProjectionXRightInput&&this.customProjectionXRightInput.set(e.customXRightText,e.customXRightRegex),this.customProjectionYUpInput&&this.customProjectionYUpInput.set(e.customYUpText,e.customYUpRegex),this.customProjectionYDownInput&&this.customProjectionYDownInput.set(e.customYDownText,e.customYDownRegex),this.computeAllCentroids(),this.setZDropdownEnabled(this.pcaIs3d),this.updateTSNEPerplexityFromSliderChange(),this.updateTSNELearningRateFromUIChange(),this.iterationLabelTsne&&(this.iterationLabelTsne.innerText=e.tSNEIteration.toString()),null!=e.selectedProjection&&this.showTab(e.selectedProjection),this.enablePolymerChangesTriggerReprojection()}populateBookmarkFromUI(e){this.disablePolymerChangesTriggerReprojection(),e.pcaComponentDimensions=[this.pcaX,this.pcaY],this.pcaIs3d&&e.pcaComponentDimensions.push(this.pcaZ),null!=this.perplexitySlider&&(e.tSNEPerplexity=+this.perplexitySlider.value),null!=this.learningRateInput&&(e.tSNELearningRate=+this.learningRateInput.value),e.tSNEis3d=this.tSNEis3d,e.umapIs3d=this.umapIs3d,e.customSelectedSearchByMetadataOption=this.customSelectedSearchByMetadataOption,null!=this.customProjectionXLeftInput&&(e.customXLeftText=this.customProjectionXLeftInput.getValue(),e.customXLeftRegex=this.customProjectionXLeftInput.getInRegexMode()),null!=this.customProjectionXRightInput&&(e.customXRightText=this.customProjectionXRightInput.getValue(),e.customXRightRegex=this.customProjectionXRightInput.getInRegexMode()),null!=this.customProjectionYUpInput&&(e.customYUpText=this.customProjectionYUpInput.getValue(),e.customYUpRegex=this.customProjectionYUpInput.getInRegexMode()),null!=this.customProjectionYDownInput&&(e.customYDownText=this.customProjectionYDownInput.getValue(),e.customYDownRegex=this.customProjectionYDownInput.getInRegexMode()),this.enablePolymerChangesTriggerReprojection()}setZDropdownEnabled(e){this.zDropdown&&(e?this.zDropdown.removeAttribute("disabled"):this.zDropdown.setAttribute("disabled","true"))}dataSetUpdated(e,t,n){this.dataSet=e,this.originalDataSet=t,this.dim=n;const i=null==e?0:e.points.length,r=Math.max(5,Math.ceil(Math.sqrt(i)/4));this.perplexitySlider.value=r.toString(),this.updateTSNEPerplexityFromSliderChange(),this.clearCentroids(),this.$$("#tsne-sampling").style.display=i>TSNE_SAMPLE_SIZE?null:"none";const o=null!=e&&(e.dim[0]>PCA_SAMPLE_DIM||e.dim[1]>PCA_SAMPLE_DIM);this.$$("#pca-sampling").style.display=o?null:"none",this.showTab("pca")}_pcaDimensionToggleObserver(){this.setZDropdownEnabled(this.pcaIs3d),this.beginProjection(this.currentProjection)}_tsneDimensionToggleObserver(){this.beginProjection(this.currentProjection)}_umapDimensionToggleObserver(){this.beginProjection(this.currentProjection)}metadataChanged(e){let t=-1;this.searchByMetadataOptions=e.stats.map(((e,n)=>(e.isNumeric||-1!==t||(t=n),e.name))),this.customSelectedSearchByMetadataOption=this.searchByMetadataOptions[Math.max(0,t)]}showTab(e){this.currentProjection=e;const t=this.$$('.ink-tab[data-tab="'+e+'"]'),n=this.root.querySelectorAll(".ink-tab");for(let e=0;e<n.length;e++)classed(n[e],"active",!1);classed(t,"active",!0);const i=this.root.querySelectorAll(".ink-panel-content");for(let e=0;e<i.length;e++)classed(i[e],"active",!1);if(classed(this.$$('.ink-panel-content[data-panel="'+e+'"]'),"active",!0),null!=this.$){const e=this.$.main;requestAnimationFrame((()=>{this.style.height=e.clientHeight+"px"}))}this.beginProjection(e)}beginProjection(e){!1!==this.polymerChangesTriggerReprojection&&("pca"===e?(null!=this.dataSet&&this.dataSet.stopTSNE(),this.showPCA()):"tsne"===e?this.showTSNE():"umap"===e?this.showUmap():"custom"===e&&(null!=this.dataSet&&this.dataSet.stopTSNE(),this.computeAllCentroids(),this.reprojectCustom()))}showTSNE(){const e=this.dataSet;if(null==e)return;const t=getProjectionComponents("tsne",[0,1,this.tSNEis3d?2:null]),n=new Projection("tsne",t,this.tSNEis3d?3:2,e);this.projector.setProjection(n),this.dataSet.hasTSNERun?this.projector.notifyProjectionPositionsUpdated():this.runTSNE()}runTSNE(){let e=!1;this.runTsneButton.innerText="Stop",this.runTsneButton.disabled=!0,this.pauseTsneButton.innerText="Pause",this.pauseTsneButton.disabled=!0,this.perturbTsneButton.disabled=!1,this.dataSet.projectTSNE(this.perplexity,this.learningRate,this.tSNEis3d?3:2,(t=>{null!=t?(this.runTsneButton.disabled=!1,this.pauseTsneButton.disabled=!1,this.iterationLabelTsne.innerText=""+t,this.projector.notifyProjectionPositionsUpdated(),!e&&this.dataSet.projections.tsne&&(this.projector.onProjectionChanged(),e=!0)):(this.runTsneButton.innerText="Re-run",this.runTsneButton.disabled=!1,this.pauseTsneButton.innerText="Pause",this.pauseTsneButton.disabled=!0,this.perturbTsneButton.disabled=!0,this.projector.onProjectionChanged())}))}showUmap(){const e=this.dataSet;if(null==e)return;const t=getProjectionComponents("umap",[0,1,this.umapIs3d?2:null]),n=new Projection("umap",t,this.umapIs3d?3:2,e);this.projector.setProjection(n),this.dataSet.hasUmapRun?this.projector.notifyProjectionPositionsUpdated():this.runUmap()}runUmap(){let e=!1;this.runUmapButton.disabled=!0,this.dataSet.projectUmap(this.umapIs3d?3:2,this.umapNeighbors,(t=>{null!=t?(this.runUmapButton.disabled=!1,this.projector.notifyProjectionPositionsUpdated(),!e&&this.dataSet.projections.umap&&(this.projector.onProjectionChanged(),e=!0)):(this.runUmapButton.innerText="Re-run",this.runUmapButton.disabled=!1,this.projector.onProjectionChanged())}))}showPCAIfEnabled(){this.polymerChangesTriggerReprojection&&this.showPCA()}updateTotalVarianceMessage(){let e=this.dataSet.fracVariancesExplained,t=e[this.pcaX]+e[this.pcaY],n="Total variance described: ";this.pcaIs3d&&(t+=e[this.pcaZ]),n+=(100*t).toFixed(1)+"%.",this.$$("#total-variance").textContent=n}showPCA(){null!=this.dataSet&&this.dataSet.projectPCA().then((()=>{const e=getProjectionComponents("pca",[this.pcaX,this.pcaY,this.pcaZ]),t=new Projection("pca",e,this.pcaIs3d?3:2,this.dataSet);this.projector.setProjection(t);let n=Math.min(NUM_PCA_COMPONENTS,this.dataSet.dim[1]);this.updateTotalVarianceMessage(),this.pcaComponents=range(n).map((e=>({id:e,componentNumber:e+1,percVariance:(100*this.dataSet.fracVariancesExplained[e]).toFixed(1)})))}))}reprojectCustom(){if(null==this.centroids||null==this.centroids.xLeft||null==this.centroids.xRight||null==this.centroids.yUp||null==this.centroids.yDown)return;const e=sub(this.centroids.xRight,this.centroids.xLeft);this.dataSet.projectLinear(e,"linear-x");const t=sub(this.centroids.yUp,this.centroids.yDown);this.dataSet.projectLinear(t,"linear-y");const n=getProjectionComponents("custom",["x","y"]),i=new Projection("custom",n,2,this.dataSet);this.projector.setProjection(i)}clearCentroids(){this.centroids={xLeft:null,xRight:null,yUp:null,yDown:null},this.allCentroid=null}_customSelectedSearchByMetadataOptionChanged(e,t){!1!==this.polymerChangesTriggerReprojection&&"custom"===this.currentProjection&&(this.computeAllCentroids(),this.reprojectCustom())}setupCustomProjectionInputFields(){this.customProjectionXLeftInput=this.setupCustomProjectionInputField("xLeft"),this.customProjectionXRightInput=this.setupCustomProjectionInputField("xRight"),this.customProjectionYUpInput=this.setupCustomProjectionInputField("yUp"),this.customProjectionYDownInput=this.setupCustomProjectionInputField("yDown")}computeAllCentroids(){this.computeCentroid("xLeft"),this.computeCentroid("xRight"),this.computeCentroid("yUp"),this.computeCentroid("yDown")}computeCentroid(e){const t=this.$$("#"+e);if(null==t)return;const n=t.getValue();if(null==n)return;let i=t.getInRegexMode(),r=this.getCentroid(n,i);0===r.numMatches?(t.message="0 matches. Using a random vector.",r.centroid=rn(this.dim)):t.message=`${r.numMatches} matches.`,this.centroids[e]=r.centroid,this.centroidValues[e]=n}setupCustomProjectionInputField(e){let t=this.$$("#"+e);return t.registerInputChangedListener(((t,n)=>{this.polymerChangesTriggerReprojection&&(this.computeCentroid(e),this.reprojectCustom())})),t}getCentroid(e,t){if(null==e||""===e)return{numMatches:0};let n=this.originalDataSet.query(e,t,this.customSelectedSearchByMetadataOption);return{centroid:centroid(n,(e=>this.originalDataSet.points[e].vector)),numMatches:n.length}}getPcaSampledDimText(){return PCA_SAMPLE_DIM.toLocaleString()}getPcaSampleSizeText(){return PCA_SAMPLE_SIZE.toLocaleString()}getTsneSampleSizeText(){return TSNE_SAMPLE_SIZE.toLocaleString()}getUmapSampleSizeText(){return UMAP_SAMPLE_SIZE.toLocaleString()}};ProjectionsPanel.template=template$3,__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],ProjectionsPanel.prototype,"pcaIs3d",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],ProjectionsPanel.prototype,"tSNEis3d",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"superviseFactor",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],ProjectionsPanel.prototype,"umapIs3d",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"umapNeighbors",void 0),__decorate([property({type:Array}),__metadata("design:type",Array)],ProjectionsPanel.prototype,"pcaComponents",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"pcaX",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"pcaY",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"pcaZ",void 0),__decorate([property({type:String}),__metadata("design:type",String)],ProjectionsPanel.prototype,"customSelectedSearchByMetadataOption",void 0),__decorate([observe("pcaIs3d"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"_pcaDimensionToggleObserver",null),__decorate([observe("tSNEis3d"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"_tsneDimensionToggleObserver",null),__decorate([observe("umapIs3d"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"_umapDimensionToggleObserver",null),__decorate([observe("pcaX","pcaY","pcaZ"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"showPCAIfEnabled",null),__decorate([observe("customSelectedSearchByMetadataOption"),__metadata("design:type",Function),__metadata("design:paramtypes",[String,String]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"_customSelectedSearchByMetadataOptionChanged",null),ProjectionsPanel=__decorate([customElement("vz-projector-projections-panel")],ProjectionsPanel);const template$2=html` <style include="vz-projector-styles"></style> <style> #title { background-color: #fafafa; color: black; font-weight: 500; left: 0; line-height: 60px; padding-left: 24px; position: absolute; width: 276px; } #bookmark-container { background-color: #fafafa; } #icon-container { line-height: 60px; position: absolute; right: 0; } #header { border-top: 1px solid rgba(0, 0, 0, 0.1); position: relative; } #panel { background-color: #fafafa; position: relative; overflow-y: scroll; top: 60px; max-height: 50vh; } #save-container { text-align: center; } .state-radio { display: table-cell; vertical-align: middle; padding-top: 16px; } .state-label { display: table-cell; vertical-align: middle; top: 14px; } .state-label-input { width: 194px; } .state-clear { display: table-cell; vertical-align: middle; padding-top: 20px; } #state-file { display: none; } #no-bookmarks { padding: 0 24px; } #action-buttons-container .add-icon-button { background-color: #03a9f4; color: white; margin: 0 4px 4px auto; right: 7px; top: -4px; } .upload-download-icon-button { padding: 0; } #action-buttons-container { display: flex; margin-left: 34px; margin-top: 6px; } .ink-fab { border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); } paper-textarea { --paper-input-container-input: { font-size: 12px; } --paper-font-caption: { display: none; } } </style> <!-- Bookmarking controls --> <div id="bookmark-container"> <div id="header"> <div id="title"> BOOKMARKS ([[savedStates.length]]) <paper-icon-button icon="help" class="help-icon"></paper-icon-button> <paper-tooltip animation-delay="0" position="top" offset="0"> Open this drawer to save a set of views of the projection, including selected points. A file containing the bookmarks can then be saved and later loaded to view them. </paper-tooltip> </div> <div id="icon-container"> <!-- Icons and event handlers are inverted because the tray expands upwards. --> <paper-icon-button id="expand-more" icon="expand-less" on-tap="_expandMore" ></paper-icon-button> <paper-icon-button id="expand-less" style="display: none" icon="expand-more" on-tap="_expandLess" ></paper-icon-button> </div> </div> <iron-collapse id="panel"> <!-- Saving state section --> <div id="state-section"> <template is="dom-if" if="[[!savedStates.length]]"> <p id="no-bookmarks"> No bookmarks yet, upload a bookmarks file or add a new bookmark by clicking the "+" below. </p> </template> <template is="dom-repeat" items="{{savedStates}}"> <div class="state-row"> <div class="state-radio"> <template is="dom-if" if="{{item.isSelected}}"> <paper-icon-button icon="radio-button-checked" ></paper-icon-button> </template> <template is="dom-if" if="{{!item.isSelected}}"> <paper-icon-button icon="radio-button-unchecked" data-index$="{{index}}" on-tap="_radioButtonHandler" ></paper-icon-button> </template> </div> <div class="state-label"> <paper-textarea value="[[item.label]]" class="state-label-input" on-keyup="_labelChange" data-index$="[[index]]" autoresizing ></paper-textarea> </div> <div class="state-clear"> <paper-icon-button icon="clear" data-index$="{{index}}" on-tap="_clearButtonHandler" ></paper-icon-button> </div> </div> </template> <div id="action-buttons-container"> <paper-icon-button class="upload-download-icon-button" icon="save" title="Save bookmarks" disabled="[[!hasStates]]" on-tap="_downloadFile" ></paper-icon-button> <paper-icon-button class="upload-download-icon-button" icon="file-upload" title="Load bookmarks" on-tap="_uploadFile" ></paper-icon-button> <paper-icon-button class="add-icon-button ink-fab" icon="add" title="Add bookmark" on-tap="_addBookmark" ></paper-icon-button> <input type="file" id="state-file" name="state-file" /> </div> </div> </iron-collapse> </div> `;let BookmarkPanel=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.hasStates=!1}ready(){super.ready(),this.savedStates=[],this.setupUploadButton(),this.ignoreNextProjectionEvent=!1,this.expandLessButton=this.$$("#expand-less"),this.expandMoreButton=this.$$("#expand-more")}initialize(e,t){this.projector=e,t.registerProjectionChangedListener((()=>{this.ignoreNextProjectionEvent?this.ignoreNextProjectionEvent=!1:this.clearStateSelection()}))}setSelectedTensor(e,t,n){this.addStates(null),t&&t.bookmarksPath?n.getBookmarks(e,t.tensorName,(e=>{this.addStates(e),this._expandMore()})):this._expandLess()}_expandMore(){this.$.panel.show(),this.expandMoreButton.style.display="none",this.expandLessButton.style.display=""}_expandLess(){this.$.panel.hide(),this.expandMoreButton.style.display="",this.expandLessButton.style.display="none"}_addBookmark(){let e=this.projector.getCurrentState();e.label="State "+this.savedStates.length,e.isSelected=!0,this.selectedState=this.savedStates.length;for(let e=0;e<this.savedStates.length;e++)this.savedStates[e].isSelected=!1,this.notifyPath("savedStates."+e+".isSelected",!1);this.push("savedStates",e),this.updateHasStates()}_downloadFile(){let e=this.serializeAllSavedStates(),t=new Blob([e],{type:"text/plain"}),n=window.URL.createObjectURL(t),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",Object.assign(i,{href:n}),i.download="state",i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(n)}_uploadFile(){this.$$("#state-file").click()}setupUploadButton(){const e=this.$$("#state-file");e.onchange=()=>{const t=e.files[0];e.value="";const n=new FileReader;n.onload=e=>{const t=JSON.parse(n.result);this.savedStatesValid(t)?(this.addStates(t),this.loadSavedState(0)):setWarningMessage(`Unable to load bookmarks: wrong dataset, expected dataset with shape (${t[0].dataSetDimensions}).`)},n.readAsText(t)}}addStates(e){if(null==e)this.savedStates=[];else for(let t=0;t<e.length;t++)e[t].isSelected=!1,this.push("savedStates",e[t]);this.updateHasStates()}clearStateSelection(){for(let e=0;e<this.savedStates.length;e++)this.setSelectionState(e,!1)}_radioButtonHandler(e){const t=this.getParentDataIndex(e);this.loadSavedState(t),this.setSelectionState(t,!0)}loadSavedState(e){for(let t=0;t<this.savedStates.length;t++)this.savedStates[t].isSelected?this.setSelectionState(t,!1):e===t&&(this.setSelectionState(t,!0),this.ignoreNextProjectionEvent=!0,this.projector.loadState(this.savedStates[t]))}setSelectionState(e,t){this.savedStates[e].isSelected=t,this.notifyPath("savedStates."+e+".isSelected",t)}getParentDataIndex(e){for(let t=0;t<e.path.length;t++){let n=e.path[t];if(n instanceof HTMLElement){let e=n.getAttribute("data-index");if(null!=e)return+e}}return-1}_clearButtonHandler(e){let t=this.getParentDataIndex(e);this.splice("savedStates",t,1),this.updateHasStates()}_labelChange(e){let t=this.getParentDataIndex(e);this.savedStates[t].label=e.target.value}_isSelectedState(e){return e===this.selectedState}_isNotSelectedState(e){return e!==this.selectedState}serializeAllSavedStates(){return JSON.stringify(this.savedStates)}loadSavedStates(e){this.savedStates=JSON.parse(e),this.updateHasStates()}updateHasStates(){this.hasStates=0!==this.savedStates.length}savedStatesValid(e){for(let t=0;t<e.length;t++)if(e[t].dataSetDimensions[0]!==this.projector.dataSet.dim[0]||e[t].dataSetDimensions[1]!==this.projector.dataSet.dim[1])return!1;return!0}};BookmarkPanel.template=template$2,__decorate([property({type:Object}),__metadata("design:type",Array)],BookmarkPanel.prototype,"savedStates",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],BookmarkPanel.prototype,"hasStates",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],BookmarkPanel.prototype,"selectedState",void 0),BookmarkPanel=__decorate([customElement("vz-projector-bookmark-panel")],BookmarkPanel);let TfWbrString=class extends PolymerElement{get _parts(){var e=this.value,t=this.delimiterPattern;const n=[];for(;;){const i=new RegExp(t,"g");if(i.test(e),0===i.lastIndex){n.push(e);break}n.push(e.slice(0,i.lastIndex)),e=e.slice(i.lastIndex)}return n}};TfWbrString.template=html` <!-- This ugly formatting is required to prevent spaces from slipping into the HTML. --> <template is="dom-repeat" items="[[_parts]]" as="part" >[[part]]<wbr /></template> `,__decorate([property({type:String}),__metadata("design:type",String)],TfWbrString.prototype,"value",void 0),__decorate([property({type:String}),__metadata("design:type",String)],TfWbrString.prototype,"delimiterPattern",void 0),__decorate([computed("value","delimiterPattern"),__metadata("design:type",Array),__metadata("design:paramtypes",[])],TfWbrString.prototype,"_parts",null),TfWbrString=__decorate([customElement("tf-wbr-string")],TfWbrString);const template$1=html` <style include="vz-projector-styles"></style> <style> .container { padding: 5px 20px 20px 20px; } input[type='file'] { display: none; } .file-name { margin-right: 10px; } .dirs { color: rgba(0, 0, 0, 0.7); font-size: 12px; } .dirs table tr { vertical-align: top; } .dirs table tr td { padding-bottom: 10px; } paper-item { --paper-item-disabled: { border-bottom: 1px solid black; justify-content: center; font-size: 12px; line-height: normal; min-height: 0px; } } .item-details { margin-left: 5px; color: gray; font-size: 12px; } paper-input { font-size: 15px; --paper-input-container: { padding: 5px 0; } --paper-input-container-label-floating: { white-space: normal; line-height: normal; } } paper-dropdown-menu { width: 100%; --paper-input-container: { padding: 5px 0; } --paper-input-container-input: { font-size: 15px; } --paper-input-container-label-floating: { white-space: normal; line-height: normal; } } paper-dropdown-menu paper-item { justify-content: space-between; } .title { align-items: center; border-bottom: 1px solid rgba(0, 0, 0, 0.1); color: black; display: flex; font-weight: 500; height: 59px; padding-left: 20px; } #normalize-data-checkbox { margin: 10px 0; } #projector-config-template { --paper-input-container-input: { line-height: 13px; font-family: monospace; font-size: 12px; } } #generate-share-url { padding: 16px; margin-left: 24px; } #projector-share-button-container { margin: 10px 0; } .metadata-editor, .supervise-settings, .colorlabel-container { display: flex; } #labelby { width: 100px; margin-right: 10px; } #colorby { width: calc(100% - 110px); } [hidden] { display: none; } .supervise-settings paper-dropdown-menu { width: 100px; margin-right: 10px; } .supervise-settings paper-input { width: calc(100% - 110px); } .metadata-editor paper-dropdown-menu { width: 100px; margin-right: 10px; } .metadata-editor paper-input { width: calc(100% - 110px); } .config-checkbox { display: inline-block; font-size: 11px; margin-left: 10px; } .projector-config-options { margin-top: 12px; } .projector-config-dialog-container { padding: 24px; } .code { background-color: #f7f7f7; display: table; font-family: monospace; margin-top: 7px; padding: 15px; } .delimiter { color: #b71c1c; } .button-container { flex: 1 100%; margin-right: 5px; } .button-container paper-button { min-width: 50px; width: 100%; } #label-button { margin-right: 0px; } .upload-step { display: flex; justify-content: space-between; margin-bottom: 6px; } .upload-step paper-button { margin-left: 30px; } .step-label { color: rgb(38, 180, 226); } .scrollable-container { margin-top: 0; min-width: 400px; } #projectorConfigDialog p { margin: 8px 0 8px; } .data-step { margin-top: 40px; } .data-step-contents { display: table; width: 100%; } .data-step-contents-contents { display: table-cell; margin-top: 6px; } .data-step-contents-upload { display: table-cell; text-align: right; vertical-align: bottom; } #demo-data-buttons-container { display: none; margin-top: 10px; } </style> <div class="title">DATA</div> <div class="container"> <!-- List of runs --> <template is="dom-if" if="[[_hasChoices(runNames)]]"> <paper-dropdown-menu no-animations label="[[_getNumRunsLabel(runNames)]] found" > <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedRun}}" slot="dropdown-content" > <template is="dom-repeat" items="[[runNames]]"> <paper-item value="[[item]]" label="[[item]]"> [[item]] </paper-item> </template> </paper-listbox> </paper-dropdown-menu> </template> <template is="dom-if" if="[[tensorNames]]"> <!-- List of tensors in checkpoint --> <paper-dropdown-menu no-animations label="[[_getNumTensorsLabel(tensorNames)]] found" > <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedTensor}}" slot="dropdown-content" > <template is="dom-repeat" items="[[tensorNames]]"> <paper-item value="[[item.name]]" label="[[item.name]]"> [[item.name]] <span class="item-details"> [[item.shape.0]]x[[item.shape.1]] </span> </paper-item> </template> </paper-listbox> </paper-dropdown-menu> </template> <div hidden$="[[!_hasChoices(colorOptions)]]"> <div class="colorlabel-container"> <!-- Label by --> <paper-dropdown-menu id="labelby" no-animations label="Label by"> <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedLabelOption}}" slot="dropdown-content" > <template is="dom-repeat" items="[[labelOptions]]"> <paper-item value="[[item]]" label="[[item]]"> [[item]] </paper-item> </template> </paper-listbox> </paper-dropdown-menu> <!-- Color by --> <paper-dropdown-menu id="colorby" no-animations label="Color by"> <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedColorOptionName}}" slot="dropdown-content" > <template is="dom-repeat" items="[[colorOptions]]"> <paper-item class$="[[getSeparatorClass(item.isSeparator)]]" value="[[item.name]]" label="[[item.name]]" disabled="[[item.isSeparator]]" > [[item.name]] <span class="item-details">[[item.desc]]</span> </paper-item> </template> </paper-listbox> </paper-dropdown-menu> </div> <div hidden$="[[!showForceCategoricalColorsCheckbox]]"> <paper-checkbox id="force-categorical-checkbox" >Use categorical coloring</paper-checkbox > <paper-icon-button icon="help" class="help-icon"></paper-icon-button> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > For metadata fields that have many unique values we use a gradient color map by default. This checkbox allows you to force categorical coloring by a given metadata field. </paper-tooltip> </div> <template dom-if="[[colorLegendRenderInfo]]"> <vz-projector-legend render-info="[[colorLegendRenderInfo]]" ></vz-projector-legend> </template> </div> <template is="dom-if" if="[[_hasChoice(labelOptions)]]"> <!-- Supervise by --> <div hidden$="[[!showSuperviseSettings]]" class="supervise-settings"> <paper-dropdown-menu no-animations label="Supervise with"> <paper-listbox attr-for-selected="value" class="dropdown-content" on-selected-item-changed="superviseColumnChanged" selected="{{superviseColumn}}" slot="dropdown-content" > <template is="dom-repeat" items="[[metadataFields]]"> <paper-item value="[[item]]" label="[[item]]"> [[item]] </paper-item> </template> </paper-listbox> </paper-dropdown-menu> <paper-input value="{{superviseInput}}" label="{{superviseInputLabel}}" on-change="superviseInputChange" on-input="superviseInputTyping" > </paper-input> </div> <!-- Edit by --> <div class="metadata-editor"> <paper-dropdown-menu no-animations label="Edit by"> <paper-listbox attr-for-selected="value" class="dropdown-content" slot="dropdown-content" on-selected-item-changed="metadataEditorColumnChange" selected="{{metadataEditorColumn}}" > <template is="dom-repeat" items="[[metadataFields]]"> <paper-item value="[[item]]" label="[[item]]"> [[item]] </paper-item> </template> </paper-listbox> </paper-dropdown-menu> <paper-input value="{{metadataEditorInput}}" label="{{metadataEditorInputLabel}}" on-input="metadataEditorInputChange" on-keydown="metadataEditorInputKeydown" > </paper-input> </div> </template> <div id="demo-data-buttons-container"> <span class="button-container"> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > Load data from your computer </paper-tooltip> <paper-button id="upload" class="ink-button" on-tap="_openDataDialog" >Load</paper-button > </span> <span id="publish-container" class="button-container"> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > Publish your embedding visualization and data </paper-tooltip> <paper-button id="host-embedding" class="ink-button" on-tap="_openConfigDialog" >Publish</paper-button > </span> <span class="button-container"> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > Download the metadata with applied modifications </paper-tooltip> <paper-button class="ink-button" on-click="downloadMetadataClicked" >Download</paper-button > <a href="#" id="downloadMetadataLink" hidden></a> </span> <span id="label-button" class="button-container"> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > Label selected metadata </paper-tooltip> <paper-button class="ink-button" on-click="metadataEditorButtonClicked" disabled="[[metadataEditorButtonDisabled]]" >Label</paper-button > </span> </div> <div> <paper-dialog id="dataDialog" with-backdrop> <h2>Load data from your computer</h2> <paper-dialog-scrollable class="scrollable-container"> <div class="data-step" id="upload-tensors-step-container"> <div class="upload-step"> <div> <b ><span class="step-label">Step 1:</span> Load a TSV file of vectors.</b > </div> </div> <div class="data-step-contents"> <div class="data-step-contents-contents"> Example of 3 vectors with dimension 4: <div class="code"> 0.1<span class="delimiter"> </span>0.2<span class="delimiter"> </span >0.5<span class="delimiter"> </span>0.9<br /> 0.2<span class="delimiter"> </span>0.1<span class="delimiter"> </span >5.0<span class="delimiter"> </span>0.2<br /> 0.4<span class="delimiter"> </span>0.1<span class="delimiter"> </span >7.0<span class="delimiter"> </span>0.8 </div> </div> <div class="data-step-contents-upload"> <paper-button id="upload-tensors" title="Choose a TSV tensor file" >Choose file</paper-button > <input type="file" id="file" name="file" /> </div> </div> </div> <div class="data-step"> <div class="upload-step"> <div> <span class="step-label" id="upload-metadata-label" ><b>Step 2</b> (optional):</span > <b>Load a TSV file of metadata.</b> </div> </div> <div class="data-step-contents"> <div class="data-step-contents-contents"> Example of 3 data points and 2 columns.<br /> <i >Note: If there is more than one column, the first row will be parsed as column labels.</i > <div class="code"> <b>Pokémon<span class="delimiter"> </span>Species</b><br /> Wartortle<span class="delimiter"> </span>Turtle<br /> Venusaur<span class="delimiter"> </span>Seed<br /> Charmeleon<span class="delimiter"> </span>Flame </div> </div> <div class="data-step-contents-upload"> <paper-button id="upload-metadata" title="Choose a TSV metadata file" class="ink-button" >Choose file</paper-button > <input type="file" id="file-metadata" name="file-metadata" /> </div> </div> </div> </paper-dialog-scrollable> <div class="dismiss-dialog-note">Click outside to dismiss.</div> </paper-dialog> <paper-dialog id="projectorConfigDialog" with-backdrop> <h2>Publish your embedding visualization and data</h2> <paper-dialog-scrollable class="scrollable-container"> <div> <p> If you'd like to share your visualization with the world, follow these simple steps. See <a target="_blank" rel="noopener noreferrer" href="https://www.tensorflow.org/get_started/embedding_viz" >this tutorial</a > for more. </p> <h4><span class="step-label">Step 1:</span> Make data public</h4> <p> Host tensors, metadata, sprite image, and bookmarks TSV files <i>publicly</i> on the web. </p> <p> One option is using a <a target="_blank" href="https://gist.github.com/" rel="noopener noreferrer" >github gist</a >. If you choose this approach, make sure to link directly to the raw file. </p> </div> <div> <h4><span class="step-label">Step 2:</span> Projector config</h4> <div class="projector-config-options"> <i>Optional:</i> <div class="config-checkbox"> <paper-checkbox id="config-metadata-checkbox" checked >Metadata</paper-checkbox > </div> <div class="config-checkbox"> <paper-checkbox id="config-sprite-checkbox" >Sprite</paper-checkbox > </div> <div class="config-checkbox"> <paper-checkbox id="config-bookmarks-checkbox" >Bookmarks</paper-checkbox > </div> </div> </div> <paper-textarea id="projector-config-template" label="template_projector_config.json" ></paper-textarea> <div> <h4> <span class="step-label">Step 3:</span> Host projector config </h4> After you have hosted the projector config JSON file you built above, paste the URL to the config below. </div> <paper-input id="projector-config-url" label="Path to projector config" ></paper-input> <paper-input id="projector-share-url" label="Your shareable URL" readonly ></paper-input> <div id="projector-share-button-container"> <a target="_blank" id="projector-share-url-link" rel="noopener noreferrer" > <paper-button title="Test your shareable URL" class="ink-button" >Test your shareable URL</paper-button > </a> </div> </paper-dialog-scrollable> <div class="dismiss-dialog-note">Click outside to dismiss.</div> </paper-dialog> </div> <paper-checkbox id="normalize-data-checkbox" checked="{{normalizeData}}"> Sphereize data <paper-icon-button icon="help" class="help-icon"></paper-icon-button> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > The data is normalized by shifting each point by the centroid and making it unit norm. </paper-tooltip> </paper-checkbox> <div class="dirs"> <table> <tr> <td>Checkpoint:</td> <td> <span id="checkpoint-file"> <tf-wbr-string title="[[projectorConfig.modelCheckpointPath]]" delimiter-pattern="[[_wordDelimiter]]" value="[[projectorConfig.modelCheckpointPath]]" ></tf-wbr-string> </span> </td> </tr> <tr> <td>Metadata:</td> <td> <span id="metadata-file"> <tf-wbr-string title="[[metadataFile]]" delimiter-pattern="[[_wordDelimiter]]" value="[[metadataFile]]" ></tf-wbr-string> </span> </td> </tr> </table> </div> </div> `;let Legend=class extends(LegacyElementMixin(PolymerElement)){_renderInfoChanged(){null!=this.renderInfo&&this.renderInfo.thresholds&&this.async((()=>this.setupLinearGradient()))}_getLastThreshold(){if(null!=this.renderInfo&&null!=this.renderInfo.thresholds)return this.renderInfo.thresholds[this.renderInfo.thresholds.length-1].value}getOffset(e){const t=this.renderInfo.thresholds[0].value;return(100*(e-t)/(this.renderInfo.thresholds[this.renderInfo.thresholds.length-1].value-t)).toFixed(2)+"%"}setupLinearGradient(){const e=this.$$("#gradient"),t=this.$$("svg.gradient").clientWidth;this.$$("svg.gradient rect").style.width=t+"px",e.textContent="",this.renderInfo.thresholds.forEach((e=>{const t=document.createElementNS("http://www.w3.org/2000/svg","stop");t.setAttribute("offset",this.getOffset(e.value)),t.setAttribute("stop-color",e.color)}))}};Legend.template=html` <style include="vz-projector-styles"></style> <style> .item { display: flex; align-items: flex-start; margin-bottom: 10px; } .shape { width: 10px; height: 10px; margin-right: 10px; margin-top: 5px; border-radius: 50%; } .label { flex-grow: 1; } .gradient { width: 100%; height: 10px; } .gradient-boundaries { display: flex; justify-content: space-between; } </style> <template is="dom-repeat" items="[[renderInfo.items]]"> <div class="item"> <div class="shape" style="background-color: [[item.color]];"></div> <div class="label">[[item.label]]</div> <div class="info" style="color: [[item.color]];">[[item.count]]</div> </div> </template> <template is="dom-if" if="[[renderInfo.thresholds]]"> <svg class="gradient"> <defs> <linearGradient id="gradient" x1="0%" y1="100%" x2="100%" y2="100%" ></linearGradient> </defs> <rect height="10" style="fill: url('#gradient');"></rect> </svg> <div class="gradient-boundaries"> <div>[[renderInfo.thresholds.0.value]]</div> <div>[[_getLastThreshold(renderInfo.thresholds)]]</div> </div> </template> `,__decorate([property({type:Object}),__metadata("design:type",Object)],Legend.prototype,"renderInfo",void 0),__decorate([observe("renderInfo"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],Legend.prototype,"_renderInfoChanged",null),Legend=__decorate([customElement("vz-projector-legend")],Legend);let DataPanel=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.metadataEditorInputLabel="Tag selection as",this.superviseInputLabel="Ignored label",this.showSuperviseSettings=!1,this._wordDelimiter="[/=_,-]",this.forceCategoricalColoring=!1}ready(){super.ready(),this.normalizeData=!0,this.superviseInputSelected=""}initialize(e,t){this.projector=e,this.dataProvider=t,this.setupUploadButtons(),this.$$("#normalize-data-checkbox").addEventListener("change",(()=>{this.projector.setNormalizeData(this.normalizeData)}));let n=this.$$("#force-categorical-checkbox");n.addEventListener("change",(()=>{this.setForceCategoricalColoring(n.checked)})),this.dataProvider.retrieveRuns((e=>{this.runNames=e,this.runNames.length>0&&(this.selectedRun!=e[0]?this.selectedRun=e[0]:this._generateUiForNewCheckpointForRun(this.selectedRun))}))}setForceCategoricalColoring(e){this.forceCategoricalColoring=e,this.$$("#force-categorical-checkbox").checked=this.forceCategoricalColoring,this.updateMetadataUI(this.spriteAndMetadata.stats,this.metadataFile),this._selectedColorOptionNameChanged()}getSeparatorClass(e){return e?"separator":null}metadataChanged(e,t){this.spriteAndMetadata=e,null!=t&&(this.metadataFile=t),this.updateMetadataUI(this.spriteAndMetadata.stats,this.metadataFile),null!=this.selectedColorOptionName&&0!==this.colorOptions.filter((e=>e.name===this.selectedColorOptionName)).length||(this.selectedColorOptionName=this.colorOptions[0].name);let n=-1;this.metadataFields=e.stats.map(((e,t)=>(e.isNumeric||-1!==n||(n=t),e.name))),null!=this.metadataEditorColumn&&0!==this.metadataFields.filter((e=>e===this.metadataEditorColumn)).length||(this.metadataEditorColumn=this.metadataFields[Math.max(0,n)]),null!=this.superviseColumn&&0!==this.metadataFields.filter((e=>e===this.superviseColumn)).length||(this.superviseColumn=this.metadataFields[Math.max(0,n)],this.superviseInput=""),this.superviseInputChange()}projectionChanged(e){if(e)switch(e.projectionType){case"tsne":this.set("showSuperviseSettings",!0);break;default:this.set("showSuperviseSettings",!1)}}onProjectorSelectionChanged(e,t){this.selectedPointIndices=e,this.neighborsOfFirstPoint=t,this.metadataEditorInputChange()}updateMetadataUI(e,t){let n=-1;this.labelOptions=e.map(((e,t)=>(e.isNumeric||-1!==n||(n=t),e.name))),null!=this.selectedLabelOption&&0!==this.labelOptions.filter((e=>e===this.selectedLabelOption)).length||(this.selectedLabelOption=this.labelOptions[Math.max(0,n)]),null!=this.metadataEditorColumn&&0!==this.labelOptions.filter((e=>e===this.metadataEditorColumn)).length||(this.metadataEditorColumn=this.labelOptions[Math.max(0,n)]);const i=[{name:"No color map"}],r=e.filter((e=>!e.tooManyUniqueValues||e.isNumeric)).map((e=>{let t,n,i,r;if(this.forceCategoricalColoring||!e.tooManyUniqueValues){const i=ordinal(category10);let o=i.range(),a=o.map(((e,t)=>o[3*t%o.length]));n=e.uniqueEntries,i.range(a).domain(n.map((e=>e.label))),t=i;const s=e.uniqueEntries.length;r=`${s} ${s>o.length?" non-unique":""} colors`}else i=[{color:"#ffffdd",value:e.min},{color:"#1f2d86",value:e.max}],t=linear().domain(i.map((e=>e.value))).range(i.map((e=>e.color))),r="gradient";return{name:e.name,desc:r,map:t,items:n,thresholds:i,tooManyUniqueValues:e.tooManyUniqueValues}}));r.length>0&&i.push({name:"Metadata",isSeparator:!0}),this.colorOptions=i.concat(r)}metadataEditorContext(e){this.metadataEditorButtonDisabled=!e,this.projector&&this.projector.metadataEditorContext(e,this.metadataEditorColumn)}metadataEditorInputChange(){let e=this.metadataEditorColumn,t=this.metadataEditorInput,n=this.selectedPointIndices.length+this.neighborsOfFirstPoint.length;if(n>0)if(null!=t&&""!==t.trim())if(this.spriteAndMetadata.stats.filter((t=>t.name===e))[0].isNumeric&&isNaN(+t))this.metadataEditorInputLabel="Label must be numeric",this.metadataEditorContext(!1);else{let i=this.projector.dataSet.points.filter((n=>n.metadata[e].toString()===t.trim())).length;this.metadataEditorInputLabel=0===i?`Tag ${n} with new label`:`Tag ${n} points as`,this.metadataEditorContext(!0)}else this.metadataEditorInputLabel="Tag selection as",this.metadataEditorContext(!1);else this.metadataEditorContext(!1),this.metadataEditorInputLabel=null!=t&&""!==t.trim()?"Select points to tag":"Tag selection as"}metadataEditorInputKeydown(e){13===e.keyCode&&this.metadataEditorButtonClicked(),e.stopPropagation()}metadataEditorColumnChange(){this.metadataEditorInputChange()}metadataEditorButtonClicked(){if(!this.metadataEditorButtonDisabled){let e=this.metadataEditorInput.trim(),t=this.selectedPointIndices.length+this.neighborsOfFirstPoint.length;this.projector.metadataEdit(this.metadataEditorColumn,e),this.projector.metadataEditorContext(!0,this.metadataEditorColumn),this.metadataEditorInputLabel=`${t} labeled as '${e}'`}}downloadMetadataClicked(){if(this.projector&&this.projector.dataSet&&this.projector.dataSet.spriteAndMetadataInfo){let e=this.projector.dataSet.spriteAndMetadataInfo.stats.map((e=>e.name)).join("\t");this.projector.dataSet.spriteAndMetadataInfo.pointsInfo.forEach((t=>{let n=[];for(const e in t)n.push(t[e]);e+="\n"+n.join("\t")}));const t=new Blob([e],{type:"text/plain"}),n=this.$.downloadMetadataLink;n.download="metadata-edited.tsv",Object.assign(n,{href:window.URL.createObjectURL(t)}),n.click()}}superviseInputTyping(){let e=this.superviseInput.trim();if(null!=e&&""!==e.trim()){if(this.projector&&this.projector.dataSet){let t=this.projector.dataSet.points.filter((t=>t.metadata[this.superviseColumn].toString().trim()===e)).length;0===t?this.superviseInputLabel="Label not found":this.projector.dataSet.superviseInput!=e&&(this.superviseInputLabel=`Supervise without '${e}' [${t} points]`)}}else this.superviseInputLabel=""===this.superviseInputSelected?"No ignored label":`Supervising without '${this.superviseInputSelected}'`}superviseInputChange(){let e=this.superviseInput.trim();if(null==e||""===e.trim())return this.superviseInputSelected="",this.superviseInputLabel="No ignored label",void this.setSupervision(this.superviseColumn,"");if(this.projector&&this.projector.dataSet){let t=this.projector.dataSet.points.filter((t=>t.metadata[this.superviseColumn].toString().trim()===e)).length;0===t?this.superviseInputLabel=`Supervising without '${this.superviseInputSelected}'`:(this.superviseInputSelected=e,this.superviseInputLabel=`Supervising without '${e}' [${t} points]`,this.setSupervision(this.superviseColumn,e))}}superviseColumnChanged(){this.superviseInput="",this.superviseInputChange()}setSupervision(e,t){this.projector&&this.projector.dataSet&&this.projector.dataSet.setSupervision(e,t)}setNormalizeData(e){this.normalizeData=e}_selectedTensorChanged(){this.projector.updateDataSet(null,null,null),null!=this.selectedTensor&&(this.dataProvider.retrieveTensor(this.selectedRun,this.selectedTensor,(e=>{let t=this.getEmbeddingInfoByName(this.selectedTensor).metadataPath;this.dataProvider.retrieveSpriteAndMetadata(this.selectedRun,this.selectedTensor,(n=>{this.projector.updateDataSet(e,n,t)}))})),this.projector.setSelectedTensor(this.selectedRun,this.getEmbeddingInfoByName(this.selectedTensor)))}_generateUiForNewCheckpointForRun(e){this.dataProvider.retrieveProjectorConfig(e,(e=>{this.projectorConfig=e;let t=this.projectorConfig.embeddings.map((e=>e.tensorName)).filter((e=>{let t=this.getEmbeddingInfoByName(e).tensorShape;return 2===t.length&&t[0]>1&&t[1]>1})).sort(((e,t)=>{let n=this.getEmbeddingInfoByName(e),i=this.getEmbeddingInfoByName(t);if(xor(!!n.metadataPath,!!i.metadataPath))return n.metadataPath?-1:1;let r=tensorIsGenerated(e),o=tensorIsGenerated(t);if(xor(r,o))return o?-1:1;let a=n.tensorShape[0],s=i.tensorShape[0];return a!==s?s-a:e<=t?-1:1}));this.tensorNames=t.map((e=>({name:e,shape:this.getEmbeddingInfoByName(e).tensorShape})));const n="demo"===this.projector.servingMode?this.projectorConfig.embeddings[0].tensorName:t[0];this.selectedTensor===n?this._selectedTensorChanged():this.selectedTensor=n}))}_selectedLabelOptionChanged(){this.projector.setSelectedLabelOption(this.selectedLabelOption)}_selectedColorOptionNameChanged(){let e;for(let t=0;t<this.colorOptions.length;t++)if(this.colorOptions[t].name===this.selectedColorOptionName){e=this.colorOptions[t];break}if(e){if(this.showForceCategoricalColorsCheckbox=!!e.tooManyUniqueValues,null==e.map)this.colorLegendRenderInfo=null;else if(e.items){let t=e.items.map((t=>({color:e.map(t.label),label:t.label,count:t.count})));this.colorLegendRenderInfo={items:t,thresholds:null}}else this.colorLegendRenderInfo={items:null,thresholds:e.thresholds};this.projector.setSelectedColorOption(e)}}tensorWasReadFromFile(e,t){parseRawTensors(e,(e=>{const n=this.$$("#checkpoint-file");n.innerText=t,n.title=t,this.projector.updateDataSet(e)}))}metadataWasReadFromFile(e,t){parseRawMetadata(e,(e=>{this.projector.updateDataSet(this.projector.dataSet,e,t)}))}getEmbeddingInfoByName(e){for(let t=0;t<this.projectorConfig.embeddings.length;t++){const n=this.projectorConfig.embeddings[t];if(n.tensorName===e)return n}}setupUploadButtons(){const e=this.$$("#file");e.onchange=()=>{const t=e.files[0];e.value="";const n=new FileReader;n.onload=e=>{this.tensorWasReadFromFile(n.result,t.name)},n.readAsArrayBuffer(t)},this.$$("#upload-tensors").onclick=()=>{e.click()};const t=this.$$("#file-metadata");t.onchange=()=>{const e=t.files[0];t.value="";const n=new FileReader;n.onload=t=>{this.metadataWasReadFromFile(n.result,e.name)},n.readAsArrayBuffer(e)},this.$$("#upload-metadata").onclick=()=>{t.click()},"demo"!==this.projector.servingMode&&(this.$$("#publish-container").style.display="none",this.$$("#upload-tensors-step-container").style.display="none",this.$$("#upload-metadata-label").style.display="none"),this.$$("#demo-data-buttons-container").style.display="flex";const n=this.$$("#projector-config-template"),i={embeddings:[{tensorName:"My tensor",tensorShape:[1e3,50],tensorPath:"https://raw.githubusercontent.com/.../tensors.tsv",metadataPath:"https://raw.githubusercontent.com/.../optional.metadata.tsv"}]};this.setProjectorConfigTemplateJson(n,i);const r=this.$$("#config-sprite-checkbox");r.onchange=()=>{r.checked?i.embeddings[0].sprite={imagePath:"https://github.com/.../optional.sprite.png",singleImageDim:[32,32]}:delete i.embeddings[0].sprite,this.setProjectorConfigTemplateJson(n,i)};const o=this.$$("#config-bookmarks-checkbox");o.onchange=()=>{o.checked?i.embeddings[0].bookmarksPath="https://raw.githubusercontent.com/.../bookmarks.txt":delete i.embeddings[0].bookmarksPath,this.setProjectorConfigTemplateJson(n,i)};const a=this.$$("#config-metadata-checkbox");a.onchange=()=>{a.checked?i.embeddings[0].metadataPath="https://raw.githubusercontent.com/.../optional.metadata.tsv":delete i.embeddings[0].metadataPath,this.setProjectorConfigTemplateJson(n,i)};const s=this.$$("#projector-config-url"),l=this.$$("#projector-share-url"),c=this.$$("#projector-share-url-link");s.onchange=()=>{let e=location.protocol+"//"+location.host+location.pathname+"?config="+s.value;l.value=e,Object.assign(c,{href:e})}}setProjectorConfigTemplateJson(e,t){e.value=JSON.stringify(t,null,2)}_getNumTensorsLabel(){return 1===this.tensorNames.length?"1 tensor":this.tensorNames.length+" tensors"}_getNumRunsLabel(){return 1===this.runNames.length?"1 run":this.runNames.length+" runs"}_hasChoice(e){return e.length>0}_hasChoices(e){return e.length>1}_openDataDialog(){this.$.dataDialog.open()}_openConfigDialog(){this.$.projectorConfigDialog.open()}};DataPanel.template=template$1,__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"selectedTensor",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"selectedRun",void 0),__decorate([property({type:String,notify:!0}),__metadata("design:type",String)],DataPanel.prototype,"selectedColorOptionName",void 0),__decorate([property({type:String,notify:!0}),__metadata("design:type",String)],DataPanel.prototype,"selectedLabelOption",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],DataPanel.prototype,"normalizeData",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],DataPanel.prototype,"showForceCategoricalColorsCheckbox",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"metadataEditorInput",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"metadataEditorInputLabel",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"metadataEditorColumn",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],DataPanel.prototype,"metadataEditorButtonDisabled",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"superviseInput",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"superviseInputLabel",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"superviseColumn",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],DataPanel.prototype,"showSuperviseSettings",void 0),__decorate([property({type:String}),__metadata("design:type",Object)],DataPanel.prototype,"_wordDelimiter",void 0),__decorate([observe("selectedTensor"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],DataPanel.prototype,"_selectedTensorChanged",null),__decorate([observe("selectedRun"),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],DataPanel.prototype,"_generateUiForNewCheckpointForRun",null),__decorate([observe("selectedLabelOption"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],DataPanel.prototype,"_selectedLabelOptionChanged",null),__decorate([observe("selectedColorOptionName"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],DataPanel.prototype,"_selectedColorOptionNameChanged",null),DataPanel=__decorate([customElement("vz-projector-data-panel")],DataPanel);const template=html` <style include="vz-projector-styles"></style> <style> :host { display: flex; flex-direction: column; /* Account for the bookmark pane at the bottom */ height: calc(100% - 55px); } .container { display: block; padding: 10px 20px 0 20px; } .buttons { display: flex; height: 60px; } .button { margin-right: 10px; border: none; border-radius: 7px; font-size: 13px; padding: 10px; background: #e3e3e3; } .button:last-child { margin-right: 0; } .nn, .metadata-info { display: flex; flex-direction: column; } .nn > *, .metadata-info > * { padding: 0 20px; } .nn-list, .metadata-list { overflow-y: auto; } .nn-list .neighbor, .metadata-list .metadata { font-size: 12px; margin-bottom: 8px; } .nn-list .label-and-value, .metadata-list .label-and-value { display: flex; justify-content: space-between; } .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .nn-list .value, .metadata-list .value { color: #666; float: right; font-weight: 300; margin-left: 8px; } .nn-list .bar, .metadata-list .bar { position: relative; border-top: 1px solid rgba(0, 0, 0, 0.15); margin: 2px 0; } .nn-list .bar .fill, .metadata-list .bar .fill { position: absolute; top: -1px; border-top: 1px solid white; } .nn-list .tick, .metadata-list .tick { position: absolute; top: 0px; height: 3px; border-left: 1px solid rgba(0, 0, 0, 0.15); } .nn-list .sprite-image, .metadata-list .sprite-image { width: 100%; } .nn-list.nn-img-show .sprite-image, .metadata-list.nn-img-show .sprite-image { display: block; } .nn-list .neighbor-link:hover, .metadata-list .metadata-link:hover { cursor: pointer; } .search-by { display: flex; } .search-by vz-projector-input { width: 100%; } .search-by paper-dropdown-menu { margin-left: 10px; width: 100px; } .distance .options { float: right; } .neighbor-image-controls { display: flex; padding: 0.8em 0.1em; } .options a { color: #727272; font-size: 13px; margin-left: 12px; text-decoration: none; } .options a.selected { color: #009efe; } .neighbors { margin-bottom: 15px; } .neighbors-options { margin-top: 6px; } .neighbors-options .option-label, .distance .option-label { color: #727272; margin-right: 2px; width: auto; } .num-neighbors-container { display: inline-block; } .nn-slider { --paper-slider-input: { width: 64px; } --paper-input-container-input: { font-size: 14px; } } .euclidean { margin-right: 10px; } .matches-list { padding: 0 20px; } .matches-list .row { border-bottom: 1px solid #ddd; cursor: pointer; display: flex; font-size: 12px; margin: 5px 0; padding: 4px 0; } .results { display: flex; flex-direction: column; } .results, .nn, .nn-list { flex: 1 0 100px; } </style> <div class="container"> <div class="buttons"> <button class="button reset-filter">Show All Data</button> <button class="button set-filter">Isolate selection</button> <button class="button clear-selection">Clear selection</button> </div> <div class="search-by"> <vz-projector-input id="search-box" label="Search"></vz-projector-input> <paper-dropdown-menu no-animations label="by"> <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedMetadataField}}" slot="dropdown-content" > <template is="dom-repeat" items="[[metadataFields]]"> <paper-item value="[[item]]" label="[[item]]"> [[item]] </paper-item> </template> </paper-listbox> </paper-dropdown-menu> </div> </div> <div class="results"> <div class="nn" style="display: none"> <div class="neighbors"> <div class="neighbors-options"> <div class="slider num-nn"> <span class="option-label">neighbors</span> <paper-icon-button icon="help" class="help-icon" ></paper-icon-button> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > The number of neighbors (in the original space) to show when clicking on a point. </paper-tooltip> <paper-slider class="nn-slider" pin min="5" max="999" editable value="{{numNN}}" on-change="updateNumNN" ></paper-slider> </div> </div> <div class="distance"> <span class="option-label">distance</span> <div class="options"> <a class="selected cosine" href="javascript:void(0);">COSINE</a> <a class="euclidean" href="javascript:void(0);">EUCLIDEAN</a> </div> </div> <div class="neighbor-image-controls"> <template is="dom-if" if="[[spriteImagesAvailable]]"> <paper-checkbox checked="{{showNeighborImages}}"> show images <paper-icon-button icon="help" class="help-icon" ></paper-icon-button> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > Show the images of the nearest neighbors. </paper-tooltip> </paper-checkbox> </template> </div> </div> <p>Nearest points in the original space:</p> <div class="nn-list"></div> </div> <div class="metadata-info" style="display: none"> <div class="neighbors-options"> <div class="slider num-nn"> <span class="option-label">neighbors</span> <paper-icon-button icon="help" class="help-icon"></paper-icon-button> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds > The number of neighbors (in the selected space) to show when clicking on a point. </paper-tooltip> <paper-slider class="nn-slider" pin min="5" max="999" editable value="{{numNN}}" on-change="updateNumNN" ></paper-slider> </div> </div> <p>{{metadataColumn}} labels (click to apply):</p> <div class="metadata-list"></div> </div> <div class="matches-list" style="display: none"> <div class="list"></div> <div class="limit-msg">Showing only the first 100 results...</div> </div> </div> `;class LabelRenderParams{constructor(e,t,n,i,r,o,a){this.pointIndices=e,this.labelStrings=t,this.scaleFactors=n,this.useSceneOpacityFlags=i,this.defaultFontSize=r,this.fillColors=o,this.strokeColors=a}}var CameraType;!(function(e){e[e.Perspective=0]="Perspective",e[e.Orthographic=1]="Orthographic"})(CameraType||(CameraType={}));class RenderContext{constructor(e,t,n,i,r,o,a,s,l,c,h,u,d,p){this.camera=e,this.cameraType=t,this.cameraTarget=n,this.screenWidth=i,this.screenHeight=r,this.nearestCameraSpacePointZ=o,this.farthestCameraSpacePointZ=a,this.backgroundColor=s,this.pointColors=l,this.pointScaleFactors=c,this.labels=h,this.polylineColors=u,this.polylineOpacities=d,this.polylineWidths=p}}var OrbitControls=function(e,t){var n,i,r,o,a,s;void 0===t&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.enabled=!0,this.target=new Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:MOUSE.ROTATE,MIDDLE:MOUSE.DOLLY,RIGHT:MOUSE.PAN},this.touches={ONE:TOUCH.ROTATE,TWO:TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return f.phi},this.getAzimuthalAngle=function(){return f.theta},this.listenToKeyEvents=function(e){e.addEventListener("keydown",Y),this._domElementKeyEvents=e},this.saveState=function(){l.target0.copy(l.target),l.position0.copy(l.object.position),l.zoom0=l.object.zoom},this.reset=function(){l.target.copy(l.target0),l.object.position.copy(l.position0),l.object.zoom=l.zoom0,l.object.updateProjectionMatrix(),l.dispatchEvent(c),l.update(),p=d.NONE},this.update=(n=new Vector3,i=(new Quaternion).setFromUnitVectors(e.up,new Vector3(0,1,0)),r=i.clone().invert(),o=new Vector3,a=new Quaternion,s=2*Math.PI,function e(){var t=l.object.position;n.copy(t).sub(l.target),n.applyQuaternion(i),f.setFromVector3(n),l.autoRotate&&p===d.NONE&&k((function h(){return 2*Math.PI/60/60*l.autoRotateSpeed})()),l.enableDamping?(f.theta+=g.theta*l.dampingFactor,f.phi+=g.phi*l.dampingFactor):(f.theta+=g.theta,f.phi+=g.phi);var u=l.minAzimuthAngle,_=l.maxAzimuthAngle;return isFinite(u)&&isFinite(_)&&(u<-Math.PI?u+=s:u>Math.PI&&(u-=s),_<-Math.PI?_+=s:_>Math.PI&&(_-=s),f.theta=u<=_?Math.max(u,Math.min(_,f.theta)):f.theta>(u+_)/2?Math.max(u,f.theta):Math.min(_,f.theta)),f.phi=Math.max(l.minPolarAngle,Math.min(l.maxPolarAngle,f.phi)),f.makeSafe(),f.radius*=v,f.radius=Math.max(l.minDistance,Math.min(l.maxDistance,f.radius)),!0===l.enableDamping?l.target.addScaledVector(y,l.dampingFactor):l.target.add(y),n.setFromSpherical(f),n.applyQuaternion(r),t.copy(l.target).add(n),l.object.lookAt(l.target),!0===l.enableDamping?(g.theta*=1-l.dampingFactor,g.phi*=1-l.dampingFactor,y.multiplyScalar(1-l.dampingFactor)):(g.set(0,0,0),y.set(0,0,0)),v=1,!!(b||o.distanceToSquared(l.object.position)>m||8*(1-a.dot(l.object.quaternion))>m)&&(l.dispatchEvent(c),o.copy(l.object.position),a.copy(l.object.quaternion),b=!1,!0)}),this.dispose=function(){l.domElement.removeEventListener("contextmenu",ee),l.domElement.removeEventListener("pointerdown",W),l.domElement.removeEventListener("wheel",K),l.domElement.removeEventListener("touchstart",Z),l.domElement.removeEventListener("touchend",Q),l.domElement.removeEventListener("touchmove",J),l.domElement.ownerDocument.removeEventListener("pointermove",q),l.domElement.ownerDocument.removeEventListener("pointerup",X),null!==l._domElementKeyEvents&&l._domElementKeyEvents.removeEventListener("keydown",Y)};var l=this,c={type:"change"},h={type:"start"},u={type:"end"},d={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},p=d.NONE,m=1e-6,f=new Spherical,g=new Spherical,v=1,y=new Vector3,b=!1,_=new Vector2,x=new Vector2,w=new Vector2,S=new Vector2,C=new Vector2,M=new Vector2,E=new Vector2,T=new Vector2,I=new Vector2;function A(){return Math.pow(.95,l.zoomSpeed)}function k(e){g.theta-=e}function P(e){g.phi-=e}var R,L=(R=new Vector3,function e(t,n){R.setFromMatrixColumn(n,0),R.multiplyScalar(-t),y.add(R)}),N=(function(){var e=new Vector3;return function t(n,i){!0===l.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(l.object.up,e)),e.multiplyScalar(n),y.add(e)}})(),D=(function(){var e=new Vector3;return function t(n,i){var r=l.domElement;if(l.object.isPerspectiveCamera){e.copy(l.object.position).sub(l.target);var o=e.length();o*=Math.tan(l.object.fov/2*Math.PI/180),L(2*n*o/r.clientHeight,l.object.matrix),N(2*i*o/r.clientHeight,l.object.matrix)}else l.object.isOrthographicCamera?(L(n*(l.object.right-l.object.left)/l.object.zoom/r.clientWidth,l.object.matrix),N(i*(l.object.top-l.object.bottom)/l.object.zoom/r.clientHeight,l.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),l.enablePan=!1)}})();function O(e){l.object.isPerspectiveCamera?v/=e:l.object.isOrthographicCamera?(l.object.zoom=Math.max(l.minZoom,Math.min(l.maxZoom,l.object.zoom*e)),l.object.updateProjectionMatrix(),b=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),l.enableZoom=!1)}function z(e){l.object.isPerspectiveCamera?v*=e:l.object.isOrthographicCamera?(l.object.zoom=Math.max(l.minZoom,Math.min(l.maxZoom,l.object.zoom/e)),l.object.updateProjectionMatrix(),b=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),l.enableZoom=!1)}function F(e){_.set(e.clientX,e.clientY)}function $(e){S.set(e.clientX,e.clientY)}function B(e){1==e.touches.length?_.set(e.touches[0].pageX,e.touches[0].pageY):_.set(.5*(e.touches[0].pageX+e.touches[1].pageX),.5*(e.touches[0].pageY+e.touches[1].pageY))}function V(e){1==e.touches.length?S.set(e.touches[0].pageX,e.touches[0].pageY):S.set(.5*(e.touches[0].pageX+e.touches[1].pageX),.5*(e.touches[0].pageY+e.touches[1].pageY))}function H(e){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+n*n);E.set(0,i)}function U(e){1==e.touches.length?x.set(e.touches[0].pageX,e.touches[0].pageY):x.set(.5*(e.touches[0].pageX+e.touches[1].pageX),.5*(e.touches[0].pageY+e.touches[1].pageY)),w.subVectors(x,_).multiplyScalar(l.rotateSpeed);var t=l.domElement;k(2*Math.PI*w.x/t.clientHeight),P(2*Math.PI*w.y/t.clientHeight),_.copy(x)}function G(e){1==e.touches.length?C.set(e.touches[0].pageX,e.touches[0].pageY):C.set(.5*(e.touches[0].pageX+e.touches[1].pageX),.5*(e.touches[0].pageY+e.touches[1].pageY)),M.subVectors(C,S).multiplyScalar(l.panSpeed),D(M.x,M.y),S.copy(C)}function j(e){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+n*n);T.set(0,i),I.set(0,Math.pow(T.y/E.y,l.zoomSpeed)),O(I.y),E.copy(T)}function W(e){if(!1!==l.enabled)switch(e.pointerType){case"mouse":case"pen":!(function t(e){var t;switch(e.preventDefault(),l.domElement.focus?l.domElement.focus():window.focus(),e.button){case 0:t=l.mouseButtons.LEFT;break;case 1:t=l.mouseButtons.MIDDLE;break;case 2:t=l.mouseButtons.RIGHT;break;default:t=-1}switch(t){case MOUSE.DOLLY:if(!1===l.enableZoom)return;!(function n(e){E.set(e.clientX,e.clientY)})(e),p=d.DOLLY;break;case MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===l.enablePan)return;$(e),p=d.PAN}else{if(!1===l.enableRotate)return;F(e),p=d.ROTATE}break;case MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===l.enableRotate)return;F(e),p=d.ROTATE}else{if(!1===l.enablePan)return;$(e),p=d.PAN}break;default:p=d.NONE}p!==d.NONE&&(l.domElement.ownerDocument.addEventListener("pointermove",q),l.domElement.ownerDocument.addEventListener("pointerup",X),l.dispatchEvent(h))})(e)}}function q(e){if(!1!==l.enabled)switch(e.pointerType){case"mouse":case"pen":!(function t(e){if(!1!==l.enabled)switch(e.preventDefault(),p){case d.ROTATE:if(!1===l.enableRotate)return;!(function t(e){x.set(e.clientX,e.clientY),w.subVectors(x,_).multiplyScalar(l.rotateSpeed);var t=l.domElement;k(2*Math.PI*w.x/t.clientHeight),P(2*Math.PI*w.y/t.clientHeight),_.copy(x),l.update()})(e);break;case d.DOLLY:if(!1===l.enableZoom)return;!(function n(e){T.set(e.clientX,e.clientY),I.subVectors(T,E),I.y>0?O(A()):I.y<0&&z(A()),E.copy(T),l.update()})(e);break;case d.PAN:if(!1===l.enablePan)return;!(function i(e){C.set(e.clientX,e.clientY),M.subVectors(C,S).multiplyScalar(l.panSpeed),D(M.x,M.y),S.copy(C),l.update()})(e)}})(e)}}function X(e){switch(e.pointerType){case"mouse":case"pen":!(function t(e){l.domElement.ownerDocument.removeEventListener("pointermove",q),l.domElement.ownerDocument.removeEventListener("pointerup",X),!1!==l.enabled&&(l.dispatchEvent(u),p=d.NONE)})()}}function K(e){!1===l.enabled||!1===l.enableZoom||p!==d.NONE&&p!==d.ROTATE||(e.preventDefault(),e.stopPropagation(),l.dispatchEvent(h),(function t(e){e.deltaY<0?z(A()):e.deltaY>0&&O(A()),l.update()})(e),l.dispatchEvent(u))}function Y(e){!1!==l.enabled&&!1!==l.enablePan&&(function t(e){var t=!1;switch(e.keyCode){case l.keys.UP:D(0,l.keyPanSpeed),t=!0;break;case l.keys.BOTTOM:D(0,-l.keyPanSpeed),t=!0;break;case l.keys.LEFT:D(l.keyPanSpeed,0),t=!0;break;case l.keys.RIGHT:D(-l.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),l.update())})(e)}function Z(e){if(!1!==l.enabled){switch(e.preventDefault(),e.touches.length){case 1:switch(l.touches.ONE){case TOUCH.ROTATE:if(!1===l.enableRotate)return;B(e),p=d.TOUCH_ROTATE;break;case TOUCH.PAN:if(!1===l.enablePan)return;V(e),p=d.TOUCH_PAN;break;default:p=d.NONE}break;case 2:switch(l.touches.TWO){case TOUCH.DOLLY_PAN:if(!1===l.enableZoom&&!1===l.enablePan)return;!(function t(e){l.enableZoom&&H(e),l.enablePan&&V(e)})(e),p=d.TOUCH_DOLLY_PAN;break;case TOUCH.DOLLY_ROTATE:if(!1===l.enableZoom&&!1===l.enableRotate)return;!(function n(e){l.enableZoom&&H(e),l.enableRotate&&B(e)})(e),p=d.TOUCH_DOLLY_ROTATE;break;default:p=d.NONE}break;default:p=d.NONE}p!==d.NONE&&l.dispatchEvent(h)}}function J(e){if(!1!==l.enabled)switch(e.preventDefault(),e.stopPropagation(),p){case d.TOUCH_ROTATE:if(!1===l.enableRotate)return;U(e),l.update();break;case d.TOUCH_PAN:if(!1===l.enablePan)return;G(e),l.update();break;case d.TOUCH_DOLLY_PAN:if(!1===l.enableZoom&&!1===l.enablePan)return;!(function t(e){l.enableZoom&&j(e),l.enablePan&&G(e)})(e),l.update();break;case d.TOUCH_DOLLY_ROTATE:if(!1===l.enableZoom&&!1===l.enableRotate)return;!(function n(e){l.enableZoom&&j(e),l.enableRotate&&U(e)})(e),l.update();break;default:p=d.NONE}}function Q(e){!1!==l.enabled&&(l.dispatchEvent(u),p=d.NONE)}function ee(e){!1!==l.enabled&&e.preventDefault()}l.domElement.addEventListener("contextmenu",ee),l.domElement.addEventListener("pointerdown",W),l.domElement.addEventListener("wheel",K),l.domElement.addEventListener("touchstart",Z),l.domElement.addEventListener("touchend",Q),l.domElement.addEventListener("touchmove",J),this.update()};OrbitControls.prototype=Object.create(EventDispatcher.prototype),OrbitControls.prototype.constructor=OrbitControls;var MapControls=function(e,t){OrbitControls.call(this,e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=MOUSE.PAN,this.mouseButtons.RIGHT=MOUSE.ROTATE,this.touches.ONE=TOUCH.PAN,this.touches.TWO=TOUCH.DOLLY_ROTATE};MapControls.prototype=Object.create(EventDispatcher.prototype),MapControls.prototype.constructor=MapControls;const FILL="#dddddd",FILL_OPACITY=.2,STROKE="#aaaaaa",STROKE_WIDTH=2,STROKE_DASHARRAY="10 5";class ScatterPlotRectangleSelector{constructor(e,t){this.svgElement=e.querySelector("#selector"),this.rectElement=document.createElementNS("http://www.w3.org/2000/svg","rect"),this.rectElement.style.stroke=STROKE,this.rectElement.style.strokeDasharray=STROKE_DASHARRAY,this.rectElement.style.strokeWidth=""+STROKE_WIDTH,this.rectElement.style.fill=FILL,this.rectElement.style.fillOpacity=""+FILL_OPACITY,this.svgElement.appendChild(this.rectElement),this.selectionCallback=t,this.isMouseDown=!1}onMouseDown(e,t){this.isMouseDown=!0,this.svgElement.style.display="block",this.startCoordinates=[e,t],this.lastBoundingBox={x:this.startCoordinates[0],y:this.startCoordinates[1],width:1,height:1}}onMouseMove(e,t){this.isMouseDown&&(this.lastBoundingBox.x=Math.min(e,this.startCoordinates[0]),this.lastBoundingBox.y=Math.max(t,this.startCoordinates[1]),this.lastBoundingBox.width=Math.max(e,this.startCoordinates[0])-this.lastBoundingBox.x,this.lastBoundingBox.height=this.lastBoundingBox.y-Math.min(t,this.startCoordinates[1]),this.rectElement.setAttribute("x",""+this.lastBoundingBox.x),this.rectElement.setAttribute("y",""+(this.lastBoundingBox.y-this.lastBoundingBox.height)),this.rectElement.setAttribute("width",""+this.lastBoundingBox.width),this.rectElement.setAttribute("height",""+this.lastBoundingBox.height))}onMouseUp(){this.isMouseDown=!1,this.svgElement.style.display="none",this.rectElement.setAttribute("width","0"),this.rectElement.setAttribute("height","0"),this.selectionCallback(this.lastBoundingBox)}}const BACKGROUND_COLOR=16777215,CUBE_LENGTH=2,MAX_ZOOM=5*CUBE_LENGTH,MIN_ZOOM=.025*CUBE_LENGTH,PERSP_CAMERA_FOV_VERTICAL=70,PERSP_CAMERA_NEAR_CLIP_PLANE=.01,PERSP_CAMERA_FAR_CLIP_PLANE=100,ORTHO_CAMERA_FRUSTUM_HALF_EXTENT=1.2,SHIFT_KEY=16,CTRL_KEY=17,ORBIT_MOUSE_ROTATION_SPEED=1,ORBIT_ANIMATION_ROTATION_CYCLE_IN_SECONDS=7;var MouseMode;!(function(e){e[e.AREA_SELECT=0]="AREA_SELECT",e[e.CAMERA_AND_CLICK_SELECT=1]="CAMERA_AND_CLICK_SELECT"})(MouseMode||(MouseMode={}));class CameraDef{constructor(){this.orthographic=!1}}class ScatterPlot{constructor(e,t){this.container=e,this.projectorEventContext=t,this.START_CAMERA_POS_3D=new Vector3(.45,.9,1.6),this.START_CAMERA_TARGET_3D=new Vector3(0,0,0),this.START_CAMERA_POS_2D=new Vector3(0,0,4),this.START_CAMERA_TARGET_2D=new Vector3(0,0,0),this.visualizers=[],this.onCameraMoveListeners=[],this.backgroundColor=BACKGROUND_COLOR,this.dimensionality=3,this.cameraDef=null,this.orbitAnimationOnNextCameraCreation=!1,this.selecting=!1,this.mouseIsDown=!1,this.isDragSequence=!1,this.getLayoutValues(),this.scene=new Scene,this.renderer=new WebGLRenderer({alpha:!0,premultipliedAlpha:!1,antialias:!1}),this.renderer.setClearColor(BACKGROUND_COLOR,1),this.container.appendChild(this.renderer.domElement),this.light=new PointLight(16772287,1,0),this.scene.add(this.light),this.setDimensions(3),this.recreateCamera(this.makeDefaultCameraDef(this.dimensionality)),this.renderer.render(this.scene,this.camera),this.rectangleSelector=new ScatterPlotRectangleSelector(this.container,(e=>this.selectBoundingBox(e))),this.addInteractionListeners()}addInteractionListeners(){this.container.addEventListener("mousemove",this.onMouseMove.bind(this)),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),this.container.addEventListener("mouseup",this.onMouseUp.bind(this)),this.container.addEventListener("click",this.onClick.bind(this)),window.addEventListener("keydown",this.onKeyDown.bind(this),!1),window.addEventListener("keyup",this.onKeyUp.bind(this),!1)}addCameraControlsEventListeners(e){e.addEventListener("start",(()=>{this.stopOrbitAnimation(),this.onCameraMoveListeners.forEach((t=>t(this.camera.position,e.target)))})),e.addEventListener("change",(()=>{this.render()})),e.addEventListener("end",(()=>{}))}makeOrbitControls(e,t,n){null!=this.orbitCameraControls&&this.orbitCameraControls.dispose();const i=new OrbitControls(e,this.renderer.domElement);i.target0=new Vector3(t.target[0],t.target[1],t.target[2]),i.position0=(new Vector3).copy(e.position),i.zoom0=t.zoom,i.enableRotate=n,i.autoRotate=!1,i.rotateSpeed=ORBIT_MOUSE_ROTATION_SPEED,n?(i.mouseButtons.ORBIT=MOUSE.LEFT,i.mouseButtons.PAN=MOUSE.RIGHT):(i.mouseButtons.ORBIT=null,i.mouseButtons.PAN=MOUSE.LEFT),i.reset(),this.camera=e,this.orbitCameraControls=i,this.addCameraControlsEventListeners(this.orbitCameraControls)}makeCamera3D(e,t,n){let i;{i=new PerspectiveCamera(PERSP_CAMERA_FOV_VERTICAL,t/n,PERSP_CAMERA_NEAR_CLIP_PLANE,PERSP_CAMERA_FAR_CLIP_PLANE),i.position.set(e.position[0],e.position[1],e.position[2]);const r=new Vector3(e.target[0],e.target[1],e.target[2]);i.lookAt(r),i.zoom=e.zoom,i.updateProjectionMatrix()}this.camera=i,this.makeOrbitControls(i,e,!0)}makeCamera2D(e,t,n){let i;const r=new Vector3(e.target[0],e.target[1],e.target[2]);{const o=t/n;let a=-ORTHO_CAMERA_FRUSTUM_HALF_EXTENT,s=ORTHO_CAMERA_FRUSTUM_HALF_EXTENT,l=-ORTHO_CAMERA_FRUSTUM_HALF_EXTENT,c=ORTHO_CAMERA_FRUSTUM_HALF_EXTENT;o>1?(a*=o,s*=o):(c/=o,l/=o),i=new OrthographicCamera(a,s,c,l,-1e3,1e3),i.position.set(e.position[0],e.position[1],e.position[2]),i.up=new Vector3(0,1,0),i.lookAt(r),i.zoom=e.zoom,i.updateProjectionMatrix()}this.camera=i,this.makeOrbitControls(i,e,!1)}makeDefaultCameraDef(e){const t=new CameraDef;return t.orthographic=2===e,t.zoom=1,t.orthographic?(t.position=[this.START_CAMERA_POS_2D.x,this.START_CAMERA_POS_2D.y,this.START_CAMERA_POS_2D.z],t.target=[this.START_CAMERA_TARGET_2D.x,this.START_CAMERA_TARGET_2D.y,this.START_CAMERA_TARGET_2D.z]):(t.position=[this.START_CAMERA_POS_3D.x,this.START_CAMERA_POS_3D.y,this.START_CAMERA_POS_3D.z],t.target=[this.START_CAMERA_TARGET_3D.x,this.START_CAMERA_TARGET_3D.y,this.START_CAMERA_TARGET_3D.z]),t}recreateCamera(e){e.orthographic?this.makeCamera2D(e,this.width,this.height):this.makeCamera3D(e,this.width,this.height),this.orbitCameraControls.minDistance=MIN_ZOOM,this.orbitCameraControls.maxDistance=MAX_ZOOM,this.orbitCameraControls.update(),this.orbitAnimationOnNextCameraCreation&&this.startOrbitAnimation()}onClick(e,t=!0){e&&this.selecting||(!this.isDragSequence&&t&&this.projectorEventContext.notifySelectionChanged(null!=this.nearestPoint?[this.nearestPoint]:[]),this.isDragSequence=!1,this.render())}onMouseDown(e){this.isDragSequence=!1,this.mouseIsDown=!0,this.selecting?(this.orbitCameraControls.enabled=!1,this.rectangleSelector.onMouseDown(e.offsetX,e.offsetY),this.setNearestPointToMouse(e)):!e.ctrlKey&&this.sceneIs3D()&&this.orbitCameraControls.mouseButtons.ORBIT===MOUSE.RIGHT?(this.orbitCameraControls.mouseButtons.ORBIT=MOUSE.LEFT,this.orbitCameraControls.mouseButtons.PAN=MOUSE.RIGHT):e.ctrlKey&&this.sceneIs3D()&&this.orbitCameraControls.mouseButtons.ORBIT===MOUSE.LEFT&&(this.orbitCameraControls.mouseButtons.ORBIT=MOUSE.RIGHT,this.orbitCameraControls.mouseButtons.PAN=MOUSE.LEFT)}onMouseUp(e){this.selecting&&(this.orbitCameraControls.enabled=!0,this.rectangleSelector.onMouseUp(),this.render()),this.mouseIsDown=!1}onMouseMove(e){this.isDragSequence=this.mouseIsDown,this.selecting&&this.mouseIsDown?(this.rectangleSelector.onMouseMove(e.offsetX,e.offsetY),this.render()):this.mouseIsDown||(this.setNearestPointToMouse(e),this.projectorEventContext.notifyHoverOverPoint(this.nearestPoint))}onKeyDown(e){e.keyCode===CTRL_KEY&&this.sceneIs3D()&&(this.orbitCameraControls.mouseButtons.ORBIT=MOUSE.RIGHT,this.orbitCameraControls.mouseButtons.PAN=MOUSE.LEFT),e.keyCode===SHIFT_KEY&&(this.selecting=!0,this.container.style.cursor="crosshair")}onKeyUp(e){e.keyCode===CTRL_KEY&&this.sceneIs3D()&&(this.orbitCameraControls.mouseButtons.ORBIT=MOUSE.LEFT,this.orbitCameraControls.mouseButtons.PAN=MOUSE.RIGHT),e.keyCode===SHIFT_KEY&&(this.selecting=this.getMouseMode()===MouseMode.AREA_SELECT,this.selecting||(this.container.style.cursor="default"),this.render())}getPointIndicesFromPickingTexture(e){if(null==this.worldSpacePointPositions)return null;const t=this.worldSpacePointPositions.length/3,n=window.devicePixelRatio||1,i=Math.floor(e.x*n),r=Math.floor(e.y*n),o=Math.floor(e.width*n),a=Math.floor(e.height*n);let s=new Uint8Array(o*a*4);this.renderer.readRenderTargetPixels(this.pickingTexture,i,this.pickingTexture.height-r,o,a,s);let l=new Uint8Array(this.worldSpacePointPositions.length);for(let e=0;e<o*a;e++){const n=s[4*e]<<16|s[4*e+1]<<8|s[4*e+2];16777215!==n&&n<t&&(l[n]=1)}let c=[];for(let e=0;e<l.length;e++)1===l[e]&&c.push(e);return c}selectBoundingBox(e){let t=this.getPointIndicesFromPickingTexture(e);this.projectorEventContext.notifySelectionChanged(t)}setNearestPointToMouse(e){if(null==this.pickingTexture)return void(this.nearestPoint=null);const t=this.getPointIndicesFromPickingTexture({x:e.offsetX,y:e.offsetY,width:1,height:1});this.nearestPoint=null!=t?t[0]:null}getLayoutValues(){return this.width=this.container.offsetWidth,this.height=Math.max(1,this.container.offsetHeight),[this.width,this.height]}sceneIs3D(){return 3===this.dimensionality}remove3dAxisFromScene(){const e=this.scene.getObjectByName("axes");return null!=e&&this.scene.remove(e),e}add3dAxis(){const e=new AxesHelper;e.name="axes",this.scene.add(e)}setDimensions(e){if(2!==e&&3!==e)throw new RangeError("dimensionality must be 2 or 3");this.dimensionality=e;const t=this.cameraDef||this.makeDefaultCameraDef(e);this.recreateCamera(t),this.remove3dAxisFromScene(),3===e&&this.add3dAxis()}getCameraDef(){const e=new CameraDef,t=this.camera.position,n=this.orbitCameraControls.target;return e.orthographic=!this.sceneIs3D(),e.position=[t.x,t.y,t.z],e.target=[n.x,n.y,n.z],e.zoom=this.camera.zoom,e}setCameraParametersForNextCameraCreation(e,t){this.cameraDef=e,this.orbitAnimationOnNextCameraCreation=t}getCameraPosition(){const e=this.camera.position;return[e.x,e.y,e.z]}getCameraTarget(){let e=this.orbitCameraControls.target;return[e.x,e.y,e.z]}setCameraPositionAndTarget(e,t){this.stopOrbitAnimation(),this.camera.position.set(e[0],e[1],e[2]),this.orbitCameraControls.target.set(t[0],t[1],t[2]),this.orbitCameraControls.update(),this.render()}startOrbitAnimation(){this.sceneIs3D()&&(null!=this.orbitAnimationId&&this.stopOrbitAnimation(),this.orbitCameraControls.autoRotate=!0,this.orbitCameraControls.rotateSpeed=ORBIT_ANIMATION_ROTATION_CYCLE_IN_SECONDS,this.updateOrbitAnimation())}updateOrbitAnimation(){this.orbitCameraControls.update(),this.orbitAnimationId=requestAnimationFrame((()=>this.updateOrbitAnimation()))}stopOrbitAnimation(){this.orbitCameraControls.autoRotate=!1,this.orbitCameraControls.rotateSpeed=ORBIT_MOUSE_ROTATION_SPEED,null!=this.orbitAnimationId&&(cancelAnimationFrame(this.orbitAnimationId),this.orbitAnimationId=null)}addVisualizer(e){this.scene&&e.setScene(this.scene),e.onResize(this.width,this.height),e.onPointPositionsChanged(this.worldSpacePointPositions),this.visualizers.push(e)}removeAllVisualizers(){this.visualizers.forEach((e=>e.dispose())),this.visualizers=[]}setPointPositions(e){this.worldSpacePointPositions=e,this.visualizers.forEach((t=>t.onPointPositionsChanged(e)))}render(){{const e=this.camera.position.clone();e.x+=1,e.y+=1,this.light.position.set(e.x,e.y,e.z)}const e=this.camera instanceof PerspectiveCamera?CameraType.Perspective:CameraType.Orthographic;let t=[0,0];null!=this.worldSpacePointPositions&&(t=getNearFarPoints(this.worldSpacePointPositions,this.camera.position,this.orbitCameraControls.target));const n=new RenderContext(this.camera,e,this.orbitCameraControls.target,this.width,this.height,t[0],t[1],this.backgroundColor,this.pointColors,this.pointScaleFactors,this.labels,this.polylineColors,this.polylineOpacities,this.polylineWidths);this.visualizers.forEach((e=>e.onPickingRender(n)));{const e=this.remove3dAxisFromScene();this.renderer.setRenderTarget(this.pickingTexture?this.pickingTexture:null),this.renderer.render(this.scene,this.camera),this.renderer.setRenderTarget(null),null!=e&&this.scene.add(e)}this.visualizers.forEach((e=>e.onRender(n))),this.renderer.render(this.scene,this.camera)}setMouseMode(e){this.mouseMode=e,e===MouseMode.AREA_SELECT?(this.selecting=!0,this.container.style.cursor="crosshair"):(this.selecting=!1,this.container.style.cursor="default")}setPointColors(e){this.pointColors=e}setPointScaleFactors(e){this.pointScaleFactors=e}setLabels(e){this.labels=e}setPolylineColors(e){this.polylineColors=e}setPolylineOpacities(e){this.polylineOpacities=e}setPolylineWidths(e){this.polylineWidths=e}getMouseMode(){return this.mouseMode}resetZoom(){this.recreateCamera(this.makeDefaultCameraDef(this.dimensionality)),this.render()}setDayNightMode(e){const t=this.container.querySelectorAll("canvas"),n=e?"invert(100%)":null;for(let e=0;e<t.length;e++)t[e].style.filter=n}resize(e=!0){const[t,n]=[this.width,this.height],[i,r]=this.getLayoutValues();if(3===this.dimensionality){const e=this.camera;e.aspect=i/r,e.updateProjectionMatrix()}else{const e=this.camera,o=i/t*(e.right-e.left)/2,a=r/n*(e.top-e.bottom)/2;e.top=a,e.bottom=-a,e.left=-o,e.right=o,e.updateProjectionMatrix()}const o=window.devicePixelRatio||1;this.renderer.setPixelRatio(o),this.renderer.setSize(i,r);{const e=new Vector2;this.renderer.getSize(e);const t=this.renderer.getPixelRatio();this.pickingTexture=new WebGLRenderTarget(e.width*t,e.height*t),this.pickingTexture.texture.minFilter=LinearFilter}this.visualizers.forEach((e=>e.onResize(i,r))),e&&this.render()}onCameraMove(e){this.onCameraMoveListeners.push(e)}clickOnPoint(e){this.nearestPoint=e,this.onClick(null,!1)}}const NUM_POINTS_FOG_THRESHOLD=5e3,MIN_POINT_SIZE=5,IMAGE_SIZE=30,RGB_NUM_ELEMENTS$1=3,INDEX_NUM_ELEMENTS=1,XYZ_NUM_ELEMENTS$1=3;function createVertexShader(){return`\n // Index of the specific vertex (passed in as bufferAttribute), and the\n // variable that will be used to pass it to the fragment shader.\n attribute float spriteIndex;\n attribute vec3 color;\n attribute float scaleFactor;\n\n varying vec2 xyIndex;\n varying vec3 vColor;\n\n uniform bool sizeAttenuation;\n uniform float pointSize;\n uniform float spritesPerRow;\n uniform float spritesPerColumn;\n\n ${ShaderChunk.fog_pars_vertex}\n\n void main() {\n // Pass index and color values to fragment shader.\n vColor = color;\n xyIndex = vec2(mod(spriteIndex, spritesPerRow),\n floor(spriteIndex / spritesPerColumn));\n\n // Transform current vertex by modelViewMatrix (model world position and\n // camera world position matrix).\n vec4 cameraSpacePos = modelViewMatrix * vec4(position, 1.0);\n\n // Project vertex in camera-space to screen coordinates using the camera's\n // projection matrix.\n gl_Position = projectionMatrix * cameraSpacePos;\n\n // Create size attenuation (if we're in 3D mode) by making the size of\n // each point inversly proportional to its distance to the camera.\n float outputPointSize = pointSize;\n if (sizeAttenuation) {\n outputPointSize = -pointSize / cameraSpacePos.z;\n } else { // Create size attenuation (if we're in 2D mode)\n const float PI = 3.1415926535897932384626433832795;\n const float minScale = 0.1; // minimum scaling factor\n const float outSpeed = 2.0; // shrink speed when zooming out\n const float outNorm = (1. - minScale) / atan(outSpeed);\n const float maxScale = 15.0; // maximum scaling factor\n const float inSpeed = 0.02; // enlarge speed when zooming in\n const float zoomOffset = 0.3; // offset zoom pivot\n float zoom = projectionMatrix[0][0] + zoomOffset; // zoom pivot\n float scale = zoom < 1. ? 1. + outNorm * atan(outSpeed * (zoom - 1.)) :\n 1. + 2. / PI * (maxScale - 1.) * atan(inSpeed * (zoom - 1.));\n outputPointSize = pointSize * scale;\n }\n\n gl_PointSize =\n max(outputPointSize * scaleFactor, ${MIN_POINT_SIZE.toFixed(1)});\n }`}const FRAGMENT_SHADER_POINT_TEST_CHUNK="\n bool point_in_unit_circle(vec2 spriteCoord) {\n vec2 centerToP = spriteCoord - vec2(0.5, 0.5);\n return dot(centerToP, centerToP) < (0.5 * 0.5);\n }\n\n bool point_in_unit_equilateral_triangle(vec2 spriteCoord) {\n vec3 v0 = vec3(0, 1, 0);\n vec3 v1 = vec3(0.5, 0, 0);\n vec3 v2 = vec3(1, 1, 0);\n vec3 p = vec3(spriteCoord, 0);\n float p_in_v0_v1 = cross(v1 - v0, p - v0).z;\n float p_in_v1_v2 = cross(v2 - v1, p - v1).z;\n return (p_in_v0_v1 > 0.0) && (p_in_v1_v2 > 0.0);\n }\n\n bool point_in_unit_square(vec2 spriteCoord) {\n return true;\n }\n";function createFragmentShader(){return`\n varying vec2 xyIndex;\n varying vec3 vColor;\n\n uniform sampler2D spriteTexture;\n uniform float spritesPerRow;\n uniform float spritesPerColumn;\n uniform bool isImage;\n\n ${ShaderChunk.common}\n ${ShaderChunk.fog_pars_fragment}\n ${FRAGMENT_SHADER_POINT_TEST_CHUNK}\n\n void main() {\n if (isImage) {\n // Coordinates of the vertex within the entire sprite image.\n vec2 coords =\n (gl_PointCoord + xyIndex) / vec2(spritesPerRow, spritesPerColumn);\n if (texture2D(spriteTexture, coords).a==0.0) {\n discard;\n }\n gl_FragColor = vec4(vColor, 1.0) * texture2D(spriteTexture, coords);\n } else {\n bool inside = point_in_unit_circle(gl_PointCoord);\n if (!inside) {\n discard;\n }\n gl_FragColor = vec4(vColor, 1);\n }\n ${ShaderChunk.fog_fragment}\n }`}const FRAGMENT_SHADER_PICKING=`\n varying vec2 xyIndex;\n varying vec3 vColor;\n uniform bool isImage;\n\n ${FRAGMENT_SHADER_POINT_TEST_CHUNK}\n\n void main() {\n xyIndex; // Silence 'unused variable' warning.\n if (isImage) {\n gl_FragColor = vec4(vColor, 1);\n } else {\n bool inside = point_in_unit_circle(gl_PointCoord);\n if (!inside) {\n discard;\n }\n gl_FragColor = vec4(vColor, 1);\n }\n }`;class ScatterPlotVisualizerSprites{constructor(){this.VERTEX_SHADER=createVertexShader(),this.FRAGMENT_SHADER=createFragmentShader(),this.texture=null,this.standinTextureForPoints=createTexture(document.createElement("canvas")),this.renderMaterial=this.createRenderMaterial(!1),this.pickingMaterial=this.createPickingMaterial(!1)}createTextureFromSpriteAtlas(e,t,n){this.texture=createTexture(e),this.spritesPerRow=e.width/t[0],this.spritesPerColumn=e.height/t[1],this.spriteDimensions=t,this.spriteIndexBufferAttribute=new BufferAttribute(n,INDEX_NUM_ELEMENTS),null!=this.points&&this.points.geometry.setAttribute("spriteIndex",this.spriteIndexBufferAttribute)}createUniforms(){return{spriteTexture:{type:"t"},spritesPerRow:{type:"f"},spritesPerColumn:{type:"f"},fogColor:{type:"c"},fogNear:{type:"f"},fogFar:{type:"f"},isImage:{type:"bool"},sizeAttenuation:{type:"bool"},pointSize:{type:"f"}}}createRenderMaterial(e){return new ShaderMaterial({uniforms:this.createUniforms(),vertexShader:this.VERTEX_SHADER,fragmentShader:this.FRAGMENT_SHADER,transparent:!e,depthTest:e,depthWrite:e,fog:!0,blending:NormalBlending})}createPickingMaterial(e){return new ShaderMaterial({uniforms:this.createUniforms(),vertexShader:this.VERTEX_SHADER,fragmentShader:FRAGMENT_SHADER_PICKING,transparent:!0,depthTest:!0,depthWrite:!0,fog:!1,blending:NormalBlending})}createPointSprites(e,t){const n=this.createGeometry(null!=t?t.length/XYZ_NUM_ELEMENTS$1:0);this.fog=new Fog(16777215),this.points=new Points(n,this.renderMaterial),this.points.frustumCulled=!1,null!=this.spriteIndexBufferAttribute&&this.points.geometry.setAttribute("spriteIndex",this.spriteIndexBufferAttribute),e.add(this.points)}calculatePointSize(e){if(null!=this.texture)return e?IMAGE_SIZE:this.spriteDimensions[0];const t=200/Math.log(null!=this.worldSpacePointPositions?this.worldSpacePointPositions.length/XYZ_NUM_ELEMENTS$1:1)/Math.log(8);return e?t:t/1.5}createGeometry(e){const t=e;this.pickingColors=new Float32Array(t*RGB_NUM_ELEMENTS$1);{let e=0;for(let n=0;n<t;n++){const t=new Color(n);this.pickingColors[e++]=t.r,this.pickingColors[e++]=t.g,this.pickingColors[e++]=t.b}}const n=new BufferGeometry;return n.setAttribute("position",new BufferAttribute(void 0,XYZ_NUM_ELEMENTS$1)),n.setAttribute("color",new BufferAttribute(void 0,RGB_NUM_ELEMENTS$1)),n.setAttribute("scaleFactor",new BufferAttribute(void 0,INDEX_NUM_ELEMENTS)),n}setFogDistances(e,t,n){if(e){const e=this.worldSpacePointPositions.length/XYZ_NUM_ELEMENTS$1;this.fog.near=t;let i=2-Math.min(e,NUM_POINTS_FOG_THRESHOLD)/NUM_POINTS_FOG_THRESHOLD;this.fog.far=n*i}else this.fog.near=1/0,this.fog.far=1/0}dispose(){this.disposeGeometry(),this.disposeTextureAtlas()}disposeGeometry(){null!=this.points&&(this.scene.remove(this.points),this.points.geometry.dispose(),this.points=null,this.worldSpacePointPositions=null)}disposeTextureAtlas(){null!=this.texture&&this.texture.dispose(),this.texture=null,this.renderMaterial=null,this.pickingMaterial=null}setScene(e){this.scene=e}setSpriteAtlas(e,t,n){this.disposeTextureAtlas(),this.createTextureFromSpriteAtlas(e,t,n),this.renderMaterial=this.createRenderMaterial(!0),this.pickingMaterial=this.createPickingMaterial(!0)}clearSpriteAtlas(){this.disposeTextureAtlas(),this.renderMaterial=this.createRenderMaterial(!1),this.pickingMaterial=this.createPickingMaterial(!1)}onPointPositionsChanged(e){if(null==e||0===e.length)return void this.dispose();null!=this.points&&this.worldSpacePointPositions.length!==e.length&&this.disposeGeometry(),this.worldSpacePointPositions=e,null==this.points&&this.createPointSprites(this.scene,e);const t=new BufferAttribute(e,3);this.points.geometry.setAttribute("position",t),t.needsUpdate=!0}onPickingRender(e){if(null==this.points)return;const t=e.cameraType===CameraType.Perspective;this.pickingMaterial.uniforms.spritesPerRow.value=this.spritesPerRow,this.pickingMaterial.uniforms.spritesPerRow.value=this.spritesPerColumn,this.pickingMaterial.uniforms.sizeAttenuation.value=t,this.pickingMaterial.uniforms.pointSize.value=this.calculatePointSize(t),this.points.material=this.pickingMaterial;const n=new BufferAttribute(this.pickingColors,3);this.points.geometry.setAttribute("color",n),n.needsUpdate=!0;const i=new BufferAttribute(e.pointScaleFactors,1);this.points.geometry.setAttribute("scaleFactor",i),i.needsUpdate=!0}onRender(e){if(!this.points)return;const t=e.camera instanceof PerspectiveCamera;this.setFogDistances(t,e.nearestCameraSpacePointZ,e.farthestCameraSpacePointZ),this.scene.fog=this.fog,this.scene.fog.color=new Color(e.backgroundColor),this.renderMaterial.uniforms.fogColor.value=this.scene.fog.color,this.renderMaterial.uniforms.fogNear.value=this.fog.near,this.renderMaterial.uniforms.fogFar.value=this.fog.far,this.renderMaterial.uniforms.spritesPerRow.value=this.spritesPerRow,this.renderMaterial.uniforms.spritesPerColumn.value=this.spritesPerColumn,this.renderMaterial.uniforms.isImage.value=null!=this.texture,this.renderMaterial.uniforms.spriteTexture.value=null!=this.texture?this.texture:this.standinTextureForPoints,this.renderMaterial.uniforms.sizeAttenuation.value=t,this.renderMaterial.uniforms.pointSize.value=this.calculatePointSize(t),this.points.material=this.renderMaterial,this.renderColors=e.pointColors;const n=new BufferAttribute(this.renderColors,3);this.points.geometry.setAttribute("color",n),n.needsUpdate=!0;const i=new BufferAttribute(e.pointScaleFactors,1);this.points.geometry.setAttribute("scaleFactor",i),i.needsUpdate=!0}onResize(e,t){}}const FONT_SIZE=80,ONE_OVER_FONT_SIZE=1/FONT_SIZE,LABEL_SCALE=2.2,LABEL_COLOR="black",LABEL_BACKGROUND="white",MAX_CANVAS_DIMENSION=8192,NUM_GLYPHS=256,RGB_ELEMENTS_PER_ENTRY=3,XYZ_ELEMENTS_PER_ENTRY=3,UV_ELEMENTS_PER_ENTRY=2,VERTICES_PER_GLYPH=6,VERTEX_SHADER=`\n attribute vec2 posObj;\n attribute vec3 color;\n varying vec2 vUv;\n varying vec3 vColor;\n\n void main() {\n vUv = uv;\n vColor = color;\n\n // Rotate label to face camera.\n\n vec4 vRight = vec4(\n modelViewMatrix[0][0], modelViewMatrix[1][0], modelViewMatrix[2][0], 0);\n\n vec4 vUp = vec4(\n modelViewMatrix[0][1], modelViewMatrix[1][1], modelViewMatrix[2][1], 0);\n\n vec4 vAt = -vec4(\n modelViewMatrix[0][2], modelViewMatrix[1][2], modelViewMatrix[2][2], 0);\n\n mat4 pointToCamera = mat4(vRight, vUp, vAt, vec4(0, 0, 0, 1));\n\n vec2 scaledPos = posObj * ${ONE_OVER_FONT_SIZE} * ${LABEL_SCALE};\n\n vec4 posRotated = pointToCamera * vec4(scaledPos, 0, 1);\n vec4 mvPosition = modelViewMatrix * (vec4(position, 0) + posRotated);\n gl_Position = projectionMatrix * mvPosition;\n }`,FRAGMENT_SHADER="\n uniform sampler2D shaderTexture;\n uniform bool picking;\n varying vec2 vUv;\n varying vec3 vColor;\n\n void main() {\n if (picking) {\n gl_FragColor = vec4(vColor, 1.0);\n } else {\n vec4 fromTexture = texture2D(shaderTexture, vUv);\n gl_FragColor = vec4(vColor, 1.0) * fromTexture;\n }\n }";class ScatterPlotVisualizer3DLabels{createGlyphTexture(){let e=document.createElement("canvas");e.width=MAX_CANVAS_DIMENSION,e.height=FONT_SIZE;let t=e.getContext("2d");t.font="bold "+.75*FONT_SIZE+"px roboto",t.textBaseline="top",t.fillStyle=LABEL_BACKGROUND,t.rect(0,0,e.width,e.height),t.fill(),t.fillStyle=LABEL_COLOR;let n=t.measureText(" ").width,i=new Float32Array(NUM_GLYPHS),r=new Float32Array(NUM_GLYPHS),o=0;for(let e=0;e<NUM_GLYPHS;e++){let a=" "+String.fromCharCode(e),s=t.measureText(a).width;i[e]=s-n,r[e]=o,t.fillText(a,o-n,0),o+=s}return{texture:createTexture(e),lengths:i,offsets:r}}processLabelVerts(e){let t=0;this.labelVertexMap=[];for(let n=0;n<e;n++){const e=this.labelStrings[n];let i=[];for(let n=0;n<e.length;n++){for(let e=0;e<VERTICES_PER_GLYPH;e++)i.push(t*VERTICES_PER_GLYPH+e);t++}this.labelVertexMap.push(i)}this.totalVertexCount=t*VERTICES_PER_GLYPH}createColorBuffers(e){this.pickingColors=new Float32Array(this.totalVertexCount*RGB_ELEMENTS_PER_ENTRY),this.renderColors=new Float32Array(this.totalVertexCount*RGB_ELEMENTS_PER_ENTRY);for(let t=0;t<e;t++){let e=new Color(t);this.labelVertexMap[t].forEach((t=>{this.pickingColors[RGB_ELEMENTS_PER_ENTRY*t]=e.r,this.pickingColors[RGB_ELEMENTS_PER_ENTRY*t+1]=e.g,this.pickingColors[RGB_ELEMENTS_PER_ENTRY*t+2]=e.b,this.renderColors[RGB_ELEMENTS_PER_ENTRY*t]=1,this.renderColors[RGB_ELEMENTS_PER_ENTRY*t+1]=1,this.renderColors[RGB_ELEMENTS_PER_ENTRY*t+2]=1}))}}createLabels(){if(null==this.labelStrings||null==this.worldSpacePointPositions)return;const e=this.worldSpacePointPositions.length/XYZ_ELEMENTS_PER_ENTRY;if(e!==this.labelStrings.length)return;this.glyphTexture=this.createGlyphTexture(),this.uniforms={shaderTexture:{type:"t"},picking:{type:"bool"}},this.material=new ShaderMaterial({uniforms:this.uniforms,transparent:!0,vertexShader:VERTEX_SHADER,fragmentShader:FRAGMENT_SHADER}),this.processLabelVerts(e),this.createColorBuffers(e);let t=new Float32Array(this.totalVertexCount*XYZ_ELEMENTS_PER_ENTRY);this.positions=new BufferAttribute(t,XYZ_ELEMENTS_PER_ENTRY);let n=new Float32Array(this.totalVertexCount*XYZ_ELEMENTS_PER_ENTRY),i=new Float32Array(this.totalVertexCount*UV_ELEMENTS_PER_ENTRY),r=new Float32Array(this.totalVertexCount*RGB_ELEMENTS_PER_ENTRY),o=new BufferAttribute(n,2),a=new BufferAttribute(i,UV_ELEMENTS_PER_ENTRY),s=new BufferAttribute(r,RGB_ELEMENTS_PER_ENTRY);this.geometry=new BufferGeometry,this.geometry.setAttribute("posObj",o),this.geometry.setAttribute("position",this.positions),this.geometry.setAttribute("uv",a),this.geometry.setAttribute("color",s);let l=0;for(let t=0;t<e;t++){const e=this.labelStrings[t];let n=0;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n+=this.glyphTexture.lengths[i]}n/=-2;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t),r=this.glyphTexture.lengths[i],s=(n+r)/FONT_SIZE,c=n/FONT_SIZE,h=FONT_SIZE/FONT_SIZE;o.setXY(l*VERTICES_PER_GLYPH+0,c,0),o.setXY(l*VERTICES_PER_GLYPH+1,s,0),o.setXY(l*VERTICES_PER_GLYPH+2,c,h),o.setXY(l*VERTICES_PER_GLYPH+3,c,h),o.setXY(l*VERTICES_PER_GLYPH+4,s,0),o.setXY(l*VERTICES_PER_GLYPH+5,s,h);let u=this.glyphTexture.offsets[i],d=this.glyphTexture.offsets[i]+r;u/=MAX_CANVAS_DIMENSION,d/=MAX_CANVAS_DIMENSION;let p=1,m=0;a.setXY(l*VERTICES_PER_GLYPH+0,u,p),a.setXY(l*VERTICES_PER_GLYPH+1,d,p),a.setXY(l*VERTICES_PER_GLYPH+2,u,m),a.setXY(l*VERTICES_PER_GLYPH+3,u,m),a.setXY(l*VERTICES_PER_GLYPH+4,d,p),a.setXY(l*VERTICES_PER_GLYPH+5,d,m),l++,n+=r}}for(let t=0;t<e;t++){const e=vector3FromPackedArray(this.worldSpacePointPositions,t);this.labelVertexMap[t].forEach((t=>{this.positions.setXYZ(t,e.x,e.y,e.z)}))}this.labelsMesh=new Mesh(this.geometry,this.material),this.labelsMesh.frustumCulled=!1,this.scene.add(this.labelsMesh)}colorLabels(e){if(null==this.labelStrings||null==this.geometry||null==e)return;const t=new BufferAttribute(this.renderColors,3);this.geometry.setAttribute("color",t);const n=e.length/XYZ_ELEMENTS_PER_ENTRY;let i=0;for(let r=0;r<n;++r){const n=new Color(e[i],e[i+1],e[i+2]),o=this.labelVertexMap[r].length;for(let e=0;e<o;++e)t.setXYZ(this.labelVertexMap[r][e],n.r,n.g,n.b);i+=RGB_ELEMENTS_PER_ENTRY}t.needsUpdate=!0}setScene(e){this.scene=e}dispose(){this.labelsMesh&&(this.scene&&this.scene.remove(this.labelsMesh),this.labelsMesh=null),this.geometry&&(this.geometry.dispose(),this.geometry=null),null!=this.glyphTexture&&null!=this.glyphTexture.texture&&(this.glyphTexture.texture.dispose(),this.glyphTexture.texture=null)}onPickingRender(e){if(null==this.geometry&&this.createLabels(),null==this.geometry)return;this.material.uniforms.shaderTexture.value=this.glyphTexture.texture,this.material.uniforms.picking.value=!0;const t=new BufferAttribute(this.pickingColors,3);this.geometry.setAttribute("color",t),t.needsUpdate=!0}onRender(e){if(null==this.geometry&&this.createLabels(),null==this.geometry)return;this.colorLabels(e.pointColors),this.material.uniforms.shaderTexture.value=this.glyphTexture.texture,this.material.uniforms.picking.value=!1;const t=new BufferAttribute(this.renderColors,3);this.geometry.setAttribute("color",t),t.needsUpdate=!0}onPointPositionsChanged(e){this.worldSpacePointPositions=e,this.dispose()}setLabelStrings(e){this.labelStrings=e,this.dispose()}onResize(e,t){}}class CollisionGrid{constructor(e,t,n){this.bound=e,this.cellWidth=t,this.cellHeight=n,this.numHorizCells=Math.ceil(this.boundWidth(e)/t),this.numVertCells=Math.ceil(this.boundHeight(e)/n),this.grid=new Array(this.numHorizCells*this.numVertCells)}boundWidth(e){return e.hiX-e.loX}boundHeight(e){return e.hiY-e.loY}boundsIntersect(e,t){return!(e.loX>t.hiX||e.loY>t.hiY||e.hiX<t.loX||e.hiY<t.loY)}insert(e,t=!1){if(e.hiX<this.bound.loX||e.loX>this.bound.hiX||e.hiY<this.bound.loY||e.loY>this.bound.hiY)return!1;let n=this.getCellX(e.loX),i=this.getCellX(e.hiX),r=this.getCellY(e.loY),o=this.getCellY(e.hiY),a=r*this.numHorizCells+n,s=a;for(let t=r;t<=o;t++){for(let t=n;t<=i;t++){let t=this.grid[s++];if(t)for(let n=0;n<t.length;n++)if(this.boundsIntersect(e,t[n]))return!1}s+=this.numHorizCells-(i-n+1)}if(t)return!0;s=a;for(let t=r;t<=o;t++){for(let t=n;t<=i;t++)this.grid[s]?this.grid[s].push(e):this.grid[s]=[e],s++;s+=this.numHorizCells-(i-n+1)}return!0}getCellX(e){return Math.floor((e-this.bound.loX)/this.cellWidth)}getCellY(e){return Math.floor((e-this.bound.loY)/this.cellHeight)}}const MAX_LABELS_ON_SCREEN=1e4,LABEL_STROKE_WIDTH=3,LABEL_FILL_WIDTH=6;class ScatterPlotVisualizerCanvasLabels{constructor(e){this.labelsActive=!0,this.canvas=document.createElement("canvas"),e.appendChild(this.canvas),this.gc=this.canvas.getContext("2d"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.pointerEvents="none"}removeAllLabels(){const e=this.canvas.width*window.devicePixelRatio,t=this.canvas.height*window.devicePixelRatio;this.gc.clearRect(0,0,e,t)}makeLabels(e){if(null==e.labels||0===e.labels.pointIndices.length)return;if(null==this.worldSpacePointPositions)return;const t=e.labels,n=e.cameraType===CameraType.Perspective,i=parseInt(this.gc.font,10),r=window.devicePixelRatio;let o;{const e=this.canvas.width*r,t=this.canvas.height*r;o=new CollisionGrid({loX:0,hiX:e,loY:0,hiY:t},e/25,t/50)}let a=pow().exponent(Math.E).domain([e.farthestCameraSpacePointZ,e.nearestCameraSpacePointZ]).range([.1,1]);const s=e.camera.position,l=s.clone().sub(e.cameraTarget);let c=new Vector3;this.gc.textBaseline="middle",this.gc.miterLimit=2;const h=Math.min(MAX_LABELS_ON_SCREEN,t.pointIndices.length);for(let u=0;u<h;++u){let h;if(h=vector3FromPackedArray(this.worldSpacePointPositions,t.pointIndices[u]),c.copy(s).sub(h),l.dot(c)<0)continue;let[d,p]=vector3DToScreenCoords(e.camera,e.screenWidth,e.screenHeight,h);d+=4;const m={loX:d-2,hiX:d+1+2,loY:p-i/2-2,hiY:p+i/2+2};if(o.insert(m,!0)){const e=t.labelStrings[u];if(this.gc.font=t.defaultFontSize*t.scaleFactors[u]*r+"px roboto",m.hiX+=this.gc.measureText(e).width-1,o.insert(m)){let i=1;n&&1===t.useSceneOpacityFlags[u]&&(i=a(c.length())),this.gc.fillStyle=this.styleStringFromPackedRgba(t.fillColors,u,i),this.gc.strokeStyle=this.styleStringFromPackedRgba(t.strokeColors,u,i),this.gc.lineWidth=LABEL_STROKE_WIDTH,this.gc.strokeText(e,d,p),this.gc.lineWidth=LABEL_FILL_WIDTH,this.gc.fillText(e,d,p)}}}}styleStringFromPackedRgba(e,t,n){const i=3*t;return"rgba("+e[i]+","+e[i+1]+","+e[i+2]+","+n+")"}onResize(e,t){let n=window.devicePixelRatio;this.canvas.width=e*n,this.canvas.height=t*n,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px"}dispose(){this.removeAllLabels(),this.canvas=null,this.gc=null}onPointPositionsChanged(e){this.worldSpacePointPositions=e,this.removeAllLabels()}onRender(e){this.labelsActive&&(this.removeAllLabels(),this.makeLabels(e))}setScene(e){}onPickingRender(e){}}const RGB_NUM_ELEMENTS=3,XYZ_NUM_ELEMENTS=3;class ScatterPlotVisualizerPolylines{constructor(){this.polylinePositionBuffer={},this.polylineColorBuffer={}}updateSequenceIndicesInDataSet(e){for(let t=0;t<e.sequences.length;t++){const n=e.sequences[t];for(let i=0;i<n.pointIndices.length-1;i++)e.points[n.pointIndices[i]].sequenceIndex=t,e.points[n.pointIndices[i+1]].sequenceIndex=t}}createPolylines(e){if(this.dataSet&&this.dataSet.sequences){this.updateSequenceIndicesInDataSet(this.dataSet),this.polylines=[];for(let t=0;t<this.dataSet.sequences.length;t++){const n=new BufferGeometry;n.setAttribute("position",this.polylinePositionBuffer[t]),n.setAttribute("color",this.polylineColorBuffer[t]);const i=new LineSegments(n,new LineBasicMaterial({linewidth:1,opacity:1,transparent:!0,vertexColors:!0}));i.frustumCulled=!1,this.polylines.push(i),e.add(i)}}}dispose(){if(null!=this.polylines){for(let e=0;e<this.polylines.length;e++)this.scene.remove(this.polylines[e]),this.polylines[e].geometry.dispose();this.polylines=null,this.polylinePositionBuffer={},this.polylineColorBuffer={}}}setScene(e){this.scene=e}setDataSet(e){this.dataSet=e}onPointPositionsChanged(e){if(null!=e&&null==this.polylines||this.dispose(),null!=e&&null!=this.dataSet){for(let e=0;e<this.dataSet.sequences.length;e++){const t=2*(this.dataSet.sequences[e].pointIndices.length-1);let n=new Float32Array(t*XYZ_NUM_ELEMENTS);this.polylinePositionBuffer[e]=new BufferAttribute(n,XYZ_NUM_ELEMENTS);let i=new Float32Array(t*RGB_NUM_ELEMENTS);this.polylineColorBuffer[e]=new BufferAttribute(i,RGB_NUM_ELEMENTS)}for(let t=0;t<this.dataSet.sequences.length;t++){const n=this.dataSet.sequences[t];let i=0;for(let r=0;r<n.pointIndices.length-1;r++){const o=n.pointIndices[r+1],a=vector3FromPackedArray(e,n.pointIndices[r]),s=vector3FromPackedArray(e,o);this.polylinePositionBuffer[t].setXYZ(i,a.x,a.y,a.z),this.polylinePositionBuffer[t].setXYZ(i+1,s.x,s.y,s.z),i+=2}this.polylinePositionBuffer[t].needsUpdate=!0}null==this.polylines&&this.createPolylines(this.scene)}}onRender(e){if(null!=this.polylines)for(let t=0;t<this.polylines.length;t++){const n=this.polylines[t].material;n.opacity=e.polylineOpacities[t],n.linewidth=e.polylineWidths[t];const i=new BufferAttribute(e.polylineColors[t],3);this.polylineColorBuffer[t]=i,i.needsUpdate=!0,this.polylines[t].geometry.setAttribute("color",i)}}onPickingRender(e){}onResize(e,t){}}const LABEL_FONT_SIZE=10,LABEL_SCALE_DEFAULT=1,LABEL_SCALE_LARGE=2,LABEL_FILL_COLOR_SELECTED=0,LABEL_FILL_COLOR_HOVER=0,LABEL_FILL_COLOR_NEIGHBOR=0,LABEL_STROKE_COLOR_SELECTED=16777215,LABEL_STROKE_COLOR_HOVER=16777215,LABEL_STROKE_COLOR_NEIGHBOR=16777215,POINT_COLOR_UNSELECTED=14935011,POINT_COLOR_NO_SELECTION=7697881,POINT_COLOR_SELECTED=16410214,POINT_COLOR_HOVER=7736143,POINT_SCALE_DEFAULT=1,POINT_SCALE_SELECTED=1.2,POINT_SCALE_NEIGHBOR=1.2,POINT_SCALE_HOVER=1.2,LABELS_3D_COLOR_UNSELECTED=16777215,LABELS_3D_COLOR_NO_SELECTION=16777215,SPRITE_IMAGE_COLOR_UNSELECTED=16777215,SPRITE_IMAGE_COLOR_NO_SELECTION=16777215,POLYLINE_START_HUE=60,POLYLINE_END_HUE=360,POLYLINE_SATURATION=1,POLYLINE_LIGHTNESS=.3,POLYLINE_DEFAULT_OPACITY=.2,POLYLINE_DEFAULT_LINEWIDTH=2,POLYLINE_SELECTED_OPACITY=.9,POLYLINE_SELECTED_LINEWIDTH=3,POLYLINE_DESELECTED_OPACITY=.05,SCATTER_PLOT_CUBE_LENGTH=2,NN_COLOR_SCALE=linear().domain([1,.7,.4]).range(["hsl(285, 80%, 40%)","hsl(0, 80%, 65%)","hsl(40, 70%, 60%)"]).clamp(!0);class ProjectorScatterPlotAdapter{constructor(e,t){this.scatterPlotContainer=e,this.renderLabelsIn3D=!1,this.scatterPlot=new ScatterPlot(e,t),t.registerProjectionChangedListener((e=>{this.projection=e,this.updateScatterPlotWithNewProjection(e)})),t.registerSelectionChangedListener(((e,t)=>{this.selectedPointIndices=e,this.neighborsOfFirstSelectedPoint=t,this.updateScatterPlotPositions(),this.updateScatterPlotAttributes(),this.scatterPlot.render()})),t.registerHoverListener((e=>{this.hoverPointIndex=e,this.updateScatterPlotAttributes(),this.scatterPlot.render()})),t.registerDistanceMetricChangedListener((e=>{this.distanceMetric=e,this.updateScatterPlotAttributes(),this.scatterPlot.render()})),this.createVisualizers(!1)}notifyProjectionPositionsUpdated(){this.updateScatterPlotPositions(),this.scatterPlot.render()}setDataSet(e){if(null!=this.projection&&(this.projection.dataSet=e),null!=this.polylineVisualizer&&this.polylineVisualizer.setDataSet(e),null!=this.labels3DVisualizer&&this.labels3DVisualizer.setLabelStrings(this.generate3DLabelsArray(e,this.labelPointAccessor)),null==this.spriteVisualizer)return;if(this.spriteVisualizer.clearSpriteAtlas(),null==e||null==e.spriteAndMetadataInfo)return;const t=e.spriteAndMetadataInfo;if(null==t.spriteImage||null==t.spriteMetadata)return;const n=e.points.length,i=new Float32Array(n);for(let t=0;t<n;++t)i[t]=e.points[t].index;this.spriteVisualizer.setSpriteAtlas(t.spriteImage,t.spriteMetadata.singleImageDim,i)}set3DLabelMode(e){this.renderLabelsIn3D=e,this.createVisualizers(e),this.updateScatterPlotAttributes(),this.scatterPlot.render()}setLegendPointColorer(e){this.legendPointColorer=e}setLabelPointAccessor(e){this.labelPointAccessor=e,null!=this.labels3DVisualizer&&this.labels3DVisualizer.setLabelStrings(this.generate3DLabelsArray(null==this.projection?null:this.projection.dataSet,e))}resize(){this.scatterPlot.resize()}populateBookmarkFromUI(e){e.cameraDef=this.scatterPlot.getCameraDef()}restoreUIFromBookmark(e){this.scatterPlot.setCameraParametersForNextCameraCreation(e.cameraDef,!1)}updateScatterPlotPositions(){const e=this.generatePointPositionArray(null==this.projection?null:this.projection.dataSet,null==this.projection?null:this.projection.projectionComponents);this.scatterPlot.setPointPositions(e)}updateScatterPlotAttributes(){if(null==this.projection)return;const e=this.projection.dataSet,t=this.selectedPointIndices,n=this.hoverPointIndex,i=this.neighborsOfFirstSelectedPoint,r=this.legendPointColorer,o=this.generatePointColorArray(e,r,this.distanceMetric,t,i,n,this.renderLabelsIn3D,this.getSpriteImageMode()),a=this.generatePointScaleFactorArray(e,t,i,n),s=this.generateVisibleLabelRenderParams(e,t,i,n),l=this.generateLineSegmentColorMap(e,r),c=this.generateLineSegmentOpacityArray(e,t),h=this.generateLineSegmentWidthArray(e,t);this.scatterPlot.setPointColors(o),this.scatterPlot.setPointScaleFactors(a),this.scatterPlot.setLabels(s),this.scatterPlot.setPolylineColors(l),this.scatterPlot.setPolylineOpacities(c),this.scatterPlot.setPolylineWidths(h)}render(){this.scatterPlot.render()}generatePointPositionArray(e,t){if(null==e)return null;const n=linear(),i=linear();let r=null;{const o=extent(e.points,((n,i)=>e.points[i].projections[t[0]])),a=extent(e.points,((n,i)=>e.points[i].projections[t[1]])),s=[-SCATTER_PLOT_CUBE_LENGTH/2,SCATTER_PLOT_CUBE_LENGTH/2];if(n.domain(o).range(s),i.domain(a).range(s),null!=t[2]){const n=extent(e.points,((n,i)=>e.points[i].projections[t[2]]));r=linear(),r.domain(n).range(s)}}const o=new Float32Array(3*e.points.length);let a=0;return e.points.forEach(((r,s)=>{o[a++]=n(e.points[s].projections[t[0]]),o[a++]=i(e.points[s].projections[t[1]]),o[a++]=0})),r&&(a=2,e.points.forEach(((n,i)=>{o[a]=r(e.points[i].projections[t[2]]),a+=3}))),o}generateVisibleLabelRenderParams(e,t,n,i){if(null==e)return null;const r=null==t?0:t.length,o=null==n?0:n.length,a=r+o+(null!=i?1:0),s=new Uint32Array(a),l=new Float32Array(a),c=new Int8Array(a),h=new Uint8Array(3*a),u=new Uint8Array(3*a),d=[];l.fill(LABEL_SCALE_DEFAULT),c.fill(1);let p=0;if(null!=i){d.push(this.getLabelText(e,i,this.labelPointAccessor)),s[p]=i,l[p]=LABEL_SCALE_LARGE,c[p]=0;const t=styleRgbFromHexColor(LABEL_FILL_COLOR_HOVER);packRgbIntoUint8Array(h,p,t[0],t[1],t[2]);const n=styleRgbFromHexColor(LABEL_STROKE_COLOR_HOVER);packRgbIntoUint8Array(u,p,n[0],n[1],n[1]),++p}{const n=r,i=styleRgbFromHexColor(LABEL_FILL_COLOR_SELECTED),o=styleRgbFromHexColor(LABEL_STROKE_COLOR_SELECTED);for(let r=0;r<n;++r){const a=t[r];d.push(this.getLabelText(e,a,this.labelPointAccessor)),s[p]=a,l[p]=LABEL_SCALE_LARGE,c[p]=1===n?0:1,packRgbIntoUint8Array(h,p,i[0],i[1],i[2]),packRgbIntoUint8Array(u,p,o[0],o[1],o[2]),++p}}{const t=o,i=styleRgbFromHexColor(LABEL_FILL_COLOR_NEIGHBOR),r=styleRgbFromHexColor(LABEL_STROKE_COLOR_NEIGHBOR);for(let o=0;o<t;++o){const t=n[o].index;d.push(this.getLabelText(e,t,this.labelPointAccessor)),s[p]=t,packRgbIntoUint8Array(h,p,i[0],i[1],i[2]),packRgbIntoUint8Array(u,p,r[0],r[1],r[2]),++p}}return new LabelRenderParams(new Float32Array(s),d,l,c,LABEL_FONT_SIZE,h,u)}generatePointScaleFactorArray(e,t,n,i){if(null==e)return new Float32Array(0);const r=new Float32Array(e.points.length);r.fill(POINT_SCALE_DEFAULT);const o=null==n?0:n.length;{const e=null==t?0:t.length;for(let n=0;n<e;++n)r[t[n]]=POINT_SCALE_SELECTED}{const e=o;for(let t=0;t<e;++t)r[n[t].index]=POINT_SCALE_NEIGHBOR}return null!=i&&(r[i]=POINT_SCALE_HOVER),r}generateLineSegmentColorMap(e,t){let n={};if(null==e)return n;for(let i=0;i<e.sequences.length;i++){let r=e.sequences[i],o=new Float32Array(2*(r.pointIndices.length-1)*3),a=0;if(t)for(let n=0;n<r.pointIndices.length-1;n++){const i=new Color(t(e,r.pointIndices[n])),s=new Color(t(e,r.pointIndices[n+1]));o[a++]=i.r,o[a++]=i.g,o[a++]=i.b,o[a++]=s.r,o[a++]=s.g,o[a++]=s.b}else for(let e=0;e<r.pointIndices.length-1;e++){const t=getDefaultPointInPolylineColor(e,r.pointIndices.length),n=getDefaultPointInPolylineColor(e+1,r.pointIndices.length);o[a++]=t.r,o[a++]=t.g,o[a++]=t.b,o[a++]=n.r,o[a++]=n.g,o[a++]=n.b}n[i]=o}return n}generateLineSegmentOpacityArray(e,t){if(null==e)return new Float32Array(0);const n=new Float32Array(e.sequences.length);return(null==t?0:t.length)>0?(n.fill(POLYLINE_DESELECTED_OPACITY),n[e.points[t[0]].sequenceIndex]=POLYLINE_SELECTED_OPACITY):n.fill(POLYLINE_DEFAULT_OPACITY),n}generateLineSegmentWidthArray(e,t){if(null==e)return new Float32Array(0);const n=new Float32Array(e.sequences.length);return n.fill(POLYLINE_DEFAULT_LINEWIDTH),(null==t?0:t.length)>0&&(n[e.points[t[0]].sequenceIndex]=POLYLINE_SELECTED_LINEWIDTH),n}generatePointColorArray(e,t,n,i,r,o,a,s){if(null==e)return new Float32Array(0);const l=null==i?0:i.length,c=null==r?0:r.length,h=new Float32Array(3*e.points.length);let u=POINT_COLOR_UNSELECTED,d=POINT_COLOR_NO_SELECTION;a&&(u=LABELS_3D_COLOR_UNSELECTED,d=LABELS_3D_COLOR_NO_SELECTION),s&&(u=SPRITE_IMAGE_COLOR_UNSELECTED,d=SPRITE_IMAGE_COLOR_NO_SELECTION);{const n=e.points.length;let i=0;if(l>0){const e=new Color(u);for(let t=0;t<n;++t)h[i++]=e.r,h[i++]=e.g,h[i++]=e.b}else if(null!=t)for(let r=0;r<n;++r){const n=new Color(t(e,r));h[i++]=n.r,h[i++]=n.g,h[i++]=n.b}else{const e=new Color(d);for(let t=0;t<n;++t)h[i++]=e.r,h[i++]=e.g,h[i++]=e.b}}{const e=l,t=new Color(POINT_COLOR_SELECTED);for(let n=0;n<e;++n){let e=3*i[n];h[e++]=t.r,h[e++]=t.g,h[e++]=t.b}}{const e=c;let t=e>0?r[0].dist:0;for(let i=0;i<e;++i){const e=new Color(dist2color(n,r[i].dist,t));let o=3*r[i].index;h[o++]=e.r,h[o++]=e.g,h[o++]=e.b}}if(null!=o){const e=new Color(POINT_COLOR_HOVER);let t=3*o;h[t++]=e.r,h[t++]=e.g,h[t++]=e.b}return h}generate3DLabelsArray(e,t){if(null==e||null==t)return null;let n=[];const i=e.points.length;for(let r=0;r<i;++r)n.push(this.getLabelText(e,r,t));return n}getLabelText(e,t,n){return void 0!==e.points[t].metadata[n]?String(e.points[t].metadata[n]):`Unknown #${t}`}updateScatterPlotWithNewProjection(e){if(null==e)return this.createVisualizers(this.renderLabelsIn3D),void this.scatterPlot.render();this.setDataSet(e.dataSet),this.scatterPlot.setDimensions(e.dimensionality),e.dataSet.projectionCanBeRendered(e.projectionType)&&(this.updateScatterPlotAttributes(),this.notifyProjectionPositionsUpdated()),this.scatterPlot.setCameraParametersForNextCameraCreation(null,!1)}createVisualizers(e){const t=null==this.projection?null:this.projection.dataSet,n=this.scatterPlot;n.removeAllVisualizers(),this.labels3DVisualizer=null,this.canvasLabelsVisualizer=null,this.spriteVisualizer=null,this.polylineVisualizer=null,e?(this.labels3DVisualizer=new ScatterPlotVisualizer3DLabels,this.labels3DVisualizer.setLabelStrings(this.generate3DLabelsArray(t,this.labelPointAccessor))):(this.spriteVisualizer=new ScatterPlotVisualizerSprites,n.addVisualizer(this.spriteVisualizer),this.canvasLabelsVisualizer=new ScatterPlotVisualizerCanvasLabels(this.scatterPlotContainer)),this.polylineVisualizer=new ScatterPlotVisualizerPolylines,this.setDataSet(t),this.spriteVisualizer&&n.addVisualizer(this.spriteVisualizer),this.labels3DVisualizer&&n.addVisualizer(this.labels3DVisualizer),this.canvasLabelsVisualizer&&n.addVisualizer(this.canvasLabelsVisualizer),n.addVisualizer(this.polylineVisualizer)}getSpriteImageMode(){if(null==this.projection)return!1;const e=this.projection.dataSet;return null!=e&&null!=e.spriteAndMetadataInfo&&null!=e.spriteAndMetadataInfo.spriteImage}}function packRgbIntoUint8Array(e,t,n,i,r){e[3*t]=n,e[3*t+1]=i,e[3*t+2]=r}function styleRgbFromHexColor(e){const t=new Color(e);return[255*t.r|0,255*t.g|0,255*t.b|0]}function getDefaultPointInPolylineColor(e,t){let n=hsl(POLYLINE_START_HUE+(POLYLINE_END_HUE-POLYLINE_START_HUE)*e/t,POLYLINE_SATURATION,POLYLINE_LIGHTNESS).rgb();return new Color(n.r/255,n.g/255,n.b/255)}function normalizeDist(e,t,n){return e===dist?n/t:1-t}function dist2color(e,t,n){return NN_COLOR_SCALE(normalizeDist(e,t,n))}const LIMIT_RESULTS=100,DEFAULT_NEIGHBORS=100;let InspectorPanel=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.numNN=DEFAULT_NEIGHBORS,this.showNeighborImages=!0,this.spriteImagesAvailable=!0}ready(){super.ready(),this.resetFilterButton=this.$$(".reset-filter"),this.setFilterButton=this.$$(".set-filter"),this.clearSelectionButton=this.$$(".clear-selection"),this.limitMessage=this.$$(".limit-msg"),this.searchBox=this.$$("#search-box"),this.displayContexts=[]}initialize(e,t){this.projector=e,this.projectorEventContext=t,this.setupUI(e),t.registerSelectionChangedListener(((e,t)=>this.updateInspectorPane(e,t)))}updateInspectorPane(e,t){this.neighborsOfFirstPoint=t,this.selectedPointIndices=e,this.updateFilterButtons(e.length+t.length),this.updateNeighborsList(t),this.updateSearchResults(0===t.length?e:[])}enableResetFilterButton(e){this.resetFilterButton.disabled=!e}restoreUIFromBookmark(e){this.enableResetFilterButton(null!=e.filteredPoints)}metadataChanged(e){let t=-1;if(this.metadataFields=e.stats.map(((e,n)=>(e.isNumeric||-1!==t||(t=n),e.name))),e.spriteMetadata&&e.spriteMetadata.imagePath){const[t,n]=e.spriteMetadata.singleImageDim;this.spriteMeta={imagePath:e.spriteImage.src,aspectRatio:t/n,nCols:Math.floor(e.spriteImage.width/t),singleImageDim:[t,n]}}else this.spriteMeta={};this.spriteImagesAvailable=!!this.spriteMeta.imagePath,null!=this.selectedMetadataField&&0!==this.metadataFields.filter((e=>e===this.selectedMetadataField)).length||(this.selectedMetadataField=this.metadataFields[Math.max(0,t)]),this.updateInspectorPane(this.selectedPointIndices,this.neighborsOfFirstPoint)}datasetChanged(){this.enableResetFilterButton(!1)}_refreshNeighborsList(){this.updateNeighborsList()}metadataEditorContext(e,t){if(!this.projector||!this.projector.dataSet)return;let n=this.projector.dataSet.spriteAndMetadataInfo.stats.filter((e=>e.name===t));if(!e||0===n.length||n[0].tooManyUniqueValues)return void this.removeContext(".metadata-info");this.metadataColumn=t,this.addContext(".metadata-info");let i=this.$$(".metadata-list");i.textContent="";let r=n[0].uniqueEntries.sort(((e,t)=>e.count-t.count)),o=r[r.length-1].count;r.forEach((e=>{const n=document.createElement("div");n.className="metadata";const r=document.createElement("a");r.className="metadata-link",r.title=e.label;const a=document.createElement("div");a.className="label-and-value";const s=document.createElement("div");s.className="label",s.style.color=dist2color(this.distFunc,o,e.count),s.innerText=e.label;const l=document.createElement("div");l.className="value",l.innerText=e.count.toString(),a.appendChild(s),a.appendChild(l);const c=document.createElement("div");c.className="bar";const h=document.createElement("div");h.className="fill",h.style.borderTopColor=dist2color(this.distFunc,o,e.count),h.style.width=100*normalizeDist(this.distFunc,o,e.count)+"%",c.appendChild(h);for(let e=1;e<4;e++){const t=document.createElement("div");t.className="tick",t.style.left=100*e/4+"%",c.appendChild(t)}r.appendChild(a),r.appendChild(c),n.appendChild(r),i.appendChild(n),r.onclick=()=>{this.projector.metadataEdit(t,e.label)}}))}addContext(e){-1===this.displayContexts.indexOf(e)&&this.displayContexts.push(e),this.displayContexts.forEach((e=>{this.$$(e).style.display="none"})),this.$$(e).style.display=null}removeContext(e){this.displayContexts=this.displayContexts.filter((t=>t!==e)),this.$$(e).style.display="none",this.displayContexts.length>0&&(this.$$(this.displayContexts[this.displayContexts.length-1]).style.display=null)}updateSearchResults(e){const t=this.$$(".matches-list").querySelector(".list");if(t.textContent="",0!==e.length){this.addContext(".matches-list"),this.limitMessage.style.display=e.length<=LIMIT_RESULTS?"none":null,e=e.slice(0,LIMIT_RESULTS);for(let n=0;n<e.length;n++){const i=e[n],r=document.createElement("div");r.className="row";const o=this.getLabelFromIndex(i),a=document.createElement("a");a.className="label",a.title=o,a.innerText=o,a.onmouseenter=()=>{this.projectorEventContext.notifyHoverOverPoint(i)},a.onmouseleave=()=>{this.projectorEventContext.notifyHoverOverPoint(null)},a.onclick=()=>{this.projectorEventContext.notifySelectionChanged([i])},r.appendChild(a),t.appendChild(r)}}else this.removeContext(".matches-list")}getLabelFromIndex(e){const t=this.projector.dataSet.points[e].metadata[this.selectedMetadataField];return void 0!==t?String(t):`Unknown #${e}`}spriteImageRenderer(){const e=this.spriteMeta.imagePath,{aspectRatio:t,nCols:n}=this.spriteMeta,i=100/t+"%",r=`${100*n}% ${100*n}%`,o=`url(${CSS.escape(e)})`;return e=>{const t=document.createElement("div");t.className="sprite-image",t.style.backgroundImage=o,t.style.paddingBottom=i,t.style.backgroundSize=r;const[a,s]=[Math.floor(e.index/n),e.index%n],[l,c]=[a/(n-1)*100,s/(n-1)*100];return t.style.backgroundPosition=`${c}% ${l}%`,t}}updateNeighborsList(e){if(this._currentNeighbors=e=e||this._currentNeighbors,null==e)return;const t=this.$$(".nn-list");if(t.textContent="",0===e.length)return void this.removeContext(".nn");this.addContext(".nn"),this.searchBox.message="";const n=e.length>0?e[0].dist:0;if(this.spriteImagesAvailable&&this.showNeighborImages)var i=this.spriteImageRenderer();for(let r=0;r<e.length;r++){const o=e[r],a=document.createElement("div");a.className="neighbor";const s=document.createElement("a");s.className="neighbor-link",s.title=this.getLabelFromIndex(o.index);const l=document.createElement("div");l.className="label-and-value";const c=document.createElement("div");c.className="label",c.style.color=dist2color(this.distFunc,o.dist,n),c.innerText=this.getLabelFromIndex(o.index);const h=document.createElement("div");h.className="value",h.innerText=o.dist.toFixed(3),l.appendChild(c),l.appendChild(h);const u=document.createElement("div");u.className="bar";const d=document.createElement("div");d.className="fill",d.style.borderTopColor=dist2color(this.distFunc,o.dist,n),d.style.width=100*normalizeDist(this.distFunc,o.dist,n)+"%",u.appendChild(d);for(let e=1;e<4;e++){const t=document.createElement("div");t.className="tick",t.style.left=100*e/4+"%",u.appendChild(t)}if(this.spriteImagesAvailable&&this.showNeighborImages){const e=i(o);a.appendChild(e)}s.appendChild(l),s.appendChild(u),a.appendChild(s),t.appendChild(a),s.onmouseenter=()=>{this.projectorEventContext.notifyHoverOverPoint(o.index)},s.onmouseleave=()=>{this.projectorEventContext.notifyHoverOverPoint(null)},s.onclick=()=>{this.projectorEventContext.notifySelectionChanged([o.index])}}}updateFilterButtons(e){e>1?(this.setFilterButton.innerText=`Isolate ${e} points`,this.setFilterButton.disabled=null,this.clearSelectionButton.disabled=null):(this.setFilterButton.disabled=!0,this.clearSelectionButton.disabled=!0)}setupUI(e){this.distFunc=cosDist;const t=this.$$(".distance a.euclidean");t.onclick=()=>{const n=this.root.querySelectorAll(".distance a");for(let e=0;e<n.length;e++)classed(n[e],"selected",!1);classed(t,"selected",!0),this.distFunc=dist,this.projectorEventContext.notifyDistanceMetricChanged(this.distFunc);const i=e.dataSet.findNeighbors(this.selectedPointIndices[0],this.distFunc,this.numNN);this.updateNeighborsList(i)};const n=this.$$(".distance a.cosine");n.onclick=()=>{const t=this.root.querySelectorAll(".distance a");for(let e=0;e<t.length;e++)classed(t[e],"selected",!1);classed(n,"selected",!0),this.distFunc=cosDist,this.projectorEventContext.notifyDistanceMetricChanged(this.distFunc);const i=e.dataSet.findNeighbors(this.selectedPointIndices[0],this.distFunc,this.numNN);this.updateNeighborsList(i)};const i=(t,n)=>{if(null==t||""===t.trim())return this.searchBox.message="",void this.projectorEventContext.notifySelectionChanged([]);const i=e.dataSet.query(t,n,this.selectedMetadataField);this.searchBox.message=0===i.length?"0 matches.":`${i.length} matches.`,this.projectorEventContext.notifySelectionChanged(i)};this.searchBox.registerInputChangedListener(((e,t)=>{i(e,t)})),this.setFilterButton.onclick=()=>{const t=this.selectedPointIndices.concat(this.neighborsOfFirstPoint.map((e=>e.index)));e.filterDataset(t),this.enableResetFilterButton(!0),this.updateFilterButtons(0)},this.resetFilterButton.onclick=()=>{e.resetFilterDataset(),this.enableResetFilterButton(!1)},this.clearSelectionButton.onclick=()=>{e.adjustSelectionAndHover([])},this.enableResetFilterButton(!1)}updateNumNN(){null!=this.selectedPointIndices&&this.projectorEventContext.notifySelectionChanged([this.selectedPointIndices[0]])}};InspectorPanel.template=template,__decorate([property({type:String}),__metadata("design:type",String)],InspectorPanel.prototype,"selectedMetadataField",void 0),__decorate([property({type:Array}),__metadata("design:type",Array)],InspectorPanel.prototype,"metadataFields",void 0),__decorate([property({type:String}),__metadata("design:type",String)],InspectorPanel.prototype,"metadataColumn",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],InspectorPanel.prototype,"numNN",void 0),__decorate([property({type:Object}),__metadata("design:type",Object)],InspectorPanel.prototype,"spriteMeta",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],InspectorPanel.prototype,"showNeighborImages",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],InspectorPanel.prototype,"spriteImagesAvailable",void 0),__decorate([observe("showNeighborImages","spriteImagesAvailable"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],InspectorPanel.prototype,"_refreshNeighborsList",null),InspectorPanel=__decorate([customElement("vz-projector-inspector-panel")],InspectorPanel);const THRESHOLD_DIM_NORMALIZE=50,POINT_COLOR_MISSING="black",INDEX_METADATA_FIELD="__index__",initialURLQueryString=window.location.search;let Projector=class extends(LegacyElementMixin(PolymerElement)){ready(){const e=Object.create(null,{ready:{get:()=>super.ready}});return __awaiter(this,void 0,void 0,(function*(){if(e.ready.call(this),setDomContainer(this),this.analyticsLogger=new AnalyticsLogger(this.pageViewLogging,this.eventLogging),this.analyticsLogger.logPageView("embeddings"),!(yield hasWebGLSupport()))return this.analyticsLogger.logWebGLDisabled(),void setErrorMessage("Your browser or device does not have WebGL enabled. Please enable hardware acceleration, or use a browser that supports WebGL.");this.selectionChangedListeners=[],this.hoverListeners=[],this.projectionChangedListeners=[],this.distanceMetricChangedListeners=[],this.selectedPointIndices=[],this.neighborsOfFirstPoint=[],this.editMode=!1,this.dataPanel=this.$["data-panel"],this.inspectorPanel=this.$["inspector-panel"],this.projectionsPanel=this.$["projections-panel"],this.bookmarkPanel=this.$["bookmark-panel"],this.metadataCard=this.$["metadata-card"],this.statusBar=this.$$("#status-bar"),this.inspectorPanel.initialize(this,this),this.projectionsPanel.initialize(this),this.bookmarkPanel.initialize(this,this),this.setupUIControls(),this.initializeDataProvider()}))}setSelectedLabelOption(e){this.selectedLabelOption=e,this.metadataCard.setLabelOption(this.selectedLabelOption),this.projectorScatterPlotAdapter.setLabelPointAccessor(e),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.projectorScatterPlotAdapter.render()}setSelectedColorOption(e){this.selectedColorOption=e,this.projectorScatterPlotAdapter.setLegendPointColorer(this.getLegendPointColorer(e)),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.projectorScatterPlotAdapter.render()}setNormalizeData(e){this.normalizeData=e,this.setCurrentDataSet(this.originalDataSet.getSubset())}updateDataSet(e,t,n){if(this.dataSetFilterIndices=null,this.originalDataSet=e,null!=e){if(this.normalizeData=this.originalDataSet.dim[1]>=THRESHOLD_DIM_NORMALIZE,null==(t=t||{}).pointsInfo){let[n,i]=this.makeDefaultPointsInfoAndStats(e.points);t.pointsInfo=n,t.stats=i}if(!e.mergeMetadata(t))return}null!=this.projectorScatterPlotAdapter&&(null==e?(this.projectorScatterPlotAdapter.setLabelPointAccessor(null),this.setProjection(null)):(this.projectorScatterPlotAdapter.updateScatterPlotPositions(),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.projectorScatterPlotAdapter.resize(),this.projectorScatterPlotAdapter.render())),null!=e?(this.dataPanel.setNormalizeData(this.normalizeData),this.setCurrentDataSet(e.getSubset()),this.projectorScatterPlotAdapter.setLabelPointAccessor(this.selectedLabelOption),this.inspectorPanel.datasetChanged(),this.inspectorPanel.metadataChanged(t),this.projectionsPanel.metadataChanged(t),this.dataPanel.metadataChanged(t,n)):this.setCurrentDataSet(null)}metadataEdit(e,t){this.selectedPointIndices.forEach((n=>this.dataSet.points[n].metadata[e]=t)),this.neighborsOfFirstPoint.forEach((n=>this.dataSet.points[n.index].metadata[e]=t)),this.dataSet.spriteAndMetadataInfo.stats=analyzeMetadata(this.dataSet.spriteAndMetadataInfo.stats.map((e=>e.name)),this.dataSet.points.map((e=>e.metadata))),this.metadataChanged(this.dataSet.spriteAndMetadataInfo),this.metadataEditorContext(!0,e)}metadataChanged(e,t){null!=t&&(this.metadataFile=t),this.dataSet.spriteAndMetadataInfo=e,this.projectionsPanel.metadataChanged(e),this.inspectorPanel.metadataChanged(e),this.dataPanel.metadataChanged(e,this.metadataFile),this.metadataCard.updateMetadata(this.selectedPointIndices.length>0?this.dataSet.points[this.selectedPointIndices[0]].metadata:null),this.setSelectedLabelOption(this.selectedLabelOption)}metadataEditorContext(e,t){this.inspectorPanel&&this.inspectorPanel.metadataEditorContext(e,t)}setSelectedTensor(e,t){this.bookmarkPanel.setSelectedTensor(e,t,this.dataProvider)}registerSelectionChangedListener(e){this.selectionChangedListeners.push(e)}filterDataset(e){const t=this.selectedPointIndices.length;null==this.dataSetBeforeFilter&&(this.dataSetBeforeFilter=this.dataSet),this.setCurrentDataSet(this.dataSet.getSubset(e)),this.dataSetFilterIndices=e,this.projectorScatterPlotAdapter.updateScatterPlotPositions(),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.adjustSelectionAndHover(range(t))}resetFilterDataset(){const e=this.selectedPointIndices.map((e=>this.dataSet.points[e].index));this.setCurrentDataSet(this.dataSetBeforeFilter),null!=this.projection&&(this.projection.dataSet=this.dataSetBeforeFilter),this.dataSetBeforeFilter=null,this.projectorScatterPlotAdapter.updateScatterPlotPositions(),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.dataSetFilterIndices=[],this.adjustSelectionAndHover(e)}notifySelectionChanged(e){let t=[];if(this.editMode&&e.length>0)if(1===this.selectedPointIndices.length){let n=this.dataSet.points[this.selectedPointIndices[0]].vector;t=this.neighborsOfFirstPoint.filter((t=>0==e.filter((e=>e==t.index)).length)),e.forEach((e=>{if(e!=this.selectedPointIndices[0]&&0==this.neighborsOfFirstPoint.filter((t=>t.index==e)).length){let i=this.inspectorPanel.distFunc(n,this.dataSet.points[e].vector),r=0;for(;r<t.length&&t[r].dist<i;)r+=1;t.splice(r,0,{index:e,dist:i})}}))}else{let t=this.selectedPointIndices.filter((t=>0==e.filter((e=>e==t)).length));e.forEach((e=>{0==this.selectedPointIndices.filter((t=>t==e)).length&&t.push(e)})),this.selectedPointIndices=t,this.metadataCard.updateMetadata(this.selectedPointIndices.length>0?this.dataSet.points[this.selectedPointIndices[0]].metadata:null)}else this.selectedPointIndices=e,1===e.length?(t=this.dataSet.findNeighbors(e[0],this.inspectorPanel.distFunc,this.inspectorPanel.numNN),this.metadataCard.updateMetadata(this.dataSet.points[e[0]].metadata)):this.metadataCard.updateMetadata(null);this.selectionChangedListeners.forEach((e=>e(this.selectedPointIndices,t)))}registerHoverListener(e){this.hoverListeners.push(e)}notifyHoverOverPoint(e){this.hoverListeners.forEach((t=>t(e)))}registerProjectionChangedListener(e){this.projectionChangedListeners.push(e)}notifyProjectionChanged(e){this.projectionChangedListeners.forEach((t=>t(e)))}registerDistanceMetricChangedListener(e){this.distanceMetricChangedListeners.push(e)}notifyDistanceMetricChanged(e){this.distanceMetricChangedListeners.forEach((t=>t(e)))}_dataProtoChanged(e){let t=e?JSON.parse(e):null;this.initializeDataProvider(t)}makeDefaultPointsInfoAndStats(e){let t=[];return e.forEach((e=>{let n={};n[INDEX_METADATA_FIELD]=e.index,t.push(n)})),[t,[{name:INDEX_METADATA_FIELD,isNumeric:!1,tooManyUniqueValues:!0,min:0,max:t.length-1}]]}initializeDataProvider(e){if("demo"===this.servingMode){let e,t=getURLParams(initialURLQueryString);e="config"in t?t.config:this.projectorConfigJsonPath,this.dataProvider=new DemoDataProvider(e)}else if("server"===this.servingMode){if(!this.routePrefix)throw"route-prefix is a required parameter";this.dataProvider=new ServerDataProvider(this.routePrefix)}else{if("proto"!==this.servingMode||null==e)return;this.dataProvider=new ProtoDataProvider(e)}this.dataPanel.initialize(this,this.dataProvider)}getLegendPointColorer(e){return null==e||null==e.map?null:(t,n)=>{let i=t.points[n].metadata[this.selectedColorOption.name];return null==i?POINT_COLOR_MISSING:e.map(i)}}get3DLabelModeButton(){return this.$$("#labels3DMode")}get3DLabelMode(){return this.get3DLabelModeButton().active}adjustSelectionAndHover(e,t){this.notifySelectionChanged(e),this.notifyHoverOverPoint(t),this.setMouseMode(MouseMode.CAMERA_AND_CLICK_SELECT)}setMouseMode(e){this.$$("#selectMode").active=e===MouseMode.AREA_SELECT,this.projectorScatterPlotAdapter.scatterPlot.setMouseMode(e)}setCurrentDataSet(e){this.adjustSelectionAndHover([]),null!=this.dataSet&&this.dataSet.stopTSNE(),null!=e&&this.normalizeData&&e.normalize(),this.dim=null==e?0:e.dim[1],this.$$("span.numDataPoints").innerText=null==e?"0":""+e.dim[0],this.$$("span.dim").innerText=null==e?"0":""+e.dim[1],this.dataSet=e,this.projectionsPanel.dataSetUpdated(this.dataSet,this.originalDataSet,this.dim),this.projectorScatterPlotAdapter.setDataSet(this.dataSet),this.projectorScatterPlotAdapter.scatterPlot.setCameraParametersForNextCameraCreation(null,!0)}setupUIControls(){this.$$("#reset-zoom").addEventListener("click",(()=>{this.projectorScatterPlotAdapter.scatterPlot.resetZoom(),this.projectorScatterPlotAdapter.scatterPlot.startOrbitAnimation()}));let e=this.$$("#selectMode");e.addEventListener("click",(t=>{this.setMouseMode(e.active?MouseMode.AREA_SELECT:MouseMode.CAMERA_AND_CLICK_SELECT)}));let t=this.$$("#nightDayMode");t.addEventListener("click",(()=>{this.projectorScatterPlotAdapter.scatterPlot.setDayNightMode(t.active)}));let n=this.$$("#editMode");n.addEventListener("click",(e=>{this.editMode=n.active})),this.get3DLabelModeButton().addEventListener("click",(()=>{this.projectorScatterPlotAdapter.set3DLabelMode(this.get3DLabelMode())})),window.addEventListener("resize",(()=>{this.projectorScatterPlotAdapter.resize()})),this.projectorScatterPlotAdapter=new ProjectorScatterPlotAdapter(this.getScatterContainer(),this),this.projectorScatterPlotAdapter.setLabelPointAccessor(this.selectedLabelOption),this.projectorScatterPlotAdapter.scatterPlot.onCameraMove(((e,t)=>this.bookmarkPanel.clearStateSelection())),this.registerHoverListener((e=>this.onHover(e))),this.registerProjectionChangedListener((e=>this.onProjectionChanged(e))),this.registerSelectionChangedListener(((e,t)=>this.onSelectionChanged(e,t)))}onHover(e){this.hoverPointIndex=e;let t=null;if(null!=e){const n=this.dataSet.points[e];n.metadata[this.selectedLabelOption]&&(t=n.metadata[this.selectedLabelOption].toString())}0===this.selectedPointIndices.length&&(this.statusBar.style.display=t?null:"none",this.statusBar.innerText=t)}getScatterContainer(){return this.$$("#scatter")}onSelectionChanged(e,t){this.selectedPointIndices=e,this.neighborsOfFirstPoint=t,this.dataPanel.onProjectorSelectionChanged(e,t);let n=this.selectedPointIndices.length+t.length;this.statusBar.innerText=`Selected ${n} points`,this.statusBar.style.display=n>0?null:"none"}onProjectionChanged(e){this.dataPanel.projectionChanged(e)}setProjection(e){this.projection=e,null!=e&&this.analyticsLogger.logProjectionChanged(e.projectionType),this.notifyProjectionChanged(e)}notifyProjectionPositionsUpdated(){this.projectorScatterPlotAdapter.notifyProjectionPositionsUpdated()}getCurrentState(){const e=new State;e.projections=[];for(let t=0;t<this.dataSet.points.length;t++){const n=this.dataSet.points[t],i={},r=Object.keys(n.projections);for(let e=0;e<r.length;++e)i[r[e]]=n.projections[r[e]];e.projections.push(i)}return e.selectedProjection=this.projection.projectionType,e.dataSetDimensions=this.dataSet.dim,e.tSNEIteration=this.dataSet.tSNEIteration,e.selectedPoints=this.selectedPointIndices,e.filteredPoints=this.dataSetFilterIndices,this.projectorScatterPlotAdapter.populateBookmarkFromUI(e),e.selectedColorOptionName=this.dataPanel.selectedColorOptionName,e.forceCategoricalColoring=this.dataPanel.forceCategoricalColoring,e.selectedLabelOption=this.selectedLabelOption,this.projectionsPanel.populateBookmarkFromUI(e),e}loadState(e){this.setProjection(null),this.projectionsPanel.disablePolymerChangesTriggerReprojection(),null!=this.dataSetBeforeFilter&&this.resetFilterDataset(),null!=e.filteredPoints&&this.filterDataset(e.filteredPoints),this.projectionsPanel.enablePolymerChangesTriggerReprojection();for(let t=0;t<e.projections.length;t++){const n=this.dataSet.points[t],i=e.projections[t],r=Object.keys(i);for(let e=0;e<r.length;++e)n.projections[r[e]]=i[r[e]]}this.dataSet.hasTSNERun="tsne"===e.selectedProjection,this.dataSet.tSNEIteration=e.tSNEIteration,this.projectionsPanel.restoreUIFromBookmark(e),this.inspectorPanel.restoreUIFromBookmark(e),this.dataPanel.selectedColorOptionName=e.selectedColorOptionName,this.dataPanel.setForceCategoricalColoring(!!e.forceCategoricalColoring),this.selectedLabelOption=e.selectedLabelOption,this.projectorScatterPlotAdapter.restoreUIFromBookmark(e);{const t=stateGetAccessorDimensions(e),n=getProjectionComponents(e.selectedProjection,t),i=new Projection(e.selectedProjection,n,t.length,this.dataSet);this.setProjection(i)}this.notifySelectionChanged(e.selectedPoints)}};Projector.template=template$4,__decorate([property({type:String}),__metadata("design:type",String)],Projector.prototype,"routePrefix",void 0),__decorate([property({type:String}),__metadata("design:type",String)],Projector.prototype,"dataProto",void 0),__decorate([property({type:String}),__metadata("design:type",String)],Projector.prototype,"servingMode",void 0),__decorate([property({type:String}),__metadata("design:type",String)],Projector.prototype,"projectorConfigJsonPath",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],Projector.prototype,"pageViewLogging",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],Projector.prototype,"eventLogging",void 0),__decorate([observe("dataProto"),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",void 0)],Projector.prototype,"_dataProtoChanged",null),Projector=__decorate([customElement("vz-projector")],Projector);let VzProjectorApp=class extends PolymerElement{constructor(){super(...arguments),this.pageViewLogging=!1,this.eventLogging=!1,this.projectorConfigJsonPath="",this.routePrefix="",this.servingMode="",this.documentationLink="",this.bugReportLink=""}};VzProjectorApp.template=html` <style include="vz-projector-styles"></style> <style> #appbar { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 60px; color: white; background: #560731; } #appbar .logo { font-size: 18px; font-weight: 300; } .icons { display: flex; } .icons a { color: white; } vz-projector { height: calc(100% - 60px); } #container { height: 100%; } </style> <div id="container"> <div id="appbar"> <div>Embedding Projector</div> <div class="icons"> <a title="Documentation" target="_blank" href="[[documentationLink]]" rel="noopener noreferrer" > <paper-icon-button icon="help-outline"></paper-icon-button> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds="" > Open documentation </paper-tooltip> </a> <a title="Report bug" target="_blank" href="[[bugReportLink]]" rel="noopener noreferrer" > <paper-icon-button icon="bug-report"></paper-icon-button> <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds="" > Report a bug </paper-tooltip> </a> </div> </div> <vz-projector route-prefix="[[routePrefix]]" serving-mode="[[servingMode]]" projector-config-json-path="[[projectorConfigJsonPath]]" page-view-logging="[[pageViewLogging]]" event-logging="[[eventLogging]]" > </vz-projector> </div> `,__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],VzProjectorApp.prototype,"pageViewLogging",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],VzProjectorApp.prototype,"eventLogging",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"projectorConfigJsonPath",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"routePrefix",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"servingMode",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"documentationLink",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"bugReportLink",void 0),VzProjectorApp=__decorate([customElement("vz-projector-app")],VzProjectorApp);let VzProjectorDashboard=class extends PolymerElement{constructor(){super(...arguments),this._routePrefix="."}reload(){}connectedCallback(){if(super.connectedCallback(),this._initialized)return;let e=new XMLHttpRequest;e.open("GET",this._routePrefix+"/runs"),e.onload=()=>{this._initialized=!0;let t=JSON.parse(e.responseText);this.set("dataNotFound",0===t.length)},e.onerror=()=>{this.set("dataNotFound",!1)},e.send()}};VzProjectorDashboard.template=html` <template is="dom-if" if="[[dataNotFound]]"> <div style="max-width: 540px; margin: 0 auto; padding: 80px 0 0"> <h3>No checkpoint was found.</h3> <p>Probable causes:</p> <ul> <li> No checkpoint has been saved yet. Please refresh the page periodically. </li> <li> You are not saving any checkpoint. To save your model, create a <a href="https://www.tensorflow.org/api_docs/python/tf/train/Saver" ><code>tf.train.Saver</code></a > and save your model periodically by calling <code>saver.save(session, LOG_DIR/model.ckpt, step)</code>. </li> </ul> <p> If you’re new to using TensorBoard, and want to find out how to add data and set up your event files, check out the <a href="https://github.com/tensorflow/tensorboard/blob/master/README.md" >README</a > and perhaps the <a href="https://www.tensorflow.org/get_started/summaries_and_tensorboard" >TensorBoard tutorial</a >. </p> <p> If you think TensorBoard is configured properly, please see <a href="https://github.com/tensorflow/tensorboard/blob/master/README.md#my-tensorboard-isnt-showing-any-data-whats-wrong" >the section of the README devoted to missing data problems</a > and consider filing an issue on GitHub. </p> </div> </template> <template is="dom-if" if="[[!dataNotFound]]"> <vz-projector id="projector" route-prefix="[[_routePrefix]]" serving-mode="server" page-view-logging="" event-logging="" ></vz-projector> </template> `,__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],VzProjectorDashboard.prototype,"dataNotFound",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorDashboard.prototype,"_routePrefix",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],VzProjectorDashboard.prototype,"_initialized",void 0),VzProjectorDashboard=__decorate([customElement("vz-projector-dashboard")],VzProjectorDashboard)})();