!function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n/gm),b=v(/^data-[\-\w.\u00B7-\uFFFF]/),w=v(/^aria-[\-\w]+$/),T=v(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),L=v(/^(?:\w+script|data):/i),E=v(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g),A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function k(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:_(),d=function(t){return e(t)};if(d.version="2.0.7",d.removed=[],!s||!s.document||9!==s.document.nodeType)return d.isSupported=!1,d;var f=s.document,h=!1,v=!1,C=s.document,N=s.DocumentFragment,F=s.HTMLTemplateElement,P=s.Node,D=s.NodeFilter,z=s.NamedNodeMap,R=void 0===z?s.NamedNodeMap||s.MozNamedAttrMap:z,j=s.Text,I=s.Comment,B=s.DOMParser,U=s.TrustedTypes;if("function"==typeof F){var H=C.createElement("template");H.content&&H.content.ownerDocument&&(C=H.content.ownerDocument)}var V=M(U,f),q=V?V.createHTML(""):"",Z=C,W=Z.implementation,G=Z.createNodeIterator,Y=Z.getElementsByTagName,X=Z.createDocumentFragment,K=f.importNode,Q={};d.isSupported=W&&void 0!==W.createHTMLDocument&&9!==C.documentMode;var J=y,$=g,ee=b,te=w,ne=L,ie=E,oe=T,re=null,se=m({},[].concat(k(t),k(n),k(i),k(o),k(r))),ae=null,le=m({},[].concat(k(a),k(l),k(c),k(u))),ce=null,ue=null,de=!0,fe=!0,he=!1,me=!1,pe=!1,ve=!1,ye=!1,ge=!1,be=!1,we=!1,Te=!1,Le=!1,Ee=!0,Ae=!0,ke=!1,Se={},Oe=m({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","plaintext","script","style","svg","template","thead","title","video","xmp"]),xe=m({},["audio","video","img","source","image"]),_e=null,Me=m({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),Ce=null,Ne=C.createElement("form"),Fe=function(e){Ce&&Ce===e||(e&&"object"===(void 0===e?"undefined":A(e))||(e={}),re="ALLOWED_TAGS"in e?m({},e.ALLOWED_TAGS):se,ae="ALLOWED_ATTR"in e?m({},e.ALLOWED_ATTR):le,_e="ADD_URI_SAFE_ATTR"in e?m(p(Me),e.ADD_URI_SAFE_ATTR):Me,ce="FORBID_TAGS"in e?m({},e.FORBID_TAGS):{},ue="FORBID_ATTR"in e?m({},e.FORBID_ATTR):{},Se="USE_PROFILES"in e&&e.USE_PROFILES,de=!1!==e.ALLOW_ARIA_ATTR,fe=!1!==e.ALLOW_DATA_ATTR,he=e.ALLOW_UNKNOWN_PROTOCOLS||!1,me=e.SAFE_FOR_JQUERY||!1,pe=e.SAFE_FOR_TEMPLATES||!1,ve=e.WHOLE_DOCUMENT||!1,be=e.RETURN_DOM||!1,we=e.RETURN_DOM_FRAGMENT||!1,Te=e.RETURN_DOM_IMPORT||!1,Le=e.RETURN_TRUSTED_TYPE||!1,ge=e.FORCE_BODY||!1,Ee=!1!==e.SANITIZE_DOM,Ae=!1!==e.KEEP_CONTENT,ke=e.IN_PLACE||!1,oe=e.ALLOWED_URI_REGEXP||oe,pe&&(fe=!1),we&&(be=!0),Se&&(re=m({},[].concat(k(r))),ae=[],!0===Se.html&&(m(re,t),m(ae,a)),!0===Se.svg&&(m(re,n),m(ae,l),m(ae,u)),!0===Se.svgFilters&&(m(re,i),m(ae,l),m(ae,u)),!0===Se.mathMl&&(m(re,o),m(ae,c),m(ae,u))),e.ADD_TAGS&&(re===se&&(re=p(re)),m(re,e.ADD_TAGS)),e.ADD_ATTR&&(ae===le&&(ae=p(ae)),m(ae,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&m(_e,e.ADD_URI_SAFE_ATTR),Ae&&(re["#text"]=!0),ve&&m(re,["html","head","body"]),re.table&&(m(re,["tbody"]),delete ce.tbody),x&&x(e),Ce=e)},Pe=function(e){d.removed.push({element:e});try{e.parentNode.removeChild(e)}catch(t){e.outerHTML=q}},De=function(e,t){try{d.removed.push({attribute:t.getAttributeNode(e),from:t})}catch(e){d.removed.push({attribute:null,from:t})}t.removeAttribute(e)},ze=function(e){var t=void 0,n=void 0;if(ge)e=""+e;else{var i=e.match(/^[\s]+/);(n=i&&i[0])&&(e=e.slice(n.length))}if(h)try{t=(new B).parseFromString(e,"text/html")}catch(e){}if(v&&m(ce,["title"]),!t||!t.documentElement){var o=(t=W.createHTMLDocument("")).body;o.parentNode.removeChild(o.parentNode.firstElementChild),o.outerHTML=V?V.createHTML(e):e}return e&&n&&t.body.insertBefore(C.createTextNode(n),t.body.childNodes[0]||null),Y.call(t,ve?"html":"body")[0]};d.isSupported&&(function(){try{ze('

').querySelector("svg img")&&(h=!0)}catch(e){}}(),function(){try{var e=ze("</title><img>");/<\/title/.test(e.querySelector("title").innerHTML)&&(v=!0)}catch(e){}}());var Re=function(e){return G.call(e.ownerDocument||e,e,D.SHOW_ELEMENT|D.SHOW_COMMENT|D.SHOW_TEXT,(function(){return D.FILTER_ACCEPT}),!1)},je=function(e){return"object"===(void 0===P?"undefined":A(P))?e instanceof P:e&&"object"===(void 0===e?"undefined":A(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Ie=function(e,t,n){Q[e]&&Q[e].forEach((function(e){e.call(d,t,n,Ce)}))},Be=function(e){var t,n=void 0;if(Ie("beforeSanitizeElements",e,null),!((t=e)instanceof j||t instanceof I||"string"==typeof t.nodeName&&"string"==typeof t.textContent&&"function"==typeof t.removeChild&&t.attributes instanceof R&&"function"==typeof t.removeAttribute&&"function"==typeof t.setAttribute&&"string"==typeof t.namespaceURI))return Pe(e),!0;var i=e.nodeName.toLowerCase();if(Ie("uponSanitizeElement",e,{tagName:i,allowedTags:re}),("svg"===i||"math"===i)&&0!==e.querySelectorAll("p, br").length)return Pe(e),!0;if(!re[i]||ce[i]){if(Ae&&!Oe[i]&&"function"==typeof e.insertAdjacentHTML)try{var o=e.innerHTML;e.insertAdjacentHTML("AfterEnd",V?V.createHTML(o):o)}catch(e){}return Pe(e),!0}return"noscript"===i&&/<\/noscript/i.test(e.innerHTML)?(Pe(e),!0):"noembed"===i&&/<\/noembed/i.test(e.innerHTML)?(Pe(e),!0):(!me||e.firstElementChild||e.content&&e.content.firstElementChild||!/</g.test(e.textContent)||(d.removed.push({element:e.cloneNode()}),e.innerHTML?e.innerHTML=e.innerHTML.replace(/</g,"<"):e.innerHTML=e.textContent.replace(/</g,"<")),pe&&3===e.nodeType&&(n=(n=(n=e.textContent).replace(J," ")).replace($," "),e.textContent!==n&&(d.removed.push({element:e.cloneNode()}),e.textContent=n)),Ie("afterSanitizeElements",e,null),!1)},Ue=function(e,t,n){if(Ee&&("id"===t||"name"===t)&&(n in C||n in Ne))return!1;if(fe&&ee.test(t));else if(de&&te.test(t));else{if(!ae[t]||ue[t])return!1;if(_e[t]);else if(oe.test(n.replace(ie,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==n.indexOf("data:")||!xe[e])if(he&&!ne.test(n.replace(ie,"")));else if(n)return!1}return!0},He=function(e){var t=void 0,n=void 0,i=void 0,o=void 0,r=void 0;Ie("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ae};for(r=s.length;r--;){var l=t=s[r],c=l.name,u=l.namespaceURI;if(n=t.value.trim(),i=c.toLowerCase(),a.attrName=i,a.attrValue=n,a.keepAttr=!0,Ie("uponSanitizeAttribute",e,a),n=a.attrValue,"name"===i&&"IMG"===e.nodeName&&s.id)o=s.id,s=S(O,s,[]),De("id",e),De(c,e),s.indexOf(o)>r&&e.setAttribute("id",o.value);else{if("INPUT"===e.nodeName&&"type"===i&&"file"===n&&a.keepAttr&&(ae[i]||!ue[i]))continue;"id"===c&&e.setAttribute(c,""),De(c,e)}if(a.keepAttr)if(/svg|math/i.test(e.namespaceURI)&&new RegExp("</("+Object.keys(Oe).join("|")+")","i").test(n))De(c,e);else{pe&&(n=(n=n.replace(J," ")).replace($," "));var f=e.nodeName.toLowerCase();if(Ue(f,i,n))try{u?e.setAttributeNS(u,c,n):e.setAttribute(c,n),d.removed.pop()}catch(e){}}}Ie("afterSanitizeAttributes",e,null)}},Ve=function e(t){var n=void 0,i=Re(t);for(Ie("beforeSanitizeShadowDOM",t,null);n=i.nextNode();)Ie("uponSanitizeShadowNode",n,null),Be(n)||(n.content instanceof N&&e(n.content),He(n));Ie("afterSanitizeShadowDOM",t,null)};return d.sanitize=function(e,t){var n=void 0,i=void 0,o=void 0,r=void 0,a=void 0;if(e||(e="\x3c!--\x3e"),"string"!=typeof e&&!je(e)){if("function"!=typeof e.toString)throw new TypeError("toString is not a function");if("string"!=typeof(e=e.toString()))throw new TypeError("dirty is not a string, aborting")}if(!d.isSupported){if("object"===A(s.toStaticHTML)||"function"==typeof s.toStaticHTML){if("string"==typeof e)return s.toStaticHTML(e);if(je(e))return s.toStaticHTML(e.outerHTML)}return e}if(ye||Fe(t),d.removed=[],ke);else if(e instanceof P)1===(i=(n=ze("\x3c!--\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===i.nodeName?n=i:"HTML"===i.nodeName?n=i:n.appendChild(i);else{if(!be&&!pe&&!ve&&Le&&-1===e.indexOf("<"))return V?V.createHTML(e):e;if(!(n=ze(e)))return be?null:q}n&&ge&&Pe(n.firstChild);for(var l=Re(ke?e:n);o=l.nextNode();)3===o.nodeType&&o===r||Be(o)||(o.content instanceof N&&Ve(o.content),He(o),r=o);if(r=null,ke)return e;if(be){if(we)for(a=X.call(n.ownerDocument);n.firstChild;)a.appendChild(n.firstChild);else a=n;return Te&&(a=K.call(f,a,!0)),a}var c=ve?n.outerHTML:n.innerHTML;return pe&&(c=(c=c.replace(J," ")).replace($," ")),V&&Le?V.createHTML(c):c},d.setConfig=function(e){Fe(e),ye=!0},d.clearConfig=function(){Ce=null,ye=!1},d.isValidAttribute=function(e,t,n){Ce||Fe({});var i=e.toLowerCase(),o=t.toLowerCase();return Ue(i,o,n)},d.addHook=function(e,t){"function"==typeof t&&(Q[e]=Q[e]||[],Q[e].push(t))},d.removeHook=function(e){Q[e]&&Q[e].pop()},d.removeHooks=function(e){Q[e]&&(Q[e]=[])},d.removeAllHooks=function(){Q={}},d}()}()}));function L(e,t){return new Promise((function(n,i){if(m.string(t)&&null!==document.getElementById(t))n();else{var o=v("div",{hidden:"",id:t});(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";return new Promise((function(n,i){try{var o=new XMLHttpRequest;if(!("withCredentials"in o))return;o.addEventListener("load",(function(){if("text"===t)try{n(JSON.parse(o.responseText))}catch(e){n(o.responseText)}else n(o.response)})),o.addEventListener("error",(function(){throw new Error(o.status)})),o.open("GET",e,!0),o.responseType=t,o.send()}catch(e){i(e)}}))})(e).then((function(e){m.empty(e)&&n(),o.innerHTML=T.sanitize(e),document.body.insertBefore(o,document.body.firstChild),n(o)})).catch((function(e){i(e)}))}}))}var E=["zoom-in","zoom-out","fullscreen"];function A(e){var t=e.iconName,n=e.classList,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("focusable",!1),i.setAttribute("class",n.join(" "));var o=document.createElementNS("http://www.w3.org/2000/svg","use");return o.setAttributeNS("http://www.w3.org/1999/xlink","path","#".concat(t)),o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#".concat(t)),i.appendChild(o),i}var k={build:function(e){var t=e.viewer,n=e.elements,i=e.container,o=e.config,r=o.controls,s=o.iconUrl,a=v("div",{class:"shopify-model-viewer-ui__sr-only","data-shopify-model-viewer-ui-sr-only":"",role:"status"}),l=v("div",{class:"shopify-model-viewer-ui__controls-overlay"});if(i.insertBefore(a,t),i.appendChild(l),this.buildControlButton(e,l),r&&Array.isArray(r)&&r.length){var c=r.filter((function(e){return!E.includes(e)}));if(c.length>0)throw Error("Unrecognized controls passed to ModelViewerUI: ".concat(c.join(", ")));L(s,"sprites-mvui").then((function(e){n.sprites=e})).catch((function(){throw Error("Failed to load sprite from URL")})),n.zoomLevel=a,this.buildControlList(e,l)}},buildControlList:function(e,t){var n=e.config.controls,i=v("div",{class:"shopify-model-viewer-ui__controls-area"});t.appendChild(i),n.forEach((function(t){var n=v("button",{class:"shopify-model-viewer-ui__button shopify-model-viewer-ui__button--control shopify-model-viewer-ui__button--".concat(t)});switch(t){case"zoom-in":n.setAttribute("aria-label","Zoom In"),n.appendChild(A({iconName:"zoom-in-icon",classList:["shopify-model-viewer-ui__control-icon"]}));break;case"zoom-out":n.setAttribute("aria-label","Zoom Out"),n.appendChild(A({iconName:"zoom-out-icon",classList:["shopify-model-viewer-ui__control-icon"]}));break;case"fullscreen":n.setAttribute("aria-label","Enter Fullscreen"),n.appendChild(A({iconName:"enter-fullscreen-icon",classList:["shopify-model-viewer-ui__control-icon","shopify-model-viewer-ui__control-icon--enter-fullscreen"]})),n.appendChild(A({iconName:"exit-fullscreen-icon",classList:["shopify-model-viewer-ui__control-icon","shopify-model-viewer-ui__control-icon--exit-fullscreen"]}))}e.elements.buttons[t]=n,i.appendChild(n)})),e.elements.controlArea=i},buildControlButton:function(e,t){var n=e.elements,i=v("button",{class:"shopify-model-viewer-ui__button shopify-model-viewer-ui__button--poster"});i.setAttribute("aria-label","Play 3D Viewer"),i.appendChild(A({iconName:"threed-icon-button-control",classList:["shopify-model-viewer-ui__poster-control-icon"]})),n.controlButton=i,t.appendChild(i)}};function S(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement}function O(e,t){for(var n=0;n<e.length;n++){if(e[n].identifier===t)return n}return-1}var x=4;var _={isDragging:!1,cursorStartPosition:null},M=function(){function t(n){e(this,t),this.mvui=n,this.state=r({},_),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.resetState=this.resetState.bind(this)}return n(t,[{key:"add",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_,t=this.mvui.container;this.state=r({},e),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp)}},{key:"remove",value:function(){var e=this.mvui.container;e.removeEventListener("mousedown",this.onMouseDown),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)}},{key:"onMouseDown",value:function(e){this.resetState(),this.state.cursorStartPosition={x:e.pageX,y:e.pageY}}},{key:"onMouseMove",value:function(e){var t,n,i=this.state.cursorStartPosition;m.nullOrUndefined(i)||(t=i,n={x:e.pageX,y:e.pageY},(Math.abs(t.x-n.x)>x||Math.abs(t.y-n.y)>x)&&(this.state.isDragging=!0))}},{key:"onMouseUp",value:function(e){var t=this.mvui,n=t.interacting,i=t.elements,o=t.toggleable,r=i.controlArea,s=this.state.isDragging;r.contains(e.target)?this.resetState():(n||s?o&&n&&!s&&t.pause():t.play(),this.resetState())}},{key:"resetState",value:function(){this.state=r({},_)}}]),t}(),C=10;var N={isDragging:!1,isPinchZooming:!1,ongoingTouches:[],touchStartPositions:[]},F=function(){function t(n){e(this,t),this.mvui=n,this.state=r({},N),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.resetState=this.resetState.bind(this)}return n(t,[{key:"add",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N,t=this.mvui.container;this.state=r({},e),t.addEventListener("touchstart",this.onTouchStart),t.addEventListener("touchmove",this.onTouchMove),t.addEventListener("touchend",this.onTouchEnd)}},{key:"remove",value:function(){var e=this.mvui.container;e.removeEventListener("touchstart",this.onTouchStart),e.removeEventListener("touchmove",this.onTouchMove),e.removeEventListener("touchend",this.onTouchEnd)}},{key:"onTouchStart",value:function(e){for(var t,n=this.state,i=n.ongoingTouches,o=n.touchStartPositions,r=e.changedTouches,s=0;s<r.length;s++){var a={identifier:(t=r[s]).identifier,pageX:t.pageX,pageY:t.pageY};i.push(a),o.push({x:a.pageX,y:a.pageY})}}},{key:"onTouchMove",value:function(e){var t,n,i=e.changedTouches,o=this.state,r=o.ongoingTouches,s=o.touchStartPositions;r.length>=2&&(this.state.isPinchZooming=!0);for(var a=0;a<i.length;a++){var l=i[a],c=l.pageX,u=l.pageY,d=O(r,l.identifier);if(-1!==d){var f=s[d];t=f,n={x:c,y:u},(Math.abs(t.x-n.x)>C||Math.abs(t.y-n.y)>C)&&(this.state.isDragging=!0)}}}},{key:"onTouchEnd",value:function(e){for(var t=e.changedTouches,n=e.target,i=this.mvui,o=i.interacting,r=i.elements,s=i.toggleable,a=r.controlArea,l=this.state,c=l.isDragging,u=l.isPinchZooming,d=l.ongoingTouches,f=l.touchStartPositions,h=0;h<t.length;h++){var m=O(d,t[h].identifier);-1!==m&&(d.splice(m,1),f.splice(m,1))}0===d.length&&this.resetState(),a.contains(n)||(o||c||u?s&&o&&!c&&!u&&i.pause():i.play())}},{key:"resetState",value:function(){this.state=r({},N)}}]),t}(),P=function(){function t(n){e(this,t),this.mvui=n,"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?this.touchListeners=new F(n):this.mouseListeners=new M(n),this.onModelVisibilityChanged=this.onModelVisibilityChanged.bind(this),this.onViewerKeyPress=this.onViewerKeyPress.bind(this),this.onControlButtonClick=this.onControlButtonClick.bind(this),this.onFullscreenChange=this.onFullscreenChange.bind(this),this.onUIButtonFocus=this.onUIButtonFocus.bind(this),this.onUIButtonBlur=this.onUIButtonBlur.bind(this),this.onZoomOut=this.onZoomOut.bind(this),this.onZoomIn=this.onZoomIn.bind(this),this.onFullscreen=this.onFullscreen.bind(this)}return n(t,[{key:"add",value:function(){var e=this,t=this.mvui,n=t.viewer,i=t.elements,o=i.buttons,r=i.controlButton;for(var s in n.addEventListener("model-visibility",this.onModelVisibilityChanged),n.addEventListener("keypress",this.onViewerKeyPress),r.addEventListener("click",this.onControlButtonClick),["fullscreenchange","mozfullscreenchange","webkitfullscreenchange"].forEach((function(t){document.addEventListener(t,e.onFullscreenChange,!1)})),o)Object.prototype.hasOwnProperty.call(o,s)&&(o[s].addEventListener("focus",this.onUIButtonFocus),o[s].addEventListener("blur",this.onUIButtonBlur));var a=o["zoom-in"];a&&a.addEventListener("click",this.onZoomIn);var l=o["zoom-out"];l&&l.addEventListener("click",this.onZoomOut);var c=o.fullscreen;c&&c.addEventListener("click",this.onFullscreen),this.mouseListeners&&this.mouseListeners.add(),this.touchListeners&&this.touchListeners.add()}},{key:"remove",value:function(){var e=this,t=this.mvui,n=t.viewer,i=t.elements,o=i.buttons,r=i.controlButton;for(var s in n.removeEventListener("model-visibility",this.onModelVisibilityChanged),n.removeEventListener("keypress",this.onViewerKeyPress),r.removeEventListener("click",this.onControlButtonClick),["fullscreenchange","mozfullscreenchange","webkitfullscreenchange"].forEach((function(t){document.removeEventListener(t,e.onFullscreenChange,!1)})),o)Object.prototype.hasOwnProperty.call(o,s)&&(o[s].removeEventListener("focus",this.onUIButtonFocus),o[s].removeEventListener("blur",this.onUIButtonBlur));this.mouseEventListeners&&this.mouseListeners.remove(),this.touchListeners&&this.touchListeners.remove()}},{key:"onModelVisibilityChanged",value:function(e){var t=this.mvui,n=t.viewer,i=e.target,o=e.detail;i===n&&(t.modelIsVisible=o.visible)}},{key:"onViewerKeyPress",value:function(e){var t=this.mvui;if(t.interacting){var n=e.which||e.keyCode;switch(String.fromCharCode(n)){case"-":t.zoom(8);break;case"+":t.zoom(-8);break;case"f":t.toggleFullscreen()}}}},{key:"onControlButtonClick",value:function(){var e=this.mvui;e.interacting||e.play()}},{key:"onFullscreenChange",value:function(){var e=this.mvui.container;S()?e.classList.add("shopify-model-viewer-ui--fullscreen"):e.classList.remove("shopify-model-viewer-ui--fullscreen")}},{key:"onUIButtonFocus",value:function(){this.mvui.container.classList.add("shopify-model-viewer-ui--child-focused")}},{key:"onUIButtonBlur",value:function(){this.mvui.container.classList.remove("shopify-model-viewer-ui--child-focused")}},{key:"onZoomOut",value:function(e){e.stopPropagation(),this.mvui.zoom(8)}},{key:"onZoomIn",value:function(e){e.stopPropagation(),this.mvui.zoom(-8)}},{key:"onFullscreen",value:function(e){e.stopPropagation(),this.mvui.toggleFullscreen()}}]),t}(),D={add:function(e){var t=e.state.listeners;t||((t=new P(e)).add(),e.state.listeners=t)},remove:function(e){e.state.listeners.remove()}},z=new p;var R=function(){function t(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(this,t),this.config=r({},w.config,{},i);var o=function(e){var t=e;if(m.string(t)&&(t=document.querySelector(t)),m.jqueryObject(t)&&(t=t[0]),m.array(t)||m.nodeList(t))throw Error("Use static setup method when using an array or nodeList of elements");if(m.nullOrUndefined(t)||!m.element(t))throw Error("Please pass in a query selector, element, or jQuery instance");return t}(n),s=z.getCachedInstance(o);if(s)return s;var a,l,c,u=o.getAttribute("reveal"),d=Boolean(o.getAttribute("toggleable"));if(this.state={elements:{original:o.cloneNode(!0),buttons:{},container:null,controlButton:null,controlArea:null,zoomLevel:null,sprites:null},viewerProperties:{reveal:u,interaction:o.getAttribute("interaction"),orbit:o.cameraOrbit,fov:o.fieldOfView,zoomLevelTimeout:null},viewer:o,interacting:"interaction"!==u,toggleable:!!m.boolean(d)&&d,modelIsVisible:!1},this.defineProperties(),!m.element(this.container)){var f=v("div",{class:"shopify-model-viewer-ui"});void 0===window.orientation&&-1===navigator.userAgent.indexOf("IEMobile")&&f.classList.add("shopify-model-viewer-ui--desktop"),a=this.viewer,l=f,c=a.length?a:[a],Array.from(c).reverse().forEach((function(e,t){var n=t>0?l.cloneNode(!0):l,i=e.parentNode,o=e.nextSibling;n.appendChild(e),o?i.insertBefore(n,o):i.appendChild(n)})),this.container=f}z.cacheInstance(this),k.build(this),D.add(this),this.interacting?g(this.elements.controlButton,!0):(g(this.elements.controlButton,!1),b(o,"shopify-model-viewer-ui__disabled",!0),o.setAttribute("tabindex","-1"))}return n(t,[{key:"destroy",value:function(){if(this.state){var e,t,n=this.state.elements,i=n.sprites,o=n.original;i&&y(i),e=o,t=this.container,m.element(t)&&m.element(t.parentNode)&&m.element(e)&&t.parentNode.replaceChild(e,t),D.remove(this),z.removeFromCache(this.viewer),this.state=null}}},{key:"zoom",value:function(e){var t=this.viewer,n=this.elements,i=this.viewerProperties,o=t.getFieldOfView();o+=e;var r=Math.min(Math.max(o,10),45);t.fieldOfView="".concat(r,"deg");var s=100*(r-45)/-35;n.zoomLevel.innerText="".concat(Math.round(s),"% ").concat("Zoomed","."),clearTimeout(i.zoomLevelTimeout),i.zoomLevelTimeout=setTimeout((function(){n.zoomLevel.innerText=""}),5e3)}},{key:"toggleFullscreen",value:function(){var e=this.container,t=this.elements.buttons.fullscreen;S()?(t.setAttribute("aria-label","Enter Fullscreen"),document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen()):(t.setAttribute("aria-label","Exit Fullscreen"),e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT))}},{key:"play",value:function(){var e=this.elements,t=this.viewer,n=this.modelIsVisible,i=e.controlButton,o=e.controlArea;"interaction"===t.getAttribute("reveal")&&t.setAttribute("reveal","auto"),g(i,!0),t.dispatchEvent(new CustomEvent("shopify_model_viewer_ui_toggle_play",{detail:{modelViewerUI:this}})),b(t,"shopify-model-viewer-ui__disabled",!1),t.setAttribute("tabindex","0"),this.config.focusOnPlay&&t.focus(),n&&b(o,"shopify-model-viewer-ui__controls-area--playing",!0),this.interacting=!0}},{key:"pause",value:function(){var e=this.elements,t=this.viewer,n=this.viewerProperties,i=e.controlButton,o=e.controlArea,r=n.orbit,s=n.fov;g(i,!1),t.dispatchEvent(new CustomEvent("shopify_model_viewer_ui_toggle_pause",{detail:{modelViewerUI:this}})),b(t,"shopify-model-viewer-ui__disabled",!0),b(o,"shopify-model-viewer-ui__controls-area--playing",!1),t.setAttribute("tabindex","-1"),t.blur(),t.cameraOrbit=r,t.fieldOfView=s,t.pause(),this.interacting=!1}},{key:"defineProperties",value:function(){Object.defineProperty(this,"elements",{value:this.state.elements,writable:!1}),Object.defineProperty(this,"viewer",{value:this.state.viewer,writable:!1}),Object.defineProperty(this,"viewerProperties",{value:this.state.viewerProperties,writable:!1}),Object.defineProperty(this,"toggleable",{value:this.state.toggleable,writable:!1}),Object.defineProperty(this,"interacting",{value:this.state.interacting,writable:!0}),Object.defineProperty(this,"container",{value:this.elements.container,writable:!0})}},{key:"modelIsVisible",get:function(){return this.state.modelIsVisible},set:function(e){this.state.modelIsVisible=e;var t=this.elements,n=t.controlArea,i=t.controlButton;e&&!m.nullOrUndefined(n)&&(g(i,!0),b(n,"shopify-model-viewer-ui__controls-area--playing",!0))}}],[{key:"setup",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null;return m.string(e)?i=Array.from(document.querySelectorAll(e)):m.nodeList(e)?i=Array.from(e):m.array(e)&&(i=e.filter(m.element)),m.empty(i)?null:i.map((function(e){return new t(e,n)}))}}]),t}();window.Shopify=window.Shopify||{},window.Shopify.ModelViewerUI=R}(); //# sourceMappingURL=model-viewer-ui.en.js.map