Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shopar-plugin

Package Overview
Dependencies
Maintainers
0
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shopar-plugin - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2-alpha.0

2

dist/shopar-analytics.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShopAR__analytics={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t){return Number.isInteger(t)&&t>=0}function n(t){this.name="ArgumentError",this.message=t}var s=e((function(t,e){if(e=e||{},"function"!=typeof t)throw new n("fetch must be a function");if("object"!=typeof e)throw new n("defaults must be an object");if(void 0!==e.retries&&!i(e.retries))throw new n("retries must be a positive integer");if(void 0!==e.retryDelay&&!i(e.retryDelay)&&"function"!=typeof e.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");if(void 0!==e.retryOn&&!Array.isArray(e.retryOn)&&"function"!=typeof e.retryOn)throw new n("retryOn property expects an array or function");return e=Object.assign({retries:3,retryDelay:1e3,retryOn:[]},e),function(s,r){var a=e.retries,o=e.retryDelay,c=e.retryOn;if(r&&void 0!==r.retries){if(!i(r.retries))throw new n("retries must be a positive integer");a=r.retries}if(r&&void 0!==r.retryDelay){if(!i(r.retryDelay)&&"function"!=typeof r.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");o=r.retryDelay}if(r&&r.retryOn){if(!Array.isArray(r.retryOn)&&"function"!=typeof r.retryOn)throw new n("retryOn property expects an array or function");c=r.retryOn}return new Promise((function(e,i){var n=function(n){var o="undefined"!=typeof Request&&s instanceof Request?s.clone():s;t(o,r).then((function(t){if(Array.isArray(c)&&-1===c.indexOf(t.status))e(t);else if("function"==typeof c)try{return Promise.resolve(c(n,null,t)).then((function(i){i?u(n,null,t):e(t)})).catch(i)}catch(t){i(t)}else n<a?u(n,null,t):e(t)})).catch((function(t){if("function"==typeof c)try{Promise.resolve(c(n,t,null)).then((function(e){e?u(n,t,null):i(t)})).catch((function(t){i(t)}))}catch(t){i(t)}else n<a?u(n,t,null):i(t)}))};function u(t,e,i){var s="function"==typeof o?o(t,e,i):o;setTimeout((function(){n(++t)}),s)}n(0)}))}}));var r,a;!function(t){t.unknown="unknown",t.user="user",t.organization="organization",t.anonymous="anonymous"}(r||(r={})),function(t){t.api="api",t.query="query",t.ingest="ingest"}(a||(a={}));class o{scope;type;value;remaining;reset;constructor(t=r.unknown,e=a.api,i=0,n=-1,s=new Date){this.scope=t,this.type=e,this.value=i,this.remaining=n,this.reset=s}}function c(t,e,i,n,s){let a=new o;const c=t.headers.get(e.toLowerCase())||r.unknown;a.scope=r[c];const u=t.headers.get(i.toLowerCase())||"",h=parseInt(u,10);isNaN(h)||(a.value=h);const l=t.headers.get(n.toLowerCase())||"",f=parseInt(l,10);isNaN(f)||(a.remaining=f);const m=t.headers.get(s.toLowerCase())||"",y=parseInt(m,10);return isNaN(y)||(a.reset=new Date(1e3*y)),a}class u{config;constructor(t){this.config=t}async doReq(t,e,i={},n={}){let r=`${this.config.baseUrl}${t}`;const o=this._prepareSearchParams(n);o&&(r+=`?${o.toString()}`);const u={...this.config.headers,...i.headers},l=await s(fetch)(r,{retries:3,retryDelay:function(t,e,i){return 1e3*Math.pow(2,t)},retryOn:[503,502,504,500],headers:u,method:e,body:i.body?i.body:void 0});if(204===l.status)return l;if(429==l.status){const t=function(t){let e;return t.url?.endsWith("/ingest")?(e=c(t,"","X-IngestLimit-Limit","X-IngestLimit-Remaining","X-IngestLimit-Reset"),e.type=a.ingest):t.url?.endsWith("/query")||t.url?.endsWith("/_apl")?(e=c(t,"","X-QueryLimit-Limit","X-QueryLimit-Remaining","X-QueryLimit-Reset"),e.type=a.query):(e=c(t,"X-RateLimit-Scope","X-RateLimit-Limit","X-RateLimit-Remaining","X-RateLimit-Reset"),e.type=a.api),e}(l);return Promise.reject(new h(t))}if(401===l.status)return Promise.reject(new Error("Forbidden"));if(l.status>=400){const t=await l.json();return Promise.reject(new Error(t.message))}return await l.json()}post(t,e={},i={}){return this.doReq(t,"POST",e,i)}get(t,e={},i={}){return this.doReq(t,"GET",e,i)}put(t,e={},i={}){return this.doReq(t,"PUT",e,i)}delete(t,e={},i={}){return this.doReq(t,"DELETE",e,i)}_prepareSearchParams=t=>{const e=new URLSearchParams;let i=!1;return Object.keys(t).forEach((n=>{t[n]&&(e.append(n,t[n]),i=!0)})),i?e:null}}class h extends Error{limit;shortcircuit;message="";constructor(t,e=!1){super(),this.limit=t,this.shortcircuit=e,Object.setPrototypeOf(this,h.prototype);const i=h.timeUntilReset(t);this.message=`${t.type} limit exceeded, try again in ${i.minutes}m${i.seconds}s`,t.type==a.api&&(this.message=`${t.scope} `+this.message)}static timeUntilReset(t){const e=t.reset.getTime()-(new Date).getTime(),i=Math.floor(e/1e3%60);return{total:e,minutes:Math.floor(e/1e3/60%60),seconds:i}}}class l{client;constructor({orgId:t="",token:e,url:i}){e||console.warn("Missing Axiom token");const n=i??"https://api.axiom.co",s={Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+e};"undefined"==typeof window&&(s["User-Agent"]="axiom-js/1.0.0-rc.1"),t&&(s["X-Axiom-Org-Id"]=t),this.client=new u({baseUrl:n,headers:s,timeout:3e3})}}var f,m,y,p,d,g;!function(t){t.TimestampField="_time";t.Service=class extends l{localPath="/v1/datasets";list=()=>this.client.get(this.localPath);get=t=>this.client.get(this.localPath+"/"+t);create=t=>this.client.post(this.localPath,{body:JSON.stringify(t)});update=(t,e)=>this.client.put(this.localPath+"/"+t,{body:JSON.stringify(e)});delete=t=>this.client.delete(this.localPath+"/"+t);trim=(t,e)=>{const i={maxDuration:e};return this.client.post(this.localPath+"/"+t+"/trim",{body:JSON.stringify(i)})}}}(f||(f={})),function(t){t.Service=class extends l{current=()=>this.client.get("/v1/user")}}(m||(m={}));class w{ingestFn;id;options;events=[];activeFlush=Promise.resolve();nextFlush=setTimeout((()=>{}),0);lastFlush=new Date;constructor(t,e,i){this.ingestFn=t,this.id=e,this.options=i}ingest=t=>{Array.isArray(t)?this.events=this.events.concat(t):this.events.push(t),this.events.length>=1e3||this.lastFlush.getTime()<Date.now()-1e3?(clearTimeout(this.nextFlush),this.activeFlush=this.flush()):(clearTimeout(this.nextFlush),this.nextFlush=setTimeout((()=>{this.activeFlush=this.flush()}),1e3))};flush=async()=>{const t=this.events.splice(0,this.events.length);if(clearTimeout(this.nextFlush),await this.activeFlush,0===t.length)return void(this.lastFlush=new Date);const e=await this.ingestFn(this.id,t,this.options);return this.lastFlush=new Date,e}}class v extends l{datasets;users;localPath="/v1";constructor(t){super(t),this.datasets=new f.Service(t),this.users=new m.Service(t)}ingestRaw=(t,e,i=y.JSON,n=p.Identity,s)=>this.client.post(this.localPath+"/datasets/"+t+"/ingest",{headers:{"Content-Type":i,"Content-Encoding":n},body:e},{"timestamp-field":s?.timestampField,"timestamp-format":s?.timestampFormat,"csv-delimiter":s?.csvDelimiter});queryLegacy=(t,e,i)=>this.client.post(this.localPath+"/datasets/"+t+"/query",{body:JSON.stringify(e)},{"streaming-duration":i?.streamingDuration,nocache:i?.noCache});query=(t,e)=>{const i={apl:t};return e?.startTime&&(i.startTime=e?.startTime),e?.endTime&&(i.endTime=e?.endTime),this.client.post(this.localPath+"/datasets/_apl",{body:JSON.stringify(i)},{"streaming-duration":e?.streamingDuration,nocache:e?.noCache,format:"legacy"})};aplQuery=(t,e)=>this.query(t,e)}class x extends v{batch={};ingest=(t,e,i)=>{const n=function(t,e){return`${t}:${e?.timestampField||"-"}:${e?.timestampFormat||"-"}:${e?.csvDelimiter||"-"}`}(t,i);return this.batch[n]||(this.batch[n]=new w(((t,e,i)=>{const n=(Array.isArray(e)?e:[e]).map((t=>JSON.stringify(t))).join("\n");return this.ingestRaw(t,n,y.NDJSON,p.Identity,i)}),t,i)),this.batch[n].ingest(e)};flush=async()=>{let t=[];for(const e in this.batch)t.push(this.batch[e].flush());await Promise.all(t)}}let b;!function(t){t.JSON="application/json",t.NDJSON="application/x-ndjson",t.CSV="text/csv"}(y||(y={})),function(t){t.Identity="",t.GZIP="gzip"}(p||(p={})),function(t){t.Count="count",t.Distinct="distinct",t.Sum="sum",t.Avg="avg",t.Min="min",t.Max="max",t.Topk="topk",t.Percentiles="percentiles",t.Histogram="histogram",t.Variance="variance",t.Stdev="stdev",t.ArgMin="argmin",t.ArgMax="argmax",t.MakeSet="makeset",t.MakeSetIf="makesetif",t.CountIf="countif",t.CountDistinctIf="distinctif"}(d||(d={})),function(t){t.And="and",t.Or="or",t.Not="not",t.Equal="==",t.NotEqual="!=",t.Exists="exists",t.NotExists="not-exists",t.GreaterThan=">",t.GreaterThanOrEqualTo=">=",t.LessThan="<",t.LessThanOrEqualTo="<=",t.Gt="gt",t.Gte="gte",t.Lt="lt",t.Lte="lte",t.StartsWith="starts-with",t.NotStartsWith="not-starts-with",t.EndsWith="ends-with",t.NotEndsWith="not-ends-with",t.Contains="contains",t.NotContains="not-contains",t.Regexp="regexp",t.NotRegexp="not-regexp"}(g||(g={})),t.initializeImpl=function(){b=new x({token:"xaat-f69a9dd7-3988-4fc2-849b-4a0978468c25"})},t.trackEventImpl=function(t,e){b.ingest("shopar-plugin",Object.assign({name:t},e))}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShopAR__analytics={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t){return Number.isInteger(t)&&t>=0}function n(t){this.name="ArgumentError",this.message=t}var s=e((function(t,e){if(e=e||{},"function"!=typeof t)throw new n("fetch must be a function");if("object"!=typeof e)throw new n("defaults must be an object");if(void 0!==e.retries&&!i(e.retries))throw new n("retries must be a positive integer");if(void 0!==e.retryDelay&&!i(e.retryDelay)&&"function"!=typeof e.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");if(void 0!==e.retryOn&&!Array.isArray(e.retryOn)&&"function"!=typeof e.retryOn)throw new n("retryOn property expects an array or function");return e=Object.assign({retries:3,retryDelay:1e3,retryOn:[]},e),function(s,r){var a=e.retries,o=e.retryDelay,c=e.retryOn;if(r&&void 0!==r.retries){if(!i(r.retries))throw new n("retries must be a positive integer");a=r.retries}if(r&&void 0!==r.retryDelay){if(!i(r.retryDelay)&&"function"!=typeof r.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");o=r.retryDelay}if(r&&r.retryOn){if(!Array.isArray(r.retryOn)&&"function"!=typeof r.retryOn)throw new n("retryOn property expects an array or function");c=r.retryOn}return new Promise((function(e,i){var n=function(n){var o="undefined"!=typeof Request&&s instanceof Request?s.clone():s;t(o,r).then((function(t){if(Array.isArray(c)&&-1===c.indexOf(t.status))e(t);else if("function"==typeof c)try{return Promise.resolve(c(n,null,t)).then((function(i){i?u(n,null,t):e(t)})).catch(i)}catch(t){i(t)}else n<a?u(n,null,t):e(t)})).catch((function(t){if("function"==typeof c)try{Promise.resolve(c(n,t,null)).then((function(e){e?u(n,t,null):i(t)})).catch((function(t){i(t)}))}catch(t){i(t)}else n<a?u(n,t,null):i(t)}))};function u(t,e,i){var s="function"==typeof o?o(t,e,i):o;setTimeout((function(){n(++t)}),s)}n(0)}))}}));var r,a;!function(t){t.unknown="unknown",t.user="user",t.organization="organization",t.anonymous="anonymous"}(r||(r={})),function(t){t.api="api",t.query="query",t.ingest="ingest"}(a||(a={}));class o{scope;type;value;remaining;reset;constructor(t=r.unknown,e=a.api,i=0,n=-1,s=new Date){this.scope=t,this.type=e,this.value=i,this.remaining=n,this.reset=s}}function c(t,e,i,n,s){let a=new o;const c=t.headers.get(e.toLowerCase())||r.unknown;a.scope=r[c];const u=t.headers.get(i.toLowerCase())||"",h=parseInt(u,10);isNaN(h)||(a.value=h);const l=t.headers.get(n.toLowerCase())||"",f=parseInt(l,10);isNaN(f)||(a.remaining=f);const m=t.headers.get(s.toLowerCase())||"",y=parseInt(m,10);return isNaN(y)||(a.reset=new Date(1e3*y)),a}class u{config;constructor(t){this.config=t}async doReq(t,e,i={},n={}){let r=`${this.config.baseUrl}${t}`;const o=this._prepareSearchParams(n);o&&(r+=`?${o.toString()}`);const u={...this.config.headers,...i.headers},l=await s(fetch)(r,{retries:3,retryDelay:function(t,e,i){return 1e3*Math.pow(2,t)},retryOn:[503,502,504,500],headers:u,method:e,body:i.body?i.body:void 0});if(204===l.status)return l;if(429==l.status){const t=function(t){let e;return t.url?.endsWith("/ingest")?(e=c(t,"","X-IngestLimit-Limit","X-IngestLimit-Remaining","X-IngestLimit-Reset"),e.type=a.ingest):t.url?.endsWith("/query")||t.url?.endsWith("/_apl")?(e=c(t,"","X-QueryLimit-Limit","X-QueryLimit-Remaining","X-QueryLimit-Reset"),e.type=a.query):(e=c(t,"X-RateLimit-Scope","X-RateLimit-Limit","X-RateLimit-Remaining","X-RateLimit-Reset"),e.type=a.api),e}(l);return Promise.reject(new h(t))}if(401===l.status)return Promise.reject(new Error("Forbidden"));if(l.status>=400){const t=await l.json();return Promise.reject(new Error(t.message))}return await l.json()}post(t,e={},i={}){return this.doReq(t,"POST",e,i)}get(t,e={},i={}){return this.doReq(t,"GET",e,i)}put(t,e={},i={}){return this.doReq(t,"PUT",e,i)}delete(t,e={},i={}){return this.doReq(t,"DELETE",e,i)}_prepareSearchParams=t=>{const e=new URLSearchParams;let i=!1;return Object.keys(t).forEach((n=>{t[n]&&(e.append(n,t[n]),i=!0)})),i?e:null}}class h extends Error{limit;shortcircuit;message="";constructor(t,e=!1){super(),this.limit=t,this.shortcircuit=e,Object.setPrototypeOf(this,h.prototype);const i=h.timeUntilReset(t);this.message=`${t.type} limit exceeded, try again in ${i.minutes}m${i.seconds}s`,t.type==a.api&&(this.message=`${t.scope} `+this.message)}static timeUntilReset(t){const e=t.reset.getTime()-(new Date).getTime(),i=Math.floor(e/1e3%60);return{total:e,minutes:Math.floor(e/1e3/60%60),seconds:i}}}class l{client;constructor({orgId:t="",token:e,url:i}){e||console.warn("Missing Axiom token");const n=i??"https://api.axiom.co",s={Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+e};"undefined"==typeof window&&(s["User-Agent"]="axiom-js/1.0.0-rc.1"),t&&(s["X-Axiom-Org-Id"]=t),this.client=new u({baseUrl:n,headers:s,timeout:3e3})}}var f,m,y,p,d,g;!function(t){t.TimestampField="_time";t.Service=class extends l{localPath="/v1/datasets";list=()=>this.client.get(this.localPath);get=t=>this.client.get(this.localPath+"/"+t);create=t=>this.client.post(this.localPath,{body:JSON.stringify(t)});update=(t,e)=>this.client.put(this.localPath+"/"+t,{body:JSON.stringify(e)});delete=t=>this.client.delete(this.localPath+"/"+t);trim=(t,e)=>{const i={maxDuration:e};return this.client.post(this.localPath+"/"+t+"/trim",{body:JSON.stringify(i)})}}}(f||(f={})),function(t){t.Service=class extends l{current=()=>this.client.get("/v1/user")}}(m||(m={}));class w{ingestFn;id;options;events=[];activeFlush=Promise.resolve();nextFlush=setTimeout((()=>{}),0);lastFlush=new Date;constructor(t,e,i){this.ingestFn=t,this.id=e,this.options=i}ingest=t=>{Array.isArray(t)?this.events=this.events.concat(t):this.events.push(t),this.events.length>=1e3||this.lastFlush.getTime()<Date.now()-1e3?(clearTimeout(this.nextFlush),this.activeFlush=this.flush()):(clearTimeout(this.nextFlush),this.nextFlush=setTimeout((()=>{this.activeFlush=this.flush()}),1e3))};flush=async()=>{const t=this.events.splice(0,this.events.length);if(clearTimeout(this.nextFlush),await this.activeFlush,0===t.length)return void(this.lastFlush=new Date);const e=await this.ingestFn(this.id,t,this.options);return this.lastFlush=new Date,e}}class v extends l{datasets;users;localPath="/v1";constructor(t){super(t),this.datasets=new f.Service(t),this.users=new m.Service(t)}ingestRaw=(t,e,i=y.JSON,n=p.Identity,s)=>this.client.post(this.localPath+"/datasets/"+t+"/ingest",{headers:{"Content-Type":i,"Content-Encoding":n},body:e},{"timestamp-field":s?.timestampField,"timestamp-format":s?.timestampFormat,"csv-delimiter":s?.csvDelimiter});queryLegacy=(t,e,i)=>this.client.post(this.localPath+"/datasets/"+t+"/query",{body:JSON.stringify(e)},{"streaming-duration":i?.streamingDuration,nocache:i?.noCache});query=(t,e)=>{const i={apl:t};return e?.startTime&&(i.startTime=e?.startTime),e?.endTime&&(i.endTime=e?.endTime),this.client.post(this.localPath+"/datasets/_apl",{body:JSON.stringify(i)},{"streaming-duration":e?.streamingDuration,nocache:e?.noCache,format:"legacy"})};aplQuery=(t,e)=>this.query(t,e)}class b extends v{batch={};ingest=(t,e,i)=>{const n=function(t,e){return`${t}:${e?.timestampField||"-"}:${e?.timestampFormat||"-"}:${e?.csvDelimiter||"-"}`}(t,i);return this.batch[n]||(this.batch[n]=new w(((t,e,i)=>{const n=(Array.isArray(e)?e:[e]).map((t=>JSON.stringify(t))).join("\n");return this.ingestRaw(t,n,y.NDJSON,p.Identity,i)}),t,i)),this.batch[n].ingest(e)};flush=async()=>{let t=[];for(const e in this.batch)t.push(this.batch[e].flush());await Promise.all(t)}}let x;!function(t){t.JSON="application/json",t.NDJSON="application/x-ndjson",t.CSV="text/csv"}(y||(y={})),function(t){t.Identity="",t.GZIP="gzip"}(p||(p={})),function(t){t.Count="count",t.Distinct="distinct",t.Sum="sum",t.Avg="avg",t.Min="min",t.Max="max",t.Topk="topk",t.Percentiles="percentiles",t.Histogram="histogram",t.Variance="variance",t.Stdev="stdev",t.ArgMin="argmin",t.ArgMax="argmax",t.MakeSet="makeset",t.MakeSetIf="makesetif",t.CountIf="countif",t.CountDistinctIf="distinctif"}(d||(d={})),function(t){t.And="and",t.Or="or",t.Not="not",t.Equal="==",t.NotEqual="!=",t.Exists="exists",t.NotExists="not-exists",t.GreaterThan=">",t.GreaterThanOrEqualTo=">=",t.LessThan="<",t.LessThanOrEqualTo="<=",t.Gt="gt",t.Gte="gte",t.Lt="lt",t.Lte="lte",t.StartsWith="starts-with",t.NotStartsWith="not-starts-with",t.EndsWith="ends-with",t.NotEndsWith="not-ends-with",t.Contains="contains",t.NotContains="not-contains",t.Regexp="regexp",t.NotRegexp="not-regexp"}(g||(g={})),t.initializeImpl=function(){x=new b({token:"xaat-16d05fdd-4ab9-4990-acba-7cee24974bfb"})},t.trackEventImpl=function(t,e){x.ingest("shopar-plugin-alpha",Object.assign({name:t},e))}}));

@@ -1,1 +0,1 @@

function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array],r=n.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],a=window[o[i[i[r]]]][o[i[i[i.length-1]]]],s=a.charCodeAt(r),l=s^s,c=new n[1]([l]);function u(){const e=(new TextEncoder).encode(a),t=o.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[o[t[2]]](String.fromCodePoint(...e))}const d=[1e3,2e3,4e3],h=d.length;function p(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=h)throw e;return yield new Promise((e=>setTimeout(e,d[n]))),p(t,n+1)}}))}function f(e){return e*(180/Math.PI)}function m(e){return Math.round(100*e)/100}const g=["Glasses","Shoes","Watches"],v=["Shoes"];const w="0.7.1";let y=`https://cdn.jsdelivr.net/npm/shopar-plugin@${w}/dist`;const b={update:e=>{null!=e&&(y=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>y};function E(t){return e(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise((t=>{e.addEventListener("load",(()=>t()),!1),e.addEventListener("error",(()=>t()),!1),document.body.appendChild(e)}))}importScripts(t.toString())}))}let A;const S=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.error('No <meta name="viewport"> detected. This might cause ShopAR to crash on iOS.\nPlease add the following line to your HTML:\n<meta name="viewport" content="width=device-width, initial-scale=1.0">'),()=>e?window.devicePixelRatio:1})();let R,C,P;function I(e){const t=function(e){const t=new C.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,C.ClampToEdgeWrapping,C.ClampToEdgeWrapping,C.LinearFilter,C.LinearFilter,1,C.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(P.parse(e));return t.mapping=C.EquirectangularReflectionMapping,t.colorSpace=C.LinearSRGBColorSpace,t}const M=45,x=45,T=3,k=1.5,L=1,U=.5;let $,D,O,_,N,j=!1;const F=4,W=.001,q=1e-7,G=10,z=11,Q=1/(z-1),V="function"==typeof Float32Array;function K(e,t,n,r){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===r)return J;const o=V?new Float32Array(z):new Array(z);for(let t=0;t<z;++t)o[t]=Z(t*Q,e,n);function i(t){let r=0,i=1;const a=z-1;for(;i!==a&&o[i]<=t;++i)r+=Q;--i;const s=r+(t-o[i])/(o[i+1]-o[i])*Q,l=Y(s,e,n);return l>=W?function(e,t,n,r){for(let o=0;o<F;++o){const o=Y(t,n,r);if(0===o)return t;t-=(Z(t,n,r)-e)/o}return t}(t,s,e,n):0===l?s:function(e,t,n,r,o){let i,a,s=0;do{a=t+(n-t)/2,i=Z(a,r,o)-e,i>0?n=a:t=a}while(Math.abs(i)>q&&++s<G);return a}(t,r,r+Q,e,n)}return function(e){return 0===e||1===e?e:Z(i(e),t,r)}}function B(e,t){return 1-3*t+3*e}function H(e,t){return 3*t-6*e}function X(e){return 3*e}function Z(e,t,n){return((B(t,n)*e+H(t,n))*e+X(t))*e}function Y(e,t,n){return 3*B(t,n)*e*e+2*H(t,n)*e+X(t)}function J(e){return e}function ee(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=K(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function te(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:ee(n)})));let r=0,o=n[0].value;return{reset:()=>{r=0},update:e=>{for(r+=e;r>=t;)r-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(r>=t.time&&r<i.time){const e=t.interpolate((r-t.time)/(i.time-t.time));o=t.value+e*(i.value-t.value)}}},get:()=>o}}const ne="#",re="time",oe="interpolation",ie="yaw",ae="pitch",se="fov",le=[re,ie,ae,se,oe],ce="s",ue="ms",de=1e3,he="deg",pe="rad",fe=Math.PI/180,me="ease-in-out",ge="cubic-bezier(",ve=")";function we(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(ne);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const r=function(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(!le.includes(r))throw new Error(`Invalid token in header: '${r}'.`);if(t.includes(r))throw new Error(`Duplicate token in header: '${r}'.`);t.push(r)}if(!t.includes(re))throw new Error(`Missing required token: '${re}'.`);return t}(t.split(/\s+/)),o={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:i}=ye(r,e);null!=t&&(null==o.theta&&(o.theta=[]),o.theta.push(t)),null!=n&&(null==o.phi&&(o.phi=[]),o.phi.push(n)),null!=i&&(null==o.fov&&(o.fov=[]),o.fov.push(i))}if(0===Object.values(o).length)throw new Error("At least one parameter should be animated.");return o}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const r of e){const{time:e,pitch:o,yaw:i,fov:a}=r;if(null==e)throw new Error("Time missing.");const s=Ee(null!==(t=r.interpolation)&&void 0!==t?t:me);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*fe,interpolation:s})),null!=o&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:o*fe,interpolation:s})),null!=a&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:a*fe,interpolation:s}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function ye(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const r=e.indexOf(re),o=function(e){if(e.endsWith(ue))return Se(e.substring(0,e.length-ue.length));if(e.endsWith(ce))return Se(e.substring(0,e.length-ce.length))*de;return Se(e)}(n[r]),i=e.indexOf(oe),a=Ee(-1===i?me:n[i]),s={};for(let t=0;t<n.length;t++){if(t===r||t===i)continue;const l=e[t],c=n[t];switch(l){case ie:s.theta={time:o,value:be(c),interpolation:a};break;case ae:s.phi={time:o,value:be(c),interpolation:a};break;case se:s.fov={time:o,value:be(c),interpolation:a};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return s}function be(e){return e.endsWith(he)?Se(e.substring(0,e.length-he.length))*fe:e.endsWith(pe)?Se(e.substring(0,e.length-pe.length)):Se(e)*fe}function Ee(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Ae(0,0,1,1);if("sine"===e)return Ae(.37,0,.63,1);if("sine-in"===e)return Ae(.12,0,.39,0);if("sine-out"===e)return Ae(.61,1,.88,1);if("ease"===e)return Ae(.25,.1,.25,1);if("ease-in"===e)return Ae(.42,0,1,1);if("ease-out"===e)return Ae(0,0,.58,1);if("ease-in-out"===e)return Ae(.42,0,.58,1);if(e.startsWith(ge)&&e.endsWith(ve)){const t=e.substring(ge.length,e.length-ve.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:Se(t[0]),y1:Se(t[1]),x2:Se(t[2]),y2:Se(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Ae(e,t,n,r){return{type:"bezier",x1:e,y1:t,x2:n,y2:r}}function Se(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const Re=300,Ce=2e3,Pe=.05,Ie=2*Math.PI/32,Me=Ee("hold"),xe=Ee("sine"),Te=Ee("sine-in"),ke=Ee("sine-out");let Le;const Ue=0,$e=3;let De,Oe,_e,Ne=!1,je=1,Fe=1,We=1;const qe=1;let Ge;const ze=new Map;function Qe(t,n,r){const o=t.getContext("2d");null==o&&console.warn("2D context missing.");let i,a,s,l,c,u,d,h,p,f,m,g,v,w,y=!1,b=!1,E=!1,A=!0,S=!1,L=1,j=!0,F=!1,W=0,q=0,G=1,z=1,Q=1;const V={threeInit:()=>{y||(Ve(),i=new Oe.Scene,a=new Oe.PerspectiveCamera(25,1,.5),s=new De.OrbitControls(a,t),s.setInteractionEnabled(j),h=Oe.ACESFilmicToneMapping,({renderShadow:c,shadowGroup:l}=function(e){const t=new $.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new $.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const r=new $.Group;r.position.y=-.7;const o=new $.PlaneGeometry(M,x).rotateX(Math.PI/2),i=new $.MeshBasicMaterial({map:t.texture,opacity:U,transparent:!0,depthWrite:!1}),a=new $.Mesh(o,i);a.renderOrder=1,a.scale.y=-1,r.add(a);const s=new $.Mesh(o);s.visible=!1,r.add(s);const l=new $.OrthographicCamera(-M/2,M/2,x/2,-x/2,0,T);function c(e){s.visible=!0,_.uniforms.tDiffuse.value=t.texture,_.uniforms.h.value=1*e/256,s.material=_,D.setRenderTarget(n),D.render(s,l),N.uniforms.tDiffuse.value=n.texture,N.uniforms.v.value=1*e/256,s.material=N,D.setRenderTarget(t),D.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,r.add(l),{shadowGroup:r,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=O;const r=D.getClearAlpha();D.setClearAlpha(0),D.setRenderTarget(t),D.render(e,l),e.overrideMaterial=null,c(k),c(.4*k),D.setRenderTarget(null),D.setClearAlpha(r),e.background=n}}}(i)),y=!0)},threeParse:(t,n,r)=>e(this,void 0,void 0,(function*(){return null!=u&&d===r||(yield u,u=(()=>e(this,void 0,void 0,(function*(){var e,r;return C=(e=De).THREE,P=new e.RGBELoader,i.environment=I(n),function(e,t){const{THREE:n}=t;R=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder)}(Ge,De),r=t,R.parseAsync(r.buffer,"")})))(),d=r),u})),threeLoad:(e,t)=>{i.traverse((e=>{var t,n;e instanceof Oe.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach((e=>e.dispose())):null===(n=e.material)||void 0===n||n.dispose())})),i.clear(),i.add(e.scene);const n=(new Oe.Box3).setFromObject(e.scene);l.position.y=n.min.y-Ue,i.add(l),c(),b=!1,i.traverse((e=>{if(e instanceof Oe.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(b=!0)})):t.transmission>0&&(b=!0)}}));const r=n.min.clone().add(n.max).divideScalar(2),o=Math.sqrt(De.reduceVertices(e.scene,((e,t)=>Math.max(e,r.distanceToSquared(t))),0));s.reset(r,o,function(e,t){var n;const r={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?r.Glasses:null!==(n=r[e])&&void 0!==n?n:r.Glasses).normalize()}(t,Oe.Vector3)),W=0},threePaused:()=>A,threeResume:()=>{A=!1,Ge.setAnimationLoop(Ke),t.style.visibility="visible",q=0,null==f||f.reset(),null==m||m.reset(),null==g||g.reset(),null==v||v.reset(),null==w||w.reset()},threePause:()=>{A=!0,function(){for(const{threePaused:e}of ze.values())if(!e())return!1;return!0}()&&Ge.setAnimationLoop(null),t.style.visibility="hidden",r.style.opacity="0",n.style.visibility="hidden"},threeSetZoomEnabled:e=>{s.enableZoom=e},threeSetForcedTransparency:e=>{E=e},threeSetToneMapping:(e,t)=>{const n={ACES:Oe.ACESFilmicToneMapping,Linear:Oe.LinearToneMapping,Neutral:Oe.NeutralToneMapping};null!=n[e]&&(h=n[e]),L=t},threeIsInteractive:()=>j,threeSetInteractive:e=>{j=e,null==s||s.setInteractionEnabled(j)},threeSetOnInteracted:e=>{s.removeEventListener("change",p),p=e,s.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=s.getTheta(),f=te([{time:0,value:e,interpolation:Me},{time:Re,value:e,interpolation:ke},{time:Re+Ce/4,value:e+Ie,interpolation:xe},{time:Re+3*Ce/4,value:e-Ie,interpolation:Te},{time:Re+Ce,value:e,interpolation:Me},{time:Re+2*Ce,value:e,interpolation:Me}]),s.setTheta(f.get()),m=null,g=null,v=te([{time:0,value:0,interpolation:Me},{time:Re,value:1,interpolation:Me},{time:Re+Ce,value:0,interpolation:Me},{time:Re+2*Ce,value:0,interpolation:Me}]),w=te([{time:0,value:0,interpolation:Me},{time:Re,value:0,interpolation:ke},{time:Re+Ce/4,value:-Pe,interpolation:xe},{time:Re+3*Ce/4,value:Pe,interpolation:Te},{time:Re+Ce,value:0,interpolation:Me},{time:Re+2*Ce,value:0,interpolation:Me}])},threeInitThetaAnimation:e=>{f=e,null!=e&&s.setTheta(e.get())},threeInitPhiAnimation:e=>{m=e,null!=e&&s.setPhi(e.get())},threeInitFovAnimation:e=>{g=e,null!=e&&s.setFovRadians(e.get())},preRender_:e=>{if(!y||A)return;let t=0!==q?e-q:0;q=e,0===W?S=!0:W<$e&&(t=0),W++,F||(s.hasUserInteracted()?(F=!0,f=null,m=null,g=null,v=null,w=null):(null==f||f.update(t),null==m||m.update(t),null==g||g.update(t),null==v||v.update(t),null==w||w.update(t),null!=f&&(s.setTheta(f.get()),S=!0),null!=m&&(s.setPhi(m.get()),S=!0),null!=g&&(s.setFovRadians(g.get()),S=!0))),s.update()&&(S=!0)},shouldRender_:()=>!(!y||A)&&S,render_:()=>{const e=Ge.toneMapping,s=Ge.toneMappingExposure;Ge.toneMapping=h,Ge.toneMappingExposure=L,Ge.setViewport(0,0,t.width,t.height),Ge.setClearColor(new Oe.Color(16777215),b&&!E?1:0),Ge.render(i,a),Ge.toneMapping=e,Ge.toneMappingExposure=s,S=!1,null!=o&&(o.clearRect(0,0,t.width,t.height),_e.width>0&&_e.height>0&&o.drawImage(_e,0,Fe-t.height,t.width,t.height,0,0,t.width,t.height),n.style.visibility=j&&!F?"visible":"hidden",null!=v&&(r.style.opacity=`${v.get()}`),null!=w&&(r.style.transform=`translateX(${w.get()*Math.min(G,z)}px)`))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===G&&n===z&&We===Q||(t.width=Math.ceil(e*We*qe),t.height=Math.ceil(n*We*qe),G=e,z=n,Q=We,S=!0)},target_:t};return ze.set(t,V),V}function Ve(){if(Ne)return;De=window.ShopAR__THREE,Oe=De.THREE,_e=document.createElement("canvas");var e,t;_e.style.position="block",Ge=new Oe.WebGLRenderer({powerPreference:"high-performance",canvas:_e,antialias:!0,alpha:!0}),Ge.outputColorSpace=Oe.SRGBColorSpace,Ge.toneMapping=Oe.ACESFilmicToneMapping,Ge.setClearColor(new Oe.Color(16777215),0),e=Ge,t=De,j||($=t.THREE,D=e,O=new $.MeshDepthMaterial,O.userData.darkness={value:L},O.onBeforeCompile=e=>{e.uniforms.darkness=O.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},O.depthTest=!1,O.depthWrite=!1,_=new $.ShaderMaterial(t.HorizontalBlurShader),_.depthTest=!1,N=new $.ShaderMaterial(t.VerticalBlurShader),N.depthTest=!1,j=!0),Be(),Ne=!0}function Ke(e){Be(),Ge.clear();for(const{preRender_:t,shouldRender_:n,render_:r}of ze.values())t(e),n()&&r()}function Be(){let e=0,t=0;for(const{target_:n}of ze.values()){const{clientWidth:r,clientHeight:o}=n;e=Math.max(e,r),t=Math.max(t,o)}const n=S();e=Math.ceil(e*n*qe),t=Math.ceil(t*n*qe),e===je&&t===Fe&&n===We||(je=e,Fe=t,We=n,Ge.setSize(je,Fe,!1));for(const{updateSize_:e}of ze.values())e()}const He={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},Xe=Object.keys(He);function Ze(e){return He[e]}const Ye="shopar-error";function Je(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const r=document.createElementNS("http://www.w3.org/2000/svg","image");r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),r.setAttribute("width",e),r.setAttribute("height",e),n.appendChild(r)}return n}function et(e,t,n,r){const o=document.createElement("button");o.id=e,o.type="button",o.className="shopar-btn";{const e=Je("1.75rem",r);o.appendChild(e)}{const e=document.createElement("span");e.textContent=t,o.appendChild(e)}o.ariaLabel=n;const i=o.style;return i.display="none",i.pointerEvents="auto",o}const tt="shopar-control";const nt="shopar-deepar-output";function rt(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.pointerEvents="auto",n.userSelect="none",t}function ot(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function it(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function at(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const st="shopar-main";const lt="shopar-qr-output";const ct="shopar-three-output";var ut;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(ut||(ut={}));let dt=!1;function ht(){dt||(!function(){try{const e=document.createElement("style"),t=process.env.css;null!=t&&(e.innerHTML=t);const n=document.head;n.insertBefore(e,n.children[0])}catch(e){console.warn("Failed to write default ShopAR Plugin CSS.")}}(),dt=!0)}function pt(){ht();const e=function(){const e=document.createElement("div");e.id=st;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),r=function(e,t){const n=document.createElement("div");n.id=lt;const r=n.style;r.position="absolute",r.top="0",r.left="0",r.width="100%",r.height="100%",r.display="none",r.pointerEvents="auto",r.userSelect="none";const o=document.createElement("div");o.className="shopar-qr";const i=o.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(o),o.appendChild(e);const a=document.createElement("div");return a.appendChild(t),o.appendChild(a),n}(t,n);e.appendChild(r);const o=function(){const e=document.createElement("div");e.id=nt;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",t.pointerEvents="auto",e}();e.appendChild(o);const i=function(){const e=document.createElement("canvas");e.id=ct,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const a=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),s=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),l=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:r}=n;return r.position="absolute",r.width="100%",r.height="100%",r.opacity="0",n.appendChild(e),n.appendChild(t),n}(a,s);e.appendChild(l);const c=function(){const e=Je("2rem",`${b}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),u=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",t.appendChild(e),t}(c);e.appendChild(u);const d=rt("shopar-ar-loading-container"),h=ot("shopar-ar-loading-text",Ze("loading.ar"));d.appendChild(h);const p=it("shopar-ar-loading-bar-bg"),f=at("shopar-ar-loading-bar-fg");p.appendChild(f),d.appendChild(p),e.appendChild(d);const m=rt("shopar-3d-loading-container"),g=ot("shopar-3d-loading-text",Ze("loading.3d"));m.appendChild(g);const v=it("shopar-3d-loading-bar-bg"),w=at("shopar-3d-loading-bar-fg");v.appendChild(w),m.appendChild(v),e.appendChild(m);const y=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",e}(),E=function(){const e=new Image;e.draggable=!1;const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.objectFit="contain",e}();y.appendChild(E),e.appendChild(y);const A=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),S=function(e){const t=document.createElement("div");t.id=Ye;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const r=document.createElement("div"),o=r.style;return o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",t.appendChild(r),r.appendChild(e),t}(A);e.appendChild(S);const R=function(){const e=document.createElement("div");return e.id=tt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(R);const C=et("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");R.appendChild(C);const P=et("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${b}/img/icons/cube.svg`);R.appendChild(P);const I=et("shopar-btn-close","Close","Close ShopAR view",`${b}/img/icons/close.svg`);R.append(I);let M,x,T=ut.None,k=!1,L=!1,U=!1,$=!1;function D(){f.classList.remove("active"),d.style.visibility="hidden"}function O(){y.style.visibility="hidden",w.classList.remove("active"),m.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return r},getQRImage:function(){return n},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return l},getThreeTarget:function(){return i},getThreePrompt:function(){return u},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){a.textContent=e,s.src=t},customizeCameraError:function(e){A.textContent=null!=e?e:"Please reload page and allow camera access to continue"},customizeQRPrompt:function(e){t.textContent=null!=e?e:"Scan on mobile or tablet to try on"},setVisibilityParameters:function(e,t,n,r,o,i){var a;k=e,L=t,U=n,$=r,M=o,x=i,ft(R,k),ft(C,k&&(U||L)&&T===ut.None),ft(P,k&&$&&T===ut.None),ft(I,k&&T!==ut.None),D(),O(),k||""===(a=S).style.display&&ft(a,!1)},getUIState:function(){return T},setUIState:function(e){T=e,T===ut.None?(D(),O(),k&&(ft(S,!1),ft(I,!1),(L||U)&&ft(C,!0),$&&ft(P,!0))):T===ut.QR||T===ut.AR?k&&(ft(S,!1),ft(C,!1),ft(P,$&&"AR"===x),ft(I,"AR"!==x)):T===ut.Preview&&k&&(ft(S,!1),ft(C,(L||U)&&"3D"===x),ft(P,!1),ft(I,"3D"!==x))},setDefaultUIActions:function(e,t,n){k&&((L||U)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,r=`${b}/img/icons/${n}`;C.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r)}(M),C.onclick=e),$&&(P.onclick=t),I.onclick=n)},startDeepARLoading:function(){f.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:D,startThreeLoading:function(){null!=E.dataset.srcSet?y.style.visibility="visible":(w.classList.add("active"),m.style.visibility="visible")},stopThreeLoading:O,setThreePosterUrl:function(e){null!=e?(E.src=e,E.dataset.srcSet="true"):delete E.dataset.srcSet},showCameraError:function(){k&&ft(S,!0)}}}function ft(e,t){e.style.display=t?"":"none"}const mt=new Map;function gt(t){let n=mt.get(t);return null==n?(n=function(){let t=0,n=null,r=null,o=null;const i=()=>(null==n&&(n=pt()),n);return{getSetupId:()=>t,incrementSetupId_:()=>t++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==r){const{getQRTarget:t,getQRImage:n}=i();r=function(t,n){let r=!0;return{qrPaused:()=>r,qrDraw:(o,i)=>e(this,void 0,void 0,(function*(){yield A;const e=`https://ar.shopar.ai/${w.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:o,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(e),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,r=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){r=!0,t.style.display="none"}))}}(t(),n())}return r},findThree:()=>{if(null==o){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();o=Qe(e(),t(),n())}return o}}}(),mt.set(t,n)):n.incrementSetupId_(),n}function vt(e){for(const t of mt.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:r,setUIState:o}=n;r()===ut.AR&&o(ut.None)}}let wt;const yt=new Uint8Array(16);function bt(){if(!wt&&(wt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!wt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return wt(yt)}const Et=[];for(let e=0;e<256;++e)Et.push((e+256).toString(16).slice(1));var At={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function St(e,t,n){if(At.randomUUID&&!t&&!e)return At.randomUUID();const r=(e=e||{}).random||(e.rng||bt)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return Et[e[t+0]]+Et[e[t+1]]+Et[e[t+2]]+Et[e[t+3]]+"-"+Et[e[t+4]]+Et[e[t+5]]+"-"+Et[e[t+6]]+Et[e[t+7]]+"-"+Et[e[t+8]]+Et[e[t+9]]+"-"+Et[e[t+10]]+Et[e[t+11]]+Et[e[t+12]]+Et[e[t+13]]+Et[e[t+14]]+Et[e[t+15]]}(r)}const Rt="qrLaunch",Ct="arLaunch",Pt="previewLaunch",It="heartbeat";let Mt,xt,Tt=!1,kt=window.navigator.userAgent||"no user agent";const Lt=[];function Ut(){null==Mt&&(xt=St(),Mt=E(`${b}/shopar-analytics.js`),Mt.then((()=>{Tt=!0,window.ShopAR__analytics.initializeImpl(),Lt.forEach((e=>e()))})))}function $t(e){Tt?e():Lt.push(e)}function Dt(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Ot(t){return e(this,void 0,void 0,(function*(){const e=document.createElement("video");return e.setAttribute("playsinline","playsinline"),e.srcObject=yield t,e}))}const _t=200,Nt=10;let jt=!1,Ft=null,Wt=[],qt=[];function Gt(t){return e(this,void 0,void 0,(function*(){jt=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${b}/wasm/mediapipe`,t),Ft&&clearInterval(Ft);const r=[],o=[];Ft=setInterval((()=>e(this,void 0,void 0,(function*(){if(jt)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());jt||(null!=a&&null!=s&&function(e){for(let t of Wt)t(e)}({translation:a,rotation:s}),null==e&&(r.push(t),o.push(i),r.length<Nt||(r.shift(),o.shift(),function(e,t){for(let n of qt)n({faceWidth:e,IPD:t})}(Qt(r),Qt(o)))))}))),_t)}))}function zt(){qt=[],Wt=[],jt=!0}function Qt(e){let t=0;const n=e.length;for(let r=0;r<n;r++)t+=e[r];return t/n}function Vt(n){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(n).catch((e=>{throw console.error(e),new t("Resource unavailable.")}));if(!e.ok)throw new t(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield r.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}var Kt="undefined"!=typeof Float32Array?Float32Array:Array;function Bt(){var e=new Kt(16);return Kt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Ht(e,t,n){var r=t[0],o=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],E=n[2],A=n[3];return e[0]=y*r+b*s+E*d+A*m,e[1]=y*o+b*l+E*h+A*g,e[2]=y*i+b*c+E*p+A*v,e[3]=y*a+b*u+E*f+A*w,y=n[4],b=n[5],E=n[6],A=n[7],e[4]=y*r+b*s+E*d+A*m,e[5]=y*o+b*l+E*h+A*g,e[6]=y*i+b*c+E*p+A*v,e[7]=y*a+b*u+E*f+A*w,y=n[8],b=n[9],E=n[10],A=n[11],e[8]=y*r+b*s+E*d+A*m,e[9]=y*o+b*l+E*h+A*g,e[10]=y*i+b*c+E*p+A*v,e[11]=y*a+b*u+E*f+A*w,y=n[12],b=n[13],E=n[14],A=n[15],e[12]=y*r+b*s+E*d+A*m,e[13]=y*o+b*l+E*h+A*g,e[14]=y*i+b*c+E*p+A*v,e[15]=y*a+b*u+E*f+A*w,e}function Xt(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Zt(e,t){var n=t[0],r=t[1],o=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.hypot(n,r,o),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,u),e}function Yt(e,t,n,r){var o=t[0],i=t[1],a=t[2],s=t[3],l=o+o,c=i+i,u=a+a,d=o*l,h=o*c,p=o*u,f=i*c,m=i*u,g=a*u,v=s*l,w=s*c,y=s*u,b=r[0],E=r[1],A=r[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*E,e[5]=(1-(d+g))*E,e[6]=(m+v)*E,e[7]=0,e[8]=(p+w)*A,e[9]=(m-v)*A,e[10]=(1-(d+f))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Jt(){var e=new Kt(3);return Kt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function en(e,t,n){var r=new Kt(3);return r[0]=e,r[1]=t,r[2]=n,r}function tn(e,t){var n=t[0]-e[0],r=t[1]-e[1],o=t[2]-e[2];return Math.hypot(n,r,o)}function nn(e,t,n){var r=t[0],o=t[1],i=t[2],a=n[3]*r+n[7]*o+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*o+n[8]*i+n[12])/a,e[1]=(n[1]*r+n[5]*o+n[9]*i+n[13])/a,e[2]=(n[2]*r+n[6]*o+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function rn(){var e=new Kt(4);return Kt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Jt(),function(){var e,t=(e=new Kt(4),Kt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var on;let an,sn,ln;Jt(),en(1,0,0),en(0,1,0),rn(),rn(),on=new Kt(9),Kt!=Float32Array&&(on[1]=0,on[2]=0,on[3]=0,on[5]=0,on[6]=0,on[7]=0),on[0]=1,on[4]=1,on[8]=1;let cn,un,dn,hn,pn=!0,fn=null;const mn=new Set;let gn,vn,wn,yn,bn,En;function An(){null==an&&(an=E(`${b}/shopar-deepar.js`))}function Sn(){null==sn&&(sn=E(`${b}/shopar-true-scale.js`))}function Rn(n){return e(this,void 0,void 0,(function*(){const{licenseKey:r,truescaleUsecase:o}=n;return bn=o,null==gn&&(gn=(()=>e(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new t("No camera available!");var e;const n=Un(dn),o=Dt(n);cn=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:r||"your_license_key_goes_here",previewElement:hn,additionalOptions:{hint:En,cameraConfig:{disableDefaultCamera:!0}}}),un=yield Ot(o),yield $n(cn,un,"user"===n),"Glasses"===dn&&(yield sn,Gt(un),"DetectionLoop"!==bn&&Nn((e=>{yn=e.faceWidth})))})))()),gn}))}function Cn(e,t){var n,r;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===dn&&(n=t,r=En,n===r||null!=n&&null!=r&&n.length===r.length&&n.every((e=>r.find((t=>e===t))))&&r.every((e=>n.find((t=>t===e))))))||(null!=cn&&(cn.shutdown(),cn=null,gn=null),dn=e,En=t)}function Pn(e){e!==hn&&(hn=e,null!=cn&&cn.changePreviewElement(hn))}function In(e){fn=e}function Mn(e){cn.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(yn){const e=137/(yn+5);cn.changeParameterVector("GLASSES","","scale",e,e,e,0),cn.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const r=On("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),o=On("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);cn.changeParameterVector("temple_left","","rotation",0,56.6*-r,0,0),cn.changeParameterVector("temple_right","","rotation",0,56.6*-o,0,0)}catch(e){return}}(e),zt(),yn=null}e(),Dn("Glasses")}},cn.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),Dn("Shoes"))},cn.callbacks.onWristTracked=t=>{t.detected&&(e(),Dn("Watches"))}}function xn(t,n,r){return e(this,void 0,void 0,(function*(){return null!=vn&&wn===r||(yield vn,vn=cn.switchEffect(t,{envmap:n}),wn=r),vn}))}function Tn(e,t){null!=e&&null!=t&&(cn.setToneMapping(e),cn.setExposure(t))}function kn(){return e(this,void 0,void 0,(function*(){if(null!=cn){if(pn=!1,null==un){const e=Un(dn),t=Dt(e);un=yield Ot(t),yield $n(cn,un,"user"===e),"Glasses"===dn&&(Gt(un),"DetectionLoop"!==bn&&Nn((e=>{yn=e.faceWidth})))}!function(){if(null==fn)return;if(null==dn||mn.has(dn))return;fn.style.visibility="visible",fn.style.opacity="1"}(),cn.setPaused(pn),hn.style.display=""}}))}function Ln(){null!=cn&&(pn=!0,cn.setPaused(pn),zt(),null!=un&&null!=un.srcObject&&un.srcObject instanceof MediaStream&&(un.srcObject.getTracks().forEach((e=>e.stop())),un=null),function(){if(null==fn)return;fn.style.visibility="hidden",fn.style.opacity="0"}(),cn.stopCamera(),hn.style.display="none")}function Un(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function $n(t,n,r){return e(this,void 0,void 0,(function*(){yield new Promise((o=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,r),o()}))))}}))}))}function Dn(e){null!=fn&&(mn.has(e)||(mn.add(e),fn.style.opacity="0"))}function On(e,t,n,r,o,i,a){const s=cn.getTransformationBetween(e,t),l=Xt(Jt(),s),c=function(e,t){var n=new Kt(3);Zt(n,t);var r=1/n[0],o=1/n[1],i=1/n[2],a=t[0]*r,s=t[1]*o,l=t[2]*i,c=t[4]*r,u=t[5]*o,d=t[6]*i,h=t[8]*r,p=t[9]*o,f=t[10]*i,m=a+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>u&&a>f?(g=2*Math.sqrt(1+a-u-f),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):u>f?(g=2*Math.sqrt(1+u-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+f-a-u),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(d+p)/g,e[2]=.25*g),e}(rn(),s);Yt(s,c,l,en(a,a,a));const u=cn.getTransformationBetween(t,n),d=Xt(Jt(),u);Yt(u,rn(),d,Zt(Jt(),u));const h=Ht(Bt(),s,u),p=Xt(Jt(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=cn.getTransformationBetween(n,r)}catch(e){return f}const g=Ht(Bt(),u,m),v=Ht(Bt(),s,g),w=en(p[0],i[1],i[2]),y=nn(Jt(),w,function(e,t){var n=t[0],r=t[1],o=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-r*a,y=n*l-o*a,b=n*c-i*a,E=r*l-o*s,A=r*c-i*s,S=o*c-i*l,R=u*m-d*f,C=u*g-h*f,P=u*v-p*f,I=d*g-h*m,M=d*v-p*m,x=h*v-p*g,T=w*x-y*M+b*I+E*P-A*C+S*R;return T?(T=1/T,e[0]=(s*x-l*M+c*I)*T,e[1]=(o*M-r*x-i*I)*T,e[2]=(m*S-g*A+v*E)*T,e[3]=(h*A-d*S-p*E)*T,e[4]=(l*P-a*x-c*C)*T,e[5]=(n*x-o*P+i*C)*T,e[6]=(g*b-f*S-v*y)*T,e[7]=(u*S-h*b+p*y)*T,e[8]=(a*M-s*P+c*R)*T,e[9]=(r*P-n*M-i*R)*T,e[10]=(f*A-m*b+v*w)*T,e[11]=(d*b-u*A-p*w)*T,e[12]=(s*C-a*I-l*R)*T,e[13]=(n*I-r*C+o*R)*T,e[14]=(m*y-f*E-g*w)*T,e[15]=(u*E-d*y+h*w)*T,e):null}(Bt(),v));let b=cn.getClosestPointOnMesh(r,y);try{const e=cn.getClosestPointOnMesh(o,y);tn(y,e)<tn(y,b)&&(b=e)}catch(e){}const E=nn(Jt(),b,g);return f-Math.atan2(E[0]-d[0],Math.abs(E[2]-d[2]))}function _n(e){!function(e){Wt.push(e)}(e)}function Nn(e){!function(e){qt.push(e)}(e)}var jn;function Fn(){return[jn.Android,jn.iOS,jn.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],r=["Win32","Win64","Windows","WinCE"],o=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==o.indexOf(t)?jn.iOS:-1!==n.indexOf(t)?i?jn.Tablet:jn.MacOS:-1!==r.indexOf(t)?jn.Windows:/Android/.test(e)?jn.Android:/Linux/.test(t)?jn.Linux:i?jn.Tablet:jn.Unknown}return jn.Unknown}())}function Wn(r,o,i){return e(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const u=String.fromCharCode(a+14);s>>=2,a^=s+2;const d=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const f=String.fromCharCode(a-7),m=window[`${h}${d+u+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${f}`],g=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${r}`).catch((()=>{throw new t("Unknown error.")}));if(!e.ok)throw new t("Unknown error.");return e})))),v=new n[0](yield(yield g.blob().catch((()=>{throw new t("Unknown error.")}))).arrayBuffer().catch((()=>{throw new t("Unknown error.")})));i+=s;const w=v.byteLength;if(c[l]=Math.min(76,o)*((a>>5)-1),152===c[l]&&(c[l]=w),i==l)return v;i=l,i^=l;for(let e=0,t=v.length;e<t;e++)c[l]^=c[i]<<13,c[l]^=c[i]>>17,c[l]^=c[i]<<5,v[e]=v[e]^c[l];return i^=c[0],i^=c[1],i^=c[2],v}))}!function(e){e[e.Unknown=0]="Unknown",e[e.Android=1]="Android",e[e.iOS=2]="iOS",e[e.Tablet=3]="Tablet",e[e.MacOS=4]="MacOS",e[e.Windows=5]="Windows",e[e.Linux=6]="Linux"}(jn||(jn={}));const qn=["AR","3D"];function Gn(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function zn(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}function Qn(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}function Vn(e){const{apiKey:n,sku:r,targetElement:o,initialState:i,initialAnimation:a,baseUrl:s,defaultUI:l,interactive:c,strings:u}=e;Gn(n,"apiKey"),Qn(n,"apiKey"),Gn(r,"sku"),Qn(r,"sku"),Gn(o,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&function(e,n,r){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!r.includes(e))throw new t(`'${n}' must be ${r.join("' or '")}.`)}(i,"initialState",qn),null!=a&&function(e,n){if("string"!=typeof e&&!Array.isArray(e))throw new t(`'${n}' must be a string or array.`)}(a,"initialAnimation"),null!=s&&Qn(s,"baseUrl"),null!=l&&zn(l,"defaultUI"),null!=c&&zn(c,"interactive"),null!=u&&function(e,n,r){for(const o of r){const r=e[o];if(null!=r&&"string"!=typeof r)throw new t(`Value for key '${o}' in '${n}' must be a string.`)}}(u,"strings",Xe)}let Kn=!1;function Bn(n){return e(this,void 0,void 0,(function*(){const{targetElement:r}=n;b.update(n.baseUrl),Ut();const{trackEvent:o}=function(e){const t=performance.now(),n=St();return{trackEvent:(r,o={})=>{o=Object.assign(Object.assign({},o),{pluginVersion:w,userAgent:kt,sessionId:xt,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),$t((()=>{window.ShopAR__analytics.trackEventImpl(r,o)}))}}}(n.apiKey);o("visionSetup");const i=yield function(n){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:n,sid:u()})}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield r.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(n.apiKey);o("visionApiResponse",i);const{arKey:a}=i,s=gt(r),{getSetupId:l,findUI:c}=s,d=l();An(),Sn();const{setTargetElement:h,getDeepARTarget:f,setVisibilityParameters:m,getUIState:g,setUIState:v,startDeepARLoading:y,stopDeepARLoading:E,showCameraError:A}=c();if(g()!=ut.None)throw Error("UI state is not None, this is weird..");v(ut.AR),h(r),m(!1,!1,!0,!1,void 0,void 0),y(),yield an,Hn(l(),d);try{o("visionArLaunch"),Ln(),Cn("Glasses",["faceInit"]),Pn(f()),yield Rn({licenseKey:a,truescaleUsecase:"DetectionLoop"}),Hn(l(),d),yield kn(),Hn(l(),d)}catch(e){const n=e instanceof Error;throw o("visionArLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),A(),Ln(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{E()}return Kn=!0,{registerFacePoseListener:e=>{Kn&&(o("registerFacePoseListener"),_n(e))},registerFaceMeasurementListener:e=>{Kn&&(o("registerFaceMeasurementListener"),Nn(e))},switchEffect:t=>e(this,void 0,void 0,(function*(){Kn&&(o("switchEffect",{arUrl:t}),function(e){cn.switchEffect(e)}(t))})),clearEffect:()=>{Kn&&(o("clearEffect"),cn.clearEffect())},close:()=>{if(Kn){if(Kn=!1,o("visionClose"),g()!==ut.AR)throw new t("AR not launched.");Ln(),v(ut.None)}}}}))}function Hn(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}function Xn(n){var r,o;return e(this,void 0,void 0,(function*(){Vn(n);const{apiKey:i,sku:a,targetElement:s,initialState:l,initialAnimation:c}=n,d=null==n.zoomEnabled||n.zoomEnabled,h=!0===n.alwaysTransparentBackground;!function(e){const n=getComputedStyle(e);if(!["static","relative"].includes(n.position))throw new t(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${n.position}'.`)}(s),b.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(He,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(He[t]=n)}}(n.strings);const y=null!=c?we(c):null,S=null!=(null==y?void 0:y.theta)?te(y.theta):null,R=null!=(null==y?void 0:y.phi)?te(y.phi):null,C=null!=(null==y?void 0:y.fov)?te(y.fov):null,P=function(n,r,o,i,a,s){return e(this,void 0,void 0,(function*(){const l=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:n,sku:r,sid:u()},null!=o&&{yaw:`${m(f(o))}`}),null!=i&&{pitch:`${m(f(i))}`}),null!=a&&{fov:`${m(f(a))}`}),s&&{forcedTransparency:`${s}`}))}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield l.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(i,a,null==S?void 0:S.get(),null==R?void 0:R.get(),null==C?void 0:C.get(),h),I=gt(s),{getSetupId:M,findUI:x,findQR:T,findThree:k}=I,L=M();Ut();const{trackEvent:U,arInteracted:$,previewInteracted:D}=function(e,t){const n=performance.now(),r=St();let o=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(o=i+a,c=!1,u(It,{engagementTotal:o,engagementAR:i,engagement3D:a}))}),1e3);const u=(o,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:kt,pluginVersion:w,sessionId:xt,setupId:r,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),$t((()=>{window.ShopAR__analytics.trackEventImpl(o,i)}))};return{trackEvent:u,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}(a,i);U("setup",{hostname:window.location.hostname});const O=yield P;U("apiResponse",O);const{category:_,arUrl:N,arEnvUrl:j,arToneMapping:F,arToneMappingExposure:W,arKey:q,arPromptEnabled:G,arPromptText:z,arPromptImage:Q,previewUrl:V,previewEnvUrl:K,previewToneMapping:B,previewToneMappingExposure:H,previewPosterUrl:X,cameraErrorText:Z,qrPromptText:Y}=O;Zn(M(),L);const J=null!=N&&function(e){return null!=e&&g.includes(e)}(_),ee=null==(null===(r=n._internalOptions)||void 0===r?void 0:r.qrEnabled)||(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled),ne=J&&function(e){return null!=e&&v.includes(e)}(_),re=ee&&ne&&!Fn(),oe=J&&!re,ie=null!=V;if(Zn(M(),L),re&&function(){e(this,void 0,void 0,(function*(){null==A&&(A=E(`${b}/shopar-qr.js`))}))}(),oe&&(An(),function(e){e!==ln&&(ln=e,Vt(e),vn=null,zt())}(N),"Glasses"===_&&Sn(),null!=j&&Vt(j)),ie){null==Le&&(Le=E(`${b}/shopar-three.js`));const e=255;Wn(V,(new Date).getTime()+e,Math.random()*e),Vt(null!=K?K:`${b}/env/default.hdr`)}const{setTargetElement:ae,getDeepARTarget:se,getDeepARPrompt:le,customizeDeepARPrompt:ce,customizeCameraError:ue,customizeQRPrompt:de,setVisibilityParameters:he,getUIState:pe,setUIState:fe,setDefaultUIActions:me,startDeepARLoading:ge,stopDeepARLoading:ve,startThreeLoading:ye,stopThreeLoading:be,setThreePosterUrl:Ee,showCameraError:Ae}=x();ae(s);he(null==n.defaultUI||n.defaultUI,re,oe,ie,_,l),ce(null!=z?z:"",null!=Q?Q:""),ue(Z),de(Y),Ee(X),function(e,n){const r=e.parentNode;if(null==r)throw new t("Parent node missing.");new MutationObserver((t=>{for(const r of t)for(const t of r.removedNodes)if(t===e)return void n()})).observe(r,{childList:!0})}(s,(()=>{pe()!==ut.QR||Se()||Ce(),pe()!==ut.AR||pn||Ln(),pe()!==ut.Preview||xe()||ke(),fe(ut.None)}));const{qrPaused:Se,qrDraw:Re,qrPause:Ce}=T(),{threeInit:Pe,threeParse:Ie,threeLoad:Me,threePaused:xe,threeResume:Te,threePause:ke,threeSetZoomEnabled:Ue,threeSetForcedTransparency:$e,threeSetToneMapping:De,threeIsInteractive:Oe,threeSetInteractive:_e,threeSetOnInteracted:Ne,threeInitPromptAnimation:je,threeInitThetaAnimation:Fe,threeInitPhiAnimation:We,threeInitFovAnimation:qe}=k(),Ge=null==n.interactive||n.interactive;_e(Ge);let ze=0;if(pe()===ut.QR){if(!Se())if(re){U(Rt);try{yield Re(i,a)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else Ce(),fe(ut.None)}else if(pe()===ut.AR){if(!pn)if(oe&&!Kn){U(Ct);const e=null!=j?yield Vt(j):void 0;Zn(M(),L);const t=yield Vt(N);Zn(M(),L),vt(I),Cn(_),Pn(se()),In(G?le():null),yield xn(t,e,`${N}${j}`),Tn(F,W),Mn($),Zn(M(),L)}else Ln(),fe(ut.None)}else if(pe()===ut.Preview&&!xe())if(ie){U(Pt),ye();const e=255,t=yield Wn(V,(new Date).getTime()+e,Math.random()*e);Zn(M(),L);const n=yield Vt(null!=K?K:`${b}/env/default.hdr`);Zn(M(),L);const r=yield Ie(t,n,`${V}${K}`);Zn(M(),L),Me(r,_),Ue(d),$e(h),De(null!=B?B:"ACES",null!=H?H:1),Ne(D),je(),null!=y&&(Fe(S),We(R),qe(C)),be()}else ke(),fe(ut.None);const Qe=()=>e(this,void 0,void 0,(function*(){if(re){if(pe()===ut.QR||pe()===ut.AR)return;try{U(Rt);const e=++ze;if(pe()===ut.Preview&&ie&&!xe()&&ke(),fe(ut.QR),yield Re(i,a),ze!==e)return;return void Zn(M(),L)}catch(e){const n=e instanceof Error;throw U("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}}if(!oe)throw new t("Model does not have AR enabled.");if(pe()!==ut.AR)try{U(Ct);const e=++ze;pe()===ut.Preview&&ie&&!xe()&&ke(),vt(I),fe(ut.AR),ge();const t=null!=j?yield Vt(j):void 0;Zn(M(),L);const n=yield Vt(N);if(ze!==e)return;if(Zn(M(),L),yield an,ze!==e)return;if(Zn(M(),L),Ln(),Cn(_),Pn(se()),In(G?le():null),yield Rn({licenseKey:q}),ze!==e)return;if(Zn(M(),L),yield xn(n,t,`${N}${j}`),Tn(F,W),Mn($),ze!==e)return;if(Zn(M(),L),yield kn(),ze!==e)return;Zn(M(),L)}catch(e){const n=e instanceof Error;throw U("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),Ae(),Ln(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{ve()}})),Ve=()=>e(this,void 0,void 0,(function*(){if(!ie)throw new t("Model does not have 3D enabled.");if(pe()!==ut.Preview)try{U(Pt);const e=++ze;pe()===ut.AR&&(oe&&!pn&&Ln(),Ce()),fe(ut.Preview),ye();const t=255,n=yield Wn(V,(new Date).getTime()+t,Math.random()*t);if(ze!==e)return;Zn(M(),L);const r=yield Vt(null!=K?K:`${b}/env/default.hdr`);if(ze!==e)return;if(Zn(M(),L),yield Le,ze!==e)return;if(Zn(M(),L),Pe(),ze!==e)return;Zn(M(),L);const o=yield Ie(n,r,`${V}${K}`);if(ze!==e)return;Zn(M(),L),Me(o,_),Ue(d),$e(h),De(null!=B?B:"ACES",null!=H?H:1),Ne(D),je(),null!=y&&(Fe(S),We(R),qe(C)),Te()}catch(e){const n=e instanceof Error;throw U("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}finally{be()}})),Ke=()=>e(this,void 0,void 0,(function*(){pe()!==ut.None&&(++ze,pe()===ut.QR||pe()===ut.AR?(oe&&!pn&&Ln(),Ce()):pe()===ut.Preview&&ie&&!xe()&&ke(),fe(ut.None),"AR"!==l?"3D"!==l||(yield Ve()):yield Qe())}));return me(Qe,Ve,Ke),"AR"===l?(yield Qe(),Zn(M(),L)):"3D"===l&&(yield Ve(),Zn(M(),L)),Kn=!1,{launchAR:J?Qe:void 0,launch3D:ie?Ve:void 0,closeAR:J?()=>e(this,void 0,void 0,(function*(){pe()!==ut.AR&&pe()!==ut.QR||(++ze,oe&&!pn&&Ln(),Ce(),fe(ut.None),"3D"!==l||(yield Ve()))})):void 0,close3D:ie?()=>e(this,void 0,void 0,(function*(){pe()===ut.Preview&&(++ze,ie&&!xe()&&ke(),fe(ut.None),"AR"!==l||(yield Qe()))})):void 0,close:J||ie?Ke:void 0,isInteractive:()=>Oe(),setInteractive:e=>_e(e)}}))}function Zn(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const Yn={setup:function(t){return e(this,void 0,void 0,(function*(){return Bn(t)}))}},Jn={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,r){return e(this,void 0,void 0,(function*(){try{return r()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>Xn(n)))}))},version:w};export{qn as PREVIEW_STATES,t as PluginError,Jn as plugin,Yn as vision};
function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array],r=n.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],a=window[o[i[i[r]]]][o[i[i[i.length-1]]]],s=a.charCodeAt(r),l=s^s,c=new n[1]([l]);function u(){const e=(new TextEncoder).encode(a),t=o.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[o[t[2]]](String.fromCodePoint(...e))}const d=[1e3,2e3,4e3],h=d.length;function p(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=h)throw e;return yield new Promise((e=>setTimeout(e,d[n]))),p(t,n+1)}}))}function f(e){return e*(180/Math.PI)}function m(e){return Math.round(100*e)/100}const g=["Glasses","Shoes","Watches"],v=["Shoes"];const w="0.7.2-alpha.0";let y=`https://cdn.jsdelivr.net/npm/shopar-plugin@${w}/dist`;const b={update:e=>{null!=e&&(y=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>y};function E(t){return e(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise((t=>{e.addEventListener("load",(()=>t()),!1),e.addEventListener("error",(()=>t()),!1),document.body.appendChild(e)}))}importScripts(t.toString())}))}let A;const S=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.error('No <meta name="viewport"> detected. This might cause ShopAR to crash on iOS.\nPlease add the following line to your HTML:\n<meta name="viewport" content="width=device-width, initial-scale=1.0">'),()=>e?window.devicePixelRatio:1})();let R,M,C;function P(e){const t=function(e){const t=new M.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,M.ClampToEdgeWrapping,M.ClampToEdgeWrapping,M.LinearFilter,M.LinearFilter,1,M.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(C.parse(e));return t.mapping=M.EquirectangularReflectionMapping,t.colorSpace=M.LinearSRGBColorSpace,t}const I=45,T=45,x=3,k=1.5,L=1,U=.5;let $,D,O,_,N,j=!1;const F=4,W=.001,q=1e-7,G=10,z=11,B=1/(z-1),Q="function"==typeof Float32Array;function V(e,t,n,r){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===r)return J;const o=Q?new Float32Array(z):new Array(z);for(let t=0;t<z;++t)o[t]=Z(t*B,e,n);function i(t){let r=0,i=1;const a=z-1;for(;i!==a&&o[i]<=t;++i)r+=B;--i;const s=r+(t-o[i])/(o[i+1]-o[i])*B,l=Y(s,e,n);return l>=W?function(e,t,n,r){for(let o=0;o<F;++o){const o=Y(t,n,r);if(0===o)return t;t-=(Z(t,n,r)-e)/o}return t}(t,s,e,n):0===l?s:function(e,t,n,r,o){let i,a,s=0;do{a=t+(n-t)/2,i=Z(a,r,o)-e,i>0?n=a:t=a}while(Math.abs(i)>q&&++s<G);return a}(t,r,r+B,e,n)}return function(e){return 0===e||1===e?e:Z(i(e),t,r)}}function K(e,t){return 1-3*t+3*e}function H(e,t){return 3*t-6*e}function X(e){return 3*e}function Z(e,t,n){return((K(t,n)*e+H(t,n))*e+X(t))*e}function Y(e,t,n){return 3*K(t,n)*e*e+2*H(t,n)*e+X(t)}function J(e){return e}function ee(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=V(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function te(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:ee(n)})));let r=0,o=n[0].value;return{reset:()=>{r=0},update:e=>{for(r+=e;r>=t;)r-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(r>=t.time&&r<i.time){const e=t.interpolate((r-t.time)/(i.time-t.time));o=t.value+e*(i.value-t.value)}}},get:()=>o}}const ne="#",re="time",oe="interpolation",ie="yaw",ae="pitch",se="fov",le=[re,ie,ae,se,oe],ce="s",ue="ms",de=1e3,he="deg",pe="rad",fe=Math.PI/180,me="ease-in-out",ge="cubic-bezier(",ve=")";function we(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(ne);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const r=function(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(!le.includes(r))throw new Error(`Invalid token in header: '${r}'.`);if(t.includes(r))throw new Error(`Duplicate token in header: '${r}'.`);t.push(r)}if(!t.includes(re))throw new Error(`Missing required token: '${re}'.`);return t}(t.split(/\s+/)),o={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:i}=ye(r,e);null!=t&&(null==o.theta&&(o.theta=[]),o.theta.push(t)),null!=n&&(null==o.phi&&(o.phi=[]),o.phi.push(n)),null!=i&&(null==o.fov&&(o.fov=[]),o.fov.push(i))}if(0===Object.values(o).length)throw new Error("At least one parameter should be animated.");return o}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const r of e){const{time:e,pitch:o,yaw:i,fov:a}=r;if(null==e)throw new Error("Time missing.");const s=Ee(null!==(t=r.interpolation)&&void 0!==t?t:me);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*fe,interpolation:s})),null!=o&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:o*fe,interpolation:s})),null!=a&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:a*fe,interpolation:s}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function ye(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const r=e.indexOf(re),o=function(e){if(e.endsWith(ue))return Se(e.substring(0,e.length-ue.length));if(e.endsWith(ce))return Se(e.substring(0,e.length-ce.length))*de;return Se(e)}(n[r]),i=e.indexOf(oe),a=Ee(-1===i?me:n[i]),s={};for(let t=0;t<n.length;t++){if(t===r||t===i)continue;const l=e[t],c=n[t];switch(l){case ie:s.theta={time:o,value:be(c),interpolation:a};break;case ae:s.phi={time:o,value:be(c),interpolation:a};break;case se:s.fov={time:o,value:be(c),interpolation:a};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return s}function be(e){return e.endsWith(he)?Se(e.substring(0,e.length-he.length))*fe:e.endsWith(pe)?Se(e.substring(0,e.length-pe.length)):Se(e)*fe}function Ee(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Ae(0,0,1,1);if("sine"===e)return Ae(.37,0,.63,1);if("sine-in"===e)return Ae(.12,0,.39,0);if("sine-out"===e)return Ae(.61,1,.88,1);if("ease"===e)return Ae(.25,.1,.25,1);if("ease-in"===e)return Ae(.42,0,1,1);if("ease-out"===e)return Ae(0,0,.58,1);if("ease-in-out"===e)return Ae(.42,0,.58,1);if(e.startsWith(ge)&&e.endsWith(ve)){const t=e.substring(ge.length,e.length-ve.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:Se(t[0]),y1:Se(t[1]),x2:Se(t[2]),y2:Se(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Ae(e,t,n,r){return{type:"bezier",x1:e,y1:t,x2:n,y2:r}}function Se(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const Re=300,Me=2e3,Ce=.05,Pe=2*Math.PI/32,Ie=Ee("hold"),Te=Ee("sine"),xe=Ee("sine-in"),ke=Ee("sine-out");const Le=8,Ue=2*Math.PI,$e=Ue/12,De=Ue/60,Oe=Ue/60,_e=60,Ne=60,je=1e3,Fe=_e*Ne,We=-1;let qe;const Ge=0,ze=3;let Be,Qe,Ve,Ke=!1,He=1,Xe=1,Ze=1;const Ye=1;let Je;const et=new Map;function tt(t,n,r){const o=t.getContext("2d");null==o&&console.warn("2D context missing.");let i,a,s,l,c,u,d,h,p,f,m,g,v,w,y,b=!1,E=!1,A=!1,S=!0,L=!1,j=1,F=!0,W=!1,q=0,G=0,z=1,B=1,Q=1;const V={threeInit:()=>{b||(nt(),i=new Qe.Scene,a=new Qe.PerspectiveCamera(25,1,.5),s=new Be.OrbitControls(a,t),s.setInteractionEnabled(F),h=Qe.ACESFilmicToneMapping,({renderShadow:c,shadowGroup:l}=function(e){const t=new $.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new $.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const r=new $.Group;r.position.y=-.7;const o=new $.PlaneGeometry(I,T).rotateX(Math.PI/2),i=new $.MeshBasicMaterial({map:t.texture,opacity:U,transparent:!0,depthWrite:!1}),a=new $.Mesh(o,i);a.renderOrder=1,a.scale.y=-1,r.add(a);const s=new $.Mesh(o);s.visible=!1,r.add(s);const l=new $.OrthographicCamera(-I/2,I/2,T/2,-T/2,0,x);function c(e){s.visible=!0,_.uniforms.tDiffuse.value=t.texture,_.uniforms.h.value=1*e/256,s.material=_,D.setRenderTarget(n),D.render(s,l),N.uniforms.tDiffuse.value=n.texture,N.uniforms.v.value=1*e/256,s.material=N,D.setRenderTarget(t),D.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,r.add(l),{shadowGroup:r,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=O;const r=D.getClearAlpha();D.setClearAlpha(0),D.setRenderTarget(t),D.render(e,l),e.overrideMaterial=null,c(k),c(.4*k),D.setRenderTarget(null),D.setClearAlpha(r),e.background=n}}}(i)),b=!0)},threeParse:(t,n,r)=>e(this,void 0,void 0,(function*(){return null!=u&&d===r||(yield u,u=(()=>e(this,void 0,void 0,(function*(){var e,r;return M=(e=Be).THREE,C=new e.RGBELoader,i.environment=P(n),function(e,t){const{THREE:n}=t;R=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder)}(Je,Be),r=t,R.parseAsync(r.buffer,"")})))(),d=r),u})),threeLoad:(e,t)=>{i.traverse((e=>{var t,n;e instanceof Qe.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach((e=>e.dispose())):null===(n=e.material)||void 0===n||n.dispose())})),i.clear(),i.add(e.scene);const n=(new Qe.Box3).setFromObject(e.scene);l.position.y=n.min.y-Ge,i.add(l),c(),E=!1,i.traverse((e=>{if(e instanceof Qe.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(E=!0)})):t.transmission>0&&(E=!0)}}));const r=n.min.clone().add(n.max).divideScalar(2),o=Math.sqrt(Be.reduceVertices(e.scene,((e,t)=>Math.max(e,r.distanceToSquared(t))),0));s.reset(r,o,function(e,t){var n;const r={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?r.Glasses:null!==(n=r[e])&&void 0!==n?n:r.Glasses).normalize()}(t,Qe.Vector3)),q=0,y="Watches"===t?function(e){const t=e.getObjectByName("hours"),n=e.getObjectByName("minutes"),r=e.getObjectByName("seconds");if(null==t&&null==n&&null==r)return null;let o=new Date;return{update:()=>{const e=new Date;if(Math.abs(e.getTime()-o.getTime())<je/Le)return!1;o=e;const i=e.getHours(),a=e.getMinutes(),s=e.getSeconds(),l=e.getMilliseconds();return null!=t&&(t.rotation.y=We*$e*(i+a/_e+s/Fe)),null!=n&&(n.rotation.y=We*De*(a+s/Ne)),null!=r&&(r.rotation.y=We*Oe*(s+l/je)),!0}}}(e.scene):null},threePaused:()=>S,threeResume:()=>{S=!1,Je.setAnimationLoop(rt),t.style.visibility="visible",G=0,null==f||f.reset(),null==m||m.reset(),null==g||g.reset(),null==v||v.reset(),null==w||w.reset()},threePause:()=>{S=!0,function(){for(const{threePaused:e}of et.values())if(!e())return!1;return!0}()&&Je.setAnimationLoop(null),t.style.visibility="hidden",r.style.opacity="0",n.style.visibility="hidden"},threeSetZoomEnabled:e=>{s.enableZoom=e},threeSetForcedTransparency:e=>{A=e},threeSetToneMapping:(e,t)=>{const n={ACES:Qe.ACESFilmicToneMapping,Linear:Qe.LinearToneMapping,Neutral:Qe.NeutralToneMapping};null!=n[e]&&(h=n[e]),j=t},threeIsInteractive:()=>F,threeSetInteractive:e=>{F=e,null==s||s.setInteractionEnabled(F)},threeSetOnInteracted:e=>{s.removeEventListener("change",p),p=e,s.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=s.getTheta(),f=te([{time:0,value:e,interpolation:Ie},{time:Re,value:e,interpolation:ke},{time:Re+Me/4,value:e+Pe,interpolation:Te},{time:Re+3*Me/4,value:e-Pe,interpolation:xe},{time:Re+Me,value:e,interpolation:Ie},{time:Re+2*Me,value:e,interpolation:Ie}]),s.setTheta(f.get()),m=null,g=null,v=te([{time:0,value:0,interpolation:Ie},{time:Re,value:1,interpolation:Ie},{time:Re+Me,value:0,interpolation:Ie},{time:Re+2*Me,value:0,interpolation:Ie}]),w=te([{time:0,value:0,interpolation:Ie},{time:Re,value:0,interpolation:ke},{time:Re+Me/4,value:-Ce,interpolation:Te},{time:Re+3*Me/4,value:Ce,interpolation:xe},{time:Re+Me,value:0,interpolation:Ie},{time:Re+2*Me,value:0,interpolation:Ie}])},threeInitThetaAnimation:e=>{f=e,null!=e&&s.setTheta(e.get())},threeInitPhiAnimation:e=>{m=e,null!=e&&s.setPhi(e.get())},threeInitFovAnimation:e=>{g=e,null!=e&&s.setFovRadians(e.get())},preRender_:e=>{if(!b||S)return;let t=0!==G?e-G:0;G=e,0===q?L=!0:q<ze&&(t=0),q++,W||(s.hasUserInteracted()?(W=!0,f=null,m=null,g=null,v=null,w=null):(null==f||f.update(t),null==m||m.update(t),null==g||g.update(t),null==v||v.update(t),null==w||w.update(t),null!=f&&(s.setTheta(f.get()),L=!0),null!=m&&(s.setPhi(m.get()),L=!0),null!=g&&(s.setFovRadians(g.get()),L=!0))),s.update()&&(L=!0),(null==y?void 0:y.update())&&(L=!0)},shouldRender_:()=>!(!b||S)&&L,render_:()=>{const e=Je.toneMapping,s=Je.toneMappingExposure;Je.toneMapping=h,Je.toneMappingExposure=j,Je.setViewport(0,0,t.width,t.height),Je.setClearColor(new Qe.Color(16777215),E&&!A?1:0),Je.render(i,a),Je.toneMapping=e,Je.toneMappingExposure=s,L=!1,null!=o&&(o.clearRect(0,0,t.width,t.height),Ve.width>0&&Ve.height>0&&o.drawImage(Ve,0,Xe-t.height,t.width,t.height,0,0,t.width,t.height),n.style.visibility=F&&!W?"visible":"hidden",null!=v&&(r.style.opacity=`${v.get()}`),null!=w&&(r.style.transform=`translateX(${w.get()*Math.min(z,B)}px)`))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===z&&n===B&&Ze===Q||(t.width=Math.ceil(e*Ze*Ye),t.height=Math.ceil(n*Ze*Ye),z=e,B=n,Q=Ze,L=!0)},target_:t};return et.set(t,V),V}function nt(){if(Ke)return;Be=window.ShopAR__THREE,Qe=Be.THREE,Ve=document.createElement("canvas");var e,t;Ve.style.position="block",Je=new Qe.WebGLRenderer({powerPreference:"high-performance",canvas:Ve,antialias:!0,alpha:!0}),Je.outputColorSpace=Qe.SRGBColorSpace,Je.toneMapping=Qe.ACESFilmicToneMapping,Je.setClearColor(new Qe.Color(16777215),0),e=Je,t=Be,j||($=t.THREE,D=e,O=new $.MeshDepthMaterial,O.userData.darkness={value:L},O.onBeforeCompile=e=>{e.uniforms.darkness=O.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},O.depthTest=!1,O.depthWrite=!1,_=new $.ShaderMaterial(t.HorizontalBlurShader),_.depthTest=!1,N=new $.ShaderMaterial(t.VerticalBlurShader),N.depthTest=!1,j=!0),ot(),Ke=!0}function rt(e){ot(),Je.clear();for(const{preRender_:t,shouldRender_:n,render_:r}of et.values())t(e),n()&&r()}function ot(){let e=0,t=0;for(const{target_:n}of et.values()){const{clientWidth:r,clientHeight:o}=n;e=Math.max(e,r),t=Math.max(t,o)}const n=S();e=Math.ceil(e*n*Ye),t=Math.ceil(t*n*Ye),e===He&&t===Xe&&n===Ze||(He=e,Xe=t,Ze=n,Je.setSize(He,Xe,!1));for(const{updateSize_:e}of et.values())e()}const it={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},at=Object.keys(it);function st(e){return it[e]}const lt="shopar-error";function ct(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const r=document.createElementNS("http://www.w3.org/2000/svg","image");r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),r.setAttribute("width",e),r.setAttribute("height",e),n.appendChild(r)}return n}function ut(e,t,n,r){const o=document.createElement("button");o.id=e,o.type="button",o.className="shopar-btn";{const e=ct("1.75rem",r);o.appendChild(e)}{const e=document.createElement("span");e.textContent=t,o.appendChild(e)}o.ariaLabel=n;const i=o.style;return i.display="none",i.pointerEvents="auto",o}const dt="shopar-control";const ht="shopar-deepar-output";function pt(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.pointerEvents="auto",n.userSelect="none",t}function ft(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function mt(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function gt(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const vt="shopar-main";const wt="shopar-qr-output";const yt="shopar-three-output";var bt;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(bt||(bt={}));let Et=!1;function At(){Et||(!function(){try{const e=document.createElement("style"),t=process.env.css;null!=t&&(e.innerHTML=t);const n=document.head;n.insertBefore(e,n.children[0])}catch(e){console.warn("Failed to write default ShopAR Plugin CSS.")}}(),Et=!0)}function St(){At();const e=function(){const e=document.createElement("div");e.id=vt;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),r=function(e,t){const n=document.createElement("div");n.id=wt;const r=n.style;r.position="absolute",r.top="0",r.left="0",r.width="100%",r.height="100%",r.display="none",r.pointerEvents="auto",r.userSelect="none";const o=document.createElement("div");o.className="shopar-qr";const i=o.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(o),o.appendChild(e);const a=document.createElement("div");return a.appendChild(t),o.appendChild(a),n}(t,n);e.appendChild(r);const o=function(){const e=document.createElement("div");e.id=ht;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",t.pointerEvents="auto",e}();e.appendChild(o);const i=function(){const e=document.createElement("canvas");e.id=yt,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const a=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),s=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),l=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:r}=n;return r.position="absolute",r.width="100%",r.height="100%",r.opacity="0",n.appendChild(e),n.appendChild(t),n}(a,s);e.appendChild(l);const c=function(){const e=ct("2rem",`${b}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),u=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",t.appendChild(e),t}(c);e.appendChild(u);const d=pt("shopar-ar-loading-container"),h=ft("shopar-ar-loading-text",st("loading.ar"));d.appendChild(h);const p=mt("shopar-ar-loading-bar-bg"),f=gt("shopar-ar-loading-bar-fg");p.appendChild(f),d.appendChild(p),e.appendChild(d);const m=pt("shopar-3d-loading-container"),g=ft("shopar-3d-loading-text",st("loading.3d"));m.appendChild(g);const v=mt("shopar-3d-loading-bar-bg"),w=gt("shopar-3d-loading-bar-fg");v.appendChild(w),m.appendChild(v),e.appendChild(m);const y=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",e}(),E=function(){const e=new Image;e.draggable=!1;const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.objectFit="contain",e}();y.appendChild(E),e.appendChild(y);const A=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),S=function(e){const t=document.createElement("div");t.id=lt;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const r=document.createElement("div"),o=r.style;return o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",t.appendChild(r),r.appendChild(e),t}(A);e.appendChild(S);const R=function(){const e=document.createElement("div");return e.id=dt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(R);const M=ut("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");R.appendChild(M);const C=ut("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${b}/img/icons/cube.svg`);R.appendChild(C);const P=ut("shopar-btn-close","Close","Close ShopAR view",`${b}/img/icons/close.svg`);R.append(P);let I,T,x=bt.None,k=!1,L=!1,U=!1,$=!1;function D(){f.classList.remove("active"),d.style.visibility="hidden"}function O(){y.style.visibility="hidden",w.classList.remove("active"),m.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return r},getQRImage:function(){return n},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return l},getThreeTarget:function(){return i},getThreePrompt:function(){return u},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){a.textContent=e,s.src=t},customizeCameraError:function(e){A.textContent=null!=e?e:"Please reload page and allow camera access to continue"},customizeQRPrompt:function(e){t.textContent=null!=e?e:"Scan on mobile or tablet to try on"},setVisibilityParameters:function(e,t,n,r,o,i){var a;k=e,L=t,U=n,$=r,I=o,T=i,Rt(R,k),Rt(M,k&&(U||L)&&x===bt.None),Rt(C,k&&$&&x===bt.None),Rt(P,k&&x!==bt.None),D(),O(),k||""===(a=S).style.display&&Rt(a,!1)},getUIState:function(){return x},setUIState:function(e){x=e,x===bt.None?(D(),O(),k&&(Rt(S,!1),Rt(P,!1),(L||U)&&Rt(M,!0),$&&Rt(C,!0))):x===bt.QR||x===bt.AR?k&&(Rt(S,!1),Rt(M,!1),Rt(C,$&&"AR"===T),Rt(P,"AR"!==T)):x===bt.Preview&&k&&(Rt(S,!1),Rt(M,(L||U)&&"3D"===T),Rt(C,!1),Rt(P,"3D"!==T))},setDefaultUIActions:function(e,t,n){k&&((L||U)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,r=`${b}/img/icons/${n}`;M.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r)}(I),M.onclick=e),$&&(C.onclick=t),P.onclick=n)},startDeepARLoading:function(){f.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:D,startThreeLoading:function(){null!=E.dataset.srcSet?y.style.visibility="visible":(w.classList.add("active"),m.style.visibility="visible")},stopThreeLoading:O,setThreePosterUrl:function(e){null!=e?(E.src=e,E.dataset.srcSet="true"):delete E.dataset.srcSet},showCameraError:function(){k&&Rt(S,!0)}}}function Rt(e,t){e.style.display=t?"":"none"}const Mt=new Map;function Ct(t){let n=Mt.get(t);return null==n?(n=function(){let t=0,n=null,r=null,o=null;const i=()=>(null==n&&(n=St()),n);return{getSetupId:()=>t,incrementSetupId_:()=>t++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==r){const{getQRTarget:t,getQRImage:n}=i();r=function(t,n){let r=!0;return{qrPaused:()=>r,qrDraw:(o,i)=>e(this,void 0,void 0,(function*(){yield A;const e=`https://ar.shopar.ai/${w.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:o,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(e),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,r=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){r=!0,t.style.display="none"}))}}(t(),n())}return r},findThree:()=>{if(null==o){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();o=tt(e(),t(),n())}return o}}}(),Mt.set(t,n)):n.incrementSetupId_(),n}function Pt(e){for(const t of Mt.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:r,setUIState:o}=n;r()===bt.AR&&o(bt.None)}}let It;const Tt=new Uint8Array(16);function xt(){if(!It&&(It="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!It))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return It(Tt)}const kt=[];for(let e=0;e<256;++e)kt.push((e+256).toString(16).slice(1));var Lt={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ut(e,t,n){if(Lt.randomUUID&&!t&&!e)return Lt.randomUUID();const r=(e=e||{}).random||(e.rng||xt)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return kt[e[t+0]]+kt[e[t+1]]+kt[e[t+2]]+kt[e[t+3]]+"-"+kt[e[t+4]]+kt[e[t+5]]+"-"+kt[e[t+6]]+kt[e[t+7]]+"-"+kt[e[t+8]]+kt[e[t+9]]+"-"+kt[e[t+10]]+kt[e[t+11]]+kt[e[t+12]]+kt[e[t+13]]+kt[e[t+14]]+kt[e[t+15]]}(r)}const $t="qrLaunch",Dt="arLaunch",Ot="previewLaunch",_t="heartbeat";let Nt,jt,Ft=!1,Wt=window.navigator.userAgent||"no user agent";const qt=[];function Gt(){null==Nt&&(jt=Ut(),Nt=E(`${b}/shopar-analytics.js`),Nt.then((()=>{Ft=!0,window.ShopAR__analytics.initializeImpl(),qt.forEach((e=>e()))})))}function zt(e){Ft?e():qt.push(e)}function Bt(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Qt(t){return e(this,void 0,void 0,(function*(){const e=document.createElement("video");return e.setAttribute("playsinline","playsinline"),e.srcObject=yield t,e}))}const Vt=200,Kt=10;let Ht=!1,Xt=null,Zt=[],Yt=[];function Jt(t){return e(this,void 0,void 0,(function*(){Ht=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${b}/wasm/mediapipe`,t),Xt&&clearInterval(Xt);const r=[],o=[];Xt=setInterval((()=>e(this,void 0,void 0,(function*(){if(Ht)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());Ht||(null!=a&&null!=s&&function(e){for(let t of Zt)t(e)}({translation:a,rotation:s}),null==e&&(r.push(t),o.push(i),r.length<Kt||(r.shift(),o.shift(),function(e,t){for(let n of Yt)n({faceWidth:e,IPD:t})}(tn(r),tn(o)))))}))),Vt)}))}function en(){Yt=[],Zt=[],Ht=!0}function tn(e){let t=0;const n=e.length;for(let r=0;r<n;r++)t+=e[r];return t/n}function nn(n){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(n).catch((e=>{throw console.error(e),new t("Resource unavailable.")}));if(!e.ok)throw new t(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield r.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}var rn="undefined"!=typeof Float32Array?Float32Array:Array;function on(){var e=new rn(16);return rn!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function an(e,t,n){var r=t[0],o=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],E=n[2],A=n[3];return e[0]=y*r+b*s+E*d+A*m,e[1]=y*o+b*l+E*h+A*g,e[2]=y*i+b*c+E*p+A*v,e[3]=y*a+b*u+E*f+A*w,y=n[4],b=n[5],E=n[6],A=n[7],e[4]=y*r+b*s+E*d+A*m,e[5]=y*o+b*l+E*h+A*g,e[6]=y*i+b*c+E*p+A*v,e[7]=y*a+b*u+E*f+A*w,y=n[8],b=n[9],E=n[10],A=n[11],e[8]=y*r+b*s+E*d+A*m,e[9]=y*o+b*l+E*h+A*g,e[10]=y*i+b*c+E*p+A*v,e[11]=y*a+b*u+E*f+A*w,y=n[12],b=n[13],E=n[14],A=n[15],e[12]=y*r+b*s+E*d+A*m,e[13]=y*o+b*l+E*h+A*g,e[14]=y*i+b*c+E*p+A*v,e[15]=y*a+b*u+E*f+A*w,e}function sn(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function ln(e,t){var n=t[0],r=t[1],o=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.hypot(n,r,o),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,u),e}function cn(e,t,n,r){var o=t[0],i=t[1],a=t[2],s=t[3],l=o+o,c=i+i,u=a+a,d=o*l,h=o*c,p=o*u,f=i*c,m=i*u,g=a*u,v=s*l,w=s*c,y=s*u,b=r[0],E=r[1],A=r[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*E,e[5]=(1-(d+g))*E,e[6]=(m+v)*E,e[7]=0,e[8]=(p+w)*A,e[9]=(m-v)*A,e[10]=(1-(d+f))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function un(){var e=new rn(3);return rn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function dn(e,t,n){var r=new rn(3);return r[0]=e,r[1]=t,r[2]=n,r}function hn(e,t){var n=t[0]-e[0],r=t[1]-e[1],o=t[2]-e[2];return Math.hypot(n,r,o)}function pn(e,t,n){var r=t[0],o=t[1],i=t[2],a=n[3]*r+n[7]*o+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*o+n[8]*i+n[12])/a,e[1]=(n[1]*r+n[5]*o+n[9]*i+n[13])/a,e[2]=(n[2]*r+n[6]*o+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function fn(){var e=new rn(4);return rn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}un(),function(){var e,t=(e=new rn(4),rn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var mn;let gn,vn,wn;un(),dn(1,0,0),dn(0,1,0),fn(),fn(),mn=new rn(9),rn!=Float32Array&&(mn[1]=0,mn[2]=0,mn[3]=0,mn[5]=0,mn[6]=0,mn[7]=0),mn[0]=1,mn[4]=1,mn[8]=1;let yn,bn,En,An,Sn=!0,Rn=null;const Mn=new Set;let Cn,Pn,In,Tn,xn,kn;function Ln(){null==gn&&(gn=E(`${b}/shopar-deepar.js`))}function Un(){null==vn&&(vn=E(`${b}/shopar-true-scale.js`))}function $n(n){return e(this,void 0,void 0,(function*(){const{licenseKey:r,truescaleUsecase:o}=n;return xn=o,null==Cn&&(Cn=(()=>e(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new t("No camera available!");var e;const n=Gn(En),o=Bt(n);yn=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:r||"your_license_key_goes_here",previewElement:An,additionalOptions:{hint:kn,cameraConfig:{disableDefaultCamera:!0}}}),bn=yield Qt(o),yield zn(yn,bn,"user"===n),"Glasses"===En&&(yield vn,Jt(bn),"DetectionLoop"!==xn&&Kn((e=>{Tn=e.faceWidth})))})))()),Cn}))}function Dn(e,t){var n,r;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===En&&(n=t,r=kn,n===r||null!=n&&null!=r&&n.length===r.length&&n.every((e=>r.find((t=>e===t))))&&r.every((e=>n.find((t=>t===e))))))||(null!=yn&&(yn.shutdown(),yn=null,Cn=null),En=e,kn=t)}function On(e){e!==An&&(An=e,null!=yn&&yn.changePreviewElement(An))}function _n(e){Rn=e}function Nn(e){yn.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(Tn){const e=137/(Tn+5);yn.changeParameterVector("GLASSES","","scale",e,e,e,0),yn.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const r=Qn("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),o=Qn("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);yn.changeParameterVector("temple_left","","rotation",0,56.6*-r,0,0),yn.changeParameterVector("temple_right","","rotation",0,56.6*-o,0,0)}catch(e){return}}(e),en(),Tn=null}e(),Bn("Glasses")}},yn.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),Bn("Shoes"))},yn.callbacks.onWristTracked=t=>{t.detected&&(e(),Bn("Watches"))}}function jn(t,n,r){return e(this,void 0,void 0,(function*(){return null!=Pn&&In===r||(yield Pn,Pn=yn.switchEffect(t,{envmap:n}),In=r),Pn}))}function Fn(e,t){null!=e&&null!=t&&(yn.setToneMapping(e),yn.setExposure(t))}function Wn(){return e(this,void 0,void 0,(function*(){if(null!=yn){if(Sn=!1,null==bn){const e=Gn(En),t=Bt(e);bn=yield Qt(t),yield zn(yn,bn,"user"===e),"Glasses"===En&&(Jt(bn),"DetectionLoop"!==xn&&Kn((e=>{Tn=e.faceWidth})))}!function(){if(null==Rn)return;if(null==En||Mn.has(En))return;Rn.style.visibility="visible",Rn.style.opacity="1"}(),yn.setPaused(Sn),An.style.display=""}}))}function qn(){null!=yn&&(Sn=!0,yn.setPaused(Sn),en(),null!=bn&&null!=bn.srcObject&&bn.srcObject instanceof MediaStream&&(bn.srcObject.getTracks().forEach((e=>e.stop())),bn=null),function(){if(null==Rn)return;Rn.style.visibility="hidden",Rn.style.opacity="0"}(),yn.stopCamera(),An.style.display="none")}function Gn(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function zn(t,n,r){return e(this,void 0,void 0,(function*(){yield new Promise((o=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,r),o()}))))}}))}))}function Bn(e){null!=Rn&&(Mn.has(e)||(Mn.add(e),Rn.style.opacity="0"))}function Qn(e,t,n,r,o,i,a){const s=yn.getTransformationBetween(e,t),l=sn(un(),s),c=function(e,t){var n=new rn(3);ln(n,t);var r=1/n[0],o=1/n[1],i=1/n[2],a=t[0]*r,s=t[1]*o,l=t[2]*i,c=t[4]*r,u=t[5]*o,d=t[6]*i,h=t[8]*r,p=t[9]*o,f=t[10]*i,m=a+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>u&&a>f?(g=2*Math.sqrt(1+a-u-f),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):u>f?(g=2*Math.sqrt(1+u-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+f-a-u),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(d+p)/g,e[2]=.25*g),e}(fn(),s);cn(s,c,l,dn(a,a,a));const u=yn.getTransformationBetween(t,n),d=sn(un(),u);cn(u,fn(),d,ln(un(),u));const h=an(on(),s,u),p=sn(un(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=yn.getTransformationBetween(n,r)}catch(e){return f}const g=an(on(),u,m),v=an(on(),s,g),w=dn(p[0],i[1],i[2]),y=pn(un(),w,function(e,t){var n=t[0],r=t[1],o=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-r*a,y=n*l-o*a,b=n*c-i*a,E=r*l-o*s,A=r*c-i*s,S=o*c-i*l,R=u*m-d*f,M=u*g-h*f,C=u*v-p*f,P=d*g-h*m,I=d*v-p*m,T=h*v-p*g,x=w*T-y*I+b*P+E*C-A*M+S*R;return x?(x=1/x,e[0]=(s*T-l*I+c*P)*x,e[1]=(o*I-r*T-i*P)*x,e[2]=(m*S-g*A+v*E)*x,e[3]=(h*A-d*S-p*E)*x,e[4]=(l*C-a*T-c*M)*x,e[5]=(n*T-o*C+i*M)*x,e[6]=(g*b-f*S-v*y)*x,e[7]=(u*S-h*b+p*y)*x,e[8]=(a*I-s*C+c*R)*x,e[9]=(r*C-n*I-i*R)*x,e[10]=(f*A-m*b+v*w)*x,e[11]=(d*b-u*A-p*w)*x,e[12]=(s*M-a*P-l*R)*x,e[13]=(n*P-r*M+o*R)*x,e[14]=(m*y-f*E-g*w)*x,e[15]=(u*E-d*y+h*w)*x,e):null}(on(),v));let b=yn.getClosestPointOnMesh(r,y);try{const e=yn.getClosestPointOnMesh(o,y);hn(y,e)<hn(y,b)&&(b=e)}catch(e){}const E=pn(un(),b,g);return f-Math.atan2(E[0]-d[0],Math.abs(E[2]-d[2]))}function Vn(e){!function(e){Zt.push(e)}(e)}function Kn(e){!function(e){Yt.push(e)}(e)}var Hn;function Xn(){return[Hn.Android,Hn.iOS,Hn.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],r=["Win32","Win64","Windows","WinCE"],o=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==o.indexOf(t)?Hn.iOS:-1!==n.indexOf(t)?i?Hn.Tablet:Hn.MacOS:-1!==r.indexOf(t)?Hn.Windows:/Android/.test(e)?Hn.Android:/Linux/.test(t)?Hn.Linux:i?Hn.Tablet:Hn.Unknown}return Hn.Unknown}())}function Zn(r,o,i){return e(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const u=String.fromCharCode(a+14);s>>=2,a^=s+2;const d=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const f=String.fromCharCode(a-7),m=window[`${h}${d+u+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${f}`],g=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${r}`).catch((()=>{throw new t("Unknown error.")}));if(!e.ok)throw new t("Unknown error.");return e})))),v=new n[0](yield(yield g.blob().catch((()=>{throw new t("Unknown error.")}))).arrayBuffer().catch((()=>{throw new t("Unknown error.")})));i+=s;const w=v.byteLength;if(c[l]=Math.min(76,o)*((a>>5)-1),152===c[l]&&(c[l]=w),i==l)return v;i=l,i^=l;for(let e=0,t=v.length;e<t;e++)c[l]^=c[i]<<13,c[l]^=c[i]>>17,c[l]^=c[i]<<5,v[e]=v[e]^c[l];return i^=c[0],i^=c[1],i^=c[2],v}))}!function(e){e[e.Unknown=0]="Unknown",e[e.Android=1]="Android",e[e.iOS=2]="iOS",e[e.Tablet=3]="Tablet",e[e.MacOS=4]="MacOS",e[e.Windows=5]="Windows",e[e.Linux=6]="Linux"}(Hn||(Hn={}));const Yn=["AR","3D"];function Jn(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function er(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}function tr(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}function nr(e){const{apiKey:n,sku:r,targetElement:o,initialState:i,initialAnimation:a,baseUrl:s,defaultUI:l,interactive:c,strings:u}=e;Jn(n,"apiKey"),tr(n,"apiKey"),Jn(r,"sku"),tr(r,"sku"),Jn(o,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&function(e,n,r){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!r.includes(e))throw new t(`'${n}' must be ${r.join("' or '")}.`)}(i,"initialState",Yn),null!=a&&function(e,n){if("string"!=typeof e&&!Array.isArray(e))throw new t(`'${n}' must be a string or array.`)}(a,"initialAnimation"),null!=s&&tr(s,"baseUrl"),null!=l&&er(l,"defaultUI"),null!=c&&er(c,"interactive"),null!=u&&function(e,n,r){for(const o of r){const r=e[o];if(null!=r&&"string"!=typeof r)throw new t(`Value for key '${o}' in '${n}' must be a string.`)}}(u,"strings",at)}let rr=!1;function or(n){return e(this,void 0,void 0,(function*(){const{targetElement:r}=n;b.update(n.baseUrl),Gt();const{trackEvent:o}=function(e){const t=performance.now(),n=Ut();return{trackEvent:(r,o={})=>{o=Object.assign(Object.assign({},o),{pluginVersion:w,userAgent:Wt,sessionId:jt,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),zt((()=>{window.ShopAR__analytics.trackEventImpl(r,o)}))}}}(n.apiKey);o("visionSetup");const i=yield function(n){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:n,sid:u()})}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield r.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(n.apiKey);o("visionApiResponse",i);const{arKey:a}=i,s=Ct(r),{getSetupId:l,findUI:c}=s,d=l();Ln(),Un();const{setTargetElement:h,getDeepARTarget:f,setVisibilityParameters:m,getUIState:g,setUIState:v,startDeepARLoading:y,stopDeepARLoading:E,showCameraError:A}=c();if(g()!=bt.None)throw Error("UI state is not None, this is weird..");v(bt.AR),h(r),m(!1,!1,!0,!1,void 0,void 0),y(),yield gn,ir(l(),d);try{o("visionArLaunch"),qn(),Dn("Glasses",["faceInit"]),On(f()),yield $n({licenseKey:a,truescaleUsecase:"DetectionLoop"}),ir(l(),d),yield Wn(),ir(l(),d)}catch(e){const n=e instanceof Error;throw o("visionArLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),A(),qn(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{E()}return rr=!0,{registerFacePoseListener:e=>{rr&&(o("registerFacePoseListener"),Vn(e))},registerFaceMeasurementListener:e=>{rr&&(o("registerFaceMeasurementListener"),Kn(e))},switchEffect:t=>e(this,void 0,void 0,(function*(){rr&&(o("switchEffect",{arUrl:t}),function(e){yn.switchEffect(e)}(t))})),clearEffect:()=>{rr&&(o("clearEffect"),yn.clearEffect())},close:()=>{if(rr){if(rr=!1,o("visionClose"),g()!==bt.AR)throw new t("AR not launched.");qn(),v(bt.None)}}}}))}function ir(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}function ar(n){var r,o;return e(this,void 0,void 0,(function*(){nr(n);const{apiKey:i,sku:a,targetElement:s,initialState:l,initialAnimation:c}=n,d=null==n.zoomEnabled||n.zoomEnabled,h=!0===n.alwaysTransparentBackground;!function(e){const n=getComputedStyle(e);if(!["static","relative"].includes(n.position))throw new t(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${n.position}'.`)}(s),b.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(it,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(it[t]=n)}}(n.strings);const y=null!=c?we(c):null,S=null!=(null==y?void 0:y.theta)?te(y.theta):null,R=null!=(null==y?void 0:y.phi)?te(y.phi):null,M=null!=(null==y?void 0:y.fov)?te(y.fov):null,C=function(n,r,o,i,a,s){return e(this,void 0,void 0,(function*(){const l=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:n,sku:r,sid:u()},null!=o&&{yaw:`${m(f(o))}`}),null!=i&&{pitch:`${m(f(i))}`}),null!=a&&{fov:`${m(f(a))}`}),s&&{forcedTransparency:`${s}`}))}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield l.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(i,a,null==S?void 0:S.get(),null==R?void 0:R.get(),null==M?void 0:M.get(),h),P=Ct(s),{getSetupId:I,findUI:T,findQR:x,findThree:k}=P,L=I();Gt();const{trackEvent:U,arInteracted:$,previewInteracted:D}=function(e,t){const n=performance.now(),r=Ut();let o=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(o=i+a,c=!1,u(_t,{engagementTotal:o,engagementAR:i,engagement3D:a}))}),1e3);const u=(o,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:Wt,pluginVersion:w,sessionId:jt,setupId:r,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),zt((()=>{window.ShopAR__analytics.trackEventImpl(o,i)}))};return{trackEvent:u,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}(a,i);U("setup",{hostname:window.location.hostname});const O=yield C;U("apiResponse",O);const{category:_,arUrl:N,arEnvUrl:j,arToneMapping:F,arToneMappingExposure:W,arKey:q,arPromptEnabled:G,arPromptText:z,arPromptImage:B,previewUrl:Q,previewEnvUrl:V,previewToneMapping:K,previewToneMappingExposure:H,previewPosterUrl:X,cameraErrorText:Z,qrPromptText:Y}=O;sr(I(),L);const J=null!=N&&function(e){return null!=e&&g.includes(e)}(_),ee=null==(null===(r=n._internalOptions)||void 0===r?void 0:r.qrEnabled)||(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled),ne=J&&function(e){return null!=e&&v.includes(e)}(_),re=ee&&ne&&!Xn(),oe=J&&!re,ie=null!=Q;if(sr(I(),L),re&&function(){e(this,void 0,void 0,(function*(){null==A&&(A=E(`${b}/shopar-qr.js`))}))}(),oe&&(Ln(),function(e){e!==wn&&(wn=e,nn(e),Pn=null,en())}(N),"Glasses"===_&&Un(),null!=j&&nn(j)),ie){null==qe&&(qe=E(`${b}/shopar-three.js`));const e=255;Zn(Q,(new Date).getTime()+e,Math.random()*e),nn(null!=V?V:`${b}/env/default.hdr`)}const{setTargetElement:ae,getDeepARTarget:se,getDeepARPrompt:le,customizeDeepARPrompt:ce,customizeCameraError:ue,customizeQRPrompt:de,setVisibilityParameters:he,getUIState:pe,setUIState:fe,setDefaultUIActions:me,startDeepARLoading:ge,stopDeepARLoading:ve,startThreeLoading:ye,stopThreeLoading:be,setThreePosterUrl:Ee,showCameraError:Ae}=T();ae(s);he(null==n.defaultUI||n.defaultUI,re,oe,ie,_,l),ce(null!=z?z:"",null!=B?B:""),ue(Z),de(Y),Ee(X),function(e,n){const r=e.parentNode;if(null==r)throw new t("Parent node missing.");new MutationObserver((t=>{for(const r of t)for(const t of r.removedNodes)if(t===e)return void n()})).observe(r,{childList:!0})}(s,(()=>{pe()!==bt.QR||Se()||Me(),pe()!==bt.AR||Sn||qn(),pe()!==bt.Preview||Te()||ke(),fe(bt.None)}));const{qrPaused:Se,qrDraw:Re,qrPause:Me}=x(),{threeInit:Ce,threeParse:Pe,threeLoad:Ie,threePaused:Te,threeResume:xe,threePause:ke,threeSetZoomEnabled:Le,threeSetForcedTransparency:Ue,threeSetToneMapping:$e,threeIsInteractive:De,threeSetInteractive:Oe,threeSetOnInteracted:_e,threeInitPromptAnimation:Ne,threeInitThetaAnimation:je,threeInitPhiAnimation:Fe,threeInitFovAnimation:We}=k(),Ge=null==n.interactive||n.interactive;Oe(Ge);let ze=0;if(pe()===bt.QR){if(!Se())if(re){U($t);try{yield Re(i,a)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else Me(),fe(bt.None)}else if(pe()===bt.AR){if(!Sn)if(oe&&!rr){U(Dt);const e=null!=j?yield nn(j):void 0;sr(I(),L);const t=yield nn(N);sr(I(),L),Pt(P),Dn(_),On(se()),_n(G?le():null),yield jn(t,e,`${N}${j}`),Fn(F,W),Nn($),sr(I(),L)}else qn(),fe(bt.None)}else if(pe()===bt.Preview&&!Te())if(ie){U(Ot),ye();const e=255,t=yield Zn(Q,(new Date).getTime()+e,Math.random()*e);sr(I(),L);const n=yield nn(null!=V?V:`${b}/env/default.hdr`);sr(I(),L);const r=yield Pe(t,n,`${Q}${V}`);sr(I(),L),Ie(r,_),Le(d),Ue(h),$e(null!=K?K:"ACES",null!=H?H:1),_e(D),Ne(),null!=y&&(je(S),Fe(R),We(M)),be()}else ke(),fe(bt.None);const Be=()=>e(this,void 0,void 0,(function*(){if(re){if(pe()===bt.QR||pe()===bt.AR)return;try{U($t);const e=++ze;if(pe()===bt.Preview&&ie&&!Te()&&ke(),fe(bt.QR),yield Re(i,a),ze!==e)return;return void sr(I(),L)}catch(e){const n=e instanceof Error;throw U("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}}if(!oe)throw new t("Model does not have AR enabled.");if(pe()!==bt.AR)try{U(Dt);const e=++ze;pe()===bt.Preview&&ie&&!Te()&&ke(),Pt(P),fe(bt.AR),ge();const t=null!=j?yield nn(j):void 0;sr(I(),L);const n=yield nn(N);if(ze!==e)return;if(sr(I(),L),yield gn,ze!==e)return;if(sr(I(),L),qn(),Dn(_),On(se()),_n(G?le():null),yield $n({licenseKey:q}),ze!==e)return;if(sr(I(),L),yield jn(n,t,`${N}${j}`),Fn(F,W),Nn($),ze!==e)return;if(sr(I(),L),yield Wn(),ze!==e)return;sr(I(),L)}catch(e){const n=e instanceof Error;throw U("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),Ae(),qn(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{ve()}})),Qe=()=>e(this,void 0,void 0,(function*(){if(!ie)throw new t("Model does not have 3D enabled.");if(pe()!==bt.Preview)try{U(Ot);const e=++ze;pe()===bt.AR&&(oe&&!Sn&&qn(),Me()),fe(bt.Preview),ye();const t=255,n=yield Zn(Q,(new Date).getTime()+t,Math.random()*t);if(ze!==e)return;sr(I(),L);const r=yield nn(null!=V?V:`${b}/env/default.hdr`);if(ze!==e)return;if(sr(I(),L),yield qe,ze!==e)return;if(sr(I(),L),Ce(),ze!==e)return;sr(I(),L);const o=yield Pe(n,r,`${Q}${V}`);if(ze!==e)return;sr(I(),L),Ie(o,_),Le(d),Ue(h),$e(null!=K?K:"ACES",null!=H?H:1),_e(D),Ne(),null!=y&&(je(S),Fe(R),We(M)),xe()}catch(e){const n=e instanceof Error;throw U("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}finally{be()}})),Ve=()=>e(this,void 0,void 0,(function*(){pe()!==bt.None&&(++ze,pe()===bt.QR||pe()===bt.AR?(oe&&!Sn&&qn(),Me()):pe()===bt.Preview&&ie&&!Te()&&ke(),fe(bt.None),"AR"!==l?"3D"!==l||(yield Qe()):yield Be())}));return me(Be,Qe,Ve),"AR"===l?(yield Be(),sr(I(),L)):"3D"===l&&(yield Qe(),sr(I(),L)),rr=!1,{launchAR:J?Be:void 0,launch3D:ie?Qe:void 0,closeAR:J?()=>e(this,void 0,void 0,(function*(){pe()!==bt.AR&&pe()!==bt.QR||(++ze,oe&&!Sn&&qn(),Me(),fe(bt.None),"3D"!==l||(yield Qe()))})):void 0,close3D:ie?()=>e(this,void 0,void 0,(function*(){pe()===bt.Preview&&(++ze,ie&&!Te()&&ke(),fe(bt.None),"AR"!==l||(yield Be()))})):void 0,close:J||ie?Ve:void 0,isInteractive:()=>De(),setInteractive:e=>Oe(e)}}))}function sr(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const lr={setup:function(t){return e(this,void 0,void 0,(function*(){return or(t)}))}},cr={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,r){return e(this,void 0,void 0,(function*(){try{return r()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>ar(n)))}))},version:w};export{Yn as PREVIEW_STATES,t as PluginError,cr as plugin,lr as vision};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR={})}(this,(function(e){"use strict";function t(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const o=[Uint8Array,Uint32Array],r=o.length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],a=[2,12,7,1],s=window[i[a[a[r]]]][i[a[a[a.length-1]]]],l=s.charCodeAt(r),c=l^l,u=new o[1]([c]);function d(){const e=(new TextEncoder).encode(s),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}const h=[1e3,2e3,4e3],p=h.length;function f(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=p)throw t;return yield new Promise((e=>setTimeout(e,h[n]))),f(e,n+1)}}))}function m(e){return e*(180/Math.PI)}function g(e){return Math.round(100*e)/100}const v=["Glasses","Shoes","Watches"],w=["Shoes"];const y="0.7.1";let b=`https://cdn.jsdelivr.net/npm/shopar-plugin@${y}/dist`;const E={update:e=>{null!=e&&(b=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>b};function A(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}let S;const R=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.error('No <meta name="viewport"> detected. This might cause ShopAR to crash on iOS.\nPlease add the following line to your HTML:\n<meta name="viewport" content="width=device-width, initial-scale=1.0">'),()=>e?window.devicePixelRatio:1})();let C,P,T;function x(e){const t=function(e){const t=new P.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,P.ClampToEdgeWrapping,P.ClampToEdgeWrapping,P.LinearFilter,P.LinearFilter,1,P.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(T.parse(e));return t.mapping=P.EquirectangularReflectionMapping,t.colorSpace=P.LinearSRGBColorSpace,t}const I=45,M=45,k=3,L=1.5,U=1,$=.5;let D,_,O,N,j,F=!1;const W=4,q=.001,G=1e-7,z=10,V=11,Q=1/(V-1),K="function"==typeof Float32Array;function B(e,t,n,o){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===o)return ee;const r=K?new Float32Array(V):new Array(V);for(let t=0;t<V;++t)r[t]=Y(t*Q,e,n);function i(t){let o=0,i=1;const a=V-1;for(;i!==a&&r[i]<=t;++i)o+=Q;--i;const s=o+(t-r[i])/(r[i+1]-r[i])*Q,l=J(s,e,n);return l>=q?function(e,t,n,o){for(let r=0;r<W;++r){const r=J(t,n,o);if(0===r)return t;t-=(Y(t,n,o)-e)/r}return t}(t,s,e,n):0===l?s:function(e,t,n,o,r){let i,a,s=0;do{a=t+(n-t)/2,i=Y(a,o,r)-e,i>0?n=a:t=a}while(Math.abs(i)>G&&++s<z);return a}(t,o,o+Q,e,n)}return function(e){return 0===e||1===e?e:Y(i(e),t,o)}}function H(e,t){return 1-3*t+3*e}function X(e,t){return 3*t-6*e}function Z(e){return 3*e}function Y(e,t,n){return((H(t,n)*e+X(t,n))*e+Z(t))*e}function J(e,t,n){return 3*H(t,n)*e*e+2*X(t,n)*e+Z(t)}function ee(e){return e}function te(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=B(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function ne(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:te(n)})));let o=0,r=n[0].value;return{reset:()=>{o=0},update:e=>{for(o+=e;o>=t;)o-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(o>=t.time&&o<i.time){const e=t.interpolate((o-t.time)/(i.time-t.time));r=t.value+e*(i.value-t.value)}}},get:()=>r}}const oe="#",re="time",ie="interpolation",ae="yaw",se="pitch",le="fov",ce=[re,ae,se,le,ie],ue="s",de="ms",he=1e3,pe="deg",fe="rad",me=Math.PI/180,ge="ease-in-out",ve="cubic-bezier(",we=")";function ye(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(oe);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const o=function(e){const t=[];for(let n=0;n<e.length;n++){const o=e[n];if(!ce.includes(o))throw new Error(`Invalid token in header: '${o}'.`);if(t.includes(o))throw new Error(`Duplicate token in header: '${o}'.`);t.push(o)}if(!t.includes(re))throw new Error(`Missing required token: '${re}'.`);return t}(t.split(/\s+/)),r={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:i}=be(o,e);null!=t&&(null==r.theta&&(r.theta=[]),r.theta.push(t)),null!=n&&(null==r.phi&&(r.phi=[]),r.phi.push(n)),null!=i&&(null==r.fov&&(r.fov=[]),r.fov.push(i))}if(0===Object.values(r).length)throw new Error("At least one parameter should be animated.");return r}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const o of e){const{time:e,pitch:r,yaw:i,fov:a}=o;if(null==e)throw new Error("Time missing.");const s=Ae(null!==(t=o.interpolation)&&void 0!==t?t:ge);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*me,interpolation:s})),null!=r&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:r*me,interpolation:s})),null!=a&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:a*me,interpolation:s}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function be(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const o=e.indexOf(re),r=function(e){if(e.endsWith(de))return Re(e.substring(0,e.length-de.length));if(e.endsWith(ue))return Re(e.substring(0,e.length-ue.length))*he;return Re(e)}(n[o]),i=e.indexOf(ie),a=Ae(-1===i?ge:n[i]),s={};for(let t=0;t<n.length;t++){if(t===o||t===i)continue;const l=e[t],c=n[t];switch(l){case ae:s.theta={time:r,value:Ee(c),interpolation:a};break;case se:s.phi={time:r,value:Ee(c),interpolation:a};break;case le:s.fov={time:r,value:Ee(c),interpolation:a};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return s}function Ee(e){return e.endsWith(pe)?Re(e.substring(0,e.length-pe.length))*me:e.endsWith(fe)?Re(e.substring(0,e.length-fe.length)):Re(e)*me}function Ae(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Se(0,0,1,1);if("sine"===e)return Se(.37,0,.63,1);if("sine-in"===e)return Se(.12,0,.39,0);if("sine-out"===e)return Se(.61,1,.88,1);if("ease"===e)return Se(.25,.1,.25,1);if("ease-in"===e)return Se(.42,0,1,1);if("ease-out"===e)return Se(0,0,.58,1);if("ease-in-out"===e)return Se(.42,0,.58,1);if(e.startsWith(ve)&&e.endsWith(we)){const t=e.substring(ve.length,e.length-we.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:Re(t[0]),y1:Re(t[1]),x2:Re(t[2]),y2:Re(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Se(e,t,n,o){return{type:"bezier",x1:e,y1:t,x2:n,y2:o}}function Re(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const Ce=300,Pe=2e3,Te=.05,xe=2*Math.PI/32,Ie=Ae("hold"),Me=Ae("sine"),ke=Ae("sine-in"),Le=Ae("sine-out");let Ue;const $e=0,De=3;let _e,Oe,Ne,je=!1,Fe=1,We=1,qe=1;const Ge=1;let ze;const Ve=new Map;function Qe(e,n,o){const r=e.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,u,d,h,p,f,m,g,v,w,y=!1,b=!1,E=!1,A=!0,S=!1,R=1,U=!0,F=!1,W=0,q=0,G=1,z=1,V=1;const Q={threeInit:()=>{y||(Ke(),i=new Oe.Scene,a=new Oe.PerspectiveCamera(25,1,.5),s=new _e.OrbitControls(a,e),s.setInteractionEnabled(U),h=Oe.ACESFilmicToneMapping,({renderShadow:c,shadowGroup:l}=function(e){const t=new D.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new D.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new D.Group;o.position.y=-.7;const r=new D.PlaneGeometry(I,M).rotateX(Math.PI/2),i=new D.MeshBasicMaterial({map:t.texture,opacity:$,transparent:!0,depthWrite:!1}),a=new D.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new D.Mesh(r);s.visible=!1,o.add(s);const l=new D.OrthographicCamera(-I/2,I/2,M/2,-M/2,0,k);function c(e){s.visible=!0,N.uniforms.tDiffuse.value=t.texture,N.uniforms.h.value=1*e/256,s.material=N,_.setRenderTarget(n),_.render(s,l),j.uniforms.tDiffuse.value=n.texture,j.uniforms.v.value=1*e/256,s.material=j,_.setRenderTarget(t),_.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,o.add(l),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=O;const o=_.getClearAlpha();_.setClearAlpha(0),_.setRenderTarget(t),_.render(e,l),e.overrideMaterial=null,c(L),c(.4*L),_.setRenderTarget(null),_.setClearAlpha(o),e.background=n}}}(i)),y=!0)},threeParse:(e,n,o)=>t(this,void 0,void 0,(function*(){return null!=u&&d===o||(yield u,u=(()=>t(this,void 0,void 0,(function*(){var t,o;return P=(t=_e).THREE,T=new t.RGBELoader,i.environment=x(n),function(e,t){const{THREE:n}=t;C=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder)}(ze,_e),o=e,C.parseAsync(o.buffer,"")})))(),d=o),u})),threeLoad:(e,t)=>{i.traverse((e=>{var t,n;e instanceof Oe.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach((e=>e.dispose())):null===(n=e.material)||void 0===n||n.dispose())})),i.clear(),i.add(e.scene);const n=(new Oe.Box3).setFromObject(e.scene);l.position.y=n.min.y-$e,i.add(l),c(),b=!1,i.traverse((e=>{if(e instanceof Oe.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(b=!0)})):t.transmission>0&&(b=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(_e.reduceVertices(e.scene,((e,t)=>Math.max(e,o.distanceToSquared(t))),0));s.reset(o,r,function(e,t){var n;const o={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?o.Glasses:null!==(n=o[e])&&void 0!==n?n:o.Glasses).normalize()}(t,Oe.Vector3)),W=0},threePaused:()=>A,threeResume:()=>{A=!1,ze.setAnimationLoop(Be),e.style.visibility="visible",q=0,null==f||f.reset(),null==m||m.reset(),null==g||g.reset(),null==v||v.reset(),null==w||w.reset()},threePause:()=>{A=!0,function(){for(const{threePaused:e}of Ve.values())if(!e())return!1;return!0}()&&ze.setAnimationLoop(null),e.style.visibility="hidden",o.style.opacity="0",n.style.visibility="hidden"},threeSetZoomEnabled:e=>{s.enableZoom=e},threeSetForcedTransparency:e=>{E=e},threeSetToneMapping:(e,t)=>{const n={ACES:Oe.ACESFilmicToneMapping,Linear:Oe.LinearToneMapping,Neutral:Oe.NeutralToneMapping};null!=n[e]&&(h=n[e]),R=t},threeIsInteractive:()=>U,threeSetInteractive:e=>{U=e,null==s||s.setInteractionEnabled(U)},threeSetOnInteracted:e=>{s.removeEventListener("change",p),p=e,s.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=s.getTheta(),f=ne([{time:0,value:e,interpolation:Ie},{time:Ce,value:e,interpolation:Le},{time:Ce+Pe/4,value:e+xe,interpolation:Me},{time:Ce+3*Pe/4,value:e-xe,interpolation:ke},{time:Ce+Pe,value:e,interpolation:Ie},{time:Ce+2*Pe,value:e,interpolation:Ie}]),s.setTheta(f.get()),m=null,g=null,v=ne([{time:0,value:0,interpolation:Ie},{time:Ce,value:1,interpolation:Ie},{time:Ce+Pe,value:0,interpolation:Ie},{time:Ce+2*Pe,value:0,interpolation:Ie}]),w=ne([{time:0,value:0,interpolation:Ie},{time:Ce,value:0,interpolation:Le},{time:Ce+Pe/4,value:-Te,interpolation:Me},{time:Ce+3*Pe/4,value:Te,interpolation:ke},{time:Ce+Pe,value:0,interpolation:Ie},{time:Ce+2*Pe,value:0,interpolation:Ie}])},threeInitThetaAnimation:e=>{f=e,null!=e&&s.setTheta(e.get())},threeInitPhiAnimation:e=>{m=e,null!=e&&s.setPhi(e.get())},threeInitFovAnimation:e=>{g=e,null!=e&&s.setFovRadians(e.get())},preRender_:e=>{if(!y||A)return;let t=0!==q?e-q:0;q=e,0===W?S=!0:W<De&&(t=0),W++,F||(s.hasUserInteracted()?(F=!0,f=null,m=null,g=null,v=null,w=null):(null==f||f.update(t),null==m||m.update(t),null==g||g.update(t),null==v||v.update(t),null==w||w.update(t),null!=f&&(s.setTheta(f.get()),S=!0),null!=m&&(s.setPhi(m.get()),S=!0),null!=g&&(s.setFovRadians(g.get()),S=!0))),s.update()&&(S=!0)},shouldRender_:()=>!(!y||A)&&S,render_:()=>{const t=ze.toneMapping,s=ze.toneMappingExposure;ze.toneMapping=h,ze.toneMappingExposure=R,ze.setViewport(0,0,e.width,e.height),ze.setClearColor(new Oe.Color(16777215),b&&!E?1:0),ze.render(i,a),ze.toneMapping=t,ze.toneMappingExposure=s,S=!1,null!=r&&(r.clearRect(0,0,e.width,e.height),Ne.width>0&&Ne.height>0&&r.drawImage(Ne,0,We-e.height,e.width,e.height,0,0,e.width,e.height),n.style.visibility=U&&!F?"visible":"hidden",null!=v&&(o.style.opacity=`${v.get()}`),null!=w&&(o.style.transform=`translateX(${w.get()*Math.min(G,z)}px)`))},updateSize_:()=>{const{clientWidth:t,clientHeight:n}=e;t===G&&n===z&&qe===V||(e.width=Math.ceil(t*qe*Ge),e.height=Math.ceil(n*qe*Ge),G=t,z=n,V=qe,S=!0)},target_:e};return Ve.set(e,Q),Q}function Ke(){if(je)return;_e=window.ShopAR__THREE,Oe=_e.THREE,Ne=document.createElement("canvas");var e,t;Ne.style.position="block",ze=new Oe.WebGLRenderer({powerPreference:"high-performance",canvas:Ne,antialias:!0,alpha:!0}),ze.outputColorSpace=Oe.SRGBColorSpace,ze.toneMapping=Oe.ACESFilmicToneMapping,ze.setClearColor(new Oe.Color(16777215),0),e=ze,t=_e,F||(D=t.THREE,_=e,O=new D.MeshDepthMaterial,O.userData.darkness={value:U},O.onBeforeCompile=e=>{e.uniforms.darkness=O.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},O.depthTest=!1,O.depthWrite=!1,N=new D.ShaderMaterial(t.HorizontalBlurShader),N.depthTest=!1,j=new D.ShaderMaterial(t.VerticalBlurShader),j.depthTest=!1,F=!0),He(),je=!0}function Be(e){He(),ze.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of Ve.values())t(e),n()&&o()}function He(){let e=0,t=0;for(const{target_:n}of Ve.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=R();e=Math.ceil(e*n*Ge),t=Math.ceil(t*n*Ge),e===Fe&&t===We&&n===qe||(Fe=e,We=t,qe=n,ze.setSize(Fe,We,!1));for(const{updateSize_:e}of Ve.values())e()}const Xe={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},Ze=Object.keys(Xe);function Ye(e){return Xe[e]}const Je="shopar-error";function et(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const o=document.createElementNS("http://www.w3.org/2000/svg","image");o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),o.setAttribute("width",e),o.setAttribute("height",e),n.appendChild(o)}return n}function tt(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=et("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;const i=r.style;return i.display="none",i.pointerEvents="auto",r}const nt="shopar-control";const ot="shopar-deepar-output";function rt(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.pointerEvents="auto",n.userSelect="none",t}function it(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function at(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function st(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const lt="shopar-main";const ct="shopar-qr-output";const ut="shopar-three-output";var dt;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(dt||(dt={}));let ht=!1;function pt(){ht||(!function(){try{const e=document.createElement("style"),t=process.env.css;null!=t&&(e.innerHTML=t);const n=document.head;n.insertBefore(e,n.children[0])}catch(e){console.warn("Failed to write default ShopAR Plugin CSS.")}}(),ht=!0)}function ft(){pt();const e=function(){const e=document.createElement("div");e.id=lt;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),o=function(e,t){const n=document.createElement("div");n.id=ct;const o=n.style;o.position="absolute",o.top="0",o.left="0",o.width="100%",o.height="100%",o.display="none",o.pointerEvents="auto",o.userSelect="none";const r=document.createElement("div");r.className="shopar-qr";const i=r.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(r),r.appendChild(e);const a=document.createElement("div");return a.appendChild(t),r.appendChild(a),n}(t,n);e.appendChild(o);const r=function(){const e=document.createElement("div");e.id=ot;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",t.pointerEvents="auto",e}();e.appendChild(r);const i=function(){const e=document.createElement("canvas");e.id=ut,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const a=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),s=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),l=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:o}=n;return o.position="absolute",o.width="100%",o.height="100%",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(a,s);e.appendChild(l);const c=function(){const e=et("2rem",`${E}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),u=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",t.appendChild(e),t}(c);e.appendChild(u);const d=rt("shopar-ar-loading-container"),h=it("shopar-ar-loading-text",Ye("loading.ar"));d.appendChild(h);const p=at("shopar-ar-loading-bar-bg"),f=st("shopar-ar-loading-bar-fg");p.appendChild(f),d.appendChild(p),e.appendChild(d);const m=rt("shopar-3d-loading-container"),g=it("shopar-3d-loading-text",Ye("loading.3d"));m.appendChild(g);const v=at("shopar-3d-loading-bar-bg"),w=st("shopar-3d-loading-bar-fg");v.appendChild(w),m.appendChild(v),e.appendChild(m);const y=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",e}(),b=function(){const e=new Image;e.draggable=!1;const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.objectFit="contain",e}();y.appendChild(b),e.appendChild(y);const A=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),S=function(e){const t=document.createElement("div");t.id=Je;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const o=document.createElement("div"),r=o.style;return r.position="absolute",r.width="100%",r.height="100%",r.backgroundColor="#ffffff",r.display="flex",r.flexDirection="column",r.justifyContent="center",r.alignItems="center",t.appendChild(o),o.appendChild(e),t}(A);e.appendChild(S);const R=function(){const e=document.createElement("div");return e.id=nt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(R);const C=tt("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");R.appendChild(C);const P=tt("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${E}/img/icons/cube.svg`);R.appendChild(P);const T=tt("shopar-btn-close","Close","Close ShopAR view",`${E}/img/icons/close.svg`);R.append(T);let x,I,M=dt.None,k=!1,L=!1,U=!1,$=!1;function D(){f.classList.remove("active"),d.style.visibility="hidden"}function _(){y.style.visibility="hidden",w.classList.remove("active"),m.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return o},getQRImage:function(){return n},getDeepARTarget:function(){return r},getDeepARPrompt:function(){return l},getThreeTarget:function(){return i},getThreePrompt:function(){return u},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){a.textContent=e,s.src=t},customizeCameraError:function(e){A.textContent=null!=e?e:"Please reload page and allow camera access to continue"},customizeQRPrompt:function(e){t.textContent=null!=e?e:"Scan on mobile or tablet to try on"},setVisibilityParameters:function(e,t,n,o,r,i){var a;k=e,L=t,U=n,$=o,x=r,I=i,mt(R,k),mt(C,k&&(U||L)&&M===dt.None),mt(P,k&&$&&M===dt.None),mt(T,k&&M!==dt.None),D(),_(),k||""===(a=S).style.display&&mt(a,!1)},getUIState:function(){return M},setUIState:function(e){M=e,M===dt.None?(D(),_(),k&&(mt(S,!1),mt(T,!1),(L||U)&&mt(C,!0),$&&mt(P,!0))):M===dt.QR||M===dt.AR?k&&(mt(S,!1),mt(C,!1),mt(P,$&&"AR"===I),mt(T,"AR"!==I)):M===dt.Preview&&k&&(mt(S,!1),mt(C,(L||U)&&"3D"===I),mt(P,!1),mt(T,"3D"!==I))},setDefaultUIActions:function(e,t,n){k&&((L||U)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${E}/img/icons/${n}`;C.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(x),C.onclick=e),$&&(P.onclick=t),T.onclick=n)},startDeepARLoading:function(){f.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:D,startThreeLoading:function(){null!=b.dataset.srcSet?y.style.visibility="visible":(w.classList.add("active"),m.style.visibility="visible")},stopThreeLoading:_,setThreePosterUrl:function(e){null!=e?(b.src=e,b.dataset.srcSet="true"):delete b.dataset.srcSet},showCameraError:function(){k&&mt(S,!0)}}}function mt(e,t){e.style.display=t?"":"none"}const gt=new Map;function vt(e){let n=gt.get(e);return null==n?(n=function(){let e=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=ft()),n);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:e,getQRImage:n}=i();o=function(e,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>t(this,void 0,void 0,(function*(){yield S;const t=`https://ar.shopar.ai/${y.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:r,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(t),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,o=!1,e.style.display=""})),qrPause:()=>t(this,void 0,void 0,(function*(){o=!0,e.style.display="none"}))}}(e(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=Qe(e(),t(),n())}return r}}}(),gt.set(e,n)):n.incrementSetupId_(),n}function wt(e){for(const t of gt.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===dt.AR&&r(dt.None)}}let yt;const bt=new Uint8Array(16);function Et(){if(!yt&&(yt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!yt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yt(bt)}const At=[];for(let e=0;e<256;++e)At.push((e+256).toString(16).slice(1));var St={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Rt(e,t,n){if(St.randomUUID&&!t&&!e)return St.randomUUID();const o=(e=e||{}).random||(e.rng||Et)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function(e,t=0){return At[e[t+0]]+At[e[t+1]]+At[e[t+2]]+At[e[t+3]]+"-"+At[e[t+4]]+At[e[t+5]]+"-"+At[e[t+6]]+At[e[t+7]]+"-"+At[e[t+8]]+At[e[t+9]]+"-"+At[e[t+10]]+At[e[t+11]]+At[e[t+12]]+At[e[t+13]]+At[e[t+14]]+At[e[t+15]]}(o)}const Ct="qrLaunch",Pt="arLaunch",Tt="previewLaunch",xt="heartbeat";let It,Mt,kt=!1,Lt=window.navigator.userAgent||"no user agent";const Ut=[];function $t(){null==It&&(Mt=Rt(),It=A(`${E}/shopar-analytics.js`),It.then((()=>{kt=!0,window.ShopAR__analytics.initializeImpl(),Ut.forEach((e=>e()))})))}function Dt(e){kt?e():Ut.push(e)}function _t(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Ot(e){return t(this,void 0,void 0,(function*(){const t=document.createElement("video");return t.setAttribute("playsinline","playsinline"),t.srcObject=yield e,t}))}const Nt=200,jt=10;let Ft=!1,Wt=null,qt=[],Gt=[];function zt(e){return t(this,void 0,void 0,(function*(){Ft=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${E}/wasm/mediapipe`,e),Wt&&clearInterval(Wt);const o=[],r=[];Wt=setInterval((()=>t(this,void 0,void 0,(function*(){if(Ft)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());Ft||(null!=a&&null!=s&&function(e){for(let t of qt)t(e)}({translation:a,rotation:s}),null==e&&(o.push(t),r.push(i),o.length<jt||(o.shift(),r.shift(),function(e,t){for(let n of Gt)n({faceWidth:e,IPD:t})}(Qt(o),Qt(r)))))}))),Nt)}))}function Vt(){Gt=[],qt=[],Ft=!0}function Qt(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}function Kt(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new n("Resource unavailable.")}));if(!t.ok)throw new n(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield o.blob()).arrayBuffer()}catch(e){throw console.error(e),new n("Resource has invalid body.")}}))}var Bt="undefined"!=typeof Float32Array?Float32Array:Array;function Ht(){var e=new Bt(16);return Bt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Xt(e,t,n){var o=t[0],r=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],E=n[2],A=n[3];return e[0]=y*o+b*s+E*d+A*m,e[1]=y*r+b*l+E*h+A*g,e[2]=y*i+b*c+E*p+A*v,e[3]=y*a+b*u+E*f+A*w,y=n[4],b=n[5],E=n[6],A=n[7],e[4]=y*o+b*s+E*d+A*m,e[5]=y*r+b*l+E*h+A*g,e[6]=y*i+b*c+E*p+A*v,e[7]=y*a+b*u+E*f+A*w,y=n[8],b=n[9],E=n[10],A=n[11],e[8]=y*o+b*s+E*d+A*m,e[9]=y*r+b*l+E*h+A*g,e[10]=y*i+b*c+E*p+A*v,e[11]=y*a+b*u+E*f+A*w,y=n[12],b=n[13],E=n[14],A=n[15],e[12]=y*o+b*s+E*d+A*m,e[13]=y*r+b*l+E*h+A*g,e[14]=y*i+b*c+E*p+A*v,e[15]=y*a+b*u+E*f+A*w,e}function Zt(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Yt(e,t){var n=t[0],o=t[1],r=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,u),e}function Jt(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,u=a+a,d=r*l,h=r*c,p=r*u,f=i*c,m=i*u,g=a*u,v=s*l,w=s*c,y=s*u,b=o[0],E=o[1],A=o[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*E,e[5]=(1-(d+g))*E,e[6]=(m+v)*E,e[7]=0,e[8]=(p+w)*A,e[9]=(m-v)*A,e[10]=(1-(d+f))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function en(){var e=new Bt(3);return Bt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function tn(e,t,n){var o=new Bt(3);return o[0]=e,o[1]=t,o[2]=n,o}function nn(e,t){var n=t[0]-e[0],o=t[1]-e[1],r=t[2]-e[2];return Math.hypot(n,o,r)}function on(e,t,n){var o=t[0],r=t[1],i=t[2],a=n[3]*o+n[7]*r+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*o+n[4]*r+n[8]*i+n[12])/a,e[1]=(n[1]*o+n[5]*r+n[9]*i+n[13])/a,e[2]=(n[2]*o+n[6]*r+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function rn(){var e=new Bt(4);return Bt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}en(),function(){var e,t=(e=new Bt(4),Bt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var an;let sn,ln,cn;en(),tn(1,0,0),tn(0,1,0),rn(),rn(),an=new Bt(9),Bt!=Float32Array&&(an[1]=0,an[2]=0,an[3]=0,an[5]=0,an[6]=0,an[7]=0),an[0]=1,an[4]=1,an[8]=1;let un,dn,hn,pn,fn=!0,mn=null;const gn=new Set;let vn,wn,yn,bn,En,An;function Sn(){null==sn&&(sn=A(`${E}/shopar-deepar.js`))}function Rn(){null==ln&&(ln=A(`${E}/shopar-true-scale.js`))}function Cn(e){return t(this,void 0,void 0,(function*(){const{licenseKey:o,truescaleUsecase:r}=e;return En=r,null==vn&&(vn=(()=>t(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new n("No camera available!");var e;const t=$n(hn),r=_t(t);un=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:o||"your_license_key_goes_here",previewElement:pn,additionalOptions:{hint:An,cameraConfig:{disableDefaultCamera:!0}}}),dn=yield Ot(r),yield Dn(un,dn,"user"===t),"Glasses"===hn&&(yield ln,zt(dn),"DetectionLoop"!==En&&jn((e=>{bn=e.faceWidth})))})))()),vn}))}function Pn(e,t){var n,o;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===hn&&(n=t,o=An,n===o||null!=n&&null!=o&&n.length===o.length&&n.every((e=>o.find((t=>e===t))))&&o.every((e=>n.find((t=>t===e))))))||(null!=un&&(un.shutdown(),un=null,vn=null),hn=e,An=t)}function Tn(e){e!==pn&&(pn=e,null!=un&&un.changePreviewElement(pn))}function xn(e){mn=e}function In(e){un.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(bn){const e=137/(bn+5);un.changeParameterVector("GLASSES","","scale",e,e,e,0),un.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const o=On("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=On("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);un.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),un.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return}}(e),Vt(),bn=null}e(),_n("Glasses")}},un.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),_n("Shoes"))},un.callbacks.onWristTracked=t=>{t.detected&&(e(),_n("Watches"))}}function Mn(e,n,o){return t(this,void 0,void 0,(function*(){return null!=wn&&yn===o||(yield wn,wn=un.switchEffect(e,{envmap:n}),yn=o),wn}))}function kn(e,t){null!=e&&null!=t&&(un.setToneMapping(e),un.setExposure(t))}function Ln(){return t(this,void 0,void 0,(function*(){if(null!=un){if(fn=!1,null==dn){const e=$n(hn),t=_t(e);dn=yield Ot(t),yield Dn(un,dn,"user"===e),"Glasses"===hn&&(zt(dn),"DetectionLoop"!==En&&jn((e=>{bn=e.faceWidth})))}!function(){if(null==mn)return;if(null==hn||gn.has(hn))return;mn.style.visibility="visible",mn.style.opacity="1"}(),un.setPaused(fn),pn.style.display=""}}))}function Un(){null!=un&&(fn=!0,un.setPaused(fn),Vt(),null!=dn&&null!=dn.srcObject&&dn.srcObject instanceof MediaStream&&(dn.srcObject.getTracks().forEach((e=>e.stop())),dn=null),function(){if(null==mn)return;mn.style.visibility="hidden",mn.style.opacity="0"}(),un.stopCamera(),pn.style.display="none")}function $n(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function Dn(e,n,o){return t(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>t(this,void 0,void 0,(function*(){e.setVideoElement(n,o),r()}))))}}))}))}function _n(e){null!=mn&&(gn.has(e)||(gn.add(e),mn.style.opacity="0"))}function On(e,t,n,o,r,i,a){const s=un.getTransformationBetween(e,t),l=Zt(en(),s),c=function(e,t){var n=new Bt(3);Yt(n,t);var o=1/n[0],r=1/n[1],i=1/n[2],a=t[0]*o,s=t[1]*r,l=t[2]*i,c=t[4]*o,u=t[5]*r,d=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>u&&a>f?(g=2*Math.sqrt(1+a-u-f),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):u>f?(g=2*Math.sqrt(1+u-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+f-a-u),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(d+p)/g,e[2]=.25*g),e}(rn(),s);Jt(s,c,l,tn(a,a,a));const u=un.getTransformationBetween(t,n),d=Zt(en(),u);Jt(u,rn(),d,Yt(en(),u));const h=Xt(Ht(),s,u),p=Zt(en(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=un.getTransformationBetween(n,o)}catch(e){return f}const g=Xt(Ht(),u,m),v=Xt(Ht(),s,g),w=tn(p[0],i[1],i[2]),y=on(en(),w,function(e,t){var n=t[0],o=t[1],r=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-o*a,y=n*l-r*a,b=n*c-i*a,E=o*l-r*s,A=o*c-i*s,S=r*c-i*l,R=u*m-d*f,C=u*g-h*f,P=u*v-p*f,T=d*g-h*m,x=d*v-p*m,I=h*v-p*g,M=w*I-y*x+b*T+E*P-A*C+S*R;return M?(M=1/M,e[0]=(s*I-l*x+c*T)*M,e[1]=(r*x-o*I-i*T)*M,e[2]=(m*S-g*A+v*E)*M,e[3]=(h*A-d*S-p*E)*M,e[4]=(l*P-a*I-c*C)*M,e[5]=(n*I-r*P+i*C)*M,e[6]=(g*b-f*S-v*y)*M,e[7]=(u*S-h*b+p*y)*M,e[8]=(a*x-s*P+c*R)*M,e[9]=(o*P-n*x-i*R)*M,e[10]=(f*A-m*b+v*w)*M,e[11]=(d*b-u*A-p*w)*M,e[12]=(s*C-a*T-l*R)*M,e[13]=(n*T-o*C+r*R)*M,e[14]=(m*y-f*E-g*w)*M,e[15]=(u*E-d*y+h*w)*M,e):null}(Ht(),v));let b=un.getClosestPointOnMesh(o,y);try{const e=un.getClosestPointOnMesh(r,y);nn(y,e)<nn(y,b)&&(b=e)}catch(e){}const E=on(en(),b,g);return f-Math.atan2(E[0]-d[0],Math.abs(E[2]-d[2]))}function Nn(e){!function(e){qt.push(e)}(e)}function jn(e){!function(e){Gt.push(e)}(e)}var Fn;function Wn(){return[Fn.Android,Fn.iOS,Fn.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],o=["Win32","Win64","Windows","WinCE"],r=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==r.indexOf(t)?Fn.iOS:-1!==n.indexOf(t)?i?Fn.Tablet:Fn.MacOS:-1!==o.indexOf(t)?Fn.Windows:/Android/.test(e)?Fn.Android:/Linux/.test(t)?Fn.Linux:i?Fn.Tablet:Fn.Unknown}return Fn.Unknown}())}function qn(e,r,i){return t(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const l=String.fromCharCode(a+14);s>>=2,a^=s+2;const d=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const p=String.fromCharCode(a-7),m=window[`${h}${d+l+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${p}`],g=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield m(`${e}`).catch((()=>{throw new n("Unknown error.")}));if(!t.ok)throw new n("Unknown error.");return t})))),v=new o[0](yield(yield g.blob().catch((()=>{throw new n("Unknown error.")}))).arrayBuffer().catch((()=>{throw new n("Unknown error.")})));i+=s;const w=v.byteLength;if(u[c]=Math.min(76,r)*((a>>5)-1),152===u[c]&&(u[c]=w),i==c)return v;i=c,i^=c;for(let e=0,t=v.length;e<t;e++)u[c]^=u[i]<<13,u[c]^=u[i]>>17,u[c]^=u[i]<<5,v[e]=v[e]^u[c];return i^=u[0],i^=u[1],i^=u[2],v}))}!function(e){e[e.Unknown=0]="Unknown",e[e.Android=1]="Android",e[e.iOS=2]="iOS",e[e.Tablet=3]="Tablet",e[e.MacOS=4]="MacOS",e[e.Windows=5]="Windows",e[e.Linux=6]="Linux"}(Fn||(Fn={}));const Gn=["AR","3D"];function zn(e,t){if(null==e)throw new n(`'${t}' not specified.`)}function Vn(e,t){if("boolean"!=typeof e)throw new n(`'${t}' must be a boolean.`)}function Qn(e,t){if("string"!=typeof e)throw new n(`'${t}' must be a string.`)}function Kn(e){const{apiKey:t,sku:o,targetElement:r,initialState:i,initialAnimation:a,baseUrl:s,defaultUI:l,interactive:c,strings:u}=e;zn(t,"apiKey"),Qn(t,"apiKey"),zn(o,"sku"),Qn(o,"sku"),zn(r,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new n(`'${t}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,t,o){if("string"!=typeof e)throw new n(`'${t}' must be a string.`);if(!o.includes(e))throw new n(`'${t}' must be ${o.join("' or '")}.`)}(i,"initialState",Gn),null!=a&&function(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new n(`'${t}' must be a string or array.`)}(a,"initialAnimation"),null!=s&&Qn(s,"baseUrl"),null!=l&&Vn(l,"defaultUI"),null!=c&&Vn(c,"interactive"),null!=u&&function(e,t,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new n(`Value for key '${r}' in '${t}' must be a string.`)}}(u,"strings",Ze)}let Bn=!1;function Hn(e){return t(this,void 0,void 0,(function*(){const{targetElement:o}=e;E.update(e.baseUrl),$t();const{trackEvent:r}=function(e){const t=performance.now(),n=Rt();return{trackEvent:(o,r={})=>{r=Object.assign(Object.assign({},r),{pluginVersion:y,userAgent:Lt,sessionId:Mt,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),Dt((()=>{window.ShopAR__analytics.trackEventImpl(o,r)}))}}}(e.apiKey);r("visionSetup");const i=yield function(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:e,sid:d()})}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield o.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(e.apiKey);r("visionApiResponse",i);const{arKey:a}=i,s=vt(o),{getSetupId:l,findUI:c}=s,u=l();Sn(),Rn();const{setTargetElement:h,getDeepARTarget:p,setVisibilityParameters:m,getUIState:g,setUIState:v,startDeepARLoading:w,stopDeepARLoading:b,showCameraError:A}=c();if(g()!=dt.None)throw Error("UI state is not None, this is weird..");v(dt.AR),h(o),m(!1,!1,!0,!1,void 0,void 0),w(),yield sn,Xn(l(),u);try{r("visionArLaunch"),Un(),Pn("Glasses",["faceInit"]),Tn(p()),yield Cn({licenseKey:a,truescaleUsecase:"DetectionLoop"}),Xn(l(),u),yield Ln(),Xn(l(),u)}catch(e){const t=e instanceof Error;throw r("visionArLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),A(),Un(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{b()}return Bn=!0,{registerFacePoseListener:e=>{Bn&&(r("registerFacePoseListener"),Nn(e))},registerFaceMeasurementListener:e=>{Bn&&(r("registerFaceMeasurementListener"),jn(e))},switchEffect:e=>t(this,void 0,void 0,(function*(){Bn&&(r("switchEffect",{arUrl:e}),function(e){un.switchEffect(e)}(e))})),clearEffect:()=>{Bn&&(r("clearEffect"),un.clearEffect())},close:()=>{if(Bn){if(Bn=!1,r("visionClose"),g()!==dt.AR)throw new n("AR not launched.");Un(),v(dt.None)}}}}))}function Xn(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}function Zn(e){var o,r;return t(this,void 0,void 0,(function*(){Kn(e);const{apiKey:i,sku:a,targetElement:s,initialState:l,initialAnimation:c}=e,u=null==e.zoomEnabled||e.zoomEnabled,h=!0===e.alwaysTransparentBackground;!function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new n(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(s),E.update(e.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(Xe,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(Xe[t]=n)}}(e.strings);const p=null!=c?ye(c):null,b=null!=(null==p?void 0:p.theta)?ne(p.theta):null,R=null!=(null==p?void 0:p.phi)?ne(p.phi):null,C=null!=(null==p?void 0:p.fov)?ne(p.fov):null,P=function(e,o,r,i,a,s){return t(this,void 0,void 0,(function*(){const l=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:e,sku:o,sid:d()},null!=r&&{yaw:`${g(m(r))}`}),null!=i&&{pitch:`${g(m(i))}`}),null!=a&&{fov:`${g(m(a))}`}),s&&{forcedTransparency:`${s}`}))}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield l.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(i,a,null==b?void 0:b.get(),null==R?void 0:R.get(),null==C?void 0:C.get(),h),T=vt(s),{getSetupId:x,findUI:I,findQR:M,findThree:k}=T,L=x();$t();const{trackEvent:U,arInteracted:$,previewInteracted:D}=function(e,t){const n=performance.now(),o=Rt();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,u(xt,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const u=(r,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:Lt,pluginVersion:y,sessionId:Mt,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),Dt((()=>{window.ShopAR__analytics.trackEventImpl(r,i)}))};return{trackEvent:u,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}(a,i);U("setup",{hostname:window.location.hostname});const _=yield P;U("apiResponse",_);const{category:O,arUrl:N,arEnvUrl:j,arToneMapping:F,arToneMappingExposure:W,arKey:q,arPromptEnabled:G,arPromptText:z,arPromptImage:V,previewUrl:Q,previewEnvUrl:K,previewToneMapping:B,previewToneMappingExposure:H,previewPosterUrl:X,cameraErrorText:Z,qrPromptText:Y}=_;Yn(x(),L);const J=null!=N&&function(e){return null!=e&&v.includes(e)}(O),ee=null==(null===(o=e._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=e._internalOptions)||void 0===r?void 0:r.qrEnabled),te=J&&function(e){return null!=e&&w.includes(e)}(O),oe=ee&&te&&!Wn(),re=J&&!oe,ie=null!=Q;if(Yn(x(),L),oe&&function(){t(this,void 0,void 0,(function*(){null==S&&(S=A(`${E}/shopar-qr.js`))}))}(),re&&(Sn(),function(e){e!==cn&&(cn=e,Kt(e),wn=null,Vt())}(N),"Glasses"===O&&Rn(),null!=j&&Kt(j)),ie){null==Ue&&(Ue=A(`${E}/shopar-three.js`));const e=255;qn(Q,(new Date).getTime()+e,Math.random()*e),Kt(null!=K?K:`${E}/env/default.hdr`)}const{setTargetElement:ae,getDeepARTarget:se,getDeepARPrompt:le,customizeDeepARPrompt:ce,customizeCameraError:ue,customizeQRPrompt:de,setVisibilityParameters:he,getUIState:pe,setUIState:fe,setDefaultUIActions:me,startDeepARLoading:ge,stopDeepARLoading:ve,startThreeLoading:we,stopThreeLoading:be,setThreePosterUrl:Ee,showCameraError:Ae}=I();ae(s);he(null==e.defaultUI||e.defaultUI,oe,re,ie,O,l),ce(null!=z?z:"",null!=V?V:""),ue(Z),de(Y),Ee(X),function(e,t){const o=e.parentNode;if(null==o)throw new n("Parent node missing.");new MutationObserver((n=>{for(const o of n)for(const n of o.removedNodes)if(n===e)return void t()})).observe(o,{childList:!0})}(s,(()=>{pe()!==dt.QR||Se()||Ce(),pe()!==dt.AR||fn||Un(),pe()!==dt.Preview||Ie()||ke(),fe(dt.None)}));const{qrPaused:Se,qrDraw:Re,qrPause:Ce}=M(),{threeInit:Pe,threeParse:Te,threeLoad:xe,threePaused:Ie,threeResume:Me,threePause:ke,threeSetZoomEnabled:Le,threeSetForcedTransparency:$e,threeSetToneMapping:De,threeIsInteractive:_e,threeSetInteractive:Oe,threeSetOnInteracted:Ne,threeInitPromptAnimation:je,threeInitThetaAnimation:Fe,threeInitPhiAnimation:We,threeInitFovAnimation:qe}=k(),Ge=null==e.interactive||e.interactive;Oe(Ge);let ze=0;if(pe()===dt.QR){if(!Se())if(oe){U(Ct);try{yield Re(i,a)}catch(e){throw new n(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else Ce(),fe(dt.None)}else if(pe()===dt.AR){if(!fn)if(re&&!Bn){U(Pt);const e=null!=j?yield Kt(j):void 0;Yn(x(),L);const t=yield Kt(N);Yn(x(),L),wt(T),Pn(O),Tn(se()),xn(G?le():null),yield Mn(t,e,`${N}${j}`),kn(F,W),In($),Yn(x(),L)}else Un(),fe(dt.None)}else if(pe()===dt.Preview&&!Ie())if(ie){U(Tt),we();const e=255,t=yield qn(Q,(new Date).getTime()+e,Math.random()*e);Yn(x(),L);const n=yield Kt(null!=K?K:`${E}/env/default.hdr`);Yn(x(),L);const o=yield Te(t,n,`${Q}${K}`);Yn(x(),L),xe(o,O),Le(u),$e(h),De(null!=B?B:"ACES",null!=H?H:1),Ne(D),je(),null!=p&&(Fe(b),We(R),qe(C)),be()}else ke(),fe(dt.None);const Ve=()=>t(this,void 0,void 0,(function*(){if(oe){if(pe()===dt.QR||pe()===dt.AR)return;try{U(Ct);const e=++ze;if(pe()===dt.Preview&&ie&&!Ie()&&ke(),fe(dt.QR),yield Re(i,a),ze!==e)return;return void Yn(x(),L)}catch(e){const t=e instanceof Error;throw U("qrLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`QR failed: ${t?e.message:"Unknown error."}`)}}if(!re)throw new n("Model does not have AR enabled.");if(pe()!==dt.AR)try{U(Pt);const e=++ze;pe()===dt.Preview&&ie&&!Ie()&&ke(),wt(T),fe(dt.AR),ge();const t=null!=j?yield Kt(j):void 0;Yn(x(),L);const n=yield Kt(N);if(ze!==e)return;if(Yn(x(),L),yield sn,ze!==e)return;if(Yn(x(),L),Un(),Pn(O),Tn(se()),xn(G?le():null),yield Cn({licenseKey:q}),ze!==e)return;if(Yn(x(),L),yield Mn(n,t,`${N}${j}`),kn(F,W),In($),ze!==e)return;if(Yn(x(),L),yield Ln(),ze!==e)return;Yn(x(),L)}catch(e){const t=e instanceof Error;throw U("arLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),Ae(),Un(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{ve()}})),Qe=()=>t(this,void 0,void 0,(function*(){if(!ie)throw new n("Model does not have 3D enabled.");if(pe()!==dt.Preview)try{U(Tt);const e=++ze;pe()===dt.AR&&(re&&!fn&&Un(),Ce()),fe(dt.Preview),we();const t=255,n=yield qn(Q,(new Date).getTime()+t,Math.random()*t);if(ze!==e)return;Yn(x(),L);const o=yield Kt(null!=K?K:`${E}/env/default.hdr`);if(ze!==e)return;if(Yn(x(),L),yield Ue,ze!==e)return;if(Yn(x(),L),Pe(),ze!==e)return;Yn(x(),L);const r=yield Te(n,o,`${Q}${K}`);if(ze!==e)return;Yn(x(),L),xe(r,O),Le(u),$e(h),De(null!=B?B:"ACES",null!=H?H:1),Ne(D),je(),null!=p&&(Fe(b),We(R),qe(C)),Me()}catch(e){const t=e instanceof Error;throw U("previewLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`3D failed: ${t?e.message:"Unknown error."}`)}finally{be()}})),Ke=()=>t(this,void 0,void 0,(function*(){pe()!==dt.None&&(++ze,pe()===dt.QR||pe()===dt.AR?(re&&!fn&&Un(),Ce()):pe()===dt.Preview&&ie&&!Ie()&&ke(),fe(dt.None),"AR"!==l?"3D"!==l||(yield Qe()):yield Ve())}));return me(Ve,Qe,Ke),"AR"===l?(yield Ve(),Yn(x(),L)):"3D"===l&&(yield Qe(),Yn(x(),L)),Bn=!1,{launchAR:J?Ve:void 0,launch3D:ie?Qe:void 0,closeAR:J?()=>t(this,void 0,void 0,(function*(){pe()!==dt.AR&&pe()!==dt.QR||(++ze,re&&!fn&&Un(),Ce(),fe(dt.None),"3D"!==l||(yield Qe()))})):void 0,close3D:ie?()=>t(this,void 0,void 0,(function*(){pe()===dt.Preview&&(++ze,ie&&!Ie()&&ke(),fe(dt.None),"AR"!==l||(yield Ve()))})):void 0,close:J||ie?Ke:void 0,isInteractive:()=>_e(),setInteractive:e=>Oe(e)}}))}function Yn(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}const Jn={setup:function(e){return t(this,void 0,void 0,(function*(){return Hn(e)}))}},eo={setup:function(e){return t(this,void 0,void 0,(function*(){return function(e,o){return t(this,void 0,void 0,(function*(){try{return o()}catch(t){throw t instanceof Error?new n(`${e} failed: ${t.message}`):(console.error(t),new n(`${e} failed.`))}}))}("setup",(()=>Zn(e)))}))},version:y};e.PREVIEW_STATES=Gn,e.PluginError=n,e.plugin=eo,e.vision=Jn}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR={})}(this,(function(e){"use strict";function t(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const o=[Uint8Array,Uint32Array],r=o.length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],a=[2,12,7,1],s=window[i[a[a[r]]]][i[a[a[a.length-1]]]],l=s.charCodeAt(r),c=l^l,u=new o[1]([c]);function d(){const e=(new TextEncoder).encode(s),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}const h=[1e3,2e3,4e3],p=h.length;function f(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=p)throw t;return yield new Promise((e=>setTimeout(e,h[n]))),f(e,n+1)}}))}function m(e){return e*(180/Math.PI)}function g(e){return Math.round(100*e)/100}const v=["Glasses","Shoes","Watches"],w=["Shoes"];const y="0.7.2-alpha.0";let b=`https://cdn.jsdelivr.net/npm/shopar-plugin@${y}/dist`;const E={update:e=>{null!=e&&(b=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>b};function A(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}let S;const R=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.error('No <meta name="viewport"> detected. This might cause ShopAR to crash on iOS.\nPlease add the following line to your HTML:\n<meta name="viewport" content="width=device-width, initial-scale=1.0">'),()=>e?window.devicePixelRatio:1})();let T,M,P;function C(e){const t=function(e){const t=new M.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,M.ClampToEdgeWrapping,M.ClampToEdgeWrapping,M.LinearFilter,M.LinearFilter,1,M.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(P.parse(e));return t.mapping=M.EquirectangularReflectionMapping,t.colorSpace=M.LinearSRGBColorSpace,t}const I=45,x=45,k=3,L=1.5,U=1,$=.5;let D,O,_,N,j,F=!1;const W=4,q=.001,G=1e-7,z=10,V=11,B=1/(V-1),Q="function"==typeof Float32Array;function K(e,t,n,o){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===o)return ee;const r=Q?new Float32Array(V):new Array(V);for(let t=0;t<V;++t)r[t]=Y(t*B,e,n);function i(t){let o=0,i=1;const a=V-1;for(;i!==a&&r[i]<=t;++i)o+=B;--i;const s=o+(t-r[i])/(r[i+1]-r[i])*B,l=J(s,e,n);return l>=q?function(e,t,n,o){for(let r=0;r<W;++r){const r=J(t,n,o);if(0===r)return t;t-=(Y(t,n,o)-e)/r}return t}(t,s,e,n):0===l?s:function(e,t,n,o,r){let i,a,s=0;do{a=t+(n-t)/2,i=Y(a,o,r)-e,i>0?n=a:t=a}while(Math.abs(i)>G&&++s<z);return a}(t,o,o+B,e,n)}return function(e){return 0===e||1===e?e:Y(i(e),t,o)}}function H(e,t){return 1-3*t+3*e}function X(e,t){return 3*t-6*e}function Z(e){return 3*e}function Y(e,t,n){return((H(t,n)*e+X(t,n))*e+Z(t))*e}function J(e,t,n){return 3*H(t,n)*e*e+2*X(t,n)*e+Z(t)}function ee(e){return e}function te(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=K(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function ne(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:te(n)})));let o=0,r=n[0].value;return{reset:()=>{o=0},update:e=>{for(o+=e;o>=t;)o-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(o>=t.time&&o<i.time){const e=t.interpolate((o-t.time)/(i.time-t.time));r=t.value+e*(i.value-t.value)}}},get:()=>r}}const oe="#",re="time",ie="interpolation",ae="yaw",se="pitch",le="fov",ce=[re,ae,se,le,ie],ue="s",de="ms",he=1e3,pe="deg",fe="rad",me=Math.PI/180,ge="ease-in-out",ve="cubic-bezier(",we=")";function ye(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(oe);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const o=function(e){const t=[];for(let n=0;n<e.length;n++){const o=e[n];if(!ce.includes(o))throw new Error(`Invalid token in header: '${o}'.`);if(t.includes(o))throw new Error(`Duplicate token in header: '${o}'.`);t.push(o)}if(!t.includes(re))throw new Error(`Missing required token: '${re}'.`);return t}(t.split(/\s+/)),r={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:i}=be(o,e);null!=t&&(null==r.theta&&(r.theta=[]),r.theta.push(t)),null!=n&&(null==r.phi&&(r.phi=[]),r.phi.push(n)),null!=i&&(null==r.fov&&(r.fov=[]),r.fov.push(i))}if(0===Object.values(r).length)throw new Error("At least one parameter should be animated.");return r}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const o of e){const{time:e,pitch:r,yaw:i,fov:a}=o;if(null==e)throw new Error("Time missing.");const s=Ae(null!==(t=o.interpolation)&&void 0!==t?t:ge);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*me,interpolation:s})),null!=r&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:r*me,interpolation:s})),null!=a&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:a*me,interpolation:s}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function be(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const o=e.indexOf(re),r=function(e){if(e.endsWith(de))return Re(e.substring(0,e.length-de.length));if(e.endsWith(ue))return Re(e.substring(0,e.length-ue.length))*he;return Re(e)}(n[o]),i=e.indexOf(ie),a=Ae(-1===i?ge:n[i]),s={};for(let t=0;t<n.length;t++){if(t===o||t===i)continue;const l=e[t],c=n[t];switch(l){case ae:s.theta={time:r,value:Ee(c),interpolation:a};break;case se:s.phi={time:r,value:Ee(c),interpolation:a};break;case le:s.fov={time:r,value:Ee(c),interpolation:a};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return s}function Ee(e){return e.endsWith(pe)?Re(e.substring(0,e.length-pe.length))*me:e.endsWith(fe)?Re(e.substring(0,e.length-fe.length)):Re(e)*me}function Ae(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Se(0,0,1,1);if("sine"===e)return Se(.37,0,.63,1);if("sine-in"===e)return Se(.12,0,.39,0);if("sine-out"===e)return Se(.61,1,.88,1);if("ease"===e)return Se(.25,.1,.25,1);if("ease-in"===e)return Se(.42,0,1,1);if("ease-out"===e)return Se(0,0,.58,1);if("ease-in-out"===e)return Se(.42,0,.58,1);if(e.startsWith(ve)&&e.endsWith(we)){const t=e.substring(ve.length,e.length-we.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:Re(t[0]),y1:Re(t[1]),x2:Re(t[2]),y2:Re(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Se(e,t,n,o){return{type:"bezier",x1:e,y1:t,x2:n,y2:o}}function Re(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const Te=300,Me=2e3,Pe=.05,Ce=2*Math.PI/32,Ie=Ae("hold"),xe=Ae("sine"),ke=Ae("sine-in"),Le=Ae("sine-out");const Ue=8,$e=2*Math.PI,De=$e/12,Oe=$e/60,_e=$e/60,Ne=60,je=60,Fe=1e3,We=Ne*je,qe=-1;let Ge;const ze=0,Ve=3;let Be,Qe,Ke,He=!1,Xe=1,Ze=1,Ye=1;const Je=1;let et;const tt=new Map;function nt(e,n,o){const r=e.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,u,d,h,p,f,m,g,v,w,y,b=!1,E=!1,A=!1,S=!0,R=!1,U=1,F=!0,W=!1,q=0,G=0,z=1,V=1,B=1;const Q={threeInit:()=>{b||(ot(),i=new Qe.Scene,a=new Qe.PerspectiveCamera(25,1,.5),s=new Be.OrbitControls(a,e),s.setInteractionEnabled(F),h=Qe.ACESFilmicToneMapping,({renderShadow:c,shadowGroup:l}=function(e){const t=new D.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new D.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new D.Group;o.position.y=-.7;const r=new D.PlaneGeometry(I,x).rotateX(Math.PI/2),i=new D.MeshBasicMaterial({map:t.texture,opacity:$,transparent:!0,depthWrite:!1}),a=new D.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new D.Mesh(r);s.visible=!1,o.add(s);const l=new D.OrthographicCamera(-I/2,I/2,x/2,-x/2,0,k);function c(e){s.visible=!0,N.uniforms.tDiffuse.value=t.texture,N.uniforms.h.value=1*e/256,s.material=N,O.setRenderTarget(n),O.render(s,l),j.uniforms.tDiffuse.value=n.texture,j.uniforms.v.value=1*e/256,s.material=j,O.setRenderTarget(t),O.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,o.add(l),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=_;const o=O.getClearAlpha();O.setClearAlpha(0),O.setRenderTarget(t),O.render(e,l),e.overrideMaterial=null,c(L),c(.4*L),O.setRenderTarget(null),O.setClearAlpha(o),e.background=n}}}(i)),b=!0)},threeParse:(e,n,o)=>t(this,void 0,void 0,(function*(){return null!=u&&d===o||(yield u,u=(()=>t(this,void 0,void 0,(function*(){var t,o;return M=(t=Be).THREE,P=new t.RGBELoader,i.environment=C(n),function(e,t){const{THREE:n}=t;T=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder)}(et,Be),o=e,T.parseAsync(o.buffer,"")})))(),d=o),u})),threeLoad:(e,t)=>{i.traverse((e=>{var t,n;e instanceof Qe.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach((e=>e.dispose())):null===(n=e.material)||void 0===n||n.dispose())})),i.clear(),i.add(e.scene);const n=(new Qe.Box3).setFromObject(e.scene);l.position.y=n.min.y-ze,i.add(l),c(),E=!1,i.traverse((e=>{if(e instanceof Qe.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(E=!0)})):t.transmission>0&&(E=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(Be.reduceVertices(e.scene,((e,t)=>Math.max(e,o.distanceToSquared(t))),0));s.reset(o,r,function(e,t){var n;const o={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?o.Glasses:null!==(n=o[e])&&void 0!==n?n:o.Glasses).normalize()}(t,Qe.Vector3)),q=0,y="Watches"===t?function(e){const t=e.getObjectByName("hours"),n=e.getObjectByName("minutes"),o=e.getObjectByName("seconds");if(null==t&&null==n&&null==o)return null;let r=new Date;return{update:()=>{const e=new Date;if(Math.abs(e.getTime()-r.getTime())<Fe/Ue)return!1;r=e;const i=e.getHours(),a=e.getMinutes(),s=e.getSeconds(),l=e.getMilliseconds();return null!=t&&(t.rotation.y=qe*De*(i+a/Ne+s/We)),null!=n&&(n.rotation.y=qe*Oe*(a+s/je)),null!=o&&(o.rotation.y=qe*_e*(s+l/Fe)),!0}}}(e.scene):null},threePaused:()=>S,threeResume:()=>{S=!1,et.setAnimationLoop(rt),e.style.visibility="visible",G=0,null==f||f.reset(),null==m||m.reset(),null==g||g.reset(),null==v||v.reset(),null==w||w.reset()},threePause:()=>{S=!0,function(){for(const{threePaused:e}of tt.values())if(!e())return!1;return!0}()&&et.setAnimationLoop(null),e.style.visibility="hidden",o.style.opacity="0",n.style.visibility="hidden"},threeSetZoomEnabled:e=>{s.enableZoom=e},threeSetForcedTransparency:e=>{A=e},threeSetToneMapping:(e,t)=>{const n={ACES:Qe.ACESFilmicToneMapping,Linear:Qe.LinearToneMapping,Neutral:Qe.NeutralToneMapping};null!=n[e]&&(h=n[e]),U=t},threeIsInteractive:()=>F,threeSetInteractive:e=>{F=e,null==s||s.setInteractionEnabled(F)},threeSetOnInteracted:e=>{s.removeEventListener("change",p),p=e,s.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=s.getTheta(),f=ne([{time:0,value:e,interpolation:Ie},{time:Te,value:e,interpolation:Le},{time:Te+Me/4,value:e+Ce,interpolation:xe},{time:Te+3*Me/4,value:e-Ce,interpolation:ke},{time:Te+Me,value:e,interpolation:Ie},{time:Te+2*Me,value:e,interpolation:Ie}]),s.setTheta(f.get()),m=null,g=null,v=ne([{time:0,value:0,interpolation:Ie},{time:Te,value:1,interpolation:Ie},{time:Te+Me,value:0,interpolation:Ie},{time:Te+2*Me,value:0,interpolation:Ie}]),w=ne([{time:0,value:0,interpolation:Ie},{time:Te,value:0,interpolation:Le},{time:Te+Me/4,value:-Pe,interpolation:xe},{time:Te+3*Me/4,value:Pe,interpolation:ke},{time:Te+Me,value:0,interpolation:Ie},{time:Te+2*Me,value:0,interpolation:Ie}])},threeInitThetaAnimation:e=>{f=e,null!=e&&s.setTheta(e.get())},threeInitPhiAnimation:e=>{m=e,null!=e&&s.setPhi(e.get())},threeInitFovAnimation:e=>{g=e,null!=e&&s.setFovRadians(e.get())},preRender_:e=>{if(!b||S)return;let t=0!==G?e-G:0;G=e,0===q?R=!0:q<Ve&&(t=0),q++,W||(s.hasUserInteracted()?(W=!0,f=null,m=null,g=null,v=null,w=null):(null==f||f.update(t),null==m||m.update(t),null==g||g.update(t),null==v||v.update(t),null==w||w.update(t),null!=f&&(s.setTheta(f.get()),R=!0),null!=m&&(s.setPhi(m.get()),R=!0),null!=g&&(s.setFovRadians(g.get()),R=!0))),s.update()&&(R=!0),(null==y?void 0:y.update())&&(R=!0)},shouldRender_:()=>!(!b||S)&&R,render_:()=>{const t=et.toneMapping,s=et.toneMappingExposure;et.toneMapping=h,et.toneMappingExposure=U,et.setViewport(0,0,e.width,e.height),et.setClearColor(new Qe.Color(16777215),E&&!A?1:0),et.render(i,a),et.toneMapping=t,et.toneMappingExposure=s,R=!1,null!=r&&(r.clearRect(0,0,e.width,e.height),Ke.width>0&&Ke.height>0&&r.drawImage(Ke,0,Ze-e.height,e.width,e.height,0,0,e.width,e.height),n.style.visibility=F&&!W?"visible":"hidden",null!=v&&(o.style.opacity=`${v.get()}`),null!=w&&(o.style.transform=`translateX(${w.get()*Math.min(z,V)}px)`))},updateSize_:()=>{const{clientWidth:t,clientHeight:n}=e;t===z&&n===V&&Ye===B||(e.width=Math.ceil(t*Ye*Je),e.height=Math.ceil(n*Ye*Je),z=t,V=n,B=Ye,R=!0)},target_:e};return tt.set(e,Q),Q}function ot(){if(He)return;Be=window.ShopAR__THREE,Qe=Be.THREE,Ke=document.createElement("canvas");var e,t;Ke.style.position="block",et=new Qe.WebGLRenderer({powerPreference:"high-performance",canvas:Ke,antialias:!0,alpha:!0}),et.outputColorSpace=Qe.SRGBColorSpace,et.toneMapping=Qe.ACESFilmicToneMapping,et.setClearColor(new Qe.Color(16777215),0),e=et,t=Be,F||(D=t.THREE,O=e,_=new D.MeshDepthMaterial,_.userData.darkness={value:U},_.onBeforeCompile=e=>{e.uniforms.darkness=_.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},_.depthTest=!1,_.depthWrite=!1,N=new D.ShaderMaterial(t.HorizontalBlurShader),N.depthTest=!1,j=new D.ShaderMaterial(t.VerticalBlurShader),j.depthTest=!1,F=!0),it(),He=!0}function rt(e){it(),et.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of tt.values())t(e),n()&&o()}function it(){let e=0,t=0;for(const{target_:n}of tt.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=R();e=Math.ceil(e*n*Je),t=Math.ceil(t*n*Je),e===Xe&&t===Ze&&n===Ye||(Xe=e,Ze=t,Ye=n,et.setSize(Xe,Ze,!1));for(const{updateSize_:e}of tt.values())e()}const at={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},st=Object.keys(at);function lt(e){return at[e]}const ct="shopar-error";function ut(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const o=document.createElementNS("http://www.w3.org/2000/svg","image");o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),o.setAttribute("width",e),o.setAttribute("height",e),n.appendChild(o)}return n}function dt(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=ut("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;const i=r.style;return i.display="none",i.pointerEvents="auto",r}const ht="shopar-control";const pt="shopar-deepar-output";function ft(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.pointerEvents="auto",n.userSelect="none",t}function mt(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function gt(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function vt(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const wt="shopar-main";const yt="shopar-qr-output";const bt="shopar-three-output";var Et;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(Et||(Et={}));let At=!1;function St(){At||(!function(){try{const e=document.createElement("style"),t=process.env.css;null!=t&&(e.innerHTML=t);const n=document.head;n.insertBefore(e,n.children[0])}catch(e){console.warn("Failed to write default ShopAR Plugin CSS.")}}(),At=!0)}function Rt(){St();const e=function(){const e=document.createElement("div");e.id=wt;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),o=function(e,t){const n=document.createElement("div");n.id=yt;const o=n.style;o.position="absolute",o.top="0",o.left="0",o.width="100%",o.height="100%",o.display="none",o.pointerEvents="auto",o.userSelect="none";const r=document.createElement("div");r.className="shopar-qr";const i=r.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(r),r.appendChild(e);const a=document.createElement("div");return a.appendChild(t),r.appendChild(a),n}(t,n);e.appendChild(o);const r=function(){const e=document.createElement("div");e.id=pt;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",t.pointerEvents="auto",e}();e.appendChild(r);const i=function(){const e=document.createElement("canvas");e.id=bt,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const a=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),s=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),l=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:o}=n;return o.position="absolute",o.width="100%",o.height="100%",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(a,s);e.appendChild(l);const c=function(){const e=ut("2rem",`${E}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),u=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",t.appendChild(e),t}(c);e.appendChild(u);const d=ft("shopar-ar-loading-container"),h=mt("shopar-ar-loading-text",lt("loading.ar"));d.appendChild(h);const p=gt("shopar-ar-loading-bar-bg"),f=vt("shopar-ar-loading-bar-fg");p.appendChild(f),d.appendChild(p),e.appendChild(d);const m=ft("shopar-3d-loading-container"),g=mt("shopar-3d-loading-text",lt("loading.3d"));m.appendChild(g);const v=gt("shopar-3d-loading-bar-bg"),w=vt("shopar-3d-loading-bar-fg");v.appendChild(w),m.appendChild(v),e.appendChild(m);const y=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",e}(),b=function(){const e=new Image;e.draggable=!1;const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.objectFit="contain",e}();y.appendChild(b),e.appendChild(y);const A=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),S=function(e){const t=document.createElement("div");t.id=ct;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const o=document.createElement("div"),r=o.style;return r.position="absolute",r.width="100%",r.height="100%",r.backgroundColor="#ffffff",r.display="flex",r.flexDirection="column",r.justifyContent="center",r.alignItems="center",t.appendChild(o),o.appendChild(e),t}(A);e.appendChild(S);const R=function(){const e=document.createElement("div");return e.id=ht,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(R);const T=dt("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");R.appendChild(T);const M=dt("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${E}/img/icons/cube.svg`);R.appendChild(M);const P=dt("shopar-btn-close","Close","Close ShopAR view",`${E}/img/icons/close.svg`);R.append(P);let C,I,x=Et.None,k=!1,L=!1,U=!1,$=!1;function D(){f.classList.remove("active"),d.style.visibility="hidden"}function O(){y.style.visibility="hidden",w.classList.remove("active"),m.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return o},getQRImage:function(){return n},getDeepARTarget:function(){return r},getDeepARPrompt:function(){return l},getThreeTarget:function(){return i},getThreePrompt:function(){return u},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){a.textContent=e,s.src=t},customizeCameraError:function(e){A.textContent=null!=e?e:"Please reload page and allow camera access to continue"},customizeQRPrompt:function(e){t.textContent=null!=e?e:"Scan on mobile or tablet to try on"},setVisibilityParameters:function(e,t,n,o,r,i){var a;k=e,L=t,U=n,$=o,C=r,I=i,Tt(R,k),Tt(T,k&&(U||L)&&x===Et.None),Tt(M,k&&$&&x===Et.None),Tt(P,k&&x!==Et.None),D(),O(),k||""===(a=S).style.display&&Tt(a,!1)},getUIState:function(){return x},setUIState:function(e){x=e,x===Et.None?(D(),O(),k&&(Tt(S,!1),Tt(P,!1),(L||U)&&Tt(T,!0),$&&Tt(M,!0))):x===Et.QR||x===Et.AR?k&&(Tt(S,!1),Tt(T,!1),Tt(M,$&&"AR"===I),Tt(P,"AR"!==I)):x===Et.Preview&&k&&(Tt(S,!1),Tt(T,(L||U)&&"3D"===I),Tt(M,!1),Tt(P,"3D"!==I))},setDefaultUIActions:function(e,t,n){k&&((L||U)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${E}/img/icons/${n}`;T.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(C),T.onclick=e),$&&(M.onclick=t),P.onclick=n)},startDeepARLoading:function(){f.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:D,startThreeLoading:function(){null!=b.dataset.srcSet?y.style.visibility="visible":(w.classList.add("active"),m.style.visibility="visible")},stopThreeLoading:O,setThreePosterUrl:function(e){null!=e?(b.src=e,b.dataset.srcSet="true"):delete b.dataset.srcSet},showCameraError:function(){k&&Tt(S,!0)}}}function Tt(e,t){e.style.display=t?"":"none"}const Mt=new Map;function Pt(e){let n=Mt.get(e);return null==n?(n=function(){let e=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Rt()),n);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:e,getQRImage:n}=i();o=function(e,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>t(this,void 0,void 0,(function*(){yield S;const t=`https://ar.shopar.ai/${y.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:r,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(t),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,o=!1,e.style.display=""})),qrPause:()=>t(this,void 0,void 0,(function*(){o=!0,e.style.display="none"}))}}(e(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=nt(e(),t(),n())}return r}}}(),Mt.set(e,n)):n.incrementSetupId_(),n}function Ct(e){for(const t of Mt.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===Et.AR&&r(Et.None)}}let It;const xt=new Uint8Array(16);function kt(){if(!It&&(It="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!It))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return It(xt)}const Lt=[];for(let e=0;e<256;++e)Lt.push((e+256).toString(16).slice(1));var Ut={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $t(e,t,n){if(Ut.randomUUID&&!t&&!e)return Ut.randomUUID();const o=(e=e||{}).random||(e.rng||kt)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function(e,t=0){return Lt[e[t+0]]+Lt[e[t+1]]+Lt[e[t+2]]+Lt[e[t+3]]+"-"+Lt[e[t+4]]+Lt[e[t+5]]+"-"+Lt[e[t+6]]+Lt[e[t+7]]+"-"+Lt[e[t+8]]+Lt[e[t+9]]+"-"+Lt[e[t+10]]+Lt[e[t+11]]+Lt[e[t+12]]+Lt[e[t+13]]+Lt[e[t+14]]+Lt[e[t+15]]}(o)}const Dt="qrLaunch",Ot="arLaunch",_t="previewLaunch",Nt="heartbeat";let jt,Ft,Wt=!1,qt=window.navigator.userAgent||"no user agent";const Gt=[];function zt(){null==jt&&(Ft=$t(),jt=A(`${E}/shopar-analytics.js`),jt.then((()=>{Wt=!0,window.ShopAR__analytics.initializeImpl(),Gt.forEach((e=>e()))})))}function Vt(e){Wt?e():Gt.push(e)}function Bt(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Qt(e){return t(this,void 0,void 0,(function*(){const t=document.createElement("video");return t.setAttribute("playsinline","playsinline"),t.srcObject=yield e,t}))}const Kt=200,Ht=10;let Xt=!1,Zt=null,Yt=[],Jt=[];function en(e){return t(this,void 0,void 0,(function*(){Xt=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${E}/wasm/mediapipe`,e),Zt&&clearInterval(Zt);const o=[],r=[];Zt=setInterval((()=>t(this,void 0,void 0,(function*(){if(Xt)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());Xt||(null!=a&&null!=s&&function(e){for(let t of Yt)t(e)}({translation:a,rotation:s}),null==e&&(o.push(t),r.push(i),o.length<Ht||(o.shift(),r.shift(),function(e,t){for(let n of Jt)n({faceWidth:e,IPD:t})}(nn(o),nn(r)))))}))),Kt)}))}function tn(){Jt=[],Yt=[],Xt=!0}function nn(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}function on(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new n("Resource unavailable.")}));if(!t.ok)throw new n(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield o.blob()).arrayBuffer()}catch(e){throw console.error(e),new n("Resource has invalid body.")}}))}var rn="undefined"!=typeof Float32Array?Float32Array:Array;function an(){var e=new rn(16);return rn!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function sn(e,t,n){var o=t[0],r=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],E=n[2],A=n[3];return e[0]=y*o+b*s+E*d+A*m,e[1]=y*r+b*l+E*h+A*g,e[2]=y*i+b*c+E*p+A*v,e[3]=y*a+b*u+E*f+A*w,y=n[4],b=n[5],E=n[6],A=n[7],e[4]=y*o+b*s+E*d+A*m,e[5]=y*r+b*l+E*h+A*g,e[6]=y*i+b*c+E*p+A*v,e[7]=y*a+b*u+E*f+A*w,y=n[8],b=n[9],E=n[10],A=n[11],e[8]=y*o+b*s+E*d+A*m,e[9]=y*r+b*l+E*h+A*g,e[10]=y*i+b*c+E*p+A*v,e[11]=y*a+b*u+E*f+A*w,y=n[12],b=n[13],E=n[14],A=n[15],e[12]=y*o+b*s+E*d+A*m,e[13]=y*r+b*l+E*h+A*g,e[14]=y*i+b*c+E*p+A*v,e[15]=y*a+b*u+E*f+A*w,e}function ln(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function cn(e,t){var n=t[0],o=t[1],r=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,u),e}function un(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,u=a+a,d=r*l,h=r*c,p=r*u,f=i*c,m=i*u,g=a*u,v=s*l,w=s*c,y=s*u,b=o[0],E=o[1],A=o[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*E,e[5]=(1-(d+g))*E,e[6]=(m+v)*E,e[7]=0,e[8]=(p+w)*A,e[9]=(m-v)*A,e[10]=(1-(d+f))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function dn(){var e=new rn(3);return rn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function hn(e,t,n){var o=new rn(3);return o[0]=e,o[1]=t,o[2]=n,o}function pn(e,t){var n=t[0]-e[0],o=t[1]-e[1],r=t[2]-e[2];return Math.hypot(n,o,r)}function fn(e,t,n){var o=t[0],r=t[1],i=t[2],a=n[3]*o+n[7]*r+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*o+n[4]*r+n[8]*i+n[12])/a,e[1]=(n[1]*o+n[5]*r+n[9]*i+n[13])/a,e[2]=(n[2]*o+n[6]*r+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function mn(){var e=new rn(4);return rn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}dn(),function(){var e,t=(e=new rn(4),rn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var gn;let vn,wn,yn;dn(),hn(1,0,0),hn(0,1,0),mn(),mn(),gn=new rn(9),rn!=Float32Array&&(gn[1]=0,gn[2]=0,gn[3]=0,gn[5]=0,gn[6]=0,gn[7]=0),gn[0]=1,gn[4]=1,gn[8]=1;let bn,En,An,Sn,Rn=!0,Tn=null;const Mn=new Set;let Pn,Cn,In,xn,kn,Ln;function Un(){null==vn&&(vn=A(`${E}/shopar-deepar.js`))}function $n(){null==wn&&(wn=A(`${E}/shopar-true-scale.js`))}function Dn(e){return t(this,void 0,void 0,(function*(){const{licenseKey:o,truescaleUsecase:r}=e;return kn=r,null==Pn&&(Pn=(()=>t(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new n("No camera available!");var e;const t=zn(An),r=Bt(t);bn=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:o||"your_license_key_goes_here",previewElement:Sn,additionalOptions:{hint:Ln,cameraConfig:{disableDefaultCamera:!0}}}),En=yield Qt(r),yield Vn(bn,En,"user"===t),"Glasses"===An&&(yield wn,en(En),"DetectionLoop"!==kn&&Hn((e=>{xn=e.faceWidth})))})))()),Pn}))}function On(e,t){var n,o;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===An&&(n=t,o=Ln,n===o||null!=n&&null!=o&&n.length===o.length&&n.every((e=>o.find((t=>e===t))))&&o.every((e=>n.find((t=>t===e))))))||(null!=bn&&(bn.shutdown(),bn=null,Pn=null),An=e,Ln=t)}function _n(e){e!==Sn&&(Sn=e,null!=bn&&bn.changePreviewElement(Sn))}function Nn(e){Tn=e}function jn(e){bn.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(xn){const e=137/(xn+5);bn.changeParameterVector("GLASSES","","scale",e,e,e,0),bn.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const o=Qn("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Qn("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);bn.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),bn.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return}}(e),tn(),xn=null}e(),Bn("Glasses")}},bn.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),Bn("Shoes"))},bn.callbacks.onWristTracked=t=>{t.detected&&(e(),Bn("Watches"))}}function Fn(e,n,o){return t(this,void 0,void 0,(function*(){return null!=Cn&&In===o||(yield Cn,Cn=bn.switchEffect(e,{envmap:n}),In=o),Cn}))}function Wn(e,t){null!=e&&null!=t&&(bn.setToneMapping(e),bn.setExposure(t))}function qn(){return t(this,void 0,void 0,(function*(){if(null!=bn){if(Rn=!1,null==En){const e=zn(An),t=Bt(e);En=yield Qt(t),yield Vn(bn,En,"user"===e),"Glasses"===An&&(en(En),"DetectionLoop"!==kn&&Hn((e=>{xn=e.faceWidth})))}!function(){if(null==Tn)return;if(null==An||Mn.has(An))return;Tn.style.visibility="visible",Tn.style.opacity="1"}(),bn.setPaused(Rn),Sn.style.display=""}}))}function Gn(){null!=bn&&(Rn=!0,bn.setPaused(Rn),tn(),null!=En&&null!=En.srcObject&&En.srcObject instanceof MediaStream&&(En.srcObject.getTracks().forEach((e=>e.stop())),En=null),function(){if(null==Tn)return;Tn.style.visibility="hidden",Tn.style.opacity="0"}(),bn.stopCamera(),Sn.style.display="none")}function zn(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function Vn(e,n,o){return t(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>t(this,void 0,void 0,(function*(){e.setVideoElement(n,o),r()}))))}}))}))}function Bn(e){null!=Tn&&(Mn.has(e)||(Mn.add(e),Tn.style.opacity="0"))}function Qn(e,t,n,o,r,i,a){const s=bn.getTransformationBetween(e,t),l=ln(dn(),s),c=function(e,t){var n=new rn(3);cn(n,t);var o=1/n[0],r=1/n[1],i=1/n[2],a=t[0]*o,s=t[1]*r,l=t[2]*i,c=t[4]*o,u=t[5]*r,d=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>u&&a>f?(g=2*Math.sqrt(1+a-u-f),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):u>f?(g=2*Math.sqrt(1+u-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+f-a-u),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(d+p)/g,e[2]=.25*g),e}(mn(),s);un(s,c,l,hn(a,a,a));const u=bn.getTransformationBetween(t,n),d=ln(dn(),u);un(u,mn(),d,cn(dn(),u));const h=sn(an(),s,u),p=ln(dn(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=bn.getTransformationBetween(n,o)}catch(e){return f}const g=sn(an(),u,m),v=sn(an(),s,g),w=hn(p[0],i[1],i[2]),y=fn(dn(),w,function(e,t){var n=t[0],o=t[1],r=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-o*a,y=n*l-r*a,b=n*c-i*a,E=o*l-r*s,A=o*c-i*s,S=r*c-i*l,R=u*m-d*f,T=u*g-h*f,M=u*v-p*f,P=d*g-h*m,C=d*v-p*m,I=h*v-p*g,x=w*I-y*C+b*P+E*M-A*T+S*R;return x?(x=1/x,e[0]=(s*I-l*C+c*P)*x,e[1]=(r*C-o*I-i*P)*x,e[2]=(m*S-g*A+v*E)*x,e[3]=(h*A-d*S-p*E)*x,e[4]=(l*M-a*I-c*T)*x,e[5]=(n*I-r*M+i*T)*x,e[6]=(g*b-f*S-v*y)*x,e[7]=(u*S-h*b+p*y)*x,e[8]=(a*C-s*M+c*R)*x,e[9]=(o*M-n*C-i*R)*x,e[10]=(f*A-m*b+v*w)*x,e[11]=(d*b-u*A-p*w)*x,e[12]=(s*T-a*P-l*R)*x,e[13]=(n*P-o*T+r*R)*x,e[14]=(m*y-f*E-g*w)*x,e[15]=(u*E-d*y+h*w)*x,e):null}(an(),v));let b=bn.getClosestPointOnMesh(o,y);try{const e=bn.getClosestPointOnMesh(r,y);pn(y,e)<pn(y,b)&&(b=e)}catch(e){}const E=fn(dn(),b,g);return f-Math.atan2(E[0]-d[0],Math.abs(E[2]-d[2]))}function Kn(e){!function(e){Yt.push(e)}(e)}function Hn(e){!function(e){Jt.push(e)}(e)}var Xn;function Zn(){return[Xn.Android,Xn.iOS,Xn.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],o=["Win32","Win64","Windows","WinCE"],r=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==r.indexOf(t)?Xn.iOS:-1!==n.indexOf(t)?i?Xn.Tablet:Xn.MacOS:-1!==o.indexOf(t)?Xn.Windows:/Android/.test(e)?Xn.Android:/Linux/.test(t)?Xn.Linux:i?Xn.Tablet:Xn.Unknown}return Xn.Unknown}())}function Yn(e,r,i){return t(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const l=String.fromCharCode(a+14);s>>=2,a^=s+2;const d=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const p=String.fromCharCode(a-7),m=window[`${h}${d+l+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${p}`],g=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield m(`${e}`).catch((()=>{throw new n("Unknown error.")}));if(!t.ok)throw new n("Unknown error.");return t})))),v=new o[0](yield(yield g.blob().catch((()=>{throw new n("Unknown error.")}))).arrayBuffer().catch((()=>{throw new n("Unknown error.")})));i+=s;const w=v.byteLength;if(u[c]=Math.min(76,r)*((a>>5)-1),152===u[c]&&(u[c]=w),i==c)return v;i=c,i^=c;for(let e=0,t=v.length;e<t;e++)u[c]^=u[i]<<13,u[c]^=u[i]>>17,u[c]^=u[i]<<5,v[e]=v[e]^u[c];return i^=u[0],i^=u[1],i^=u[2],v}))}!function(e){e[e.Unknown=0]="Unknown",e[e.Android=1]="Android",e[e.iOS=2]="iOS",e[e.Tablet=3]="Tablet",e[e.MacOS=4]="MacOS",e[e.Windows=5]="Windows",e[e.Linux=6]="Linux"}(Xn||(Xn={}));const Jn=["AR","3D"];function eo(e,t){if(null==e)throw new n(`'${t}' not specified.`)}function to(e,t){if("boolean"!=typeof e)throw new n(`'${t}' must be a boolean.`)}function no(e,t){if("string"!=typeof e)throw new n(`'${t}' must be a string.`)}function oo(e){const{apiKey:t,sku:o,targetElement:r,initialState:i,initialAnimation:a,baseUrl:s,defaultUI:l,interactive:c,strings:u}=e;eo(t,"apiKey"),no(t,"apiKey"),eo(o,"sku"),no(o,"sku"),eo(r,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new n(`'${t}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,t,o){if("string"!=typeof e)throw new n(`'${t}' must be a string.`);if(!o.includes(e))throw new n(`'${t}' must be ${o.join("' or '")}.`)}(i,"initialState",Jn),null!=a&&function(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new n(`'${t}' must be a string or array.`)}(a,"initialAnimation"),null!=s&&no(s,"baseUrl"),null!=l&&to(l,"defaultUI"),null!=c&&to(c,"interactive"),null!=u&&function(e,t,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new n(`Value for key '${r}' in '${t}' must be a string.`)}}(u,"strings",st)}let ro=!1;function io(e){return t(this,void 0,void 0,(function*(){const{targetElement:o}=e;E.update(e.baseUrl),zt();const{trackEvent:r}=function(e){const t=performance.now(),n=$t();return{trackEvent:(o,r={})=>{r=Object.assign(Object.assign({},r),{pluginVersion:y,userAgent:qt,sessionId:Ft,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),Vt((()=>{window.ShopAR__analytics.trackEventImpl(o,r)}))}}}(e.apiKey);r("visionSetup");const i=yield function(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:e,sid:d()})}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield o.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(e.apiKey);r("visionApiResponse",i);const{arKey:a}=i,s=Pt(o),{getSetupId:l,findUI:c}=s,u=l();Un(),$n();const{setTargetElement:h,getDeepARTarget:p,setVisibilityParameters:m,getUIState:g,setUIState:v,startDeepARLoading:w,stopDeepARLoading:b,showCameraError:A}=c();if(g()!=Et.None)throw Error("UI state is not None, this is weird..");v(Et.AR),h(o),m(!1,!1,!0,!1,void 0,void 0),w(),yield vn,ao(l(),u);try{r("visionArLaunch"),Gn(),On("Glasses",["faceInit"]),_n(p()),yield Dn({licenseKey:a,truescaleUsecase:"DetectionLoop"}),ao(l(),u),yield qn(),ao(l(),u)}catch(e){const t=e instanceof Error;throw r("visionArLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),A(),Gn(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{b()}return ro=!0,{registerFacePoseListener:e=>{ro&&(r("registerFacePoseListener"),Kn(e))},registerFaceMeasurementListener:e=>{ro&&(r("registerFaceMeasurementListener"),Hn(e))},switchEffect:e=>t(this,void 0,void 0,(function*(){ro&&(r("switchEffect",{arUrl:e}),function(e){bn.switchEffect(e)}(e))})),clearEffect:()=>{ro&&(r("clearEffect"),bn.clearEffect())},close:()=>{if(ro){if(ro=!1,r("visionClose"),g()!==Et.AR)throw new n("AR not launched.");Gn(),v(Et.None)}}}}))}function ao(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}function so(e){var o,r;return t(this,void 0,void 0,(function*(){oo(e);const{apiKey:i,sku:a,targetElement:s,initialState:l,initialAnimation:c}=e,u=null==e.zoomEnabled||e.zoomEnabled,h=!0===e.alwaysTransparentBackground;!function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new n(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(s),E.update(e.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(at,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(at[t]=n)}}(e.strings);const p=null!=c?ye(c):null,b=null!=(null==p?void 0:p.theta)?ne(p.theta):null,R=null!=(null==p?void 0:p.phi)?ne(p.phi):null,T=null!=(null==p?void 0:p.fov)?ne(p.fov):null,M=function(e,o,r,i,a,s){return t(this,void 0,void 0,(function*(){const l=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:e,sku:o,sid:d()},null!=r&&{yaw:`${g(m(r))}`}),null!=i&&{pitch:`${g(m(i))}`}),null!=a&&{fov:`${g(m(a))}`}),s&&{forcedTransparency:`${s}`}))}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield l.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(i,a,null==b?void 0:b.get(),null==R?void 0:R.get(),null==T?void 0:T.get(),h),P=Pt(s),{getSetupId:C,findUI:I,findQR:x,findThree:k}=P,L=C();zt();const{trackEvent:U,arInteracted:$,previewInteracted:D}=function(e,t){const n=performance.now(),o=$t();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,u(Nt,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const u=(r,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:qt,pluginVersion:y,sessionId:Ft,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),Vt((()=>{window.ShopAR__analytics.trackEventImpl(r,i)}))};return{trackEvent:u,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}(a,i);U("setup",{hostname:window.location.hostname});const O=yield M;U("apiResponse",O);const{category:_,arUrl:N,arEnvUrl:j,arToneMapping:F,arToneMappingExposure:W,arKey:q,arPromptEnabled:G,arPromptText:z,arPromptImage:V,previewUrl:B,previewEnvUrl:Q,previewToneMapping:K,previewToneMappingExposure:H,previewPosterUrl:X,cameraErrorText:Z,qrPromptText:Y}=O;lo(C(),L);const J=null!=N&&function(e){return null!=e&&v.includes(e)}(_),ee=null==(null===(o=e._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=e._internalOptions)||void 0===r?void 0:r.qrEnabled),te=J&&function(e){return null!=e&&w.includes(e)}(_),oe=ee&&te&&!Zn(),re=J&&!oe,ie=null!=B;if(lo(C(),L),oe&&function(){t(this,void 0,void 0,(function*(){null==S&&(S=A(`${E}/shopar-qr.js`))}))}(),re&&(Un(),function(e){e!==yn&&(yn=e,on(e),Cn=null,tn())}(N),"Glasses"===_&&$n(),null!=j&&on(j)),ie){null==Ge&&(Ge=A(`${E}/shopar-three.js`));const e=255;Yn(B,(new Date).getTime()+e,Math.random()*e),on(null!=Q?Q:`${E}/env/default.hdr`)}const{setTargetElement:ae,getDeepARTarget:se,getDeepARPrompt:le,customizeDeepARPrompt:ce,customizeCameraError:ue,customizeQRPrompt:de,setVisibilityParameters:he,getUIState:pe,setUIState:fe,setDefaultUIActions:me,startDeepARLoading:ge,stopDeepARLoading:ve,startThreeLoading:we,stopThreeLoading:be,setThreePosterUrl:Ee,showCameraError:Ae}=I();ae(s);he(null==e.defaultUI||e.defaultUI,oe,re,ie,_,l),ce(null!=z?z:"",null!=V?V:""),ue(Z),de(Y),Ee(X),function(e,t){const o=e.parentNode;if(null==o)throw new n("Parent node missing.");new MutationObserver((n=>{for(const o of n)for(const n of o.removedNodes)if(n===e)return void t()})).observe(o,{childList:!0})}(s,(()=>{pe()!==Et.QR||Se()||Te(),pe()!==Et.AR||Rn||Gn(),pe()!==Et.Preview||Ie()||ke(),fe(Et.None)}));const{qrPaused:Se,qrDraw:Re,qrPause:Te}=x(),{threeInit:Me,threeParse:Pe,threeLoad:Ce,threePaused:Ie,threeResume:xe,threePause:ke,threeSetZoomEnabled:Le,threeSetForcedTransparency:Ue,threeSetToneMapping:$e,threeIsInteractive:De,threeSetInteractive:Oe,threeSetOnInteracted:_e,threeInitPromptAnimation:Ne,threeInitThetaAnimation:je,threeInitPhiAnimation:Fe,threeInitFovAnimation:We}=k(),qe=null==e.interactive||e.interactive;Oe(qe);let ze=0;if(pe()===Et.QR){if(!Se())if(oe){U(Dt);try{yield Re(i,a)}catch(e){throw new n(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else Te(),fe(Et.None)}else if(pe()===Et.AR){if(!Rn)if(re&&!ro){U(Ot);const e=null!=j?yield on(j):void 0;lo(C(),L);const t=yield on(N);lo(C(),L),Ct(P),On(_),_n(se()),Nn(G?le():null),yield Fn(t,e,`${N}${j}`),Wn(F,W),jn($),lo(C(),L)}else Gn(),fe(Et.None)}else if(pe()===Et.Preview&&!Ie())if(ie){U(_t),we();const e=255,t=yield Yn(B,(new Date).getTime()+e,Math.random()*e);lo(C(),L);const n=yield on(null!=Q?Q:`${E}/env/default.hdr`);lo(C(),L);const o=yield Pe(t,n,`${B}${Q}`);lo(C(),L),Ce(o,_),Le(u),Ue(h),$e(null!=K?K:"ACES",null!=H?H:1),_e(D),Ne(),null!=p&&(je(b),Fe(R),We(T)),be()}else ke(),fe(Et.None);const Ve=()=>t(this,void 0,void 0,(function*(){if(oe){if(pe()===Et.QR||pe()===Et.AR)return;try{U(Dt);const e=++ze;if(pe()===Et.Preview&&ie&&!Ie()&&ke(),fe(Et.QR),yield Re(i,a),ze!==e)return;return void lo(C(),L)}catch(e){const t=e instanceof Error;throw U("qrLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`QR failed: ${t?e.message:"Unknown error."}`)}}if(!re)throw new n("Model does not have AR enabled.");if(pe()!==Et.AR)try{U(Ot);const e=++ze;pe()===Et.Preview&&ie&&!Ie()&&ke(),Ct(P),fe(Et.AR),ge();const t=null!=j?yield on(j):void 0;lo(C(),L);const n=yield on(N);if(ze!==e)return;if(lo(C(),L),yield vn,ze!==e)return;if(lo(C(),L),Gn(),On(_),_n(se()),Nn(G?le():null),yield Dn({licenseKey:q}),ze!==e)return;if(lo(C(),L),yield Fn(n,t,`${N}${j}`),Wn(F,W),jn($),ze!==e)return;if(lo(C(),L),yield qn(),ze!==e)return;lo(C(),L)}catch(e){const t=e instanceof Error;throw U("arLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),Ae(),Gn(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{ve()}})),Be=()=>t(this,void 0,void 0,(function*(){if(!ie)throw new n("Model does not have 3D enabled.");if(pe()!==Et.Preview)try{U(_t);const e=++ze;pe()===Et.AR&&(re&&!Rn&&Gn(),Te()),fe(Et.Preview),we();const t=255,n=yield Yn(B,(new Date).getTime()+t,Math.random()*t);if(ze!==e)return;lo(C(),L);const o=yield on(null!=Q?Q:`${E}/env/default.hdr`);if(ze!==e)return;if(lo(C(),L),yield Ge,ze!==e)return;if(lo(C(),L),Me(),ze!==e)return;lo(C(),L);const r=yield Pe(n,o,`${B}${Q}`);if(ze!==e)return;lo(C(),L),Ce(r,_),Le(u),Ue(h),$e(null!=K?K:"ACES",null!=H?H:1),_e(D),Ne(),null!=p&&(je(b),Fe(R),We(T)),xe()}catch(e){const t=e instanceof Error;throw U("previewLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`3D failed: ${t?e.message:"Unknown error."}`)}finally{be()}})),Qe=()=>t(this,void 0,void 0,(function*(){pe()!==Et.None&&(++ze,pe()===Et.QR||pe()===Et.AR?(re&&!Rn&&Gn(),Te()):pe()===Et.Preview&&ie&&!Ie()&&ke(),fe(Et.None),"AR"!==l?"3D"!==l||(yield Be()):yield Ve())}));return me(Ve,Be,Qe),"AR"===l?(yield Ve(),lo(C(),L)):"3D"===l&&(yield Be(),lo(C(),L)),ro=!1,{launchAR:J?Ve:void 0,launch3D:ie?Be:void 0,closeAR:J?()=>t(this,void 0,void 0,(function*(){pe()!==Et.AR&&pe()!==Et.QR||(++ze,re&&!Rn&&Gn(),Te(),fe(Et.None),"3D"!==l||(yield Be()))})):void 0,close3D:ie?()=>t(this,void 0,void 0,(function*(){pe()===Et.Preview&&(++ze,ie&&!Ie()&&ke(),fe(Et.None),"AR"!==l||(yield Ve()))})):void 0,close:J||ie?Qe:void 0,isInteractive:()=>De(),setInteractive:e=>Oe(e)}}))}function lo(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}const co={setup:function(e){return t(this,void 0,void 0,(function*(){return io(e)}))}},uo={setup:function(e){return t(this,void 0,void 0,(function*(){return function(e,o){return t(this,void 0,void 0,(function*(){try{return o()}catch(t){throw t instanceof Error?new n(`${e} failed: ${t.message}`):(console.error(t),new n(`${e} failed.`))}}))}("setup",(()=>so(e)))}))},version:y};e.PREVIEW_STATES=Jn,e.PluginError=n,e.plugin=uo,e.vision=co}));
{
"name": "shopar-plugin",
"version": "0.7.1",
"version": "0.7.2-alpha.0",
"description": "Plugin for the Web that seamlessly integrates into your webpage to create embedded virtual try-on and 3D preview capabilities.",

@@ -5,0 +5,0 @@ "main": "dist/shopar-plugin.esm.js",

@@ -35,3 +35,3 @@ # ShopAR Plugin

```html
<script src="https://cdn.jsdelivr.net/npm/shopar-plugin@0.7.1/dist/shopar-plugin.js"></script>
<script src="https://cdn.jsdelivr.net/npm/shopar-plugin@{{VERSION}}/dist/shopar-plugin.js"></script>
```

@@ -157,3 +157,3 @@

- If provided, defines where the additional ShopAR plugin files are fetched from.
- Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@0.7.1/dist`
- Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@{{VERSION}}/dist`
- `defaultUI` (optional)

@@ -160,0 +160,0 @@ - Type: `boolean`

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc