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

shopar-plugin

Package Overview
Dependencies
Maintainers
1
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.1.1-alpha.5 to 0.1.1

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 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))}}));
!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))}}));

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

function e(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;pointer-events:none}.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;pointer-events:auto}.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}"};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],o=n.length-2,r=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],a=window[r[i[i[o]]]][r[i[i[i.length-1]]]],s=a.charCodeAt(o),l=s^s,c=new n[1]([l]);function d(){const e=(new TextEncoder).encode(a),t=r.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[r[t[2]]](String.fromCodePoint(...e))}const u=[1e3,2e3,4e3],h=u.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,u[n]))),p(t,n+1)}}))}const f=["Glasses","Shoes","Watches"],m=["Shoes"];const g="0.1.1-alpha.5";let v=`https://cdn.jsdelivr.net/npm/shopar-plugin@${g}/dist`;const w={update:e=>{null!=e&&(v=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>v};function y(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 b;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.warn('No <meta name="viewport"> detected; ShopAR will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})();let S,A,C;function E(e){const t=function(e){const t=new A.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,A.ClampToEdgeWrapping,A.ClampToEdgeWrapping,A.LinearFilter,A.LinearFilter,1,A.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(C.parse(e));return t.mapping=A.EquirectangularReflectionMapping,t.colorSpace=A.LinearSRGBColorSpace,t}const M=45,P=45,T=3,I=1.5,x=1,L=.5;let k,$,D,U,_,N,j=!1;const O=0,q=300,F=2e3,G=.05,W=1/(32*Math.PI);let Q,V,B,H=!1,z=1,K=1,X=1;const Z=1;let Y;const J=new Map;function ee(t,n,o){const r=t.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,d,u,h,p,f=!1,m=!0,g=!1,v=!1,w=!1,y=0,b=0,R=1,x=1,N=1;const j={threeInit:()=>{f||(te(),i=new V.Scene,a=new V.PerspectiveCamera(25,1,.5),s=new Q.OrbitControls(a,t),s.enableInteraction(),({renderShadow:c,shadowGroup:l}=function(e){const t=new k.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new k.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new k.Group;o.position.y=-.7;const r=new k.PlaneGeometry(M,P).rotateX(Math.PI/2),i=new k.MeshBasicMaterial({map:t.texture,opacity:L,transparent:!0,depthWrite:!1}),a=new k.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new k.Mesh(r);s.visible=!1,o.add(s);const l=new k.OrthographicCamera(-M/2,M/2,P/2,-P/2,0,T);function c(e){s.visible=!0,U.uniforms.tDiffuse.value=t.texture,U.uniforms.h.value=1*e/256,s.material=U,$.setRenderTarget(n),$.render(s,l),_.uniforms.tDiffuse.value=n.texture,_.uniforms.v.value=1*e/256,s.material=_,$.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=D;const o=$.getClearAlpha();$.setClearAlpha(0),$.setRenderTarget(t),$.render(e,l),e.overrideMaterial=null,c(I),c(.4*I),$.setRenderTarget(null),$.setClearAlpha(o),e.background=n}}}(i)),f=!0)},threeParse:(t,n,o)=>e(this,void 0,void 0,(function*(){return null!=d&&u===o||(yield d,d=(()=>e(this,void 0,void 0,(function*(){var e,o;return A=(e=Q).THREE,C=new e.RGBELoader,i.environment=E(n),function(e,t){const{THREE:n}=t;S=(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)}(Y,Q),o=t,S.parseAsync(o.buffer,"")})))(),u=o),d})),threeLoad:(e,t)=>{i.clear(),i.add(e.scene);const n=(new V.Box3).setFromObject(e.scene);l.position.y=n.min.y-O,i.add(l),c(),i.traverse((e=>{if(e instanceof V.Mesh){const t=e.material;t.depthWrite=!0,t instanceof V.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(Q.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,V.Vector3)),w=!0},threePaused:()=>m,threeResume:()=>{m=!1,Y.setAnimationLoop(ne),t.style.visibility="visible",y=0,b=0},threePause:()=>{m=!0,function(){for(const{threePaused:e}of J.values())if(!e())return!1;return!0}()&&Y.setAnimationLoop(null),t.style.visibility="hidden",n.style.visibility="hidden"},threeSetToneMapping:e=>({ACES:V.ACESFilmicToneMapping,Linear:V.LinearToneMapping,Neutral:V.NeutralToneMapping}[e||"ACES"]||V.ACESFilmicToneMapping),threeSetOnInteracted:e=>{s.removeEventListener("change",h),h=e,s.addEventListener("change",e)},preRender_:e=>{if(!f||m)return;e=performance.now();const t=0!==b?e-b:0;if(b=e,!s.update()){if(v)return;if(w)return void(w=!1);if(null==p&&(p=()=>{w||(v=!0,n.style.visibility="hidden",null!=p&&(s.removeEventListener("change",p),p=null))},s.addEventListener("change",p)),y+=t,!(y>q&&y<=q+F))return o.style.opacity="0",void(y>q+2*F&&(y=0));{n.style.visibility="visible",o.style.opacity="1";const e=y-q,t=2*Math.PI/F*e,r=-Math.sin(t),i=Math.cos(t);o.style.transform=`translateX(${G*r*Math.min(R,x)}px)`,s.updateTheta(W*i)}}g=!0},shouldRender_:()=>!(!f||m)&&g,render_:()=>{const e=Y.toneMapping;Y.setViewport(0,0,t.width,t.height),Y.render(i,a),Y.toneMapping=e,g=!1,null!=r&&(r.clearRect(0,0,t.width,t.height),r.drawImage(B,0,K-t.height,t.width,t.height,0,0,t.width,t.height))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===R&&n===x&&X===N||(t.width=Math.ceil(e*X*Z),t.height=Math.ceil(n*X*Z),R=e,x=n,N=X,g=!0)},target_:t};return J.set(t,j),j}function te(){if(H)return;Q=window.ShopAR__THREE,V=Q.THREE,B=document.createElement("canvas");var e,t;B.style.position="block",Y=new V.WebGLRenderer({powerPreference:"high-performance",canvas:B,antialias:!0,alpha:!0}),Y.outputColorSpace=V.SRGBColorSpace,Y.toneMapping=V.ACESFilmicToneMapping,Y.setClearColor(new V.Color(16777215)),e=Y,t=Q,j||(k=t.THREE,$=e,D=new k.MeshDepthMaterial,D.userData.darkness={value:x},D.onBeforeCompile=e=>{e.uniforms.darkness=D.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}`},D.depthTest=!1,D.depthWrite=!1,U=new k.ShaderMaterial(t.HorizontalBlurShader),U.depthTest=!1,_=new k.ShaderMaterial(t.VerticalBlurShader),_.depthTest=!1,j=!0),oe(),H=!0}function ne(e){oe(),Y.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of J.values())t(e),n()&&o()}function oe(){let e=0,t=0;for(const{target_:n}of J.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*Z),t=Math.ceil(t*n*Z),e===z&&t===K&&n===X||(z=e,K=t,X=n,Y.setSize(z,K,!1));for(const{updateSize_:e}of J.values())e()}const re={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},ie=Object.keys(re);function ae(e){return re[e]}function se(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}const le="shopar-error";function ce(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=se("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;return r.style.display="none",r}const de="shopar-control";const ue="shopar-deepar-output";function he(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%",t}function pe(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function fe(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 me(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 ge="shopar-main";const ve="shopar-qr-output";const we="shopar-three-output";var ye;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(ye||(ye={}));let be=!1;function Re(){be||(!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.")}}(),be=!0)}function Se(){Re();const e=function(){const e=document.createElement("div");e.id=ge;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}(),t=function(){const e=new Image,t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),n=function(e){const t=document.createElement("div");t.id=ve;const n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.display="none";const o=document.createElement("div");o.className="shopar-qr";const r=o.style;r.position="relative",r.top="0",r.left="0",r.width="100%",r.height="100%",t.appendChild(o);const i=document.createElement("div");i.innerText="Scan on mobile or tablet to try on",i.style.textAlign="center",o.appendChild(i);const a=document.createElement("div");return a.appendChild(e),o.appendChild(a),t}(t);e.appendChild(n);const o=function(){const e=document.createElement("div");e.id=ue;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",e}();e.appendChild(o);const r=function(){const e=document.createElement("canvas");e.id=we;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",e}();e.appendChild(r);const i=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),a=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),s=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.pointerEvents="none",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(i,a);e.appendChild(s);const l=function(){const e=se("2rem",`${w}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),c=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",n.pointerEvents="none",t.appendChild(e),t}(l);e.appendChild(c);const d=he("shopar-ar-loading-container"),u=pe("shopar-ar-loading-text",ae("loading.ar"));d.appendChild(u);const h=fe("shopar-ar-loading-bar-bg"),p=me("shopar-ar-loading-bar-fg");h.appendChild(p),d.appendChild(h),e.appendChild(d);const f=he("shopar-3d-loading-container"),m=pe("shopar-3d-loading-text",ae("loading.3d"));f.appendChild(m);const g=fe("shopar-3d-loading-bar-bg"),v=me("shopar-3d-loading-bar-fg");g.appendChild(v),f.appendChild(g),e.appendChild(f);const y=function(){const e=document.createElement("div");e.id=le;const t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const r=se("4rem",`${w}/img/icons/close.svg`);n.appendChild(r);const i=document.createElement("div");i.className="shopar-error-title",i.textContent="Camera Error",n.appendChild(i);const a=document.createElement("div");return a.className="shopar-error-body",a.textContent="Please refresh the page and allow the use of camera.",n.appendChild(a),e}();e.appendChild(y);const b=function(){const e=document.createElement("div");return e.id=de,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(b);const R=ce("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");b.appendChild(R);const S=ce("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${w}/img/icons/cube.svg`);b.appendChild(S);const A=ce("shopar-btn-close","Close","Close ShopAR view",`${w}/img/icons/close.svg`);b.append(A);let C,E=ye.None,M=!1,P=!1,T=!1,I=!1;function x(){p.classList.remove("active"),d.style.visibility="hidden"}function L(){v.classList.remove("active"),f.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return n},getQRImage:function(){return t},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return r},getThreePrompt:function(){return c},getThreePromptImage:function(){return l},customizeDeepARPrompt:function(e,t){i.textContent=e,a.src=t},setVisibilityParameters:function(e,t,n,o,r){var i;M=e,P=t,T=n,I=o,C=r,Ae(b,M),Ae(R,M&&(T||P)&&E===ye.None),Ae(S,M&&I&&E===ye.None),Ae(A,M&&E!==ye.None),x(),L(),M||""===(i=y).style.display&&Ae(i,!1)},getUIState:function(){return E},setUIState:function(e){E=e,E===ye.None?(x(),L(),M&&(Ae(y,!1),Ae(A,!1),(P||T)&&Ae(R,!0),I&&Ae(S,!0))):E!==ye.QR&&E!==ye.AR&&E!==ye.Preview||M&&(Ae(y,!1),Ae(R,!1),Ae(S,!1),Ae(A,!0))},setDefaultUIActions:function(e,t,n){M&&((P||T)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${w}/img/icons/${n}`;R.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(C),R.onclick=e),I&&(S.onclick=t),A.onclick=n)},startDeepARLoading:function(){p.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:x,startThreeLoading:function(){v.classList.add("active"),f.style.visibility="visible"},stopThreeLoading:L,showCameraError:function(){M&&Ae(y,!0)}}}function Ae(e,t){e.style.display=t?"":"none"}const Ce=new Map;function Ee(t){let n=Ce.get(t);return null==n?(n=function(){let t=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Se()),n);return{getSetupId:()=>t,incrementSetupId_:()=>t++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:t,getQRImage:n}=i();o=function(t,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>e(this,void 0,void 0,(function*(){yield b;const e=`https://apps.deepar.ai/${g.includes("alpha")?"shopar-qr-alpha":"shopar-qr"}/?${new URLSearchParams({a:r,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,o=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){o=!0,t.style.display="none"}))}}(t(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=ee(e(),t(),n())}return r}}}(),Ce.set(t,n)):n.incrementSetupId_(),n}function Me(e){for(const t of Ce.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===ye.AR&&r(ye.None)}}let Pe;const Te=new Uint8Array(16);function Ie(){if(!Pe&&(Pe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pe(Te)}const xe=[];for(let e=0;e<256;++e)xe.push((e+256).toString(16).slice(1));var Le={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ke(e,t,n){if(Le.randomUUID&&!t&&!e)return Le.randomUUID();const o=(e=e||{}).random||(e.rng||Ie)();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 xe[e[t+0]]+xe[e[t+1]]+xe[e[t+2]]+xe[e[t+3]]+"-"+xe[e[t+4]]+xe[e[t+5]]+"-"+xe[e[t+6]]+xe[e[t+7]]+"-"+xe[e[t+8]]+xe[e[t+9]]+"-"+xe[e[t+10]]+xe[e[t+11]]+xe[e[t+12]]+xe[e[t+13]]+xe[e[t+14]]+xe[e[t+15]]}(o)}const $e="qrLaunch",De="arLaunch",Ue="previewLaunch",_e="heartbeat";let Ne,je,Oe=!1;const qe=[];function Fe(e,t){const n=performance.now(),o=ke();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,d(_e,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const d=(r,i={})=>{var a;i=Object.assign(Object.assign({},i),{pluginVersion:g,sessionId:je,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),a=()=>{window.ShopAR__analytics.trackEventImpl(r,i)},Oe?a():qe.push(a)};return{trackEvent:d,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)}}}function Ge(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function We(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 Qe=200,Ve=10;let Be=!1;function He(t,n){return e(this,void 0,void 0,(function*(){Be=!1;const{ShopAR__TrueScale:o}=window;yield o.initialize(`${w}/wasm/mediapipe`,t);const r=[],i=setInterval((()=>e(this,void 0,void 0,(function*(){if(Be)return void clearInterval(i);const{error:e,faceWidth:t}=yield o.predict(performance.now());if(Be)return void clearInterval(i);if(null!=e)return void console.error(`TrueScale predict error: ${e}`);if(r.length<Ve)return void r.push(t);clearInterval(i);const a=function(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}(r);n(a)}))),Qe)}))}function ze(){Be=!0}function Ke(n){return e(this,void 0,void 0,(function*(){const o=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 o.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}var Xe="undefined"!=typeof Float32Array?Float32Array:Array;function Ze(){var e=new Xe(16);return Xe!=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 Ye(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],d=t[7],u=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],R=n[2],S=n[3];return e[0]=y*o+b*s+R*u+S*m,e[1]=y*r+b*l+R*h+S*g,e[2]=y*i+b*c+R*p+S*v,e[3]=y*a+b*d+R*f+S*w,y=n[4],b=n[5],R=n[6],S=n[7],e[4]=y*o+b*s+R*u+S*m,e[5]=y*r+b*l+R*h+S*g,e[6]=y*i+b*c+R*p+S*v,e[7]=y*a+b*d+R*f+S*w,y=n[8],b=n[9],R=n[10],S=n[11],e[8]=y*o+b*s+R*u+S*m,e[9]=y*r+b*l+R*h+S*g,e[10]=y*i+b*c+R*p+S*v,e[11]=y*a+b*d+R*f+S*w,y=n[12],b=n[13],R=n[14],S=n[15],e[12]=y*o+b*s+R*u+S*m,e[13]=y*r+b*l+R*h+S*g,e[14]=y*i+b*c+R*p+S*v,e[15]=y*a+b*d+R*f+S*w,e}function Je(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function et(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],d=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,d),e}function tt(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,d=a+a,u=r*l,h=r*c,p=r*d,f=i*c,m=i*d,g=a*d,v=s*l,w=s*c,y=s*d,b=o[0],R=o[1],S=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)*R,e[5]=(1-(u+g))*R,e[6]=(m+v)*R,e[7]=0,e[8]=(p+w)*S,e[9]=(m-v)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function nt(){var e=new Xe(3);return Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ot(e,t,n){var o=new Xe(3);return o[0]=e,o[1]=t,o[2]=n,o}function rt(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 it(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 at(){var e=new Xe(4);return Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}nt(),function(){var e,t=(e=new Xe(4),Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var st;let lt,ct,dt;nt(),ot(1,0,0),ot(0,1,0),at(),at(),st=new Xe(9),Xe!=Float32Array&&(st[1]=0,st[2]=0,st[3]=0,st[5]=0,st[6]=0,st[7]=0),st[0]=1,st[4]=1,st[8]=1;let ut,ht,pt,ft,mt=!0,gt=null;const vt=new Set;let wt,yt,bt,Rt,St;function At(n){return e(this,void 0,void 0,(function*(){return null==wt&&(wt=(()=>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 o=Lt(pt),r=Ge(o),i=function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(pt);ut=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:n||"your_license_key_goes_here",previewElement:ft,additionalOptions:{hint:i,cameraConfig:{disableDefaultCamera:!0}}}),ht=yield We(r),yield kt(ut,ht,"user"===o),"Glasses"===pt&&(yield ct,He(ht,(e=>{Rt=e})))})))()),wt}))}function Ct(e){e!==pt&&(null!=ut&&(ut.shutdown(),ut=null,wt=null),pt=e)}function Et(e){e!==ft&&(ft=e,null!=ut&&ut.changePreviewElement(ft))}function Mt(e){gt=e}function Pt(e){ut.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(Rt){const e=137/(Rt+5);ut.changeParameterVector("GLASSES","","scale",e,e,e,0),ut.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=Dt("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Dt("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);ut.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),ut.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return void console.error(e)}}(e),Rt=null}e(),$t("Glasses")}},ut.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),$t("Shoes"))},ut.callbacks.onWristTracked=t=>{t.detected&&(e(),$t("Watches"))}}function Tt(t,n){return e(this,void 0,void 0,(function*(){return null!=yt&&bt===n||(yield yt,yt=ut.switchEffect(t),bt=n),yt}))}function It(){return e(this,void 0,void 0,(function*(){if(null!=ut){if(mt=!1,null==ht){const e=Lt(pt),t=Ge(e);ht=yield We(t),yield kt(ut,ht,"user"===e),He(ht,(e=>{Rt=e}))}!function(){if(null==gt)return;if(null==pt||vt.has(pt))return;gt.style.visibility="visible",gt.style.opacity="1"}(),ut.setPaused(mt),ft.style.display=""}}))}function xt(){null!=ut&&(mt=!0,ut.setPaused(mt),ze(),null!=ht&&null!=ht.srcObject&&ht.srcObject instanceof MediaStream&&(ht.srcObject.getTracks().forEach((e=>e.stop())),ht=null),function(){if(null==gt)return;gt.style.visibility="hidden",gt.style.opacity="0"}(),ut.stopCamera(),ft.style.display="none")}function Lt(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function kt(t,n,o){return e(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,o),r()}))))}}))}))}function $t(e){null!=gt&&(vt.has(e)||(vt.add(e),gt.style.opacity="0"))}function Dt(e,t,n,o,r,i,a){const s=ut.getTransformationBetween(e,t),l=Je(nt(),s),c=function(e,t){var n=new Xe(3);et(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,d=t[5]*r,u=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+d+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(u-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>d&&a>f?(g=2*Math.sqrt(1+a-d-f),e[3]=(u-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):d>f?(g=2*Math.sqrt(1+d-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(u+p)/g):(g=2*Math.sqrt(1+f-a-d),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(u+p)/g,e[2]=.25*g),e}(at(),s);tt(s,c,l,ot(a,a,a));const d=ut.getTransformationBetween(t,n),u=Je(nt(),d);tt(d,at(),u,et(nt(),d));const h=Ye(Ze(),s,d),p=Je(nt(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=ut.getTransformationBetween(n,o)}catch(e){return console.error(e),f}const g=Ye(Ze(),d,m),v=Ye(Ze(),s,g),w=ot(p[0],i[1],i[2]),y=it(nt(),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],d=t[8],u=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,R=o*l-r*s,S=o*c-i*s,A=r*c-i*l,C=d*m-u*f,E=d*g-h*f,M=d*v-p*f,P=u*g-h*m,T=u*v-p*m,I=h*v-p*g,x=w*I-y*T+b*P+R*M-S*E+A*C;return x?(x=1/x,e[0]=(s*I-l*T+c*P)*x,e[1]=(r*T-o*I-i*P)*x,e[2]=(m*A-g*S+v*R)*x,e[3]=(h*S-u*A-p*R)*x,e[4]=(l*M-a*I-c*E)*x,e[5]=(n*I-r*M+i*E)*x,e[6]=(g*b-f*A-v*y)*x,e[7]=(d*A-h*b+p*y)*x,e[8]=(a*T-s*M+c*C)*x,e[9]=(o*M-n*T-i*C)*x,e[10]=(f*S-m*b+v*w)*x,e[11]=(u*b-d*S-p*w)*x,e[12]=(s*E-a*P-l*C)*x,e[13]=(n*P-o*E+r*C)*x,e[14]=(m*y-f*R-g*w)*x,e[15]=(d*R-u*y+h*w)*x,e):null}(Ze(),v));let b=ut.getClosestPointOnMesh(o,y);try{const e=ut.getClosestPointOnMesh(r,y);rt(y,e)<rt(y,b)&&(b=e)}catch(e){console.error(e)}const R=it(nt(),b,g);return f-Math.atan2(R[0]-u[0],Math.abs(R[2]-u[2]))}function Ut(o,r,i){return e(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const d=String.fromCharCode(a+14);s>>=2,a^=s+2;const u=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const f=String.fromCharCode(a-7),m=window[`${h}${u+d+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${f}`],g=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${o}`).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,r)*((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 _t(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function Nt(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}const jt=["AR","3D"];function Ot(e){const{apiKey:n,sku:o,targetElement:r,initialState:i,baseUrl:a,defaultUI:s,strings:l}=e;_t(n,"apiKey"),Nt(n,"apiKey"),_t(o,"sku"),Nt(o,"sku"),_t(r,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,n,o){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!o.includes(e))throw new t(`'${n}' must be ${o.join("' or '")}.`)}(i,"initialState",jt),null!=a&&Nt(a,"baseUrl"),null!=s&&function(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}(s,"defaultUI"),null!=l&&function(e,n,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new t(`Value for key '${r}' in '${n}' must be a string.`)}}(l,"strings",ie)}function qt(n){var o,r;return e(this,void 0,void 0,(function*(){Ot(n);const{apiKey:i,sku:a,targetElement:s,initialState:l}=n;!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),w.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(re,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(re[t]=n)}}(n.strings);const c=function(n,o){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?${new URLSearchParams({apiKey:n,sku:o,sid:d()})}`).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.")}}))}(i,a),u=Ee(s),{getSetupId:h,findUI:g,findQR:v,findThree:R}=u,S=h();null==Ne&&(je=ke(),Ne=y(`${w}/shopar-analytics.js`),Ne.then((()=>{Oe=!0,window.ShopAR__analytics.initializeImpl(),qe.forEach((e=>e()))})));const{trackEvent:A,arInteracted:C,previewInteracted:E}=Fe(a,i);A("setup",{hostname:window.location.hostname});const M=yield c;A("apiResponse",M);const{category:P,arUrl:T,arKey:I,arPromptEnabled:x,arPromptText:L,arPromptImage:k,previewUrl:$,previewEnvUrl:D,previewToneMapping:U}=M;Ft(h(),S);const _=null!=T&&function(e){return null!=e&&f.includes(e)}(P),j=null==(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=n._internalOptions)||void 0===r?void 0:r.qrEnabled),O=_&&function(e){return null!=e&&m.includes(e)}(P),q=j&&O&&!(yield function(){var t;return e(this,void 0,void 0,(function*(){return null==St&&(St=y(`${w}/shopar-platform.js`)),yield St,["Android","iOS","Windows Phone",void 0].includes(null===(t=window.ShopAR__platform.platform.os)||void 0===t?void 0:t.family)}))}()),F=_&&!q,G=null!=$;if(Ft(h(),S),q&&function(){e(this,void 0,void 0,(function*(){null==b&&(b=y(`${w}/shopar-qr.js`))}))}(),F&&(null==lt&&(lt=y(`${w}/shopar-deepar.js`)),function(e){e!==dt&&(dt=e,Ke(e),yt=null,ze())}(T),"Glasses"===P&&null==ct&&(ct=y(`${w}/shopar-true-scale.js`))),G){null==N&&(N=y(`${w}/shopar-three.js`));const e=255;Ut($,(new Date).getTime()+e,Math.random()*e),Ke(null!=D?D:`${w}/env/default.hdr`)}const{setTargetElement:W,getDeepARTarget:Q,getDeepARPrompt:V,customizeDeepARPrompt:B,setVisibilityParameters:H,getUIState:z,setUIState:K,setDefaultUIActions:X,startDeepARLoading:Z,stopDeepARLoading:Y,startThreeLoading:J,stopThreeLoading:ee,showCameraError:te}=g();W(s);H(null==n.defaultUI||n.defaultUI,q,F,G,P),B(null!=L?L:"",null!=k?k:""),function(e,n){const o=e.parentNode;if(null==o)throw new t("Parent node missing.");new MutationObserver((t=>{for(const o of t)for(const t of o.removedNodes)if(t===e)return void n()})).observe(o,{childList:!0})}(s,(()=>{z()!==ye.QR||ne()||ie(),z()!==ye.AR||mt||xt(),z()!==ye.Preview||ce()||ue(),K(ye.None)}));const{qrPaused:ne,qrDraw:oe,qrPause:ie}=v(),{threeInit:ae,threeParse:se,threeLoad:le,threePaused:ce,threeResume:de,threePause:ue,threeSetToneMapping:he,threeSetOnInteracted:pe}=R();let fe=0;if(z()===ye.QR){if(!ne())if(q){A($e);try{yield oe(i,a)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else ie(),K(ye.None)}else if(z()===ye.AR){if(!mt)if(F){A(De);const e=yield Ke(T);Ft(h(),S),Me(u),Ct(P),Et(Q()),Mt(x?V():null),yield Tt(e,T),Pt(C),Ft(h(),S)}else xt(),K(ye.None)}else if(z()===ye.Preview&&!ce())if(G){A(Ue),J();const e=255,t=yield Ut($,(new Date).getTime()+e,Math.random()*e);Ft(h(),S);const n=yield Ke(null!=D?D:`${w}/env/default.hdr`);Ft(h(),S);const o=yield se(t,n,`${$}${D}`);Ft(h(),S),le(o,P),he(null!=U?U:"ACES"),pe(E),ee()}else ue(),K(ye.None);const me=()=>e(this,void 0,void 0,(function*(){if(q){if(z()===ye.QR||z()===ye.AR)throw new t("AR already launched.");try{A($e);const e=++fe;if(z()===ye.Preview&&G&&!ce()&&ue(),K(ye.QR),yield oe(i,a),fe!==e)return;return void Ft(h(),S)}catch(e){const n=e instanceof Error;throw A("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}}if(!F)throw new t("Model does not have AR enabled.");if(z()===ye.AR)throw new t("AR already launched.");try{A(De);const e=++fe;z()===ye.Preview&&G&&!ce()&&ue(),Me(u),K(ye.AR),Z();const t=yield Ke(T);if(fe!==e)return;if(Ft(h(),S),yield lt,fe!==e)return;if(Ft(h(),S),xt(),Ct(P),Et(Q()),Mt(x?V():null),yield At(I),fe!==e)return;if(Ft(h(),S),yield Tt(t,T),Pt(C),fe!==e)return;if(Ft(h(),S),yield It(),fe!==e)return;Ft(h(),S)}catch(e){const n=e instanceof Error;throw A("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),te(),xt(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{Y()}})),ge=()=>e(this,void 0,void 0,(function*(){if(!G)throw new t("Model does not have 3D enabled.");if(z()===ye.Preview)throw new t("3D already launched.");try{A(Ue);const e=++fe;z()===ye.AR&&(F&&!mt&&xt(),ie()),K(ye.Preview),J();const t=255,n=yield Ut($,(new Date).getTime()+t,Math.random()*t);if(fe!==e)return;Ft(h(),S);const o=yield Ke(null!=D?D:`${w}/env/default.hdr`);if(fe!==e)return;if(Ft(h(),S),yield N,fe!==e)return;if(Ft(h(),S),ae(),fe!==e)return;Ft(h(),S);const r=yield se(n,o,`${$}${D}`);if(fe!==e)return;Ft(h(),S),le(r,P),he(null!=U?U:"ACES"),pe(E),de()}catch(e){const n=e instanceof Error;throw A("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}finally{ee()}})),ve=()=>e(this,void 0,void 0,(function*(){if(z()===ye.None)throw new t("Neither AR or 3D launched.");++fe,z()===ye.QR||z()===ye.AR?(F&&!mt&&xt(),ie()):z()===ye.Preview&&G&&!ce()&&ue(),K(ye.None)}));return X(me,ge,ve),"AR"===l?(yield me(),Ft(h(),S)):"3D"===l&&(yield ge(),Ft(h(),S)),{launchAR:_?me:void 0,launch3D:G?ge:void 0,closeAR:_?()=>e(this,void 0,void 0,(function*(){if(z()!==ye.AR&&z()!==ye.QR)throw new t("AR not launched.");++fe,F&&!mt&&xt(),ie(),K(ye.None)})):void 0,close3D:G?()=>e(this,void 0,void 0,(function*(){if(z()!==ye.Preview)throw new t("3D not launched.");++fe,G&&!ce()&&ue(),K(ye.None)})):void 0,close:_||G?ve:void 0}}))}function Ft(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const Gt={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,o){return e(this,void 0,void 0,(function*(){try{return o()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>qt(n)))}))},version:g};export{Gt as plugin};
function e(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;pointer-events:none}.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;pointer-events:auto}.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}"};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],o=n.length-2,r=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],a=window[r[i[i[o]]]][r[i[i[i.length-1]]]],s=a.charCodeAt(o),l=s^s,c=new n[1]([l]);function d(){const e=(new TextEncoder).encode(a),t=r.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[r[t[2]]](String.fromCodePoint(...e))}const u=[1e3,2e3,4e3],h=u.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,u[n]))),p(t,n+1)}}))}const f=["Glasses","Shoes","Watches"],m=["Shoes"];const g="0.1.1";let v=`https://cdn.jsdelivr.net/npm/shopar-plugin@${g}/dist`;const w={update:e=>{null!=e&&(v=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>v};function y(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 b;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.warn('No <meta name="viewport"> detected; ShopAR will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})();let S,A,C;function E(e){const t=function(e){const t=new A.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,A.ClampToEdgeWrapping,A.ClampToEdgeWrapping,A.LinearFilter,A.LinearFilter,1,A.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(C.parse(e));return t.mapping=A.EquirectangularReflectionMapping,t.colorSpace=A.LinearSRGBColorSpace,t}const M=45,P=45,T=3,I=1.5,x=1,L=.5;let k,$,D,U,_,N,j=!1;const O=0,q=300,F=2e3,G=.05,W=1/(32*Math.PI);let Q,V,B,H=!1,z=1,K=1,X=1;const Z=1;let Y;const J=new Map;function ee(t,n,o){const r=t.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,d,u,h,p,f=!1,m=!0,g=!1,v=!1,w=!1,y=0,b=0,R=1,x=1,N=1;const j={threeInit:()=>{f||(te(),i=new V.Scene,a=new V.PerspectiveCamera(25,1,.5),s=new Q.OrbitControls(a,t),s.enableInteraction(),({renderShadow:c,shadowGroup:l}=function(e){const t=new k.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new k.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new k.Group;o.position.y=-.7;const r=new k.PlaneGeometry(M,P).rotateX(Math.PI/2),i=new k.MeshBasicMaterial({map:t.texture,opacity:L,transparent:!0,depthWrite:!1}),a=new k.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new k.Mesh(r);s.visible=!1,o.add(s);const l=new k.OrthographicCamera(-M/2,M/2,P/2,-P/2,0,T);function c(e){s.visible=!0,U.uniforms.tDiffuse.value=t.texture,U.uniforms.h.value=1*e/256,s.material=U,$.setRenderTarget(n),$.render(s,l),_.uniforms.tDiffuse.value=n.texture,_.uniforms.v.value=1*e/256,s.material=_,$.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=D;const o=$.getClearAlpha();$.setClearAlpha(0),$.setRenderTarget(t),$.render(e,l),e.overrideMaterial=null,c(I),c(.4*I),$.setRenderTarget(null),$.setClearAlpha(o),e.background=n}}}(i)),f=!0)},threeParse:(t,n,o)=>e(this,void 0,void 0,(function*(){return null!=d&&u===o||(yield d,d=(()=>e(this,void 0,void 0,(function*(){var e,o;return A=(e=Q).THREE,C=new e.RGBELoader,i.environment=E(n),function(e,t){const{THREE:n}=t;S=(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)}(Y,Q),o=t,S.parseAsync(o.buffer,"")})))(),u=o),d})),threeLoad:(e,t)=>{i.clear(),i.add(e.scene);const n=(new V.Box3).setFromObject(e.scene);l.position.y=n.min.y-O,i.add(l),c(),i.traverse((e=>{if(e instanceof V.Mesh){const t=e.material;t.depthWrite=!0,t instanceof V.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(Q.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,V.Vector3)),w=!0},threePaused:()=>m,threeResume:()=>{m=!1,Y.setAnimationLoop(ne),t.style.visibility="visible",y=0,b=0},threePause:()=>{m=!0,function(){for(const{threePaused:e}of J.values())if(!e())return!1;return!0}()&&Y.setAnimationLoop(null),t.style.visibility="hidden",n.style.visibility="hidden"},threeSetToneMapping:e=>({ACES:V.ACESFilmicToneMapping,Linear:V.LinearToneMapping,Neutral:V.NeutralToneMapping}[e||"ACES"]||V.ACESFilmicToneMapping),threeSetOnInteracted:e=>{s.removeEventListener("change",h),h=e,s.addEventListener("change",e)},preRender_:e=>{if(!f||m)return;e=performance.now();const t=0!==b?e-b:0;if(b=e,!s.update()){if(v)return;if(w)return void(w=!1);if(null==p&&(p=()=>{w||(v=!0,n.style.visibility="hidden",null!=p&&(s.removeEventListener("change",p),p=null))},s.addEventListener("change",p)),y+=t,!(y>q&&y<=q+F))return o.style.opacity="0",void(y>q+2*F&&(y=0));{n.style.visibility="visible",o.style.opacity="1";const e=y-q,t=2*Math.PI/F*e,r=-Math.sin(t),i=Math.cos(t);o.style.transform=`translateX(${G*r*Math.min(R,x)}px)`,s.updateTheta(W*i)}}g=!0},shouldRender_:()=>!(!f||m)&&g,render_:()=>{const e=Y.toneMapping;Y.setViewport(0,0,t.width,t.height),Y.render(i,a),Y.toneMapping=e,g=!1,null!=r&&(r.clearRect(0,0,t.width,t.height),r.drawImage(B,0,K-t.height,t.width,t.height,0,0,t.width,t.height))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===R&&n===x&&X===N||(t.width=Math.ceil(e*X*Z),t.height=Math.ceil(n*X*Z),R=e,x=n,N=X,g=!0)},target_:t};return J.set(t,j),j}function te(){if(H)return;Q=window.ShopAR__THREE,V=Q.THREE,B=document.createElement("canvas");var e,t;B.style.position="block",Y=new V.WebGLRenderer({powerPreference:"high-performance",canvas:B,antialias:!0,alpha:!0}),Y.outputColorSpace=V.SRGBColorSpace,Y.toneMapping=V.ACESFilmicToneMapping,Y.setClearColor(new V.Color(16777215)),e=Y,t=Q,j||(k=t.THREE,$=e,D=new k.MeshDepthMaterial,D.userData.darkness={value:x},D.onBeforeCompile=e=>{e.uniforms.darkness=D.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}`},D.depthTest=!1,D.depthWrite=!1,U=new k.ShaderMaterial(t.HorizontalBlurShader),U.depthTest=!1,_=new k.ShaderMaterial(t.VerticalBlurShader),_.depthTest=!1,j=!0),oe(),H=!0}function ne(e){oe(),Y.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of J.values())t(e),n()&&o()}function oe(){let e=0,t=0;for(const{target_:n}of J.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*Z),t=Math.ceil(t*n*Z),e===z&&t===K&&n===X||(z=e,K=t,X=n,Y.setSize(z,K,!1));for(const{updateSize_:e}of J.values())e()}const re={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},ie=Object.keys(re);function ae(e){return re[e]}function se(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}const le="shopar-error";function ce(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=se("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;return r.style.display="none",r}const de="shopar-control";const ue="shopar-deepar-output";function he(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%",t}function pe(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function fe(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 me(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 ge="shopar-main";const ve="shopar-qr-output";const we="shopar-three-output";var ye;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(ye||(ye={}));let be=!1;function Re(){be||(!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.")}}(),be=!0)}function Se(){Re();const e=function(){const e=document.createElement("div");e.id=ge;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}(),t=function(){const e=new Image,t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),n=function(e){const t=document.createElement("div");t.id=ve;const n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.display="none";const o=document.createElement("div");o.className="shopar-qr";const r=o.style;r.position="relative",r.top="0",r.left="0",r.width="100%",r.height="100%",t.appendChild(o);const i=document.createElement("div");i.innerText="Scan on mobile or tablet to try on",i.style.textAlign="center",o.appendChild(i);const a=document.createElement("div");return a.appendChild(e),o.appendChild(a),t}(t);e.appendChild(n);const o=function(){const e=document.createElement("div");e.id=ue;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",e}();e.appendChild(o);const r=function(){const e=document.createElement("canvas");e.id=we;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",e}();e.appendChild(r);const i=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),a=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),s=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.pointerEvents="none",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(i,a);e.appendChild(s);const l=function(){const e=se("2rem",`${w}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),c=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",n.pointerEvents="none",t.appendChild(e),t}(l);e.appendChild(c);const d=he("shopar-ar-loading-container"),u=pe("shopar-ar-loading-text",ae("loading.ar"));d.appendChild(u);const h=fe("shopar-ar-loading-bar-bg"),p=me("shopar-ar-loading-bar-fg");h.appendChild(p),d.appendChild(h),e.appendChild(d);const f=he("shopar-3d-loading-container"),m=pe("shopar-3d-loading-text",ae("loading.3d"));f.appendChild(m);const g=fe("shopar-3d-loading-bar-bg"),v=me("shopar-3d-loading-bar-fg");g.appendChild(v),f.appendChild(g),e.appendChild(f);const y=function(){const e=document.createElement("div");e.id=le;const t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const r=se("4rem",`${w}/img/icons/close.svg`);n.appendChild(r);const i=document.createElement("div");i.className="shopar-error-title",i.textContent="Camera Error",n.appendChild(i);const a=document.createElement("div");return a.className="shopar-error-body",a.textContent="Please refresh the page and allow the use of camera.",n.appendChild(a),e}();e.appendChild(y);const b=function(){const e=document.createElement("div");return e.id=de,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(b);const R=ce("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");b.appendChild(R);const S=ce("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${w}/img/icons/cube.svg`);b.appendChild(S);const A=ce("shopar-btn-close","Close","Close ShopAR view",`${w}/img/icons/close.svg`);b.append(A);let C,E=ye.None,M=!1,P=!1,T=!1,I=!1;function x(){p.classList.remove("active"),d.style.visibility="hidden"}function L(){v.classList.remove("active"),f.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return n},getQRImage:function(){return t},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return r},getThreePrompt:function(){return c},getThreePromptImage:function(){return l},customizeDeepARPrompt:function(e,t){i.textContent=e,a.src=t},setVisibilityParameters:function(e,t,n,o,r){var i;M=e,P=t,T=n,I=o,C=r,Ae(b,M),Ae(R,M&&(T||P)&&E===ye.None),Ae(S,M&&I&&E===ye.None),Ae(A,M&&E!==ye.None),x(),L(),M||""===(i=y).style.display&&Ae(i,!1)},getUIState:function(){return E},setUIState:function(e){E=e,E===ye.None?(x(),L(),M&&(Ae(y,!1),Ae(A,!1),(P||T)&&Ae(R,!0),I&&Ae(S,!0))):E!==ye.QR&&E!==ye.AR&&E!==ye.Preview||M&&(Ae(y,!1),Ae(R,!1),Ae(S,!1),Ae(A,!0))},setDefaultUIActions:function(e,t,n){M&&((P||T)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${w}/img/icons/${n}`;R.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(C),R.onclick=e),I&&(S.onclick=t),A.onclick=n)},startDeepARLoading:function(){p.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:x,startThreeLoading:function(){v.classList.add("active"),f.style.visibility="visible"},stopThreeLoading:L,showCameraError:function(){M&&Ae(y,!0)}}}function Ae(e,t){e.style.display=t?"":"none"}const Ce=new Map;function Ee(t){let n=Ce.get(t);return null==n?(n=function(){let t=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Se()),n);return{getSetupId:()=>t,incrementSetupId_:()=>t++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:t,getQRImage:n}=i();o=function(t,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>e(this,void 0,void 0,(function*(){yield b;const e=`https://apps.deepar.ai/${g.includes("alpha")?"shopar-qr-alpha":"shopar-qr"}/?${new URLSearchParams({a:r,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,o=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){o=!0,t.style.display="none"}))}}(t(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=ee(e(),t(),n())}return r}}}(),Ce.set(t,n)):n.incrementSetupId_(),n}function Me(e){for(const t of Ce.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===ye.AR&&r(ye.None)}}let Pe;const Te=new Uint8Array(16);function Ie(){if(!Pe&&(Pe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pe(Te)}const xe=[];for(let e=0;e<256;++e)xe.push((e+256).toString(16).slice(1));var Le={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ke(e,t,n){if(Le.randomUUID&&!t&&!e)return Le.randomUUID();const o=(e=e||{}).random||(e.rng||Ie)();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 xe[e[t+0]]+xe[e[t+1]]+xe[e[t+2]]+xe[e[t+3]]+"-"+xe[e[t+4]]+xe[e[t+5]]+"-"+xe[e[t+6]]+xe[e[t+7]]+"-"+xe[e[t+8]]+xe[e[t+9]]+"-"+xe[e[t+10]]+xe[e[t+11]]+xe[e[t+12]]+xe[e[t+13]]+xe[e[t+14]]+xe[e[t+15]]}(o)}const $e="qrLaunch",De="arLaunch",Ue="previewLaunch",_e="heartbeat";let Ne,je,Oe=!1;const qe=[];function Fe(e,t){const n=performance.now(),o=ke();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,d(_e,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const d=(r,i={})=>{var a;i=Object.assign(Object.assign({},i),{pluginVersion:g,sessionId:je,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),a=()=>{window.ShopAR__analytics.trackEventImpl(r,i)},Oe?a():qe.push(a)};return{trackEvent:d,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)}}}function Ge(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function We(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 Qe=200,Ve=10;let Be=!1;function He(t,n){return e(this,void 0,void 0,(function*(){Be=!1;const{ShopAR__TrueScale:o}=window;yield o.initialize(`${w}/wasm/mediapipe`,t);const r=[],i=setInterval((()=>e(this,void 0,void 0,(function*(){if(Be)return void clearInterval(i);const{error:e,faceWidth:t}=yield o.predict(performance.now());if(Be)return void clearInterval(i);if(null!=e)return void console.error(`TrueScale predict error: ${e}`);if(r.length<Ve)return void r.push(t);clearInterval(i);const a=function(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}(r);n(a)}))),Qe)}))}function ze(){Be=!0}function Ke(n){return e(this,void 0,void 0,(function*(){const o=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 o.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}var Xe="undefined"!=typeof Float32Array?Float32Array:Array;function Ze(){var e=new Xe(16);return Xe!=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 Ye(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],d=t[7],u=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],R=n[2],S=n[3];return e[0]=y*o+b*s+R*u+S*m,e[1]=y*r+b*l+R*h+S*g,e[2]=y*i+b*c+R*p+S*v,e[3]=y*a+b*d+R*f+S*w,y=n[4],b=n[5],R=n[6],S=n[7],e[4]=y*o+b*s+R*u+S*m,e[5]=y*r+b*l+R*h+S*g,e[6]=y*i+b*c+R*p+S*v,e[7]=y*a+b*d+R*f+S*w,y=n[8],b=n[9],R=n[10],S=n[11],e[8]=y*o+b*s+R*u+S*m,e[9]=y*r+b*l+R*h+S*g,e[10]=y*i+b*c+R*p+S*v,e[11]=y*a+b*d+R*f+S*w,y=n[12],b=n[13],R=n[14],S=n[15],e[12]=y*o+b*s+R*u+S*m,e[13]=y*r+b*l+R*h+S*g,e[14]=y*i+b*c+R*p+S*v,e[15]=y*a+b*d+R*f+S*w,e}function Je(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function et(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],d=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,d),e}function tt(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,d=a+a,u=r*l,h=r*c,p=r*d,f=i*c,m=i*d,g=a*d,v=s*l,w=s*c,y=s*d,b=o[0],R=o[1],S=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)*R,e[5]=(1-(u+g))*R,e[6]=(m+v)*R,e[7]=0,e[8]=(p+w)*S,e[9]=(m-v)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function nt(){var e=new Xe(3);return Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ot(e,t,n){var o=new Xe(3);return o[0]=e,o[1]=t,o[2]=n,o}function rt(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 it(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 at(){var e=new Xe(4);return Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}nt(),function(){var e,t=(e=new Xe(4),Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var st;let lt,ct,dt;nt(),ot(1,0,0),ot(0,1,0),at(),at(),st=new Xe(9),Xe!=Float32Array&&(st[1]=0,st[2]=0,st[3]=0,st[5]=0,st[6]=0,st[7]=0),st[0]=1,st[4]=1,st[8]=1;let ut,ht,pt,ft,mt=!0,gt=null;const vt=new Set;let wt,yt,bt,Rt,St;function At(n){return e(this,void 0,void 0,(function*(){return null==wt&&(wt=(()=>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 o=Lt(pt),r=Ge(o),i=function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(pt);ut=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:n||"your_license_key_goes_here",previewElement:ft,additionalOptions:{hint:i,cameraConfig:{disableDefaultCamera:!0}}}),ht=yield We(r),yield kt(ut,ht,"user"===o),"Glasses"===pt&&(yield ct,He(ht,(e=>{Rt=e})))})))()),wt}))}function Ct(e){e!==pt&&(null!=ut&&(ut.shutdown(),ut=null,wt=null),pt=e)}function Et(e){e!==ft&&(ft=e,null!=ut&&ut.changePreviewElement(ft))}function Mt(e){gt=e}function Pt(e){ut.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(Rt){const e=137/(Rt+5);ut.changeParameterVector("GLASSES","","scale",e,e,e,0),ut.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=Dt("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Dt("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);ut.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),ut.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return void console.error(e)}}(e),Rt=null}e(),$t("Glasses")}},ut.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),$t("Shoes"))},ut.callbacks.onWristTracked=t=>{t.detected&&(e(),$t("Watches"))}}function Tt(t,n){return e(this,void 0,void 0,(function*(){return null!=yt&&bt===n||(yield yt,yt=ut.switchEffect(t),bt=n),yt}))}function It(){return e(this,void 0,void 0,(function*(){if(null!=ut){if(mt=!1,null==ht){const e=Lt(pt),t=Ge(e);ht=yield We(t),yield kt(ut,ht,"user"===e),He(ht,(e=>{Rt=e}))}!function(){if(null==gt)return;if(null==pt||vt.has(pt))return;gt.style.visibility="visible",gt.style.opacity="1"}(),ut.setPaused(mt),ft.style.display=""}}))}function xt(){null!=ut&&(mt=!0,ut.setPaused(mt),ze(),null!=ht&&null!=ht.srcObject&&ht.srcObject instanceof MediaStream&&(ht.srcObject.getTracks().forEach((e=>e.stop())),ht=null),function(){if(null==gt)return;gt.style.visibility="hidden",gt.style.opacity="0"}(),ut.stopCamera(),ft.style.display="none")}function Lt(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function kt(t,n,o){return e(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,o),r()}))))}}))}))}function $t(e){null!=gt&&(vt.has(e)||(vt.add(e),gt.style.opacity="0"))}function Dt(e,t,n,o,r,i,a){const s=ut.getTransformationBetween(e,t),l=Je(nt(),s),c=function(e,t){var n=new Xe(3);et(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,d=t[5]*r,u=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+d+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(u-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>d&&a>f?(g=2*Math.sqrt(1+a-d-f),e[3]=(u-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):d>f?(g=2*Math.sqrt(1+d-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(u+p)/g):(g=2*Math.sqrt(1+f-a-d),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(u+p)/g,e[2]=.25*g),e}(at(),s);tt(s,c,l,ot(a,a,a));const d=ut.getTransformationBetween(t,n),u=Je(nt(),d);tt(d,at(),u,et(nt(),d));const h=Ye(Ze(),s,d),p=Je(nt(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=ut.getTransformationBetween(n,o)}catch(e){return console.error(e),f}const g=Ye(Ze(),d,m),v=Ye(Ze(),s,g),w=ot(p[0],i[1],i[2]),y=it(nt(),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],d=t[8],u=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,R=o*l-r*s,S=o*c-i*s,A=r*c-i*l,C=d*m-u*f,E=d*g-h*f,M=d*v-p*f,P=u*g-h*m,T=u*v-p*m,I=h*v-p*g,x=w*I-y*T+b*P+R*M-S*E+A*C;return x?(x=1/x,e[0]=(s*I-l*T+c*P)*x,e[1]=(r*T-o*I-i*P)*x,e[2]=(m*A-g*S+v*R)*x,e[3]=(h*S-u*A-p*R)*x,e[4]=(l*M-a*I-c*E)*x,e[5]=(n*I-r*M+i*E)*x,e[6]=(g*b-f*A-v*y)*x,e[7]=(d*A-h*b+p*y)*x,e[8]=(a*T-s*M+c*C)*x,e[9]=(o*M-n*T-i*C)*x,e[10]=(f*S-m*b+v*w)*x,e[11]=(u*b-d*S-p*w)*x,e[12]=(s*E-a*P-l*C)*x,e[13]=(n*P-o*E+r*C)*x,e[14]=(m*y-f*R-g*w)*x,e[15]=(d*R-u*y+h*w)*x,e):null}(Ze(),v));let b=ut.getClosestPointOnMesh(o,y);try{const e=ut.getClosestPointOnMesh(r,y);rt(y,e)<rt(y,b)&&(b=e)}catch(e){console.error(e)}const R=it(nt(),b,g);return f-Math.atan2(R[0]-u[0],Math.abs(R[2]-u[2]))}function Ut(o,r,i){return e(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const d=String.fromCharCode(a+14);s>>=2,a^=s+2;const u=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const f=String.fromCharCode(a-7),m=window[`${h}${u+d+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${f}`],g=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${o}`).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,r)*((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 _t(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function Nt(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}const jt=["AR","3D"];function Ot(e){const{apiKey:n,sku:o,targetElement:r,initialState:i,baseUrl:a,defaultUI:s,strings:l}=e;_t(n,"apiKey"),Nt(n,"apiKey"),_t(o,"sku"),Nt(o,"sku"),_t(r,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,n,o){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!o.includes(e))throw new t(`'${n}' must be ${o.join("' or '")}.`)}(i,"initialState",jt),null!=a&&Nt(a,"baseUrl"),null!=s&&function(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}(s,"defaultUI"),null!=l&&function(e,n,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new t(`Value for key '${r}' in '${n}' must be a string.`)}}(l,"strings",ie)}function qt(n){var o,r;return e(this,void 0,void 0,(function*(){Ot(n);const{apiKey:i,sku:a,targetElement:s,initialState:l}=n;!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),w.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(re,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(re[t]=n)}}(n.strings);const c=function(n,o){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?${new URLSearchParams({apiKey:n,sku:o,sid:d()})}`).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.")}}))}(i,a),u=Ee(s),{getSetupId:h,findUI:g,findQR:v,findThree:R}=u,S=h();null==Ne&&(je=ke(),Ne=y(`${w}/shopar-analytics.js`),Ne.then((()=>{Oe=!0,window.ShopAR__analytics.initializeImpl(),qe.forEach((e=>e()))})));const{trackEvent:A,arInteracted:C,previewInteracted:E}=Fe(a,i);A("setup",{hostname:window.location.hostname});const M=yield c;A("apiResponse",M);const{category:P,arUrl:T,arKey:I,arPromptEnabled:x,arPromptText:L,arPromptImage:k,previewUrl:$,previewEnvUrl:D,previewToneMapping:U}=M;Ft(h(),S);const _=null!=T&&function(e){return null!=e&&f.includes(e)}(P),j=null==(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=n._internalOptions)||void 0===r?void 0:r.qrEnabled),O=_&&function(e){return null!=e&&m.includes(e)}(P),q=j&&O&&!(yield function(){var t;return e(this,void 0,void 0,(function*(){return null==St&&(St=y(`${w}/shopar-platform.js`)),yield St,["Android","iOS","Windows Phone",void 0].includes(null===(t=window.ShopAR__platform.platform.os)||void 0===t?void 0:t.family)}))}()),F=_&&!q,G=null!=$;if(Ft(h(),S),q&&function(){e(this,void 0,void 0,(function*(){null==b&&(b=y(`${w}/shopar-qr.js`))}))}(),F&&(null==lt&&(lt=y(`${w}/shopar-deepar.js`)),function(e){e!==dt&&(dt=e,Ke(e),yt=null,ze())}(T),"Glasses"===P&&null==ct&&(ct=y(`${w}/shopar-true-scale.js`))),G){null==N&&(N=y(`${w}/shopar-three.js`));const e=255;Ut($,(new Date).getTime()+e,Math.random()*e),Ke(null!=D?D:`${w}/env/default.hdr`)}const{setTargetElement:W,getDeepARTarget:Q,getDeepARPrompt:V,customizeDeepARPrompt:B,setVisibilityParameters:H,getUIState:z,setUIState:K,setDefaultUIActions:X,startDeepARLoading:Z,stopDeepARLoading:Y,startThreeLoading:J,stopThreeLoading:ee,showCameraError:te}=g();W(s);H(null==n.defaultUI||n.defaultUI,q,F,G,P),B(null!=L?L:"",null!=k?k:""),function(e,n){const o=e.parentNode;if(null==o)throw new t("Parent node missing.");new MutationObserver((t=>{for(const o of t)for(const t of o.removedNodes)if(t===e)return void n()})).observe(o,{childList:!0})}(s,(()=>{z()!==ye.QR||ne()||ie(),z()!==ye.AR||mt||xt(),z()!==ye.Preview||ce()||ue(),K(ye.None)}));const{qrPaused:ne,qrDraw:oe,qrPause:ie}=v(),{threeInit:ae,threeParse:se,threeLoad:le,threePaused:ce,threeResume:de,threePause:ue,threeSetToneMapping:he,threeSetOnInteracted:pe}=R();let fe=0;if(z()===ye.QR){if(!ne())if(q){A($e);try{yield oe(i,a)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else ie(),K(ye.None)}else if(z()===ye.AR){if(!mt)if(F){A(De);const e=yield Ke(T);Ft(h(),S),Me(u),Ct(P),Et(Q()),Mt(x?V():null),yield Tt(e,T),Pt(C),Ft(h(),S)}else xt(),K(ye.None)}else if(z()===ye.Preview&&!ce())if(G){A(Ue),J();const e=255,t=yield Ut($,(new Date).getTime()+e,Math.random()*e);Ft(h(),S);const n=yield Ke(null!=D?D:`${w}/env/default.hdr`);Ft(h(),S);const o=yield se(t,n,`${$}${D}`);Ft(h(),S),le(o,P),he(null!=U?U:"ACES"),pe(E),ee()}else ue(),K(ye.None);const me=()=>e(this,void 0,void 0,(function*(){if(q){if(z()===ye.QR||z()===ye.AR)throw new t("AR already launched.");try{A($e);const e=++fe;if(z()===ye.Preview&&G&&!ce()&&ue(),K(ye.QR),yield oe(i,a),fe!==e)return;return void Ft(h(),S)}catch(e){const n=e instanceof Error;throw A("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}}if(!F)throw new t("Model does not have AR enabled.");if(z()===ye.AR)throw new t("AR already launched.");try{A(De);const e=++fe;z()===ye.Preview&&G&&!ce()&&ue(),Me(u),K(ye.AR),Z();const t=yield Ke(T);if(fe!==e)return;if(Ft(h(),S),yield lt,fe!==e)return;if(Ft(h(),S),xt(),Ct(P),Et(Q()),Mt(x?V():null),yield At(I),fe!==e)return;if(Ft(h(),S),yield Tt(t,T),Pt(C),fe!==e)return;if(Ft(h(),S),yield It(),fe!==e)return;Ft(h(),S)}catch(e){const n=e instanceof Error;throw A("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),te(),xt(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{Y()}})),ge=()=>e(this,void 0,void 0,(function*(){if(!G)throw new t("Model does not have 3D enabled.");if(z()===ye.Preview)throw new t("3D already launched.");try{A(Ue);const e=++fe;z()===ye.AR&&(F&&!mt&&xt(),ie()),K(ye.Preview),J();const t=255,n=yield Ut($,(new Date).getTime()+t,Math.random()*t);if(fe!==e)return;Ft(h(),S);const o=yield Ke(null!=D?D:`${w}/env/default.hdr`);if(fe!==e)return;if(Ft(h(),S),yield N,fe!==e)return;if(Ft(h(),S),ae(),fe!==e)return;Ft(h(),S);const r=yield se(n,o,`${$}${D}`);if(fe!==e)return;Ft(h(),S),le(r,P),he(null!=U?U:"ACES"),pe(E),de()}catch(e){const n=e instanceof Error;throw A("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}finally{ee()}})),ve=()=>e(this,void 0,void 0,(function*(){if(z()===ye.None)throw new t("Neither AR or 3D launched.");++fe,z()===ye.QR||z()===ye.AR?(F&&!mt&&xt(),ie()):z()===ye.Preview&&G&&!ce()&&ue(),K(ye.None)}));return X(me,ge,ve),"AR"===l?(yield me(),Ft(h(),S)):"3D"===l&&(yield ge(),Ft(h(),S)),{launchAR:_?me:void 0,launch3D:G?ge:void 0,closeAR:_?()=>e(this,void 0,void 0,(function*(){if(z()!==ye.AR&&z()!==ye.QR)throw new t("AR not launched.");++fe,F&&!mt&&xt(),ie(),K(ye.None)})):void 0,close3D:G?()=>e(this,void 0,void 0,(function*(){if(z()!==ye.Preview)throw new t("3D not launched.");++fe,G&&!ce()&&ue(),K(ye.None)})):void 0,close:_||G?ve:void 0}}))}function Ft(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const Gt={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,o){return e(this,void 0,void 0,(function*(){try{return o()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>qt(n)))}))},version:g};export{Gt as plugin};

@@ -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;pointer-events:none}.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;pointer-events:auto}.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}"};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,d=new o[1]([c]);function u(){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)}}))}const m=["Glasses","Shoes","Watches"],g=["Shoes"];const v="0.1.1-alpha.5";let w=`https://cdn.jsdelivr.net/npm/shopar-plugin@${v}/dist`;const y={update:e=>{null!=e&&(w=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>w};function b(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 R;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.warn('No <meta name="viewport"> detected; ShopAR will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})();let A,C,E;function M(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}(E.parse(e));return t.mapping=C.EquirectangularReflectionMapping,t.colorSpace=C.LinearSRGBColorSpace,t}const T=45,P=45,x=3,I=1.5,L=1,k=.5;let $,D,U,_,N,j,O=!1;const q=0,F=300,G=2e3,W=.05,Q=1/(32*Math.PI);let V,B,H,z=!1,K=1,X=1,Z=1;const Y=1;let J;const ee=new Map;function te(e,n,o){const r=e.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,d,u,h,p,f=!1,m=!0,g=!1,v=!1,w=!1,y=0,b=0,R=1,S=1,L=1;const j={threeInit:()=>{f||(ne(),i=new B.Scene,a=new B.PerspectiveCamera(25,1,.5),s=new V.OrbitControls(a,e),s.enableInteraction(),({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 o=new $.Group;o.position.y=-.7;const r=new $.PlaneGeometry(T,P).rotateX(Math.PI/2),i=new $.MeshBasicMaterial({map:t.texture,opacity:k,transparent:!0,depthWrite:!1}),a=new $.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new $.Mesh(r);s.visible=!1,o.add(s);const l=new $.OrthographicCamera(-T/2,T/2,P/2,-P/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,o.add(l),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=U;const o=D.getClearAlpha();D.setClearAlpha(0),D.setRenderTarget(t),D.render(e,l),e.overrideMaterial=null,c(I),c(.4*I),D.setRenderTarget(null),D.setClearAlpha(o),e.background=n}}}(i)),f=!0)},threeParse:(e,n,o)=>t(this,void 0,void 0,(function*(){return null!=d&&u===o||(yield d,d=(()=>t(this,void 0,void 0,(function*(){var t,o;return C=(t=V).THREE,E=new t.RGBELoader,i.environment=M(n),function(e,t){const{THREE:n}=t;A=(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)}(J,V),o=e,A.parseAsync(o.buffer,"")})))(),u=o),d})),threeLoad:(e,t)=>{i.clear(),i.add(e.scene);const n=(new B.Box3).setFromObject(e.scene);l.position.y=n.min.y-q,i.add(l),c(),i.traverse((e=>{if(e instanceof B.Mesh){const t=e.material;t.depthWrite=!0,t instanceof B.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(V.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,B.Vector3)),w=!0},threePaused:()=>m,threeResume:()=>{m=!1,J.setAnimationLoop(oe),e.style.visibility="visible",y=0,b=0},threePause:()=>{m=!0,function(){for(const{threePaused:e}of ee.values())if(!e())return!1;return!0}()&&J.setAnimationLoop(null),e.style.visibility="hidden",n.style.visibility="hidden"},threeSetToneMapping:e=>({ACES:B.ACESFilmicToneMapping,Linear:B.LinearToneMapping,Neutral:B.NeutralToneMapping}[e||"ACES"]||B.ACESFilmicToneMapping),threeSetOnInteracted:e=>{s.removeEventListener("change",h),h=e,s.addEventListener("change",e)},preRender_:e=>{if(!f||m)return;e=performance.now();const t=0!==b?e-b:0;if(b=e,!s.update()){if(v)return;if(w)return void(w=!1);if(null==p&&(p=()=>{w||(v=!0,n.style.visibility="hidden",null!=p&&(s.removeEventListener("change",p),p=null))},s.addEventListener("change",p)),y+=t,!(y>F&&y<=F+G))return o.style.opacity="0",void(y>F+2*G&&(y=0));{n.style.visibility="visible",o.style.opacity="1";const e=y-F,t=2*Math.PI/G*e,r=-Math.sin(t),i=Math.cos(t);o.style.transform=`translateX(${W*r*Math.min(R,S)}px)`,s.updateTheta(Q*i)}}g=!0},shouldRender_:()=>!(!f||m)&&g,render_:()=>{const t=J.toneMapping;J.setViewport(0,0,e.width,e.height),J.render(i,a),J.toneMapping=t,g=!1,null!=r&&(r.clearRect(0,0,e.width,e.height),r.drawImage(H,0,X-e.height,e.width,e.height,0,0,e.width,e.height))},updateSize_:()=>{const{clientWidth:t,clientHeight:n}=e;t===R&&n===S&&Z===L||(e.width=Math.ceil(t*Z*Y),e.height=Math.ceil(n*Z*Y),R=t,S=n,L=Z,g=!0)},target_:e};return ee.set(e,j),j}function ne(){if(z)return;V=window.ShopAR__THREE,B=V.THREE,H=document.createElement("canvas");var e,t;H.style.position="block",J=new B.WebGLRenderer({powerPreference:"high-performance",canvas:H,antialias:!0,alpha:!0}),J.outputColorSpace=B.SRGBColorSpace,J.toneMapping=B.ACESFilmicToneMapping,J.setClearColor(new B.Color(16777215)),e=J,t=V,O||($=t.THREE,D=e,U=new $.MeshDepthMaterial,U.userData.darkness={value:L},U.onBeforeCompile=e=>{e.uniforms.darkness=U.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}`},U.depthTest=!1,U.depthWrite=!1,_=new $.ShaderMaterial(t.HorizontalBlurShader),_.depthTest=!1,N=new $.ShaderMaterial(t.VerticalBlurShader),N.depthTest=!1,O=!0),re(),z=!0}function oe(e){re(),J.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of ee.values())t(e),n()&&o()}function re(){let e=0,t=0;for(const{target_:n}of ee.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=S();e=Math.ceil(e*n*Y),t=Math.ceil(t*n*Y),e===K&&t===X&&n===Z||(K=e,X=t,Z=n,J.setSize(K,X,!1));for(const{updateSize_:e}of ee.values())e()}const ie={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},ae=Object.keys(ie);function se(e){return ie[e]}function le(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}const ce="shopar-error";function de(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=le("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;return r.style.display="none",r}const ue="shopar-control";const he="shopar-deepar-output";function pe(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%",t}function fe(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function me(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 ge(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 ve="shopar-main";const we="shopar-qr-output";const ye="shopar-three-output";var be;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(be||(be={}));let Re=!1;function Se(){Re||(!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.")}}(),Re=!0)}function Ae(){Se();const e=function(){const e=document.createElement("div");e.id=ve;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}(),t=function(){const e=new Image,t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),n=function(e){const t=document.createElement("div");t.id=we;const n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.display="none";const o=document.createElement("div");o.className="shopar-qr";const r=o.style;r.position="relative",r.top="0",r.left="0",r.width="100%",r.height="100%",t.appendChild(o);const i=document.createElement("div");i.innerText="Scan on mobile or tablet to try on",i.style.textAlign="center",o.appendChild(i);const a=document.createElement("div");return a.appendChild(e),o.appendChild(a),t}(t);e.appendChild(n);const o=function(){const e=document.createElement("div");e.id=he;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",e}();e.appendChild(o);const r=function(){const e=document.createElement("canvas");e.id=ye;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",e}();e.appendChild(r);const i=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),a=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),s=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.pointerEvents="none",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(i,a);e.appendChild(s);const l=function(){const e=le("2rem",`${y}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),c=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",n.pointerEvents="none",t.appendChild(e),t}(l);e.appendChild(c);const d=pe("shopar-ar-loading-container"),u=fe("shopar-ar-loading-text",se("loading.ar"));d.appendChild(u);const h=me("shopar-ar-loading-bar-bg"),p=ge("shopar-ar-loading-bar-fg");h.appendChild(p),d.appendChild(h),e.appendChild(d);const f=pe("shopar-3d-loading-container"),m=fe("shopar-3d-loading-text",se("loading.3d"));f.appendChild(m);const g=me("shopar-3d-loading-bar-bg"),v=ge("shopar-3d-loading-bar-fg");g.appendChild(v),f.appendChild(g),e.appendChild(f);const w=function(){const e=document.createElement("div");e.id=ce;const t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const r=le("4rem",`${y}/img/icons/close.svg`);n.appendChild(r);const i=document.createElement("div");i.className="shopar-error-title",i.textContent="Camera Error",n.appendChild(i);const a=document.createElement("div");return a.className="shopar-error-body",a.textContent="Please refresh the page and allow the use of camera.",n.appendChild(a),e}();e.appendChild(w);const b=function(){const e=document.createElement("div");return e.id=ue,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(b);const R=de("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");b.appendChild(R);const S=de("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${y}/img/icons/cube.svg`);b.appendChild(S);const A=de("shopar-btn-close","Close","Close ShopAR view",`${y}/img/icons/close.svg`);b.append(A);let C,E=be.None,M=!1,T=!1,P=!1,x=!1;function I(){p.classList.remove("active"),d.style.visibility="hidden"}function L(){v.classList.remove("active"),f.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return n},getQRImage:function(){return t},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return r},getThreePrompt:function(){return c},getThreePromptImage:function(){return l},customizeDeepARPrompt:function(e,t){i.textContent=e,a.src=t},setVisibilityParameters:function(e,t,n,o,r){var i;M=e,T=t,P=n,x=o,C=r,Ce(b,M),Ce(R,M&&(P||T)&&E===be.None),Ce(S,M&&x&&E===be.None),Ce(A,M&&E!==be.None),I(),L(),M||""===(i=w).style.display&&Ce(i,!1)},getUIState:function(){return E},setUIState:function(e){E=e,E===be.None?(I(),L(),M&&(Ce(w,!1),Ce(A,!1),(T||P)&&Ce(R,!0),x&&Ce(S,!0))):E!==be.QR&&E!==be.AR&&E!==be.Preview||M&&(Ce(w,!1),Ce(R,!1),Ce(S,!1),Ce(A,!0))},setDefaultUIActions:function(e,t,n){M&&((T||P)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${y}/img/icons/${n}`;R.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(C),R.onclick=e),x&&(S.onclick=t),A.onclick=n)},startDeepARLoading:function(){p.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:I,startThreeLoading:function(){v.classList.add("active"),f.style.visibility="visible"},stopThreeLoading:L,showCameraError:function(){M&&Ce(w,!0)}}}function Ce(e,t){e.style.display=t?"":"none"}const Ee=new Map;function Me(e){let n=Ee.get(e);return null==n?(n=function(){let e=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Ae()),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 R;const t=`https://apps.deepar.ai/${v.includes("alpha")?"shopar-qr-alpha":"shopar-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=te(e(),t(),n())}return r}}}(),Ee.set(e,n)):n.incrementSetupId_(),n}function Te(e){for(const t of Ee.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===be.AR&&r(be.None)}}let Pe;const xe=new Uint8Array(16);function Ie(){if(!Pe&&(Pe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pe(xe)}const Le=[];for(let e=0;e<256;++e)Le.push((e+256).toString(16).slice(1));var ke={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $e(e,t,n){if(ke.randomUUID&&!t&&!e)return ke.randomUUID();const o=(e=e||{}).random||(e.rng||Ie)();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 Le[e[t+0]]+Le[e[t+1]]+Le[e[t+2]]+Le[e[t+3]]+"-"+Le[e[t+4]]+Le[e[t+5]]+"-"+Le[e[t+6]]+Le[e[t+7]]+"-"+Le[e[t+8]]+Le[e[t+9]]+"-"+Le[e[t+10]]+Le[e[t+11]]+Le[e[t+12]]+Le[e[t+13]]+Le[e[t+14]]+Le[e[t+15]]}(o)}const De="qrLaunch",Ue="arLaunch",_e="previewLaunch",Ne="heartbeat";let je,Oe,qe=!1;const Fe=[];function Ge(e,t){const n=performance.now(),o=$e();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,d(Ne,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const d=(r,i={})=>{var a;i=Object.assign(Object.assign({},i),{pluginVersion:v,sessionId:Oe,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),a=()=>{window.ShopAR__analytics.trackEventImpl(r,i)},qe?a():Fe.push(a)};return{trackEvent:d,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)}}}function We(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Qe(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 Ve=200,Be=10;let He=!1;function ze(e,n){return t(this,void 0,void 0,(function*(){He=!1;const{ShopAR__TrueScale:o}=window;yield o.initialize(`${y}/wasm/mediapipe`,e);const r=[],i=setInterval((()=>t(this,void 0,void 0,(function*(){if(He)return void clearInterval(i);const{error:e,faceWidth:t}=yield o.predict(performance.now());if(He)return void clearInterval(i);if(null!=e)return void console.error(`TrueScale predict error: ${e}`);if(r.length<Be)return void r.push(t);clearInterval(i);const a=function(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}(r);n(a)}))),Ve)}))}function Ke(){He=!0}function Xe(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 Ze="undefined"!=typeof Float32Array?Float32Array:Array;function Ye(){var e=new Ze(16);return Ze!=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 Je(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],d=t[7],u=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],R=n[2],S=n[3];return e[0]=y*o+b*s+R*u+S*m,e[1]=y*r+b*l+R*h+S*g,e[2]=y*i+b*c+R*p+S*v,e[3]=y*a+b*d+R*f+S*w,y=n[4],b=n[5],R=n[6],S=n[7],e[4]=y*o+b*s+R*u+S*m,e[5]=y*r+b*l+R*h+S*g,e[6]=y*i+b*c+R*p+S*v,e[7]=y*a+b*d+R*f+S*w,y=n[8],b=n[9],R=n[10],S=n[11],e[8]=y*o+b*s+R*u+S*m,e[9]=y*r+b*l+R*h+S*g,e[10]=y*i+b*c+R*p+S*v,e[11]=y*a+b*d+R*f+S*w,y=n[12],b=n[13],R=n[14],S=n[15],e[12]=y*o+b*s+R*u+S*m,e[13]=y*r+b*l+R*h+S*g,e[14]=y*i+b*c+R*p+S*v,e[15]=y*a+b*d+R*f+S*w,e}function et(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function tt(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],d=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,d),e}function nt(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,d=a+a,u=r*l,h=r*c,p=r*d,f=i*c,m=i*d,g=a*d,v=s*l,w=s*c,y=s*d,b=o[0],R=o[1],S=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)*R,e[5]=(1-(u+g))*R,e[6]=(m+v)*R,e[7]=0,e[8]=(p+w)*S,e[9]=(m-v)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function ot(){var e=new Ze(3);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function rt(e,t,n){var o=new Ze(3);return o[0]=e,o[1]=t,o[2]=n,o}function it(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 at(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 st(){var e=new Ze(4);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}ot(),function(){var e,t=(e=new Ze(4),Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var lt;let ct,dt,ut;ot(),rt(1,0,0),rt(0,1,0),st(),st(),lt=new Ze(9),Ze!=Float32Array&&(lt[1]=0,lt[2]=0,lt[3]=0,lt[5]=0,lt[6]=0,lt[7]=0),lt[0]=1,lt[4]=1,lt[8]=1;let ht,pt,ft,mt,gt=!0,vt=null;const wt=new Set;let yt,bt,Rt,St,At;function Ct(e){return t(this,void 0,void 0,(function*(){return null==yt&&(yt=(()=>t(this,void 0,void 0,(function*(){if(null==(null===(t=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===t?void 0:t.getUserMedia))throw new n("No camera available!");var t;const o=kt(ft),r=We(o),i=function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(ft);ht=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:e||"your_license_key_goes_here",previewElement:mt,additionalOptions:{hint:i,cameraConfig:{disableDefaultCamera:!0}}}),pt=yield Qe(r),yield $t(ht,pt,"user"===o),"Glasses"===ft&&(yield dt,ze(pt,(e=>{St=e})))})))()),yt}))}function Et(e){e!==ft&&(null!=ht&&(ht.shutdown(),ht=null,yt=null),ft=e)}function Mt(e){e!==mt&&(mt=e,null!=ht&&ht.changePreviewElement(mt))}function Tt(e){vt=e}function Pt(e){ht.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(St){const e=137/(St+5);ht.changeParameterVector("GLASSES","","scale",e,e,e,0),ht.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=Ut("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Ut("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);ht.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),ht.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return void console.error(e)}}(e),St=null}e(),Dt("Glasses")}},ht.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),Dt("Shoes"))},ht.callbacks.onWristTracked=t=>{t.detected&&(e(),Dt("Watches"))}}function xt(e,n){return t(this,void 0,void 0,(function*(){return null!=bt&&Rt===n||(yield bt,bt=ht.switchEffect(e),Rt=n),bt}))}function It(){return t(this,void 0,void 0,(function*(){if(null!=ht){if(gt=!1,null==pt){const e=kt(ft),t=We(e);pt=yield Qe(t),yield $t(ht,pt,"user"===e),ze(pt,(e=>{St=e}))}!function(){if(null==vt)return;if(null==ft||wt.has(ft))return;vt.style.visibility="visible",vt.style.opacity="1"}(),ht.setPaused(gt),mt.style.display=""}}))}function Lt(){null!=ht&&(gt=!0,ht.setPaused(gt),Ke(),null!=pt&&null!=pt.srcObject&&pt.srcObject instanceof MediaStream&&(pt.srcObject.getTracks().forEach((e=>e.stop())),pt=null),function(){if(null==vt)return;vt.style.visibility="hidden",vt.style.opacity="0"}(),ht.stopCamera(),mt.style.display="none")}function kt(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function $t(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 Dt(e){null!=vt&&(wt.has(e)||(wt.add(e),vt.style.opacity="0"))}function Ut(e,t,n,o,r,i,a){const s=ht.getTransformationBetween(e,t),l=et(ot(),s),c=function(e,t){var n=new Ze(3);tt(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,d=t[5]*r,u=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+d+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(u-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>d&&a>f?(g=2*Math.sqrt(1+a-d-f),e[3]=(u-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):d>f?(g=2*Math.sqrt(1+d-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(u+p)/g):(g=2*Math.sqrt(1+f-a-d),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(u+p)/g,e[2]=.25*g),e}(st(),s);nt(s,c,l,rt(a,a,a));const d=ht.getTransformationBetween(t,n),u=et(ot(),d);nt(d,st(),u,tt(ot(),d));const h=Je(Ye(),s,d),p=et(ot(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=ht.getTransformationBetween(n,o)}catch(e){return console.error(e),f}const g=Je(Ye(),d,m),v=Je(Ye(),s,g),w=rt(p[0],i[1],i[2]),y=at(ot(),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],d=t[8],u=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,R=o*l-r*s,S=o*c-i*s,A=r*c-i*l,C=d*m-u*f,E=d*g-h*f,M=d*v-p*f,T=u*g-h*m,P=u*v-p*m,x=h*v-p*g,I=w*x-y*P+b*T+R*M-S*E+A*C;return I?(I=1/I,e[0]=(s*x-l*P+c*T)*I,e[1]=(r*P-o*x-i*T)*I,e[2]=(m*A-g*S+v*R)*I,e[3]=(h*S-u*A-p*R)*I,e[4]=(l*M-a*x-c*E)*I,e[5]=(n*x-r*M+i*E)*I,e[6]=(g*b-f*A-v*y)*I,e[7]=(d*A-h*b+p*y)*I,e[8]=(a*P-s*M+c*C)*I,e[9]=(o*M-n*P-i*C)*I,e[10]=(f*S-m*b+v*w)*I,e[11]=(u*b-d*S-p*w)*I,e[12]=(s*E-a*T-l*C)*I,e[13]=(n*T-o*E+r*C)*I,e[14]=(m*y-f*R-g*w)*I,e[15]=(d*R-u*y+h*w)*I,e):null}(Ye(),v));let b=ht.getClosestPointOnMesh(o,y);try{const e=ht.getClosestPointOnMesh(r,y);it(y,e)<it(y,b)&&(b=e)}catch(e){console.error(e)}const R=at(ot(),b,g);return f-Math.atan2(R[0]-u[0],Math.abs(R[2]-u[2]))}function _t(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 u=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const p=String.fromCharCode(a-7),m=window[`${h}${u+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(d[c]=Math.min(76,r)*((a>>5)-1),152===d[c]&&(d[c]=w),i==c)return v;i=c,i^=c;for(let e=0,t=v.length;e<t;e++)d[c]^=d[i]<<13,d[c]^=d[i]>>17,d[c]^=d[i]<<5,v[e]=v[e]^d[c];return i^=d[0],i^=d[1],i^=d[2],v}))}function Nt(e,t){if(null==e)throw new n(`'${t}' not specified.`)}function jt(e,t){if("string"!=typeof e)throw new n(`'${t}' must be a string.`)}const Ot=["AR","3D"];function qt(e){const{apiKey:t,sku:o,targetElement:r,initialState:i,baseUrl:a,defaultUI:s,strings:l}=e;Nt(t,"apiKey"),jt(t,"apiKey"),Nt(o,"sku"),jt(o,"sku"),Nt(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",Ot),null!=a&&jt(a,"baseUrl"),null!=s&&function(e,t){if("boolean"!=typeof e)throw new n(`'${t}' must be a boolean.`)}(s,"defaultUI"),null!=l&&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.`)}}(l,"strings",ae)}function Ft(e){var o,r;return t(this,void 0,void 0,(function*(){qt(e);const{apiKey:i,sku:a,targetElement:s,initialState:l}=e;!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),y.update(e.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(ie,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(ie[t]=n)}}(e.strings);const c=function(e,o){return t(this,void 0,void 0,(function*(){const r=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams({apiKey:e,sku:o,sid:u()})}`).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 r.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(i,a),d=Me(s),{getSetupId:h,findUI:p,findQR:v,findThree:w}=d,S=h();null==je&&(Oe=$e(),je=b(`${y}/shopar-analytics.js`),je.then((()=>{qe=!0,window.ShopAR__analytics.initializeImpl(),Fe.forEach((e=>e()))})));const{trackEvent:A,arInteracted:C,previewInteracted:E}=Ge(a,i);A("setup",{hostname:window.location.hostname});const M=yield c;A("apiResponse",M);const{category:T,arUrl:P,arKey:x,arPromptEnabled:I,arPromptText:L,arPromptImage:k,previewUrl:$,previewEnvUrl:D,previewToneMapping:U}=M;Gt(h(),S);const _=null!=P&&function(e){return null!=e&&m.includes(e)}(T),N=null==(null===(o=e._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=e._internalOptions)||void 0===r?void 0:r.qrEnabled),O=_&&function(e){return null!=e&&g.includes(e)}(T),q=N&&O&&!(yield function(){var e;return t(this,void 0,void 0,(function*(){return null==At&&(At=b(`${y}/shopar-platform.js`)),yield At,["Android","iOS","Windows Phone",void 0].includes(null===(e=window.ShopAR__platform.platform.os)||void 0===e?void 0:e.family)}))}()),F=_&&!q,G=null!=$;if(Gt(h(),S),q&&function(){t(this,void 0,void 0,(function*(){null==R&&(R=b(`${y}/shopar-qr.js`))}))}(),F&&(null==ct&&(ct=b(`${y}/shopar-deepar.js`)),function(e){e!==ut&&(ut=e,Xe(e),bt=null,Ke())}(P),"Glasses"===T&&null==dt&&(dt=b(`${y}/shopar-true-scale.js`))),G){null==j&&(j=b(`${y}/shopar-three.js`));const e=255;_t($,(new Date).getTime()+e,Math.random()*e),Xe(null!=D?D:`${y}/env/default.hdr`)}const{setTargetElement:W,getDeepARTarget:Q,getDeepARPrompt:V,customizeDeepARPrompt:B,setVisibilityParameters:H,getUIState:z,setUIState:K,setDefaultUIActions:X,startDeepARLoading:Z,stopDeepARLoading:Y,startThreeLoading:J,stopThreeLoading:ee,showCameraError:te}=p();W(s);H(null==e.defaultUI||e.defaultUI,q,F,G,T),B(null!=L?L:"",null!=k?k:""),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,(()=>{z()!==be.QR||ne()||re(),z()!==be.AR||gt||Lt(),z()!==be.Preview||ce()||ue(),K(be.None)}));const{qrPaused:ne,qrDraw:oe,qrPause:re}=v(),{threeInit:ae,threeParse:se,threeLoad:le,threePaused:ce,threeResume:de,threePause:ue,threeSetToneMapping:he,threeSetOnInteracted:pe}=w();let fe=0;if(z()===be.QR){if(!ne())if(q){A(De);try{yield oe(i,a)}catch(e){throw new n(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else re(),K(be.None)}else if(z()===be.AR){if(!gt)if(F){A(Ue);const e=yield Xe(P);Gt(h(),S),Te(d),Et(T),Mt(Q()),Tt(I?V():null),yield xt(e,P),Pt(C),Gt(h(),S)}else Lt(),K(be.None)}else if(z()===be.Preview&&!ce())if(G){A(_e),J();const e=255,t=yield _t($,(new Date).getTime()+e,Math.random()*e);Gt(h(),S);const n=yield Xe(null!=D?D:`${y}/env/default.hdr`);Gt(h(),S);const o=yield se(t,n,`${$}${D}`);Gt(h(),S),le(o,T),he(null!=U?U:"ACES"),pe(E),ee()}else ue(),K(be.None);const me=()=>t(this,void 0,void 0,(function*(){if(q){if(z()===be.QR||z()===be.AR)throw new n("AR already launched.");try{A(De);const e=++fe;if(z()===be.Preview&&G&&!ce()&&ue(),K(be.QR),yield oe(i,a),fe!==e)return;return void Gt(h(),S)}catch(e){const t=e instanceof Error;throw A("qrLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`QR failed: ${t?e.message:"Unknown error."}`)}}if(!F)throw new n("Model does not have AR enabled.");if(z()===be.AR)throw new n("AR already launched.");try{A(Ue);const e=++fe;z()===be.Preview&&G&&!ce()&&ue(),Te(d),K(be.AR),Z();const t=yield Xe(P);if(fe!==e)return;if(Gt(h(),S),yield ct,fe!==e)return;if(Gt(h(),S),Lt(),Et(T),Mt(Q()),Tt(I?V():null),yield Ct(x),fe!==e)return;if(Gt(h(),S),yield xt(t,P),Pt(C),fe!==e)return;if(Gt(h(),S),yield It(),fe!==e)return;Gt(h(),S)}catch(e){const t=e instanceof Error;throw A("arLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),te(),Lt(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{Y()}})),ge=()=>t(this,void 0,void 0,(function*(){if(!G)throw new n("Model does not have 3D enabled.");if(z()===be.Preview)throw new n("3D already launched.");try{A(_e);const e=++fe;z()===be.AR&&(F&&!gt&&Lt(),re()),K(be.Preview),J();const t=255,n=yield _t($,(new Date).getTime()+t,Math.random()*t);if(fe!==e)return;Gt(h(),S);const o=yield Xe(null!=D?D:`${y}/env/default.hdr`);if(fe!==e)return;if(Gt(h(),S),yield j,fe!==e)return;if(Gt(h(),S),ae(),fe!==e)return;Gt(h(),S);const r=yield se(n,o,`${$}${D}`);if(fe!==e)return;Gt(h(),S),le(r,T),he(null!=U?U:"ACES"),pe(E),de()}catch(e){const t=e instanceof Error;throw A("previewLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`3D failed: ${t?e.message:"Unknown error."}`)}finally{ee()}})),ve=()=>t(this,void 0,void 0,(function*(){if(z()===be.None)throw new n("Neither AR or 3D launched.");++fe,z()===be.QR||z()===be.AR?(F&&!gt&&Lt(),re()):z()===be.Preview&&G&&!ce()&&ue(),K(be.None)}));return X(me,ge,ve),"AR"===l?(yield me(),Gt(h(),S)):"3D"===l&&(yield ge(),Gt(h(),S)),{launchAR:_?me:void 0,launch3D:G?ge:void 0,closeAR:_?()=>t(this,void 0,void 0,(function*(){if(z()!==be.AR&&z()!==be.QR)throw new n("AR not launched.");++fe,F&&!gt&&Lt(),re(),K(be.None)})):void 0,close3D:G?()=>t(this,void 0,void 0,(function*(){if(z()!==be.Preview)throw new n("3D not launched.");++fe,G&&!ce()&&ue(),K(be.None)})):void 0,close:_||G?ve:void 0}}))}function Gt(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}const Wt={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",(()=>Ft(e)))}))},version:v};e.plugin=Wt}));
!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;pointer-events:none}.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;pointer-events:auto}.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}"};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,d=new o[1]([c]);function u(){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)}}))}const m=["Glasses","Shoes","Watches"],g=["Shoes"];const v="0.1.1";let w=`https://cdn.jsdelivr.net/npm/shopar-plugin@${v}/dist`;const y={update:e=>{null!=e&&(w=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>w};function b(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 R;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.warn('No <meta name="viewport"> detected; ShopAR will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})();let A,C,E;function M(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}(E.parse(e));return t.mapping=C.EquirectangularReflectionMapping,t.colorSpace=C.LinearSRGBColorSpace,t}const T=45,P=45,x=3,I=1.5,L=1,k=.5;let $,D,U,_,N,j,O=!1;const q=0,F=300,G=2e3,W=.05,Q=1/(32*Math.PI);let V,B,H,z=!1,K=1,X=1,Z=1;const Y=1;let J;const ee=new Map;function te(e,n,o){const r=e.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,d,u,h,p,f=!1,m=!0,g=!1,v=!1,w=!1,y=0,b=0,R=1,S=1,L=1;const j={threeInit:()=>{f||(ne(),i=new B.Scene,a=new B.PerspectiveCamera(25,1,.5),s=new V.OrbitControls(a,e),s.enableInteraction(),({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 o=new $.Group;o.position.y=-.7;const r=new $.PlaneGeometry(T,P).rotateX(Math.PI/2),i=new $.MeshBasicMaterial({map:t.texture,opacity:k,transparent:!0,depthWrite:!1}),a=new $.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new $.Mesh(r);s.visible=!1,o.add(s);const l=new $.OrthographicCamera(-T/2,T/2,P/2,-P/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,o.add(l),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=U;const o=D.getClearAlpha();D.setClearAlpha(0),D.setRenderTarget(t),D.render(e,l),e.overrideMaterial=null,c(I),c(.4*I),D.setRenderTarget(null),D.setClearAlpha(o),e.background=n}}}(i)),f=!0)},threeParse:(e,n,o)=>t(this,void 0,void 0,(function*(){return null!=d&&u===o||(yield d,d=(()=>t(this,void 0,void 0,(function*(){var t,o;return C=(t=V).THREE,E=new t.RGBELoader,i.environment=M(n),function(e,t){const{THREE:n}=t;A=(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)}(J,V),o=e,A.parseAsync(o.buffer,"")})))(),u=o),d})),threeLoad:(e,t)=>{i.clear(),i.add(e.scene);const n=(new B.Box3).setFromObject(e.scene);l.position.y=n.min.y-q,i.add(l),c(),i.traverse((e=>{if(e instanceof B.Mesh){const t=e.material;t.depthWrite=!0,t instanceof B.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(V.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,B.Vector3)),w=!0},threePaused:()=>m,threeResume:()=>{m=!1,J.setAnimationLoop(oe),e.style.visibility="visible",y=0,b=0},threePause:()=>{m=!0,function(){for(const{threePaused:e}of ee.values())if(!e())return!1;return!0}()&&J.setAnimationLoop(null),e.style.visibility="hidden",n.style.visibility="hidden"},threeSetToneMapping:e=>({ACES:B.ACESFilmicToneMapping,Linear:B.LinearToneMapping,Neutral:B.NeutralToneMapping}[e||"ACES"]||B.ACESFilmicToneMapping),threeSetOnInteracted:e=>{s.removeEventListener("change",h),h=e,s.addEventListener("change",e)},preRender_:e=>{if(!f||m)return;e=performance.now();const t=0!==b?e-b:0;if(b=e,!s.update()){if(v)return;if(w)return void(w=!1);if(null==p&&(p=()=>{w||(v=!0,n.style.visibility="hidden",null!=p&&(s.removeEventListener("change",p),p=null))},s.addEventListener("change",p)),y+=t,!(y>F&&y<=F+G))return o.style.opacity="0",void(y>F+2*G&&(y=0));{n.style.visibility="visible",o.style.opacity="1";const e=y-F,t=2*Math.PI/G*e,r=-Math.sin(t),i=Math.cos(t);o.style.transform=`translateX(${W*r*Math.min(R,S)}px)`,s.updateTheta(Q*i)}}g=!0},shouldRender_:()=>!(!f||m)&&g,render_:()=>{const t=J.toneMapping;J.setViewport(0,0,e.width,e.height),J.render(i,a),J.toneMapping=t,g=!1,null!=r&&(r.clearRect(0,0,e.width,e.height),r.drawImage(H,0,X-e.height,e.width,e.height,0,0,e.width,e.height))},updateSize_:()=>{const{clientWidth:t,clientHeight:n}=e;t===R&&n===S&&Z===L||(e.width=Math.ceil(t*Z*Y),e.height=Math.ceil(n*Z*Y),R=t,S=n,L=Z,g=!0)},target_:e};return ee.set(e,j),j}function ne(){if(z)return;V=window.ShopAR__THREE,B=V.THREE,H=document.createElement("canvas");var e,t;H.style.position="block",J=new B.WebGLRenderer({powerPreference:"high-performance",canvas:H,antialias:!0,alpha:!0}),J.outputColorSpace=B.SRGBColorSpace,J.toneMapping=B.ACESFilmicToneMapping,J.setClearColor(new B.Color(16777215)),e=J,t=V,O||($=t.THREE,D=e,U=new $.MeshDepthMaterial,U.userData.darkness={value:L},U.onBeforeCompile=e=>{e.uniforms.darkness=U.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}`},U.depthTest=!1,U.depthWrite=!1,_=new $.ShaderMaterial(t.HorizontalBlurShader),_.depthTest=!1,N=new $.ShaderMaterial(t.VerticalBlurShader),N.depthTest=!1,O=!0),re(),z=!0}function oe(e){re(),J.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of ee.values())t(e),n()&&o()}function re(){let e=0,t=0;for(const{target_:n}of ee.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=S();e=Math.ceil(e*n*Y),t=Math.ceil(t*n*Y),e===K&&t===X&&n===Z||(K=e,X=t,Z=n,J.setSize(K,X,!1));for(const{updateSize_:e}of ee.values())e()}const ie={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},ae=Object.keys(ie);function se(e){return ie[e]}function le(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}const ce="shopar-error";function de(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=le("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;return r.style.display="none",r}const ue="shopar-control";const he="shopar-deepar-output";function pe(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%",t}function fe(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function me(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 ge(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 ve="shopar-main";const we="shopar-qr-output";const ye="shopar-three-output";var be;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(be||(be={}));let Re=!1;function Se(){Re||(!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.")}}(),Re=!0)}function Ae(){Se();const e=function(){const e=document.createElement("div");e.id=ve;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}(),t=function(){const e=new Image,t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),n=function(e){const t=document.createElement("div");t.id=we;const n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.display="none";const o=document.createElement("div");o.className="shopar-qr";const r=o.style;r.position="relative",r.top="0",r.left="0",r.width="100%",r.height="100%",t.appendChild(o);const i=document.createElement("div");i.innerText="Scan on mobile or tablet to try on",i.style.textAlign="center",o.appendChild(i);const a=document.createElement("div");return a.appendChild(e),o.appendChild(a),t}(t);e.appendChild(n);const o=function(){const e=document.createElement("div");e.id=he;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",e}();e.appendChild(o);const r=function(){const e=document.createElement("canvas");e.id=ye;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",e}();e.appendChild(r);const i=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),a=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),s=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.pointerEvents="none",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(i,a);e.appendChild(s);const l=function(){const e=le("2rem",`${y}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),c=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",n.pointerEvents="none",t.appendChild(e),t}(l);e.appendChild(c);const d=pe("shopar-ar-loading-container"),u=fe("shopar-ar-loading-text",se("loading.ar"));d.appendChild(u);const h=me("shopar-ar-loading-bar-bg"),p=ge("shopar-ar-loading-bar-fg");h.appendChild(p),d.appendChild(h),e.appendChild(d);const f=pe("shopar-3d-loading-container"),m=fe("shopar-3d-loading-text",se("loading.3d"));f.appendChild(m);const g=me("shopar-3d-loading-bar-bg"),v=ge("shopar-3d-loading-bar-fg");g.appendChild(v),f.appendChild(g),e.appendChild(f);const w=function(){const e=document.createElement("div");e.id=ce;const t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const r=le("4rem",`${y}/img/icons/close.svg`);n.appendChild(r);const i=document.createElement("div");i.className="shopar-error-title",i.textContent="Camera Error",n.appendChild(i);const a=document.createElement("div");return a.className="shopar-error-body",a.textContent="Please refresh the page and allow the use of camera.",n.appendChild(a),e}();e.appendChild(w);const b=function(){const e=document.createElement("div");return e.id=ue,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(b);const R=de("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");b.appendChild(R);const S=de("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${y}/img/icons/cube.svg`);b.appendChild(S);const A=de("shopar-btn-close","Close","Close ShopAR view",`${y}/img/icons/close.svg`);b.append(A);let C,E=be.None,M=!1,T=!1,P=!1,x=!1;function I(){p.classList.remove("active"),d.style.visibility="hidden"}function L(){v.classList.remove("active"),f.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return n},getQRImage:function(){return t},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return r},getThreePrompt:function(){return c},getThreePromptImage:function(){return l},customizeDeepARPrompt:function(e,t){i.textContent=e,a.src=t},setVisibilityParameters:function(e,t,n,o,r){var i;M=e,T=t,P=n,x=o,C=r,Ce(b,M),Ce(R,M&&(P||T)&&E===be.None),Ce(S,M&&x&&E===be.None),Ce(A,M&&E!==be.None),I(),L(),M||""===(i=w).style.display&&Ce(i,!1)},getUIState:function(){return E},setUIState:function(e){E=e,E===be.None?(I(),L(),M&&(Ce(w,!1),Ce(A,!1),(T||P)&&Ce(R,!0),x&&Ce(S,!0))):E!==be.QR&&E!==be.AR&&E!==be.Preview||M&&(Ce(w,!1),Ce(R,!1),Ce(S,!1),Ce(A,!0))},setDefaultUIActions:function(e,t,n){M&&((T||P)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${y}/img/icons/${n}`;R.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(C),R.onclick=e),x&&(S.onclick=t),A.onclick=n)},startDeepARLoading:function(){p.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:I,startThreeLoading:function(){v.classList.add("active"),f.style.visibility="visible"},stopThreeLoading:L,showCameraError:function(){M&&Ce(w,!0)}}}function Ce(e,t){e.style.display=t?"":"none"}const Ee=new Map;function Me(e){let n=Ee.get(e);return null==n?(n=function(){let e=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Ae()),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 R;const t=`https://apps.deepar.ai/${v.includes("alpha")?"shopar-qr-alpha":"shopar-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=te(e(),t(),n())}return r}}}(),Ee.set(e,n)):n.incrementSetupId_(),n}function Te(e){for(const t of Ee.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===be.AR&&r(be.None)}}let Pe;const xe=new Uint8Array(16);function Ie(){if(!Pe&&(Pe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pe(xe)}const Le=[];for(let e=0;e<256;++e)Le.push((e+256).toString(16).slice(1));var ke={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $e(e,t,n){if(ke.randomUUID&&!t&&!e)return ke.randomUUID();const o=(e=e||{}).random||(e.rng||Ie)();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 Le[e[t+0]]+Le[e[t+1]]+Le[e[t+2]]+Le[e[t+3]]+"-"+Le[e[t+4]]+Le[e[t+5]]+"-"+Le[e[t+6]]+Le[e[t+7]]+"-"+Le[e[t+8]]+Le[e[t+9]]+"-"+Le[e[t+10]]+Le[e[t+11]]+Le[e[t+12]]+Le[e[t+13]]+Le[e[t+14]]+Le[e[t+15]]}(o)}const De="qrLaunch",Ue="arLaunch",_e="previewLaunch",Ne="heartbeat";let je,Oe,qe=!1;const Fe=[];function Ge(e,t){const n=performance.now(),o=$e();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,d(Ne,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const d=(r,i={})=>{var a;i=Object.assign(Object.assign({},i),{pluginVersion:v,sessionId:Oe,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),a=()=>{window.ShopAR__analytics.trackEventImpl(r,i)},qe?a():Fe.push(a)};return{trackEvent:d,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)}}}function We(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Qe(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 Ve=200,Be=10;let He=!1;function ze(e,n){return t(this,void 0,void 0,(function*(){He=!1;const{ShopAR__TrueScale:o}=window;yield o.initialize(`${y}/wasm/mediapipe`,e);const r=[],i=setInterval((()=>t(this,void 0,void 0,(function*(){if(He)return void clearInterval(i);const{error:e,faceWidth:t}=yield o.predict(performance.now());if(He)return void clearInterval(i);if(null!=e)return void console.error(`TrueScale predict error: ${e}`);if(r.length<Be)return void r.push(t);clearInterval(i);const a=function(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}(r);n(a)}))),Ve)}))}function Ke(){He=!0}function Xe(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 Ze="undefined"!=typeof Float32Array?Float32Array:Array;function Ye(){var e=new Ze(16);return Ze!=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 Je(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],d=t[7],u=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],R=n[2],S=n[3];return e[0]=y*o+b*s+R*u+S*m,e[1]=y*r+b*l+R*h+S*g,e[2]=y*i+b*c+R*p+S*v,e[3]=y*a+b*d+R*f+S*w,y=n[4],b=n[5],R=n[6],S=n[7],e[4]=y*o+b*s+R*u+S*m,e[5]=y*r+b*l+R*h+S*g,e[6]=y*i+b*c+R*p+S*v,e[7]=y*a+b*d+R*f+S*w,y=n[8],b=n[9],R=n[10],S=n[11],e[8]=y*o+b*s+R*u+S*m,e[9]=y*r+b*l+R*h+S*g,e[10]=y*i+b*c+R*p+S*v,e[11]=y*a+b*d+R*f+S*w,y=n[12],b=n[13],R=n[14],S=n[15],e[12]=y*o+b*s+R*u+S*m,e[13]=y*r+b*l+R*h+S*g,e[14]=y*i+b*c+R*p+S*v,e[15]=y*a+b*d+R*f+S*w,e}function et(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function tt(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],d=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,d),e}function nt(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,d=a+a,u=r*l,h=r*c,p=r*d,f=i*c,m=i*d,g=a*d,v=s*l,w=s*c,y=s*d,b=o[0],R=o[1],S=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)*R,e[5]=(1-(u+g))*R,e[6]=(m+v)*R,e[7]=0,e[8]=(p+w)*S,e[9]=(m-v)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function ot(){var e=new Ze(3);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function rt(e,t,n){var o=new Ze(3);return o[0]=e,o[1]=t,o[2]=n,o}function it(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 at(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 st(){var e=new Ze(4);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}ot(),function(){var e,t=(e=new Ze(4),Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var lt;let ct,dt,ut;ot(),rt(1,0,0),rt(0,1,0),st(),st(),lt=new Ze(9),Ze!=Float32Array&&(lt[1]=0,lt[2]=0,lt[3]=0,lt[5]=0,lt[6]=0,lt[7]=0),lt[0]=1,lt[4]=1,lt[8]=1;let ht,pt,ft,mt,gt=!0,vt=null;const wt=new Set;let yt,bt,Rt,St,At;function Ct(e){return t(this,void 0,void 0,(function*(){return null==yt&&(yt=(()=>t(this,void 0,void 0,(function*(){if(null==(null===(t=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===t?void 0:t.getUserMedia))throw new n("No camera available!");var t;const o=kt(ft),r=We(o),i=function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(ft);ht=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:e||"your_license_key_goes_here",previewElement:mt,additionalOptions:{hint:i,cameraConfig:{disableDefaultCamera:!0}}}),pt=yield Qe(r),yield $t(ht,pt,"user"===o),"Glasses"===ft&&(yield dt,ze(pt,(e=>{St=e})))})))()),yt}))}function Et(e){e!==ft&&(null!=ht&&(ht.shutdown(),ht=null,yt=null),ft=e)}function Mt(e){e!==mt&&(mt=e,null!=ht&&ht.changePreviewElement(mt))}function Tt(e){vt=e}function Pt(e){ht.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(St){const e=137/(St+5);ht.changeParameterVector("GLASSES","","scale",e,e,e,0),ht.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=Ut("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Ut("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);ht.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),ht.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return void console.error(e)}}(e),St=null}e(),Dt("Glasses")}},ht.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),Dt("Shoes"))},ht.callbacks.onWristTracked=t=>{t.detected&&(e(),Dt("Watches"))}}function xt(e,n){return t(this,void 0,void 0,(function*(){return null!=bt&&Rt===n||(yield bt,bt=ht.switchEffect(e),Rt=n),bt}))}function It(){return t(this,void 0,void 0,(function*(){if(null!=ht){if(gt=!1,null==pt){const e=kt(ft),t=We(e);pt=yield Qe(t),yield $t(ht,pt,"user"===e),ze(pt,(e=>{St=e}))}!function(){if(null==vt)return;if(null==ft||wt.has(ft))return;vt.style.visibility="visible",vt.style.opacity="1"}(),ht.setPaused(gt),mt.style.display=""}}))}function Lt(){null!=ht&&(gt=!0,ht.setPaused(gt),Ke(),null!=pt&&null!=pt.srcObject&&pt.srcObject instanceof MediaStream&&(pt.srcObject.getTracks().forEach((e=>e.stop())),pt=null),function(){if(null==vt)return;vt.style.visibility="hidden",vt.style.opacity="0"}(),ht.stopCamera(),mt.style.display="none")}function kt(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function $t(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 Dt(e){null!=vt&&(wt.has(e)||(wt.add(e),vt.style.opacity="0"))}function Ut(e,t,n,o,r,i,a){const s=ht.getTransformationBetween(e,t),l=et(ot(),s),c=function(e,t){var n=new Ze(3);tt(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,d=t[5]*r,u=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+d+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(u-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>d&&a>f?(g=2*Math.sqrt(1+a-d-f),e[3]=(u-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):d>f?(g=2*Math.sqrt(1+d-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(u+p)/g):(g=2*Math.sqrt(1+f-a-d),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(u+p)/g,e[2]=.25*g),e}(st(),s);nt(s,c,l,rt(a,a,a));const d=ht.getTransformationBetween(t,n),u=et(ot(),d);nt(d,st(),u,tt(ot(),d));const h=Je(Ye(),s,d),p=et(ot(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=ht.getTransformationBetween(n,o)}catch(e){return console.error(e),f}const g=Je(Ye(),d,m),v=Je(Ye(),s,g),w=rt(p[0],i[1],i[2]),y=at(ot(),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],d=t[8],u=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,R=o*l-r*s,S=o*c-i*s,A=r*c-i*l,C=d*m-u*f,E=d*g-h*f,M=d*v-p*f,T=u*g-h*m,P=u*v-p*m,x=h*v-p*g,I=w*x-y*P+b*T+R*M-S*E+A*C;return I?(I=1/I,e[0]=(s*x-l*P+c*T)*I,e[1]=(r*P-o*x-i*T)*I,e[2]=(m*A-g*S+v*R)*I,e[3]=(h*S-u*A-p*R)*I,e[4]=(l*M-a*x-c*E)*I,e[5]=(n*x-r*M+i*E)*I,e[6]=(g*b-f*A-v*y)*I,e[7]=(d*A-h*b+p*y)*I,e[8]=(a*P-s*M+c*C)*I,e[9]=(o*M-n*P-i*C)*I,e[10]=(f*S-m*b+v*w)*I,e[11]=(u*b-d*S-p*w)*I,e[12]=(s*E-a*T-l*C)*I,e[13]=(n*T-o*E+r*C)*I,e[14]=(m*y-f*R-g*w)*I,e[15]=(d*R-u*y+h*w)*I,e):null}(Ye(),v));let b=ht.getClosestPointOnMesh(o,y);try{const e=ht.getClosestPointOnMesh(r,y);it(y,e)<it(y,b)&&(b=e)}catch(e){console.error(e)}const R=at(ot(),b,g);return f-Math.atan2(R[0]-u[0],Math.abs(R[2]-u[2]))}function _t(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 u=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const p=String.fromCharCode(a-7),m=window[`${h}${u+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(d[c]=Math.min(76,r)*((a>>5)-1),152===d[c]&&(d[c]=w),i==c)return v;i=c,i^=c;for(let e=0,t=v.length;e<t;e++)d[c]^=d[i]<<13,d[c]^=d[i]>>17,d[c]^=d[i]<<5,v[e]=v[e]^d[c];return i^=d[0],i^=d[1],i^=d[2],v}))}function Nt(e,t){if(null==e)throw new n(`'${t}' not specified.`)}function jt(e,t){if("string"!=typeof e)throw new n(`'${t}' must be a string.`)}const Ot=["AR","3D"];function qt(e){const{apiKey:t,sku:o,targetElement:r,initialState:i,baseUrl:a,defaultUI:s,strings:l}=e;Nt(t,"apiKey"),jt(t,"apiKey"),Nt(o,"sku"),jt(o,"sku"),Nt(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",Ot),null!=a&&jt(a,"baseUrl"),null!=s&&function(e,t){if("boolean"!=typeof e)throw new n(`'${t}' must be a boolean.`)}(s,"defaultUI"),null!=l&&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.`)}}(l,"strings",ae)}function Ft(e){var o,r;return t(this,void 0,void 0,(function*(){qt(e);const{apiKey:i,sku:a,targetElement:s,initialState:l}=e;!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),y.update(e.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(ie,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(ie[t]=n)}}(e.strings);const c=function(e,o){return t(this,void 0,void 0,(function*(){const r=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams({apiKey:e,sku:o,sid:u()})}`).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 r.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(i,a),d=Me(s),{getSetupId:h,findUI:p,findQR:v,findThree:w}=d,S=h();null==je&&(Oe=$e(),je=b(`${y}/shopar-analytics.js`),je.then((()=>{qe=!0,window.ShopAR__analytics.initializeImpl(),Fe.forEach((e=>e()))})));const{trackEvent:A,arInteracted:C,previewInteracted:E}=Ge(a,i);A("setup",{hostname:window.location.hostname});const M=yield c;A("apiResponse",M);const{category:T,arUrl:P,arKey:x,arPromptEnabled:I,arPromptText:L,arPromptImage:k,previewUrl:$,previewEnvUrl:D,previewToneMapping:U}=M;Gt(h(),S);const _=null!=P&&function(e){return null!=e&&m.includes(e)}(T),N=null==(null===(o=e._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=e._internalOptions)||void 0===r?void 0:r.qrEnabled),O=_&&function(e){return null!=e&&g.includes(e)}(T),q=N&&O&&!(yield function(){var e;return t(this,void 0,void 0,(function*(){return null==At&&(At=b(`${y}/shopar-platform.js`)),yield At,["Android","iOS","Windows Phone",void 0].includes(null===(e=window.ShopAR__platform.platform.os)||void 0===e?void 0:e.family)}))}()),F=_&&!q,G=null!=$;if(Gt(h(),S),q&&function(){t(this,void 0,void 0,(function*(){null==R&&(R=b(`${y}/shopar-qr.js`))}))}(),F&&(null==ct&&(ct=b(`${y}/shopar-deepar.js`)),function(e){e!==ut&&(ut=e,Xe(e),bt=null,Ke())}(P),"Glasses"===T&&null==dt&&(dt=b(`${y}/shopar-true-scale.js`))),G){null==j&&(j=b(`${y}/shopar-three.js`));const e=255;_t($,(new Date).getTime()+e,Math.random()*e),Xe(null!=D?D:`${y}/env/default.hdr`)}const{setTargetElement:W,getDeepARTarget:Q,getDeepARPrompt:V,customizeDeepARPrompt:B,setVisibilityParameters:H,getUIState:z,setUIState:K,setDefaultUIActions:X,startDeepARLoading:Z,stopDeepARLoading:Y,startThreeLoading:J,stopThreeLoading:ee,showCameraError:te}=p();W(s);H(null==e.defaultUI||e.defaultUI,q,F,G,T),B(null!=L?L:"",null!=k?k:""),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,(()=>{z()!==be.QR||ne()||re(),z()!==be.AR||gt||Lt(),z()!==be.Preview||ce()||ue(),K(be.None)}));const{qrPaused:ne,qrDraw:oe,qrPause:re}=v(),{threeInit:ae,threeParse:se,threeLoad:le,threePaused:ce,threeResume:de,threePause:ue,threeSetToneMapping:he,threeSetOnInteracted:pe}=w();let fe=0;if(z()===be.QR){if(!ne())if(q){A(De);try{yield oe(i,a)}catch(e){throw new n(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else re(),K(be.None)}else if(z()===be.AR){if(!gt)if(F){A(Ue);const e=yield Xe(P);Gt(h(),S),Te(d),Et(T),Mt(Q()),Tt(I?V():null),yield xt(e,P),Pt(C),Gt(h(),S)}else Lt(),K(be.None)}else if(z()===be.Preview&&!ce())if(G){A(_e),J();const e=255,t=yield _t($,(new Date).getTime()+e,Math.random()*e);Gt(h(),S);const n=yield Xe(null!=D?D:`${y}/env/default.hdr`);Gt(h(),S);const o=yield se(t,n,`${$}${D}`);Gt(h(),S),le(o,T),he(null!=U?U:"ACES"),pe(E),ee()}else ue(),K(be.None);const me=()=>t(this,void 0,void 0,(function*(){if(q){if(z()===be.QR||z()===be.AR)throw new n("AR already launched.");try{A(De);const e=++fe;if(z()===be.Preview&&G&&!ce()&&ue(),K(be.QR),yield oe(i,a),fe!==e)return;return void Gt(h(),S)}catch(e){const t=e instanceof Error;throw A("qrLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`QR failed: ${t?e.message:"Unknown error."}`)}}if(!F)throw new n("Model does not have AR enabled.");if(z()===be.AR)throw new n("AR already launched.");try{A(Ue);const e=++fe;z()===be.Preview&&G&&!ce()&&ue(),Te(d),K(be.AR),Z();const t=yield Xe(P);if(fe!==e)return;if(Gt(h(),S),yield ct,fe!==e)return;if(Gt(h(),S),Lt(),Et(T),Mt(Q()),Tt(I?V():null),yield Ct(x),fe!==e)return;if(Gt(h(),S),yield xt(t,P),Pt(C),fe!==e)return;if(Gt(h(),S),yield It(),fe!==e)return;Gt(h(),S)}catch(e){const t=e instanceof Error;throw A("arLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),te(),Lt(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{Y()}})),ge=()=>t(this,void 0,void 0,(function*(){if(!G)throw new n("Model does not have 3D enabled.");if(z()===be.Preview)throw new n("3D already launched.");try{A(_e);const e=++fe;z()===be.AR&&(F&&!gt&&Lt(),re()),K(be.Preview),J();const t=255,n=yield _t($,(new Date).getTime()+t,Math.random()*t);if(fe!==e)return;Gt(h(),S);const o=yield Xe(null!=D?D:`${y}/env/default.hdr`);if(fe!==e)return;if(Gt(h(),S),yield j,fe!==e)return;if(Gt(h(),S),ae(),fe!==e)return;Gt(h(),S);const r=yield se(n,o,`${$}${D}`);if(fe!==e)return;Gt(h(),S),le(r,T),he(null!=U?U:"ACES"),pe(E),de()}catch(e){const t=e instanceof Error;throw A("previewLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`3D failed: ${t?e.message:"Unknown error."}`)}finally{ee()}})),ve=()=>t(this,void 0,void 0,(function*(){if(z()===be.None)throw new n("Neither AR or 3D launched.");++fe,z()===be.QR||z()===be.AR?(F&&!gt&&Lt(),re()):z()===be.Preview&&G&&!ce()&&ue(),K(be.None)}));return X(me,ge,ve),"AR"===l?(yield me(),Gt(h(),S)):"3D"===l&&(yield ge(),Gt(h(),S)),{launchAR:_?me:void 0,launch3D:G?ge:void 0,closeAR:_?()=>t(this,void 0,void 0,(function*(){if(z()!==be.AR&&z()!==be.QR)throw new n("AR not launched.");++fe,F&&!gt&&Lt(),re(),K(be.None)})):void 0,close3D:G?()=>t(this,void 0,void 0,(function*(){if(z()!==be.Preview)throw new n("3D not launched.");++fe,G&&!ce()&&ue(),K(be.None)})):void 0,close:_||G?ve:void 0}}))}function Gt(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}const Wt={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",(()=>Ft(e)))}))},version:v};e.plugin=Wt}));
{
"name": "shopar-plugin",
"version": "0.1.1-alpha.5",
"version": "0.1.1",
"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@{{VERSION}}/dist/shopar-plugin.js"></script>
<script src="https://cdn.jsdelivr.net/npm/shopar-plugin@0.1.1/dist/shopar-plugin.js"></script>
```

@@ -161,3 +161,3 @@

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

@@ -164,0 +164,0 @@ - Type: `object`

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