shopar-plugin 0.7.4-alpha.4 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,7 +32,7 @@ There are two distinct ways of integrating the plugin: via Script tag and via NP
32
32
  Add the following script to your HTML.
33
33
 
34
34
  ```html
35
- <script src="https://cdn.jsdelivr.net/npm/shopar-plugin@{{VERSION}}/dist/shopar-plugin.js"></script>
35
+ <script src="https://cdn.jsdelivr.net/npm/shopar-plugin@0.7.4/dist/shopar-plugin.js"></script>
36
36
  ```
37
37
 
38
38
  It is possible to use a different CDN instead of [jsDelivr](https://www.jsdelivr.com/) (e.g. [cdnjs](https://cdnjs.com/), [unpkg](https://www.unpkg.com/)), or even a relative path if the plugin is distributed as a static asset to your app. Just make sure to set the `baseUrl` parameter accordingly (see [setup options](#shoparpluginsetupoptions) for more details).
@@ -153,7 +153,7 @@ Options used for the plugin setup:
153
153
  - `baseUrl` (optional)
154
154
  - Type: `string`
155
155
  - If provided, defines where the additional ShopAR plugin files are fetched from.
156
- - Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@{{VERSION}}/dist`
156
+ - Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@0.7.4/dist`
157
157
  - `defaultUI` (optional)
158
158
  - Type: `boolean`
159
159
  - If provided and set to `false`, disables the default UI such as buttons, loading and error views.
@@ -1 +1 @@
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))}}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShopAR__analytics={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t){return Number.isInteger(t)&&t>=0}function n(t){this.name="ArgumentError",this.message=t}var s=e((function(t,e){if(e=e||{},"function"!=typeof t)throw new n("fetch must be a function");if("object"!=typeof e)throw new n("defaults must be an object");if(void 0!==e.retries&&!i(e.retries))throw new n("retries must be a positive integer");if(void 0!==e.retryDelay&&!i(e.retryDelay)&&"function"!=typeof e.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");if(void 0!==e.retryOn&&!Array.isArray(e.retryOn)&&"function"!=typeof e.retryOn)throw new n("retryOn property expects an array or function");return e=Object.assign({retries:3,retryDelay:1e3,retryOn:[]},e),function(s,r){var a=e.retries,o=e.retryDelay,c=e.retryOn;if(r&&void 0!==r.retries){if(!i(r.retries))throw new n("retries must be a positive integer");a=r.retries}if(r&&void 0!==r.retryDelay){if(!i(r.retryDelay)&&"function"!=typeof r.retryDelay)throw new n("retryDelay must be a positive integer or a function returning a positive integer");o=r.retryDelay}if(r&&r.retryOn){if(!Array.isArray(r.retryOn)&&"function"!=typeof r.retryOn)throw new n("retryOn property expects an array or function");c=r.retryOn}return new Promise((function(e,i){var n=function(n){var o="undefined"!=typeof Request&&s instanceof Request?s.clone():s;t(o,r).then((function(t){if(Array.isArray(c)&&-1===c.indexOf(t.status))e(t);else if("function"==typeof c)try{return Promise.resolve(c(n,null,t)).then((function(i){i?u(n,null,t):e(t)})).catch(i)}catch(t){i(t)}else n<a?u(n,null,t):e(t)})).catch((function(t){if("function"==typeof c)try{Promise.resolve(c(n,t,null)).then((function(e){e?u(n,t,null):i(t)})).catch((function(t){i(t)}))}catch(t){i(t)}else n<a?u(n,t,null):i(t)}))};function u(t,e,i){var s="function"==typeof o?o(t,e,i):o;setTimeout((function(){n(++t)}),s)}n(0)}))}}));var r,a;!function(t){t.unknown="unknown",t.user="user",t.organization="organization",t.anonymous="anonymous"}(r||(r={})),function(t){t.api="api",t.query="query",t.ingest="ingest"}(a||(a={}));class o{scope;type;value;remaining;reset;constructor(t=r.unknown,e=a.api,i=0,n=-1,s=new Date){this.scope=t,this.type=e,this.value=i,this.remaining=n,this.reset=s}}function c(t,e,i,n,s){let a=new o;const c=t.headers.get(e.toLowerCase())||r.unknown;a.scope=r[c];const u=t.headers.get(i.toLowerCase())||"",h=parseInt(u,10);isNaN(h)||(a.value=h);const l=t.headers.get(n.toLowerCase())||"",f=parseInt(l,10);isNaN(f)||(a.remaining=f);const m=t.headers.get(s.toLowerCase())||"",y=parseInt(m,10);return isNaN(y)||(a.reset=new Date(1e3*y)),a}class u{config;constructor(t){this.config=t}async doReq(t,e,i={},n={}){let r=`${this.config.baseUrl}${t}`;const o=this._prepareSearchParams(n);o&&(r+=`?${o.toString()}`);const u={...this.config.headers,...i.headers},l=await s(fetch)(r,{retries:3,retryDelay:function(t,e,i){return 1e3*Math.pow(2,t)},retryOn:[503,502,504,500],headers:u,method:e,body:i.body?i.body:void 0});if(204===l.status)return l;if(429==l.status){const t=function(t){let e;return t.url?.endsWith("/ingest")?(e=c(t,"","X-IngestLimit-Limit","X-IngestLimit-Remaining","X-IngestLimit-Reset"),e.type=a.ingest):t.url?.endsWith("/query")||t.url?.endsWith("/_apl")?(e=c(t,"","X-QueryLimit-Limit","X-QueryLimit-Remaining","X-QueryLimit-Reset"),e.type=a.query):(e=c(t,"X-RateLimit-Scope","X-RateLimit-Limit","X-RateLimit-Remaining","X-RateLimit-Reset"),e.type=a.api),e}(l);return Promise.reject(new h(t))}if(401===l.status)return Promise.reject(new Error("Forbidden"));if(l.status>=400){const t=await l.json();return Promise.reject(new Error(t.message))}return await l.json()}post(t,e={},i={}){return this.doReq(t,"POST",e,i)}get(t,e={},i={}){return this.doReq(t,"GET",e,i)}put(t,e={},i={}){return this.doReq(t,"PUT",e,i)}delete(t,e={},i={}){return this.doReq(t,"DELETE",e,i)}_prepareSearchParams=t=>{const e=new URLSearchParams;let i=!1;return Object.keys(t).forEach((n=>{t[n]&&(e.append(n,t[n]),i=!0)})),i?e:null}}class h extends Error{limit;shortcircuit;message="";constructor(t,e=!1){super(),this.limit=t,this.shortcircuit=e,Object.setPrototypeOf(this,h.prototype);const i=h.timeUntilReset(t);this.message=`${t.type} limit exceeded, try again in ${i.minutes}m${i.seconds}s`,t.type==a.api&&(this.message=`${t.scope} `+this.message)}static timeUntilReset(t){const e=t.reset.getTime()-(new Date).getTime(),i=Math.floor(e/1e3%60);return{total:e,minutes:Math.floor(e/1e3/60%60),seconds:i}}}class l{client;constructor({orgId:t="",token:e,url:i}){e||console.warn("Missing Axiom token");const n=i??"https://api.axiom.co",s={Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+e};"undefined"==typeof window&&(s["User-Agent"]="axiom-js/1.0.0-rc.1"),t&&(s["X-Axiom-Org-Id"]=t),this.client=new u({baseUrl:n,headers:s,timeout:3e3})}}var f,m,y,p,d,g;!function(t){t.TimestampField="_time";t.Service=class extends l{localPath="/v1/datasets";list=()=>this.client.get(this.localPath);get=t=>this.client.get(this.localPath+"/"+t);create=t=>this.client.post(this.localPath,{body:JSON.stringify(t)});update=(t,e)=>this.client.put(this.localPath+"/"+t,{body:JSON.stringify(e)});delete=t=>this.client.delete(this.localPath+"/"+t);trim=(t,e)=>{const i={maxDuration:e};return this.client.post(this.localPath+"/"+t+"/trim",{body:JSON.stringify(i)})}}}(f||(f={})),function(t){t.Service=class extends l{current=()=>this.client.get("/v1/user")}}(m||(m={}));class w{ingestFn;id;options;events=[];activeFlush=Promise.resolve();nextFlush=setTimeout((()=>{}),0);lastFlush=new Date;constructor(t,e,i){this.ingestFn=t,this.id=e,this.options=i}ingest=t=>{Array.isArray(t)?this.events=this.events.concat(t):this.events.push(t),this.events.length>=1e3||this.lastFlush.getTime()<Date.now()-1e3?(clearTimeout(this.nextFlush),this.activeFlush=this.flush()):(clearTimeout(this.nextFlush),this.nextFlush=setTimeout((()=>{this.activeFlush=this.flush()}),1e3))};flush=async()=>{const t=this.events.splice(0,this.events.length);if(clearTimeout(this.nextFlush),await this.activeFlush,0===t.length)return void(this.lastFlush=new Date);const e=await this.ingestFn(this.id,t,this.options);return this.lastFlush=new Date,e}}class v extends l{datasets;users;localPath="/v1";constructor(t){super(t),this.datasets=new f.Service(t),this.users=new m.Service(t)}ingestRaw=(t,e,i=y.JSON,n=p.Identity,s)=>this.client.post(this.localPath+"/datasets/"+t+"/ingest",{headers:{"Content-Type":i,"Content-Encoding":n},body:e},{"timestamp-field":s?.timestampField,"timestamp-format":s?.timestampFormat,"csv-delimiter":s?.csvDelimiter});queryLegacy=(t,e,i)=>this.client.post(this.localPath+"/datasets/"+t+"/query",{body:JSON.stringify(e)},{"streaming-duration":i?.streamingDuration,nocache:i?.noCache});query=(t,e)=>{const i={apl:t};return e?.startTime&&(i.startTime=e?.startTime),e?.endTime&&(i.endTime=e?.endTime),this.client.post(this.localPath+"/datasets/_apl",{body:JSON.stringify(i)},{"streaming-duration":e?.streamingDuration,nocache:e?.noCache,format:"legacy"})};aplQuery=(t,e)=>this.query(t,e)}class x extends v{batch={};ingest=(t,e,i)=>{const n=function(t,e){return`${t}:${e?.timestampField||"-"}:${e?.timestampFormat||"-"}:${e?.csvDelimiter||"-"}`}(t,i);return this.batch[n]||(this.batch[n]=new w(((t,e,i)=>{const n=(Array.isArray(e)?e:[e]).map((t=>JSON.stringify(t))).join("\n");return this.ingestRaw(t,n,y.NDJSON,p.Identity,i)}),t,i)),this.batch[n].ingest(e)};flush=async()=>{let t=[];for(const e in this.batch)t.push(this.batch[e].flush());await Promise.all(t)}}let b;!function(t){t.JSON="application/json",t.NDJSON="application/x-ndjson",t.CSV="text/csv"}(y||(y={})),function(t){t.Identity="",t.GZIP="gzip"}(p||(p={})),function(t){t.Count="count",t.Distinct="distinct",t.Sum="sum",t.Avg="avg",t.Min="min",t.Max="max",t.Topk="topk",t.Percentiles="percentiles",t.Histogram="histogram",t.Variance="variance",t.Stdev="stdev",t.ArgMin="argmin",t.ArgMax="argmax",t.MakeSet="makeset",t.MakeSetIf="makesetif",t.CountIf="countif",t.CountDistinctIf="distinctif"}(d||(d={})),function(t){t.And="and",t.Or="or",t.Not="not",t.Equal="==",t.NotEqual="!=",t.Exists="exists",t.NotExists="not-exists",t.GreaterThan=">",t.GreaterThanOrEqualTo=">=",t.LessThan="<",t.LessThanOrEqualTo="<=",t.Gt="gt",t.Gte="gte",t.Lt="lt",t.Lte="lte",t.StartsWith="starts-with",t.NotStartsWith="not-starts-with",t.EndsWith="ends-with",t.NotEndsWith="not-ends-with",t.Contains="contains",t.NotContains="not-contains",t.Regexp="regexp",t.NotRegexp="not-regexp"}(g||(g={})),t.initializeImpl=function(){b=new x({token:"xaat-f69a9dd7-3988-4fc2-849b-4a0978468c25"})},t.trackEventImpl=function(t,e){b.ingest("shopar-plugin",Object.assign({name:t},e))}}));
@@ -1 +1 @@
1
- function e(e,t,n,A){return new(n||(n=Promise))((function(o,i){function r(e){try{s(A.next(e))}catch(e){i(e)}}function a(e){try{s(A.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}s((A=A.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array],A=n.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],r=window[o[i[i[A]]]][o[i[i[i.length-1]]]],a=r.charCodeAt(A),s=a^a,l=new n[1]([s]);function c(){const e=(new TextEncoder).encode(r),t=o.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[o[t[2]]](String.fromCodePoint(...e))}const g=[1e3,2e3,4e3],u=g.length;function d(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=u)throw e;return yield new Promise((e=>setTimeout(e,g[n]))),d(t,n+1)}}))}function I(e){return e*(180/Math.PI)}function h(e){return Math.round(100*e)/100}const C=["Glasses","Shoes","Watches"],p=["Shoes"];const f={},E={};function B(n){return null==f[n]&&(f[n]=function(n){return e(this,void 0,void 0,(function*(){const A=yield d((()=>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 A.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}(n)),f[n]}function Q(A,o,i){return null==E[A]&&(E[A]=function(A,o,i){return e(this,void 0,void 0,(function*(){let r="glb".charCodeAt(0),a="3d".charCodeAt(0);r>>=1,r+=a;const c=String.fromCharCode(r+14);a>>=2,r^=a+2;const g=String.fromCharCode(r-3);r^=5;const u=String.fromCharCode(r-7);r^=2;const I=String.fromCharCode(r-7),h=window[`${u}${g+c+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${I}`],C=yield d((()=>e(this,void 0,void 0,(function*(){const e=yield h(`${A}`).catch((()=>{throw new t("Unknown error.")}));if(!e.ok)throw new t("Unknown error.");return e})))),p=new n[0](yield(yield C.blob().catch((()=>{throw new t("Unknown error.")}))).arrayBuffer().catch((()=>{throw new t("Unknown error.")})));i+=a;const f=p.byteLength;if(l[s]=Math.min(76,o)*((r>>5)-1),152===l[s]&&(l[s]=f),i==s)return p;i=s,i^=s;for(let e=0,t=p.length;e<t;e++)l[s]^=l[i]<<13,l[s]^=l[i]>>17,l[s]^=l[i]<<5,p[e]=p[e]^l[s];return i^=l[0],i^=l[1],i^=l[2],p}))}(A,o,i)),E[A]}const m="0.7.4-alpha.4";let w=`https://cdn.jsdelivr.net/npm/shopar-plugin@${m}/dist`;const y={update:e=>{null!=e&&(w=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>w};function v(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 R;function b(t,n){let A=!0;return{qrPaused:()=>A,qrDraw:(o,i)=>e(this,void 0,void 0,(function*(){!function(){e(this,void 0,void 0,(function*(){null==R&&(R=v(`${y}/shopar-qr.js`))}))}(),yield R;const r=`https://ar.shopar.ai/${m.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:o,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(r),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,A=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){A=!0,t.style.display="none"}))}}const D=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.error('No <meta name="viewport"> detected. This might cause ShopAR to crash on iOS.\nPlease add the following line to your HTML:\n<meta name="viewport" content="width=device-width, initial-scale=1.0">'),()=>e?window.devicePixelRatio:1})();let S,U=!1;var M;let F,N,k;!function(e){e[e.HDR=0]="HDR",e[e.EXR=1]="EXR"}(M||(M={}));let G=!1;function x(e,t){const n=t===M.HDR?function(e){const t=new F.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,F.ClampToEdgeWrapping,F.ClampToEdgeWrapping,F.LinearFilter,F.LinearFilter,1,F.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(N.parse(e)):function(e){const t=new F.DataTexture(e.data,e.width,e.height,e.format,e.type,void 0,F.ClampToEdgeWrapping,F.ClampToEdgeWrapping,F.LinearFilter,F.LinearFilter,1,e.colorSpace);return t.needsUpdate=!0,t}(k.parse(e));return n.mapping=F.EquirectangularReflectionMapping,n.colorSpace=F.LinearSRGBColorSpace,n}const L=45,T=45,Y=3,P=1.5,H=1,q=.5;let K,j,$,X,J,W=!1;const O=4,_=.001,z=1e-7,V=10,Z=11,ee=1/(Z-1),te="function"==typeof Float32Array;function ne(e,t,n,A){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===A)return se;const o=te?new Float32Array(Z):new Array(Z);for(let t=0;t<Z;++t)o[t]=re(t*ee,e,n);function i(t){let A=0,i=1;const r=Z-1;for(;i!==r&&o[i]<=t;++i)A+=ee;--i;const a=A+(t-o[i])/(o[i+1]-o[i])*ee,s=ae(a,e,n);return s>=_?function(e,t,n,A){for(let o=0;o<O;++o){const o=ae(t,n,A);if(0===o)return t;t-=(re(t,n,A)-e)/o}return t}(t,a,e,n):0===s?a:function(e,t,n,A,o){let i,r,a=0;do{r=t+(n-t)/2,i=re(r,A,o)-e,i>0?n=r:t=r}while(Math.abs(i)>z&&++a<V);return r}(t,A,A+ee,e,n)}return function(e){return 0===e||1===e?e:re(i(e),t,A)}}function Ae(e,t){return 1-3*t+3*e}function oe(e,t){return 3*t-6*e}function ie(e){return 3*e}function re(e,t,n){return((Ae(t,n)*e+oe(t,n))*e+ie(t))*e}function ae(e,t,n){return 3*Ae(t,n)*e*e+2*oe(t,n)*e+ie(t)}function se(e){return e}function le(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=ne(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function ce(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:le(n)})));let A=0,o=n[0].value;return{reset:()=>{A=0},update:e=>{for(A+=e;A>=t;)A-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(A>=t.time&&A<i.time){const e=t.interpolate((A-t.time)/(i.time-t.time));o=t.value+e*(i.value-t.value)}}},get:()=>o}}const ge="#",ue="time",de="interpolation",Ie="yaw",he="pitch",Ce="fov",pe=[ue,Ie,he,Ce,de],fe="s",Ee="ms",Be=1e3,Qe="deg",me="rad",we=Math.PI/180,ye="ease-in-out",ve="cubic-bezier(",Re=")";function be(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(ge);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const A=function(e){const t=[];for(let n=0;n<e.length;n++){const A=e[n];if(!pe.includes(A))throw new Error(`Invalid token in header: '${A}'.`);if(t.includes(A))throw new Error(`Duplicate token in header: '${A}'.`);t.push(A)}if(!t.includes(ue))throw new Error(`Missing required token: '${ue}'.`);return t}(t.split(/\s+/)),o={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:i}=De(A,e);null!=t&&(null==o.theta&&(o.theta=[]),o.theta.push(t)),null!=n&&(null==o.phi&&(o.phi=[]),o.phi.push(n)),null!=i&&(null==o.fov&&(o.fov=[]),o.fov.push(i))}if(0===Object.values(o).length)throw new Error("At least one parameter should be animated.");return o}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const A of e){const{time:e,pitch:o,yaw:i,fov:r}=A;if(null==e)throw new Error("Time missing.");const a=Ue(null!==(t=A.interpolation)&&void 0!==t?t:ye);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*we,interpolation:a})),null!=o&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:o*we,interpolation:a})),null!=r&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:r*we,interpolation:a}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function De(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const A=e.indexOf(ue),o=function(e){if(e.endsWith(Ee))return Fe(e.substring(0,e.length-Ee.length));if(e.endsWith(fe))return Fe(e.substring(0,e.length-fe.length))*Be;return Fe(e)}(n[A]),i=e.indexOf(de),r=Ue(-1===i?ye:n[i]),a={};for(let t=0;t<n.length;t++){if(t===A||t===i)continue;const s=e[t],l=n[t];switch(s){case Ie:a.theta={time:o,value:Se(l),interpolation:r};break;case he:a.phi={time:o,value:Se(l),interpolation:r};break;case Ce:a.fov={time:o,value:Se(l),interpolation:r};break;default:throw new Error(`Unhandled value for header '${s}'.`)}}return a}function Se(e){return e.endsWith(Qe)?Fe(e.substring(0,e.length-Qe.length))*we:e.endsWith(me)?Fe(e.substring(0,e.length-me.length)):Fe(e)*we}function Ue(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Me(0,0,1,1);if("sine"===e)return Me(.37,0,.63,1);if("sine-in"===e)return Me(.12,0,.39,0);if("sine-out"===e)return Me(.61,1,.88,1);if("ease"===e)return Me(.25,.1,.25,1);if("ease-in"===e)return Me(.42,0,1,1);if("ease-out"===e)return Me(0,0,.58,1);if("ease-in-out"===e)return Me(.42,0,.58,1);if(e.startsWith(ve)&&e.endsWith(Re)){const t=e.substring(ve.length,e.length-Re.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:Fe(t[0]),y1:Fe(t[1]),x2:Fe(t[2]),y2:Fe(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Me(e,t,n,A){return{type:"bezier",x1:e,y1:t,x2:n,y2:A}}function Fe(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const Ne=300,ke=2e3,Ge=.05,xe=2*Math.PI/32,Le=Ue("hold"),Te=Ue("sine"),Ye=Ue("sine-in"),Pe=Ue("sine-out");const He=2e3,qe=8,Ke=2*Math.PI,je=Ke/12,$e=Ke/60,Xe=Ke/60,Je=60,We=60,Oe=1e3,_e=Je*We,ze=-1;function Ve(e){return ce([{time:0,value:0,interpolation:{type:"bezier",x1:.9,y1:0,x2:.6,y2:1}},{time:He,value:e,interpolation:{type:"hold"}}])}function Ze(e,t,n){return ze*je*(e+t/Je+n/_e)}function et(e,t){return ze*$e*(e+t/We)}function tt(e,t){return ze*Xe*(e+t/Oe)}const nt=["map","alphaMap","anisotropyMap","aoMap","bumpMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","displacementMap","emissiveMap","envMap","gradientMap","iridescenceMap","iridescenceThicknessMap","lightMap","metalnessMap","normalMap","roughnessMap","sheenColorMap","sheenRoughnessMap","specularMap","specularColorMap","specularIntensityMap","thicknessMap","transmissionMap"];function At(e){null!=e&&(e.dispose(),nt.forEach((t=>{var n;return null===(n=e[t])||void 0===n?void 0:n.dispose()})))}let ot;const it=0,rt=3;let at,st,lt,ct=!1,gt=1,ut=1,dt=1;const It=1;let ht;const Ct=new Map;function pt(){null==ot&&(ot=v(`${y}/shopar-three.js`))}function ft(t,n,A){const o=t.getContext("2d");null==o&&console.warn("2D context missing.");let i,r,a,s,l,c,g,u,d,I,h,C,p,f,E,B=!1,Q=!1,m=!1,w=!0,y=!1,v=1,R=!0,b=!1,D=0,M=0,H=1,W=1,O=1;const _={threeInit:()=>{B||(Et(),i=new st.Scene,r=new st.PerspectiveCamera(25,1,.5),a=new at.OrbitControls(r,t),a.setInteractionEnabled(R),u=st.ACESFilmicToneMapping,({renderShadow:l,shadowGroup:s}=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 A=new K.Group;A.position.y=-.7;const o=new K.PlaneGeometry(L,T).rotateX(Math.PI/2),i=new K.MeshBasicMaterial({map:t.texture,opacity:q,transparent:!0,depthWrite:!1}),r=new K.Mesh(o,i);r.renderOrder=1,r.scale.y=-1,A.add(r);const a=new K.Mesh(o);a.visible=!1,A.add(a);const s=new K.OrthographicCamera(-L/2,L/2,T/2,-T/2,0,Y);function l(e){a.visible=!0,X.uniforms.tDiffuse.value=t.texture,X.uniforms.h.value=1*e/256,a.material=X,j.setRenderTarget(n),j.render(a,s),J.uniforms.tDiffuse.value=n.texture,J.uniforms.v.value=1*e/256,a.material=J,j.setRenderTarget(t),j.render(a,s),a.visible=!1}return s.rotation.x=Math.PI/2,A.add(s),{shadowGroup:A,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=$;const A=j.getClearAlpha();j.setClearAlpha(0),j.setRenderTarget(t),j.render(e,s),e.overrideMaterial=null,l(P),l(.4*P),j.setRenderTarget(null),j.setClearAlpha(A),e.background=n}}}(i)),B=!0)},threeParse:(t,n,A,o)=>e(this,void 0,void 0,(function*(){return null!=c&&g===A||(yield c,c=(()=>e(this,void 0,void 0,(function*(){var e,A,r;return A=at,G||(F=A.THREE,N=new A.RGBELoader,k=new A.EXRLoader,G=!0),null===(e=i.environment)||void 0===e||e.dispose(),i.environment=x(n,o),function(e,t){if(U)return;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),U=!0}(ht,at),r=t,S.parseAsync(r.buffer,"")})))(),g=A),c})),threeLoad:(e,t)=>{mt(i),i.add(e.scene);const n=(new st.Box3).setFromObject(e.scene);s.position.y=n.min.y-it,i.add(s),l(),Q=!1,i.traverse((e=>{if(e instanceof st.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(Q=!0)})):t.transmission>0&&(Q=!0)}}));const A=n.min.clone().add(n.max).divideScalar(2),o=Math.sqrt(at.reduceVertices(e.scene,((e,t)=>Math.max(e,A.distanceToSquared(t))),0));a.reset(A,o,function(e,t){var n;const A={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?A.Glasses:null!==(n=A[e])&&void 0!==n?n:A.Glasses).normalize()}(t,st.Vector3)),D=0,E="Watches"===t?function(e){const t=e.getObjectByName("hours"),n=e.getObjectByName("minutes"),A=e.getObjectByName("seconds");if(null==t&&null==n&&null==A)return null;let o,i,r,a,s,l;return{start:()=>{o=new Date,o.setMilliseconds(o.getMilliseconds()+He),s=!1;const e=o.getHours(),t=o.getMinutes(),n=o.getSeconds(),A=o.getMilliseconds();i=Ve(Ze(e,t,n)),r=Ve(et(t,n)),a=Ve(tt(n,A)),l=new Date},update:()=>{if(null==o)return!1;const e=new Date;if(!s){if(o.getTime()-e.getTime()>0){const o=Math.abs(e.getTime()-l.getTime());return null!=t&&(i.update(o),t.rotation.y=i.get()),null!=n&&(r.update(o),n.rotation.y=r.get()),null!=A&&(a.update(o),A.rotation.y=a.get()),l=e,!0}s=!0}if(Math.abs(e.getTime()-l.getTime())<Oe/qe)return!1;l=e;const c=e.getHours(),g=e.getMinutes(),u=e.getSeconds(),d=e.getMilliseconds();return null!=t&&(t.rotation.y=Ze(c,g,u)),null!=n&&(n.rotation.y=et(g,u)),null!=A&&(A.rotation.y=tt(u,d)),!0}}}(e.scene):null},threePaused:()=>w,threeResume:()=>{w=!1,ht.setAnimationLoop(Bt),t.style.visibility="visible",M=0,null==I||I.reset(),null==h||h.reset(),null==C||C.reset(),null==p||p.reset(),null==f||f.reset(),null==E||E.start()},threePause:()=>{w=!0,function(){for(const{threePaused:e}of Ct.values())if(!e())return!1;return!0}()&&ht.setAnimationLoop(null),t.style.visibility="hidden",A.style.opacity="0",n.style.visibility="hidden"},threeDestroy:()=>{var e;mt(i),null===(e=i.environment)||void 0===e||e.dispose(),i.environment=null,i=null,c=null,E=null,Ct.delete(t)},threeSetZoomEnabled:e=>{a.enableZoom=e},threeSetForcedTransparency:e=>{m=e},threeSetToneMapping:(e,t)=>{const n={ACES:st.ACESFilmicToneMapping,Linear:st.LinearToneMapping,Neutral:st.NeutralToneMapping};null!=n[e]&&(u=n[e]),v=t},threeIsInteractive:()=>R,threeSetInteractive:e=>{R=e,null==a||a.setInteractionEnabled(R)},threeSetOnInteracted:e=>{a.removeEventListener("change",d),d=e,a.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=a.getTheta(),I=ce([{time:0,value:e,interpolation:Le},{time:Ne,value:e,interpolation:Pe},{time:Ne+ke/4,value:e+xe,interpolation:Te},{time:Ne+3*ke/4,value:e-xe,interpolation:Ye},{time:Ne+ke,value:e,interpolation:Le},{time:Ne+2*ke,value:e,interpolation:Le}]),a.setTheta(I.get()),h=null,C=null,p=ce([{time:0,value:0,interpolation:Le},{time:Ne,value:1,interpolation:Le},{time:Ne+ke,value:0,interpolation:Le},{time:Ne+2*ke,value:0,interpolation:Le}]),f=ce([{time:0,value:0,interpolation:Le},{time:Ne,value:0,interpolation:Pe},{time:Ne+ke/4,value:-Ge,interpolation:Te},{time:Ne+3*ke/4,value:Ge,interpolation:Ye},{time:Ne+ke,value:0,interpolation:Le},{time:Ne+2*ke,value:0,interpolation:Le}])},threeInitThetaAnimation:e=>{I=e,null!=e&&a.setTheta(e.get())},threeInitPhiAnimation:e=>{h=e,null!=e&&a.setPhi(e.get())},threeInitFovAnimation:e=>{C=e,null!=e&&a.setFovRadians(e.get())},threeRenderOnce:()=>{_.render_()},preRender_:e=>{if(!B||w||!function(e){const t=e.getBoundingClientRect();return t.bottom>0&&t.top<Math.max(document.documentElement.clientHeight,window.innerHeight)&&t.right>0&&t.left<Math.max(document.documentElement.clientWidth,window.innerWidth)}(t))return;let n=0!==M?e-M:0;M=e,0===D?y=!0:D<rt&&(n=0),D++,b||(a.hasUserInteracted()?(b=!0,I=null,h=null,C=null,p=null,f=null):(null==I||I.update(n),null==h||h.update(n),null==C||C.update(n),null==p||p.update(n),null==f||f.update(n),null!=I&&(a.setTheta(I.get()),y=!0),null!=h&&(a.setPhi(h.get()),y=!0),null!=C&&(a.setFovRadians(C.get()),y=!0))),a.update()&&(y=!0),(null==E?void 0:E.update())&&(y=!0)},shouldRender_:()=>!(!B||w)&&y,render_:()=>{const e=ht.toneMapping,a=ht.toneMappingExposure;ht.toneMapping=u,ht.toneMappingExposure=v,ht.setViewport(0,0,t.width,t.height),ht.setClearColor(new st.Color(16777215),Q&&!m?1:0),ht.render(i,r),ht.toneMapping=e,ht.toneMappingExposure=a,y=!1,null!=o&&(o.clearRect(0,0,t.width,t.height),lt.width>0&&lt.height>0&&o.drawImage(lt,0,ut-t.height,t.width,t.height,0,0,t.width,t.height),n.style.visibility=R&&!b?"visible":"hidden",null!=p&&(A.style.opacity=`${p.get()}`),null!=f&&(A.style.transform=`translateX(${f.get()*Math.min(H,W)}px)`))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===H&&n===W&&dt===O||(t.width=Math.ceil(e*dt*It),t.height=Math.ceil(n*dt*It),H=e,W=n,O=dt,y=!0)},target_:t};return Ct.set(t,_),_}function Et(){if(ct)return;at=window.ShopAR__THREE,st=at.THREE,lt=document.createElement("canvas");var e,t;lt.style.position="block",ht=new st.WebGLRenderer({powerPreference:"high-performance",canvas:lt,antialias:!0,alpha:!0}),ht.outputColorSpace=st.SRGBColorSpace,ht.toneMapping=st.ACESFilmicToneMapping,ht.setClearColor(new st.Color(16777215),0),e=ht,t=at,W||(K=t.THREE,j=e,$=new K.MeshDepthMaterial,$.userData.darkness={value:H},$.onBeforeCompile=e=>{e.uniforms.darkness=$.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},$.depthTest=!1,$.depthWrite=!1,X=new K.ShaderMaterial(t.HorizontalBlurShader),X.depthTest=!1,J=new K.ShaderMaterial(t.VerticalBlurShader),J.depthTest=!1,W=!0),Qt(),ct=!0}function Bt(e){Qt(),ht.clear();for(const{preRender_:t,shouldRender_:n,render_:A}of Ct.values())t(e),n()&&A()}function Qt(){let e=0,t=0;for(const{target_:n}of Ct.values()){const{clientWidth:A,clientHeight:o}=n;e=Math.max(e,A),t=Math.max(t,o)}const n=D();e=Math.ceil(e*n*It),t=Math.ceil(t*n*It),e===gt&&t===ut&&n===dt||(gt=e,ut=t,dt=n,ht.setSize(gt,ut,!1));for(const{updateSize_:e}of Ct.values())e()}function mt(e){e.traverse((e=>{var t;e instanceof st.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach(At):At(e.material))})),e.clear()}const wt={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},yt=Object.keys(wt);function vt(e){return wt[e]}const Rt="shopar-error";function bt(e,t,n,A){const o=document.createElement("button");o.id=e,o.type="button",o.className="shopar-btn",o.appendChild(A);{const e=document.createElement("span");e.textContent=t,o.appendChild(e)}o.ariaLabel=n;const i=o.style;return i.display="none",i.pointerEvents="auto",o}const Dt="shopar-control";const St="shopar-deepar-output";function Ut(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.pointerEvents="auto",n.userSelect="none",t}function Mt(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function Ft(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 Nt(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 kt="shopar-main";const Gt="shopar-qr-output";function xt(e){var t,n;const A=document.createElementNS("http://www.w3.org/2000/svg","svg");return A.setAttribute("width",null!==(t=e.getAttribute("width"))&&void 0!==t?t:"1rem"),A.setAttribute("height",null!==(n=e.getAttribute("height"))&&void 0!==n?n:"1rem"),A.appendChild(e),A}function Lt(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","image");return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",null!=t?t:"data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E"),n.setAttribute("width",e),n.setAttribute("height",e),n}const Tt="shopar-three-output";var Yt;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(Yt||(Yt={}));let Pt=!1;function Ht(){Pt||(!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.")}}(),Pt=!0)}function qt(){Ht();const e=function(){const e=document.createElement("div");e.id=kt;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),A=function(e,t){const n=document.createElement("div");n.id=Gt;const A=n.style;A.position="absolute",A.top="0",A.left="0",A.width="100%",A.height="100%",A.display="none",A.pointerEvents="auto",A.userSelect="none";const o=document.createElement("div");o.className="shopar-qr";const i=o.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(o),o.appendChild(e);const r=document.createElement("div");return r.appendChild(t),o.appendChild(r),n}(t,n);e.appendChild(A);const o=function(){const e=document.createElement("div");e.id=St;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",t.pointerEvents="auto",e}();e.appendChild(o);const i=function(){const e=document.createElement("canvas");e.id=Tt,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const r=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:A}=n;return A.position="absolute",A.width="100%",A.height="100%",A.opacity="0",n.appendChild(e),n.appendChild(t),n}(r,a);e.appendChild(s);const l=function(){const e=xt(Lt("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",t.appendChild(e),t}(l);e.appendChild(c);const g=Ut("shopar-ar-loading-container"),u=Mt("shopar-ar-loading-text",vt("loading.ar"));g.appendChild(u);const d=Ft("shopar-ar-loading-bar-bg"),I=Nt("shopar-ar-loading-bar-fg");d.appendChild(I),g.appendChild(d),e.appendChild(g);const h=Ut("shopar-3d-loading-container"),C=Mt("shopar-3d-loading-text",vt("loading.3d"));h.appendChild(C);const p=Ft("shopar-3d-loading-bar-bg"),f=Nt("shopar-3d-loading-bar-fg");p.appendChild(f),h.appendChild(p),e.appendChild(h);const E=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",t.backgroundSize="contain",t.backgroundRepeat="no-repeat",t.backgroundPosition="center",e}();e.appendChild(E);const B=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),Q=function(e){const t=document.createElement("div");t.id=Rt;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const A=document.createElement("div"),o=A.style;return o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",t.appendChild(A),A.appendChild(e),t}(B);e.appendChild(Q);const m=function(){const e=document.createElement("div");return e.id=Dt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(m);const w=Lt("1.75rem"),v=bt("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on",xt(w));m.appendChild(v);const R=Lt("1.75rem"),b=bt("shopar-btn-3d","3D","Launch ShopAR 3D preview",xt(R));m.appendChild(b);const D=Lt("1.75rem"),S=bt("shopar-btn-close","Close","Close ShopAR view",xt(D));m.append(S);let U,M,F=Yt.None,N=!1,k=!1,G=!1,x=!1;function L(){I.classList.remove("active"),g.style.visibility="hidden"}function T(){E.style.visibility="hidden",f.classList.remove("active"),h.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return A},getQRImage:function(){return n},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return i},getThreePrompt:function(){return c},getThreePromptImage:function(){return l},customizeDeepARPrompt:function(e,t){r.textContent=e,a.src=t},customizeCameraError:function(e){B.textContent=null!=e?e:"Please reload page and allow camera access to continue"},customizeQRPrompt:function(e){t.textContent=null!=e?e:"Scan on mobile or tablet to try on"},setVisibilityParameters:function(e,t,n,A,o,i){var r;N=e,k=t,G=n,x=A,U=o,M=i,Kt(m,N),Kt(v,N&&(G||k)&&F===Yt.None),Kt(b,N&&x&&F===Yt.None),Kt(S,N&&F!==Yt.None),L(),T(),N||""===(r=Q).style.display&&Kt(r,!1)},getUIState:function(){return F},setUIState:function(e){F=e,F===Yt.None?(L(),T(),N&&(Kt(Q,!1),Kt(S,!1),(k||G)&&Kt(v,!0),x&&Kt(b,!0))):F===Yt.QR||F===Yt.AR?N&&(Kt(Q,!1),Kt(v,!1),Kt(b,x&&"AR"===M),Kt(S,"AR"!==M)):F===Yt.Preview&&N&&(Kt(Q,!1),Kt(v,(k||G)&&"3D"===M),Kt(b,!1),Kt(S,"3D"!==M))},setDefaultUIActions:function(e,t,n){N&&((k||G)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,A=`${y}/img/icons/${n}`;w.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",A)}(U),v.onclick=e),x&&(R.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${y}/img/icons/cube.svg`),b.onclick=t),D.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${y}/img/icons/close.svg`),S.onclick=n)},startDeepARLoading:function(){I.classList.add("active"),g.style.visibility="visible"},stopDeepARLoading:L,startThreeLoading:function(){null!=E.dataset.bgSet?E.style.visibility="visible":(f.classList.add("active"),h.style.visibility="visible")},stopThreeLoading:T,setThreePosterUrl:function(e){null!=e?(E.style.backgroundImage=`url(${e})`,E.dataset.bgSet="true"):delete E.dataset.bgSet},showCameraError:function(){N&&Kt(Q,!0)}}}function Kt(e,t){e.style.display=t?"":"none"}const jt=new Map;function $t(e){let t=jt.get(e);return null==t?(t=function(){let e=0,t=null,n=null,A=null;const o=()=>(null==t&&(t=qt()),t);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>t,findUI:o,findQR:()=>{if(null==n){const{getQRTarget:e,getQRImage:t}=o();n=b(e(),t())}return n},findThree:()=>{if(null==A){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=o();A=ft(e(),t(),n())}return A}}}(),jt.set(e,t)):t.incrementSetupId_(),t}function Xt(e){for(const t of jt.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:A,setUIState:o}=n;A()===Yt.AR&&o(Yt.None)}}let Jt;const Wt=new Uint8Array(16);function Ot(){if(!Jt&&(Jt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Jt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Jt(Wt)}const _t=[];for(let e=0;e<256;++e)_t.push((e+256).toString(16).slice(1));var zt={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Vt(e,t,n){if(zt.randomUUID&&!t&&!e)return zt.randomUUID();const A=(e=e||{}).random||(e.rng||Ot)();if(A[6]=15&A[6]|64,A[8]=63&A[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=A[e];return t}return function(e,t=0){return _t[e[t+0]]+_t[e[t+1]]+_t[e[t+2]]+_t[e[t+3]]+"-"+_t[e[t+4]]+_t[e[t+5]]+"-"+_t[e[t+6]]+_t[e[t+7]]+"-"+_t[e[t+8]]+_t[e[t+9]]+"-"+_t[e[t+10]]+_t[e[t+11]]+_t[e[t+12]]+_t[e[t+13]]+_t[e[t+14]]+_t[e[t+15]]}(A)}const Zt="qrLaunch",en="arLaunch",tn="previewLaunch",nn="heartbeat";let An,on,rn=!1,an=window.navigator.userAgent||"no user agent";const sn=[];function ln(){null==An&&(on=Vt(),An=v(`${y}/shopar-analytics.js`),An.then((()=>{rn=!0,window.ShopAR__analytics.initializeImpl(),sn.forEach((e=>e()))})))}function cn(e){rn?e():sn.push(e)}function gn(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function un(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 dn=200,In=10;let hn=!1,Cn=null,pn=[],fn=[];function En(t){return e(this,void 0,void 0,(function*(){hn=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${y}/wasm/mediapipe`,t),Cn&&clearInterval(Cn);const A=[],o=[];Cn=setInterval((()=>e(this,void 0,void 0,(function*(){if(hn)return;const{error:e,faceWidth:t,ipd:i,translation:r,rotation:a}=yield n.predict(performance.now());hn||(null!=r&&null!=a&&function(e){for(let t of pn)t(e)}({translation:r,rotation:a}),null==e&&(A.push(t),o.push(i),A.length<In||(A.shift(),o.shift(),function(e,t){for(let n of fn)n({faceWidth:e,IPD:t})}(Qn(A),Qn(o)))))}))),dn)}))}function Bn(){fn=[],pn=[],hn=!0}function Qn(e){let t=0;const n=e.length;for(let A=0;A<n;A++)t+=e[A];return t/n}var mn="undefined"!=typeof Float32Array?Float32Array:Array;function wn(){var e=new mn(16);return mn!=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 yn(e,t,n){var A=t[0],o=t[1],i=t[2],r=t[3],a=t[4],s=t[5],l=t[6],c=t[7],g=t[8],u=t[9],d=t[10],I=t[11],h=t[12],C=t[13],p=t[14],f=t[15],E=n[0],B=n[1],Q=n[2],m=n[3];return e[0]=E*A+B*a+Q*g+m*h,e[1]=E*o+B*s+Q*u+m*C,e[2]=E*i+B*l+Q*d+m*p,e[3]=E*r+B*c+Q*I+m*f,E=n[4],B=n[5],Q=n[6],m=n[7],e[4]=E*A+B*a+Q*g+m*h,e[5]=E*o+B*s+Q*u+m*C,e[6]=E*i+B*l+Q*d+m*p,e[7]=E*r+B*c+Q*I+m*f,E=n[8],B=n[9],Q=n[10],m=n[11],e[8]=E*A+B*a+Q*g+m*h,e[9]=E*o+B*s+Q*u+m*C,e[10]=E*i+B*l+Q*d+m*p,e[11]=E*r+B*c+Q*I+m*f,E=n[12],B=n[13],Q=n[14],m=n[15],e[12]=E*A+B*a+Q*g+m*h,e[13]=E*o+B*s+Q*u+m*C,e[14]=E*i+B*l+Q*d+m*p,e[15]=E*r+B*c+Q*I+m*f,e}function vn(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Rn(e,t){var n=t[0],A=t[1],o=t[2],i=t[4],r=t[5],a=t[6],s=t[8],l=t[9],c=t[10];return e[0]=Math.hypot(n,A,o),e[1]=Math.hypot(i,r,a),e[2]=Math.hypot(s,l,c),e}function bn(e,t,n,A){var o=t[0],i=t[1],r=t[2],a=t[3],s=o+o,l=i+i,c=r+r,g=o*s,u=o*l,d=o*c,I=i*l,h=i*c,C=r*c,p=a*s,f=a*l,E=a*c,B=A[0],Q=A[1],m=A[2];return e[0]=(1-(I+C))*B,e[1]=(u+E)*B,e[2]=(d-f)*B,e[3]=0,e[4]=(u-E)*Q,e[5]=(1-(g+C))*Q,e[6]=(h+p)*Q,e[7]=0,e[8]=(d+f)*m,e[9]=(h-p)*m,e[10]=(1-(g+I))*m,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Dn(){var e=new mn(3);return mn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Sn(e,t,n){var A=new mn(3);return A[0]=e,A[1]=t,A[2]=n,A}function Un(e,t){var n=t[0]-e[0],A=t[1]-e[1],o=t[2]-e[2];return Math.hypot(n,A,o)}function Mn(e,t,n){var A=t[0],o=t[1],i=t[2],r=n[3]*A+n[7]*o+n[11]*i+n[15];return r=r||1,e[0]=(n[0]*A+n[4]*o+n[8]*i+n[12])/r,e[1]=(n[1]*A+n[5]*o+n[9]*i+n[13])/r,e[2]=(n[2]*A+n[6]*o+n[10]*i+n[14])/r,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Fn(){var e=new mn(4);return mn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Dn(),function(){var e,t=(e=new mn(4),mn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var Nn;Dn(),Sn(1,0,0),Sn(0,1,0),Fn(),Fn(),Nn=new mn(9),mn!=Float32Array&&(Nn[1]=0,Nn[2]=0,Nn[3]=0,Nn[5]=0,Nn[6]=0,Nn[7]=0),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AQsgAiAGQQNyNgIEIAIgBmoiBSADQQFyNgIEIAMgBWogAzYCACAIBEAgCEF4cUHQFGohAEG8FCgCACEBAn9BASAIQQN2dCIHIARxRQRAQagUIAQgB3I2AgAgAAwBCyAAKAIICyEEIAAgATYCCCAEIAE2AgwgASAANgIMIAEgBDYCCAtBvBQgBTYCAEGwFCADNgIACyACQQhqIQALIApBEGokACAAC8cBAwZ/AXwBfiMAQSBrIgMkACADAn4QAkQAAAAAAECPQKMiCJlEAAAAAAAA4ENjBEAgCLAMAQtCgICAgICAgICAfwsiCTcDEEG0CEGACCADQRBqEAAhBCADIAk3AwBBzg5BgAggAxAAIQUDQCACQSBGBEAgBBAEIAUQBCADQSBqJAAFIAEgAmoiBiACIAVqIgctAAAgAiAEai0AACAAIAJqLQAAc3M6AAAgBiAHLQAAIAJBkAhqLQAAczoAICACQQFqIQIMAQsLCws3AwBBgAgLAWoAQZAICyB/bT8OSH+hRnx9UDLOjCuACx6NxKtzWvD26is8y2VImgBBsAgLAyAMAQ==";var Gn=function(e={}){var t,n,A,o,i,r,a=e,s=new Promise(((e,n)=>{t=e}));var l={1076:e=>{const t=[e,Date.now()],n=t.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame","navigator","userAgent"],i=[2,12,7,1],r=window[o[o[i[i[i.length-1]]+2].length-i[t.length]+1]][o[Math.pow(i[n],o[i.length].length)]]||"no user agent",a=c(32);for(let e=0;e<32;++e)A[a+e]=r.charCodeAt(e%r.length);return a},1870:e=>{var t,n=function(){var e;try{e=Function('return (function() {}.constructor("return this")( ));')()}catch(t){e=window}return e}(),o=Date.now();for(var i in n)if(8==i.length&&116==i.charCodeAt(7)&&101==i.charCodeAt(5)&&117==i.charCodeAt(3)&&100==i.charCodeAt(0)){o=i,t=e;break}for(var r in n[o])if(6==r.length&&110==r.charCodeAt(5)&&100==r.charCodeAt(0)){t=r;break}const a=n[o][t]||"no hostname",s=c(32);for(let e=0;e<32;++e)A[s+e]=a.charCodeAt(e%a.length);return s}};a.noExitRuntime;var c,g=[],u=(e,t,r)=>{var a=((e,t)=>{var r;for(g.length=0;r=A[e++];){var a=105!=r;t+=(a&=112!=r)&&t%8?4:0,g.push(112==r?o[t>>2]:105==r?n[t>>2]:i[t>>3]),t+=a?8:4}return g})(t,r);return l[e](...a)};var d={a:{a:(e,t,n)=>u(e,t,n),c:()=>Date.now(),b:e=>{A.length,function(e){throw"OOM"}()}}};return WebAssembly.instantiate(a.wasm,d).then((e=>{var s,l=e.instance.exports;a._magic=l.f,a._free=l.g,a._malloc=c=l.i,r=l.d,s=r.buffer,a.HEAPU8=A=new Uint8Array(s),n=new Int32Array(s),o=new Uint32Array(s),i=new Float64Array(s),function(e){e.e()}(l),t(a)})),s};function xn(){return e(this,void 0,void 0,(function*(){const t=yield function(){return e(this,void 0,void 0,(function*(){const e=yield fetch(kn);return yield Gn({wasm:yield e.arrayBuffer()})}))}();return function(e){const n=t._malloc(32);for(let A=0;A<e.size()&&A<32;A++)t.HEAPU8[n+A]=e.get(A);const A=t._malloc(64);t._magic(n,A);const o=new Uint8Array(64);for(let e=0;e<64;++e)o[e]=t.HEAPU8[A+e];return t._free(n),t._free(A),o}}))}let Ln,Tn,Yn,Pn,Hn,qn,Kn=!0,jn=null;const $n=new Set;let Xn,Jn,Wn,On,_n,zn;function Vn(){null==Ln&&(Ln=v(`${y}/shopar-deepar.js`))}function Zn(){null==Tn&&(Tn=v(`${y}/shopar-true-scale.js`))}function eA(n){return e(this,void 0,void 0,(function*(){const{licenseKey:A,truescaleUsecase:o}=n;return _n=o,null==Xn&&(Xn=(()=>e(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new t("No camera available!");var e;const n=lA(Hn),o=gn(n);Yn=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:A||"your_license_key_goes_here",previewElement:qn,rootPath:y.toString()+"/deepar",additionalOptions:{hint:zn,cameraConfig:{disableDefaultCamera:!0},onVerify:yield xn()}}),Pn=yield un(o),yield cA(Yn,Pn,"user"===n),"Glasses"===Hn&&(yield Tn,En(Pn),"DetectionLoop"!==_n&&IA((e=>{On=e.faceWidth})))})))()),Xn}))}function tA(e,t){var n,A;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===Hn&&(n=t,A=zn,n===A||null!=n&&null!=A&&n.length===A.length&&n.every((e=>A.find((t=>e===t))))&&A.every((e=>n.find((t=>t===e))))))||(null!=Yn&&(Yn.shutdown(),Yn=null,Xn=null),Hn=e,zn=t)}function nA(e){e!==qn&&(qn=e,null!=Yn&&Yn.changePreviewElement(qn))}function AA(e){jn=e}function oA(e){Yn.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(On){const e=137/(On+5);Yn.changeParameterVector("GLASSES","","scale",e,e,e,0),Yn.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const A=uA("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),o=uA("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);Yn.changeParameterVector("temple_left","","rotation",0,56.6*-A,0,0),Yn.changeParameterVector("temple_right","","rotation",0,56.6*-o,0,0)}catch(e){return}}(e),Bn(),On=null}e(),gA("Glasses")}},Yn.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),gA("Shoes"))},Yn.callbacks.onWristTracked=t=>{t.detected&&(e(),gA("Watches"))}}function iA(t,n,A){return e(this,void 0,void 0,(function*(){return null!=Jn&&Wn===A||(yield Jn,Jn=Yn.switchEffect(t,{envmap:n}),Wn=A),Jn}))}function rA(e,t){null!=e&&null!=t&&(Yn.setToneMapping(e),Yn.setExposure(t))}function aA(){return e(this,void 0,void 0,(function*(){if(null!=Yn){if(Kn=!1,null==Pn){const e=lA(Hn),t=gn(e);Pn=yield un(t),yield cA(Yn,Pn,"user"===e),"Glasses"===Hn&&(En(Pn),"DetectionLoop"!==_n&&IA((e=>{On=e.faceWidth})))}!function(){if(null==jn)return;if(null==Hn||$n.has(Hn))return;jn.style.visibility="visible",jn.style.opacity="1"}(),Yn.setPaused(Kn),qn.style.display=""}}))}function sA(){null!=Yn&&(Kn=!0,Yn.setPaused(Kn),Bn(),null!=Pn&&null!=Pn.srcObject&&Pn.srcObject instanceof MediaStream&&(Pn.srcObject.getTracks().forEach((e=>e.stop())),Pn=null),function(){if(null==jn)return;jn.style.visibility="hidden",jn.style.opacity="0"}(),Yn.stopCamera(),qn.style.display="none")}function lA(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function cA(t,n,A){return e(this,void 0,void 0,(function*(){yield new Promise((o=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,A),o()}))))}}))}))}function gA(e){null!=jn&&($n.has(e)||($n.add(e),jn.style.opacity="0"))}function uA(e,t,n,A,o,i,r){const a=Yn.getTransformationBetween(e,t),s=vn(Dn(),a),l=function(e,t){var n=new mn(3);Rn(n,t);var A=1/n[0],o=1/n[1],i=1/n[2],r=t[0]*A,a=t[1]*o,s=t[2]*i,l=t[4]*A,c=t[5]*o,g=t[6]*i,u=t[8]*A,d=t[9]*o,I=t[10]*i,h=r+c+I,C=0;return h>0?(C=2*Math.sqrt(h+1),e[3]=.25*C,e[0]=(g-d)/C,e[1]=(u-s)/C,e[2]=(a-l)/C):r>c&&r>I?(C=2*Math.sqrt(1+r-c-I),e[3]=(g-d)/C,e[0]=.25*C,e[1]=(a+l)/C,e[2]=(u+s)/C):c>I?(C=2*Math.sqrt(1+c-r-I),e[3]=(u-s)/C,e[0]=(a+l)/C,e[1]=.25*C,e[2]=(g+d)/C):(C=2*Math.sqrt(1+I-r-c),e[3]=(a-l)/C,e[0]=(u+s)/C,e[1]=(g+d)/C,e[2]=.25*C),e}(Fn(),a);bn(a,l,s,Sn(r,r,r));const c=Yn.getTransformationBetween(t,n),g=vn(Dn(),c);bn(c,Fn(),g,Rn(Dn(),c));const u=yn(wn(),a,c),d=vn(Dn(),u),I=Math.atan2(i[0]-d[0],Math.abs(i[2]-d[2]));let h;try{h=Yn.getTransformationBetween(n,A)}catch(e){return I}const C=yn(wn(),c,h),p=yn(wn(),a,C),f=Sn(d[0],i[1],i[2]),E=Mn(Dn(),f,function(e,t){var n=t[0],A=t[1],o=t[2],i=t[3],r=t[4],a=t[5],s=t[6],l=t[7],c=t[8],g=t[9],u=t[10],d=t[11],I=t[12],h=t[13],C=t[14],p=t[15],f=n*a-A*r,E=n*s-o*r,B=n*l-i*r,Q=A*s-o*a,m=A*l-i*a,w=o*l-i*s,y=c*h-g*I,v=c*C-u*I,R=c*p-d*I,b=g*C-u*h,D=g*p-d*h,S=u*p-d*C,U=f*S-E*D+B*b+Q*R-m*v+w*y;return U?(U=1/U,e[0]=(a*S-s*D+l*b)*U,e[1]=(o*D-A*S-i*b)*U,e[2]=(h*w-C*m+p*Q)*U,e[3]=(u*m-g*w-d*Q)*U,e[4]=(s*R-r*S-l*v)*U,e[5]=(n*S-o*R+i*v)*U,e[6]=(C*B-I*w-p*E)*U,e[7]=(c*w-u*B+d*E)*U,e[8]=(r*D-a*R+l*y)*U,e[9]=(A*R-n*D-i*y)*U,e[10]=(I*m-h*B+p*f)*U,e[11]=(g*B-c*m-d*f)*U,e[12]=(a*v-r*b-s*y)*U,e[13]=(n*b-A*v+o*y)*U,e[14]=(h*E-I*Q-C*f)*U,e[15]=(c*Q-g*E+u*f)*U,e):null}(wn(),p));let B=Yn.getClosestPointOnMesh(A,E);try{const e=Yn.getClosestPointOnMesh(o,E);Un(E,e)<Un(E,B)&&(B=e)}catch(e){}const Q=Mn(Dn(),B,C);return I-Math.atan2(Q[0]-g[0],Math.abs(Q[2]-g[2]))}function dA(e){!function(e){pn.push(e)}(e)}function IA(e){!function(e){fn.push(e)}(e)}var hA;function CA(){return[hA.Android,hA.iOS,hA.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],A=["Win32","Win64","Windows","WinCE"],o=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==o.indexOf(t)?hA.iOS:-1!==n.indexOf(t)?i?hA.Tablet:hA.MacOS:-1!==A.indexOf(t)?hA.Windows:/Android/.test(e)?hA.Android:/Linux/.test(t)?hA.Linux:i?hA.Tablet:hA.Unknown}return hA.Unknown}())}!function(e){e[e.Unknown=0]="Unknown",e[e.Android=1]="Android",e[e.iOS=2]="iOS",e[e.Tablet=3]="Tablet",e[e.MacOS=4]="MacOS",e[e.Windows=5]="Windows",e[e.Linux=6]="Linux"}(hA||(hA={}));const pA=["AR","3D"];function fA(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function EA(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}function BA(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}function QA(e){const{apiKey:n,sku:A,targetElement:o,initialState:i,initialAnimation:r,baseUrl:a,defaultUI:s,interactive:l,strings:c}=e;fA(n,"apiKey"),BA(n,"apiKey"),fA(A,"sku"),BA(A,"sku"),fA(o,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&function(e,n,A){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!A.includes(e))throw new t(`'${n}' must be ${A.join("' or '")}.`)}(i,"initialState",pA),null!=r&&function(e,n){if("string"!=typeof e&&!Array.isArray(e))throw new t(`'${n}' must be a string or array.`)}(r,"initialAnimation"),null!=a&&BA(a,"baseUrl"),null!=s&&EA(s,"defaultUI"),null!=l&&EA(l,"interactive"),null!=c&&function(e,n,A){for(const o of A){const A=e[o];if(null!=A&&"string"!=typeof A)throw new t(`Value for key '${o}' in '${n}' must be a string.`)}}(c,"strings",yt)}let mA=!1;function wA(n){return e(this,void 0,void 0,(function*(){const{targetElement:A}=n;y.update(n.baseUrl),ln();const{trackEvent:o}=function(e){const t=performance.now(),n=Vt();return{trackEvent:(A,o={})=>{o=Object.assign(Object.assign({},o),{pluginVersion:m,userAgent:an,sessionId:on,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),cn((()=>{window.ShopAR__analytics.trackEventImpl(A,o)}))}}}(n.apiKey);o("visionSetup");const i=yield function(n){return e(this,void 0,void 0,(function*(){const A=yield d((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:n,sid:c()})}`).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 A.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(n.apiKey);o("visionApiResponse",i);const{arKey:r}=i,a=$t(A),{getSetupId:s,findUI:l}=a,g=s();Vn(),Zn();const{setTargetElement:u,getDeepARTarget:I,setVisibilityParameters:h,getUIState:C,setUIState:p,startDeepARLoading:f,stopDeepARLoading:E,showCameraError:B}=l();if(C()!=Yt.None)throw Error("UI state is not None, this is weird..");p(Yt.AR),u(A),h(!1,!1,!0,!1,void 0,void 0),f(),yield Ln,yA(s(),g);try{o("visionArLaunch"),sA(),tA("Glasses",["faceInit"]),nA(I()),yield eA({licenseKey:r,truescaleUsecase:"DetectionLoop"}),yA(s(),g),yield aA(),yA(s(),g)}catch(e){const n=e instanceof Error;throw o("visionArLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),B(),sA(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{E()}return mA=!0,{registerFacePoseListener:e=>{mA&&(o("registerFacePoseListener"),dA(e))},registerFaceMeasurementListener:e=>{mA&&(o("registerFaceMeasurementListener"),IA(e))},switchEffect:t=>e(this,void 0,void 0,(function*(){mA&&(o("switchEffect",{arUrl:t}),function(e){Yn.switchEffect(e)}(t))})),clearEffect:()=>{mA&&(o("clearEffect"),Yn.clearEffect())},close:()=>{if(mA){if(mA=!1,o("visionClose"),C()!==Yt.AR)throw new t("AR not launched.");sA(),p(Yt.None)}}}}))}function yA(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}function vA(n){var A,o;return e(this,void 0,void 0,(function*(){QA(n);const{apiKey:i,sku:r,targetElement:a,initialState:s,initialAnimation:l}=n,g=null==n.zoomEnabled||n.zoomEnabled,u=!0===n.alwaysTransparentBackground;!function(e){const n=getComputedStyle(e);if(!["static","relative"].includes(n.position))throw new t(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${n.position}'.`)}(a),y.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(wt,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(wt[t]=n)}}(n.strings);const f=null!=l?be(l):null,E=null!=(null==f?void 0:f.theta)?ce(f.theta):null,w=null!=(null==f?void 0:f.phi)?ce(f.phi):null,v=null!=(null==f?void 0:f.fov)?ce(f.fov):null,R=function(n,A,o,i,r,a){return e(this,void 0,void 0,(function*(){const s=yield d((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:n,sku:A,sid:c()},null!=o&&{yaw:`${h(I(o))}`}),null!=i&&{pitch:`${h(I(i))}`}),null!=r&&{fov:`${h(I(r))}`}),a&&{forcedTransparency:`${a}`}))}`).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 s.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(i,r,null==E?void 0:E.get(),null==w?void 0:w.get(),null==v?void 0:v.get(),u),b=$t(a),{getSetupId:D,findUI:S,findQR:U,findThree:F}=b,N=D();ln();const{trackEvent:k,arInteracted:G,previewInteracted:x}=function(e,t){const n=performance.now(),A=Vt();let o=0,i=0,r=0,a=0,s=0,l=!1;window.setInterval((()=>{l&&(o=i+r,l=!1,c(nn,{engagementTotal:o,engagementAR:i,engagement3D:r}))}),1e3);const c=(o,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:an,pluginVersion:m,sessionId:on,setupId:A,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),cn((()=>{window.ShopAR__analytics.trackEventImpl(o,i)}))};return{trackEvent:c,arInteracted:()=>{const e=performance.now(),t=e-a;a=e,t<200&&(i+=t,l=!0)},previewInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(r+=t,l=!0)}}}(r,i);k("setup",{hostname:window.location.hostname});const L=yield R;k("apiResponse",L);const{category:T,arUrl:Y,arEnvUrl:P,arToneMapping:H,arToneMappingExposure:q,arKey:K,arPromptEnabled:j,arPromptText:$,arPromptImage:X,previewUrl:J,previewEnvUrl:W,previewToneMapping:O,previewToneMappingExposure:_,previewPosterUrl:z,cameraErrorText:V,qrPromptText:Z}=L;RA(D(),N);const ee=null!=Y&&function(e){return null!=e&&C.includes(e)}(T),te=null==(null===(A=n._internalOptions)||void 0===A?void 0:A.qrEnabled)||(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled),ne=ee&&function(e){return null!=e&&p.includes(e)}(T),Ae=te&&ne&&!CA(),oe=ee&&!Ae,ie=null!=J;RA(D(),N);const{setTargetElement:re,getDeepARTarget:ae,getDeepARPrompt:se,customizeDeepARPrompt:le,customizeCameraError:ge,customizeQRPrompt:ue,setVisibilityParameters:de,getUIState:Ie,setUIState:he,setDefaultUIActions:Ce,startDeepARLoading:pe,stopDeepARLoading:fe,startThreeLoading:Ee,stopThreeLoading:Be,setThreePosterUrl:Qe,showCameraError:me}=S();re(a);de(null==n.defaultUI||n.defaultUI,Ae,oe,ie,T,s),le(null!=$?$:"",null!=X?X:""),ge(V),ue(Z),Qe(z),function(e,n){const A=e.parentNode;if(null==A)throw new t("Parent node missing.");new MutationObserver((t=>{for(const A of t)for(const t of A.removedNodes)if(t===e)return void n()})).observe(A,{childList:!0})}(a,(()=>{Ie()!==Yt.QR||we()||ve(),Ie()!==Yt.AR||Kn||sA(),Ie()!==Yt.Preview||Ue()||Fe(),he(Yt.None),Ne(),function(e){jt.delete(e)}(a)}));const{qrPaused:we,qrDraw:ye,qrPause:ve}=U(),{threeInit:Re,threeParse:De,threeLoad:Se,threePaused:Ue,threeResume:Me,threePause:Fe,threeDestroy:Ne,threeSetZoomEnabled:ke,threeSetForcedTransparency:Ge,threeSetToneMapping:xe,threeIsInteractive:Le,threeSetInteractive:Te,threeSetOnInteracted:Ye,threeInitPromptAnimation:Pe,threeInitThetaAnimation:He,threeInitPhiAnimation:qe,threeInitFovAnimation:Ke,threeRenderOnce:je}=F(),$e=null==n.interactive||n.interactive;Te($e);let Xe=0;if(Ie()===Yt.QR){if(!we())if(Ae){k(Zt);try{yield ye(i,r)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else ve(),he(Yt.None)}else if(Ie()===Yt.AR){if(!Kn)if(oe&&!mA){k(en),Vn(),"Glasses"===T&&Zn();const e=null!=P?yield B(P):void 0;RA(D(),N);const t=yield B(Y);RA(D(),N),Xt(b),tA(T),nA(ae()),AA(j?se():null),yield iA(t,e,`${Y}${P}`),rA(H,q),oA(G),RA(D(),N)}else sA(),he(Yt.None)}else if(Ie()===Yt.Preview&&!Ue())if(ie){k(tn),pt(),Ee();const e=255,t=yield Q(J,(new Date).getTime()+e,Math.random()*e);RA(D(),N);const n=null!=W?W:`${y}/env/default.hdr`,A=yield B(n);RA(D(),N),yield ot,RA(D(),N),Re(),RA(D(),N);const o=n.endsWith(".hdr")?M.HDR:M.EXR,i=yield De(t,A,`${J}${W}`,o);RA(D(),N),Se(i,T),ke(g),Ge(u),xe(null!=O?O:"ACES",null!=_?_:1),Ye(x),Pe(),null!=f&&(He(E),qe(w),Ke(v)),je(),Me(),Be()}else Fe(),he(Yt.None);const Je=()=>e(this,void 0,void 0,(function*(){if(Ae)try{k(Zt);const e=++Xe;if(Ie()===Yt.Preview&&ie&&!Ue()&&Fe(),he(Yt.QR),yield ye(i,r),Xe!==e)return;return void RA(D(),N)}catch(e){const n=e instanceof Error;throw k("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}if(!oe)throw new t("Model does not have AR enabled.");try{k(en);const e=++Xe;Ie()===Yt.Preview&&ie&&!Ue()&&Fe(),Xt(b),he(Yt.AR),Vn(),"Glasses"===T&&Zn(),pe();const t=null!=P?yield B(P):void 0;RA(D(),N);const n=yield B(Y);if(Xe!==e)return;if(RA(D(),N),yield Ln,Xe!==e)return;if(RA(D(),N),sA(),tA(T),nA(ae()),AA(j?se():null),yield eA({licenseKey:K}),Xe!==e)return;if(RA(D(),N),yield iA(n,t,`${Y}${P}`),rA(H,q),oA(G),Xe!==e)return;if(RA(D(),N),yield aA(),Xe!==e)return;RA(D(),N)}catch(e){const n=e instanceof Error;throw k("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),me(),sA(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{fe()}})),We=()=>e(this,void 0,void 0,(function*(){if(!ie)throw new t("Model does not have 3D enabled.");try{k(tn);const e=++Xe;Ie()===Yt.AR&&(oe&&!Kn&&sA(),ve()),he(Yt.Preview),pt(),Ee();const t=255,n=yield Q(J,(new Date).getTime()+t,Math.random()*t);if(Xe!==e)return;RA(D(),N);const A=null!=W?W:`${y}/env/default.hdr`,o=yield B(A);if(Xe!==e)return;if(RA(D(),N),yield ot,Xe!==e)return;if(RA(D(),N),Re(),Xe!==e)return;RA(D(),N);const i=A.endsWith(".hdr")?M.HDR:M.EXR,r=yield De(n,o,`${J}${W}`,i);if(Xe!==e)return;RA(D(),N),Se(r,T),ke(g),Ge(u),xe(null!=O?O:"ACES",null!=_?_:1),Ye(x),Pe(),null!=f&&(He(E),qe(w),Ke(v)),je(),Me(),Be()}catch(e){const n=e instanceof Error;throw k("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}})),Oe=()=>e(this,void 0,void 0,(function*(){Ie()!==Yt.None&&("AR"!==s||Ie()!==Yt.AR&&Ie()!==Yt.QR)&&("3D"===s&&Ie()===Yt.Preview||(++Xe,Ie()===Yt.QR||Ie()===Yt.AR?(oe&&!Kn&&sA(),ve()):Ie()===Yt.Preview&&ie&&!Ue()&&Fe(),he(Yt.None),"AR"!==s?"3D"!==s||(yield We()):yield Je()))}));return Ce(Je,We,Oe),"AR"===s?(yield Je(),RA(D(),N)):"3D"===s&&(yield We(),RA(D(),N)),mA=!1,{launchAR:ee?Je:void 0,launch3D:ie?We:void 0,closeAR:ee?()=>e(this,void 0,void 0,(function*(){Ie()!==Yt.AR&&Ie()!==Yt.QR||"AR"!==s&&(++Xe,oe&&!Kn&&sA(),ve(),he(Yt.None),"3D"!==s||(yield We()))})):void 0,close3D:ie?()=>e(this,void 0,void 0,(function*(){Ie()===Yt.Preview&&"3D"!==s&&(++Xe,ie&&!Ue()&&Fe(),he(Yt.None),"AR"!==s||(yield Je()))})):void 0,close:ee||ie?Oe:void 0,isInteractive:()=>Le(),setInteractive:e=>Te(e)}}))}function RA(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const bA={setup:function(t){return e(this,void 0,void 0,(function*(){return wA(t)}))}},DA={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,A){return e(this,void 0,void 0,(function*(){try{return A()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>vA(n)))}))},version:m};export{pA as PREVIEW_STATES,t as PluginError,DA as plugin,bA as vision};
1
+ function e(e,t,n,A){return new(n||(n=Promise))((function(o,i){function r(e){try{s(A.next(e))}catch(e){i(e)}}function a(e){try{s(A.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}s((A=A.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array],A=n.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],r=window[o[i[i[A]]]][o[i[i[i.length-1]]]],a=r.charCodeAt(A),s=a^a,l=new n[1]([s]);function c(){const e=(new TextEncoder).encode(r),t=o.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[o[t[2]]](String.fromCodePoint(...e))}const g=[1e3,2e3,4e3],u=g.length;function d(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=u)throw e;return yield new Promise((e=>setTimeout(e,g[n]))),d(t,n+1)}}))}function I(e){return e*(180/Math.PI)}function h(e){return Math.round(100*e)/100}const C=["Glasses","Shoes","Watches"],p=["Shoes"];const f={},E={};function B(n){return null==f[n]&&(f[n]=function(n){return e(this,void 0,void 0,(function*(){const A=yield d((()=>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 A.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}(n)),f[n]}function Q(A,o,i){return null==E[A]&&(E[A]=function(A,o,i){return e(this,void 0,void 0,(function*(){let r="glb".charCodeAt(0),a="3d".charCodeAt(0);r>>=1,r+=a;const c=String.fromCharCode(r+14);a>>=2,r^=a+2;const g=String.fromCharCode(r-3);r^=5;const u=String.fromCharCode(r-7);r^=2;const I=String.fromCharCode(r-7),h=window[`${u}${g+c+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${I}`],C=yield d((()=>e(this,void 0,void 0,(function*(){const e=yield h(`${A}`).catch((()=>{throw new t("Unknown error.")}));if(!e.ok)throw new t("Unknown error.");return e})))),p=new n[0](yield(yield C.blob().catch((()=>{throw new t("Unknown error.")}))).arrayBuffer().catch((()=>{throw new t("Unknown error.")})));i+=a;const f=p.byteLength;if(l[s]=Math.min(76,o)*((r>>5)-1),152===l[s]&&(l[s]=f),i==s)return p;i=s,i^=s;for(let e=0,t=p.length;e<t;e++)l[s]^=l[i]<<13,l[s]^=l[i]>>17,l[s]^=l[i]<<5,p[e]=p[e]^l[s];return i^=l[0],i^=l[1],i^=l[2],p}))}(A,o,i)),E[A]}const m="0.7.4";let w=`https://cdn.jsdelivr.net/npm/shopar-plugin@${m}/dist`;const y={update:e=>{null!=e&&(w=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>w};function v(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 R;function b(t,n){let A=!0;return{qrPaused:()=>A,qrDraw:(o,i)=>e(this,void 0,void 0,(function*(){!function(){e(this,void 0,void 0,(function*(){null==R&&(R=v(`${y}/shopar-qr.js`))}))}(),yield R;const r=`https://ar.shopar.ai/${m.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:o,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(r),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,A=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){A=!0,t.style.display="none"}))}}const D=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.error('No <meta name="viewport"> detected. This might cause ShopAR to crash on iOS.\nPlease add the following line to your HTML:\n<meta name="viewport" content="width=device-width, initial-scale=1.0">'),()=>e?window.devicePixelRatio:1})();let S,U=!1;var M;let F,N,k;!function(e){e[e.HDR=0]="HDR",e[e.EXR=1]="EXR"}(M||(M={}));let G=!1;function x(e,t){const n=t===M.HDR?function(e){const t=new F.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,F.ClampToEdgeWrapping,F.ClampToEdgeWrapping,F.LinearFilter,F.LinearFilter,1,F.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(N.parse(e)):function(e){const t=new F.DataTexture(e.data,e.width,e.height,e.format,e.type,void 0,F.ClampToEdgeWrapping,F.ClampToEdgeWrapping,F.LinearFilter,F.LinearFilter,1,e.colorSpace);return t.needsUpdate=!0,t}(k.parse(e));return n.mapping=F.EquirectangularReflectionMapping,n.colorSpace=F.LinearSRGBColorSpace,n}const L=45,T=45,Y=3,P=1.5,H=1,q=.5;let K,j,$,X,J,W=!1;const O=4,_=.001,z=1e-7,V=10,Z=11,ee=1/(Z-1),te="function"==typeof Float32Array;function ne(e,t,n,A){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===A)return se;const o=te?new Float32Array(Z):new Array(Z);for(let t=0;t<Z;++t)o[t]=re(t*ee,e,n);function i(t){let A=0,i=1;const r=Z-1;for(;i!==r&&o[i]<=t;++i)A+=ee;--i;const a=A+(t-o[i])/(o[i+1]-o[i])*ee,s=ae(a,e,n);return s>=_?function(e,t,n,A){for(let o=0;o<O;++o){const o=ae(t,n,A);if(0===o)return t;t-=(re(t,n,A)-e)/o}return t}(t,a,e,n):0===s?a:function(e,t,n,A,o){let i,r,a=0;do{r=t+(n-t)/2,i=re(r,A,o)-e,i>0?n=r:t=r}while(Math.abs(i)>z&&++a<V);return r}(t,A,A+ee,e,n)}return function(e){return 0===e||1===e?e:re(i(e),t,A)}}function Ae(e,t){return 1-3*t+3*e}function oe(e,t){return 3*t-6*e}function ie(e){return 3*e}function re(e,t,n){return((Ae(t,n)*e+oe(t,n))*e+ie(t))*e}function ae(e,t,n){return 3*Ae(t,n)*e*e+2*oe(t,n)*e+ie(t)}function se(e){return e}function le(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=ne(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function ce(e){if(e.length<2)throw new Error("Expected at least two key frames.");const t=e[e.length-1].time,n=[...e].sort(((e,t)=>e.time-t.time)).map((({time:e,value:t,interpolation:n})=>({time:e,value:t,interpolate:le(n)})));let A=0,o=n[0].value;return{reset:()=>{A=0},update:e=>{for(A+=e;A>=t;)A-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(A>=t.time&&A<i.time){const e=t.interpolate((A-t.time)/(i.time-t.time));o=t.value+e*(i.value-t.value)}}},get:()=>o}}const ge="#",ue="time",de="interpolation",Ie="yaw",he="pitch",Ce="fov",pe=[ue,Ie,he,Ce,de],fe="s",Ee="ms",Be=1e3,Qe="deg",me="rad",we=Math.PI/180,ye="ease-in-out",ve="cubic-bezier(",Re=")";function be(e){if("string"==typeof e)return function(e){const[t,...n]=function(e){return e.split(/\r?\n/).map((e=>function(e){const t=e.indexOf(ge);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const A=function(e){const t=[];for(let n=0;n<e.length;n++){const A=e[n];if(!pe.includes(A))throw new Error(`Invalid token in header: '${A}'.`);if(t.includes(A))throw new Error(`Duplicate token in header: '${A}'.`);t.push(A)}if(!t.includes(ue))throw new Error(`Missing required token: '${ue}'.`);return t}(t.split(/\s+/)),o={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:i}=De(A,e);null!=t&&(null==o.theta&&(o.theta=[]),o.theta.push(t)),null!=n&&(null==o.phi&&(o.phi=[]),o.phi.push(n)),null!=i&&(null==o.fov&&(o.fov=[]),o.fov.push(i))}if(0===Object.values(o).length)throw new Error("At least one parameter should be animated.");return o}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const A of e){const{time:e,pitch:o,yaw:i,fov:r}=A;if(null==e)throw new Error("Time missing.");const a=Ue(null!==(t=A.interpolation)&&void 0!==t?t:ye);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*we,interpolation:a})),null!=o&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:o*we,interpolation:a})),null!=r&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:r*we,interpolation:a}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function De(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const A=e.indexOf(ue),o=function(e){if(e.endsWith(Ee))return Fe(e.substring(0,e.length-Ee.length));if(e.endsWith(fe))return Fe(e.substring(0,e.length-fe.length))*Be;return Fe(e)}(n[A]),i=e.indexOf(de),r=Ue(-1===i?ye:n[i]),a={};for(let t=0;t<n.length;t++){if(t===A||t===i)continue;const s=e[t],l=n[t];switch(s){case Ie:a.theta={time:o,value:Se(l),interpolation:r};break;case he:a.phi={time:o,value:Se(l),interpolation:r};break;case Ce:a.fov={time:o,value:Se(l),interpolation:r};break;default:throw new Error(`Unhandled value for header '${s}'.`)}}return a}function Se(e){return e.endsWith(Qe)?Fe(e.substring(0,e.length-Qe.length))*we:e.endsWith(me)?Fe(e.substring(0,e.length-me.length)):Fe(e)*we}function Ue(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Me(0,0,1,1);if("sine"===e)return Me(.37,0,.63,1);if("sine-in"===e)return Me(.12,0,.39,0);if("sine-out"===e)return Me(.61,1,.88,1);if("ease"===e)return Me(.25,.1,.25,1);if("ease-in"===e)return Me(.42,0,1,1);if("ease-out"===e)return Me(0,0,.58,1);if("ease-in-out"===e)return Me(.42,0,.58,1);if(e.startsWith(ve)&&e.endsWith(Re)){const t=e.substring(ve.length,e.length-Re.length).split(/\s*,\s*/);if(4!==t.length)throw new Error(`Expected 4 parameters for the Bezier curve, but got '${t}'.`);return{type:"bezier",x1:Fe(t[0]),y1:Fe(t[1]),x2:Fe(t[2]),y2:Fe(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Me(e,t,n,A){return{type:"bezier",x1:e,y1:t,x2:n,y2:A}}function Fe(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const Ne=300,ke=2e3,Ge=.05,xe=2*Math.PI/32,Le=Ue("hold"),Te=Ue("sine"),Ye=Ue("sine-in"),Pe=Ue("sine-out");const He=2e3,qe=8,Ke=2*Math.PI,je=Ke/12,$e=Ke/60,Xe=Ke/60,Je=60,We=60,Oe=1e3,_e=Je*We,ze=-1;function Ve(e){return ce([{time:0,value:0,interpolation:{type:"bezier",x1:.9,y1:0,x2:.6,y2:1}},{time:He,value:e,interpolation:{type:"hold"}}])}function Ze(e,t,n){return ze*je*(e+t/Je+n/_e)}function et(e,t){return ze*$e*(e+t/We)}function tt(e,t){return ze*Xe*(e+t/Oe)}const nt=["map","alphaMap","anisotropyMap","aoMap","bumpMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","displacementMap","emissiveMap","envMap","gradientMap","iridescenceMap","iridescenceThicknessMap","lightMap","metalnessMap","normalMap","roughnessMap","sheenColorMap","sheenRoughnessMap","specularMap","specularColorMap","specularIntensityMap","thicknessMap","transmissionMap"];function At(e){null!=e&&(e.dispose(),nt.forEach((t=>{var n;return null===(n=e[t])||void 0===n?void 0:n.dispose()})))}let ot;const it=0,rt=3;let at,st,lt,ct=!1,gt=1,ut=1,dt=1;const It=1;let ht;const Ct=new Map;function pt(){null==ot&&(ot=v(`${y}/shopar-three.js`))}function ft(t,n,A){const o=t.getContext("2d");null==o&&console.warn("2D context missing.");let i,r,a,s,l,c,g,u,d,I,h,C,p,f,E,B=!1,Q=!1,m=!1,w=!0,y=!1,v=1,R=!0,b=!1,D=0,M=0,H=1,W=1,O=1;const _={threeInit:()=>{B||(Et(),i=new st.Scene,r=new st.PerspectiveCamera(25,1,.5),a=new at.OrbitControls(r,t),a.setInteractionEnabled(R),u=st.ACESFilmicToneMapping,({renderShadow:l,shadowGroup:s}=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 A=new K.Group;A.position.y=-.7;const o=new K.PlaneGeometry(L,T).rotateX(Math.PI/2),i=new K.MeshBasicMaterial({map:t.texture,opacity:q,transparent:!0,depthWrite:!1}),r=new K.Mesh(o,i);r.renderOrder=1,r.scale.y=-1,A.add(r);const a=new K.Mesh(o);a.visible=!1,A.add(a);const s=new K.OrthographicCamera(-L/2,L/2,T/2,-T/2,0,Y);function l(e){a.visible=!0,X.uniforms.tDiffuse.value=t.texture,X.uniforms.h.value=1*e/256,a.material=X,j.setRenderTarget(n),j.render(a,s),J.uniforms.tDiffuse.value=n.texture,J.uniforms.v.value=1*e/256,a.material=J,j.setRenderTarget(t),j.render(a,s),a.visible=!1}return s.rotation.x=Math.PI/2,A.add(s),{shadowGroup:A,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=$;const A=j.getClearAlpha();j.setClearAlpha(0),j.setRenderTarget(t),j.render(e,s),e.overrideMaterial=null,l(P),l(.4*P),j.setRenderTarget(null),j.setClearAlpha(A),e.background=n}}}(i)),B=!0)},threeParse:(t,n,A,o)=>e(this,void 0,void 0,(function*(){return null!=c&&g===A||(yield c,c=(()=>e(this,void 0,void 0,(function*(){var e,A,r;return A=at,G||(F=A.THREE,N=new A.RGBELoader,k=new A.EXRLoader,G=!0),null===(e=i.environment)||void 0===e||e.dispose(),i.environment=x(n,o),function(e,t){if(U)return;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),U=!0}(ht,at),r=t,S.parseAsync(r.buffer,"")})))(),g=A),c})),threeLoad:(e,t)=>{mt(i),i.add(e.scene);const n=(new st.Box3).setFromObject(e.scene);s.position.y=n.min.y-it,i.add(s),l(),Q=!1,i.traverse((e=>{if(e instanceof st.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(Q=!0)})):t.transmission>0&&(Q=!0)}}));const A=n.min.clone().add(n.max).divideScalar(2),o=Math.sqrt(at.reduceVertices(e.scene,((e,t)=>Math.max(e,A.distanceToSquared(t))),0));a.reset(A,o,function(e,t){var n;const A={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?A.Glasses:null!==(n=A[e])&&void 0!==n?n:A.Glasses).normalize()}(t,st.Vector3)),D=0,E="Watches"===t?function(e){const t=e.getObjectByName("hours"),n=e.getObjectByName("minutes"),A=e.getObjectByName("seconds");if(null==t&&null==n&&null==A)return null;let o,i,r,a,s,l;return{start:()=>{o=new Date,o.setMilliseconds(o.getMilliseconds()+He),s=!1;const e=o.getHours(),t=o.getMinutes(),n=o.getSeconds(),A=o.getMilliseconds();i=Ve(Ze(e,t,n)),r=Ve(et(t,n)),a=Ve(tt(n,A)),l=new Date},update:()=>{if(null==o)return!1;const e=new Date;if(!s){if(o.getTime()-e.getTime()>0){const o=Math.abs(e.getTime()-l.getTime());return null!=t&&(i.update(o),t.rotation.y=i.get()),null!=n&&(r.update(o),n.rotation.y=r.get()),null!=A&&(a.update(o),A.rotation.y=a.get()),l=e,!0}s=!0}if(Math.abs(e.getTime()-l.getTime())<Oe/qe)return!1;l=e;const c=e.getHours(),g=e.getMinutes(),u=e.getSeconds(),d=e.getMilliseconds();return null!=t&&(t.rotation.y=Ze(c,g,u)),null!=n&&(n.rotation.y=et(g,u)),null!=A&&(A.rotation.y=tt(u,d)),!0}}}(e.scene):null},threePaused:()=>w,threeResume:()=>{w=!1,ht.setAnimationLoop(Bt),t.style.visibility="visible",M=0,null==I||I.reset(),null==h||h.reset(),null==C||C.reset(),null==p||p.reset(),null==f||f.reset(),null==E||E.start()},threePause:()=>{w=!0,function(){for(const{threePaused:e}of Ct.values())if(!e())return!1;return!0}()&&ht.setAnimationLoop(null),t.style.visibility="hidden",A.style.opacity="0",n.style.visibility="hidden"},threeDestroy:()=>{var e;mt(i),null===(e=i.environment)||void 0===e||e.dispose(),i.environment=null,i=null,c=null,E=null,Ct.delete(t)},threeSetZoomEnabled:e=>{a.enableZoom=e},threeSetForcedTransparency:e=>{m=e},threeSetToneMapping:(e,t)=>{const n={ACES:st.ACESFilmicToneMapping,Linear:st.LinearToneMapping,Neutral:st.NeutralToneMapping};null!=n[e]&&(u=n[e]),v=t},threeIsInteractive:()=>R,threeSetInteractive:e=>{R=e,null==a||a.setInteractionEnabled(R)},threeSetOnInteracted:e=>{a.removeEventListener("change",d),d=e,a.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=a.getTheta(),I=ce([{time:0,value:e,interpolation:Le},{time:Ne,value:e,interpolation:Pe},{time:Ne+ke/4,value:e+xe,interpolation:Te},{time:Ne+3*ke/4,value:e-xe,interpolation:Ye},{time:Ne+ke,value:e,interpolation:Le},{time:Ne+2*ke,value:e,interpolation:Le}]),a.setTheta(I.get()),h=null,C=null,p=ce([{time:0,value:0,interpolation:Le},{time:Ne,value:1,interpolation:Le},{time:Ne+ke,value:0,interpolation:Le},{time:Ne+2*ke,value:0,interpolation:Le}]),f=ce([{time:0,value:0,interpolation:Le},{time:Ne,value:0,interpolation:Pe},{time:Ne+ke/4,value:-Ge,interpolation:Te},{time:Ne+3*ke/4,value:Ge,interpolation:Ye},{time:Ne+ke,value:0,interpolation:Le},{time:Ne+2*ke,value:0,interpolation:Le}])},threeInitThetaAnimation:e=>{I=e,null!=e&&a.setTheta(e.get())},threeInitPhiAnimation:e=>{h=e,null!=e&&a.setPhi(e.get())},threeInitFovAnimation:e=>{C=e,null!=e&&a.setFovRadians(e.get())},threeRenderOnce:()=>{_.render_()},preRender_:e=>{if(!B||w||!function(e){const t=e.getBoundingClientRect();return t.bottom>0&&t.top<Math.max(document.documentElement.clientHeight,window.innerHeight)&&t.right>0&&t.left<Math.max(document.documentElement.clientWidth,window.innerWidth)}(t))return;let n=0!==M?e-M:0;M=e,0===D?y=!0:D<rt&&(n=0),D++,b||(a.hasUserInteracted()?(b=!0,I=null,h=null,C=null,p=null,f=null):(null==I||I.update(n),null==h||h.update(n),null==C||C.update(n),null==p||p.update(n),null==f||f.update(n),null!=I&&(a.setTheta(I.get()),y=!0),null!=h&&(a.setPhi(h.get()),y=!0),null!=C&&(a.setFovRadians(C.get()),y=!0))),a.update()&&(y=!0),(null==E?void 0:E.update())&&(y=!0)},shouldRender_:()=>!(!B||w)&&y,render_:()=>{const e=ht.toneMapping,a=ht.toneMappingExposure;ht.toneMapping=u,ht.toneMappingExposure=v,ht.setViewport(0,0,t.width,t.height),ht.setClearColor(new st.Color(16777215),Q&&!m?1:0),ht.render(i,r),ht.toneMapping=e,ht.toneMappingExposure=a,y=!1,null!=o&&(o.clearRect(0,0,t.width,t.height),lt.width>0&&lt.height>0&&o.drawImage(lt,0,ut-t.height,t.width,t.height,0,0,t.width,t.height),n.style.visibility=R&&!b?"visible":"hidden",null!=p&&(A.style.opacity=`${p.get()}`),null!=f&&(A.style.transform=`translateX(${f.get()*Math.min(H,W)}px)`))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===H&&n===W&&dt===O||(t.width=Math.ceil(e*dt*It),t.height=Math.ceil(n*dt*It),H=e,W=n,O=dt,y=!0)},target_:t};return Ct.set(t,_),_}function Et(){if(ct)return;at=window.ShopAR__THREE,st=at.THREE,lt=document.createElement("canvas");var e,t;lt.style.position="block",ht=new st.WebGLRenderer({powerPreference:"high-performance",canvas:lt,antialias:!0,alpha:!0}),ht.outputColorSpace=st.SRGBColorSpace,ht.toneMapping=st.ACESFilmicToneMapping,ht.setClearColor(new st.Color(16777215),0),e=ht,t=at,W||(K=t.THREE,j=e,$=new K.MeshDepthMaterial,$.userData.darkness={value:H},$.onBeforeCompile=e=>{e.uniforms.darkness=$.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},$.depthTest=!1,$.depthWrite=!1,X=new K.ShaderMaterial(t.HorizontalBlurShader),X.depthTest=!1,J=new K.ShaderMaterial(t.VerticalBlurShader),J.depthTest=!1,W=!0),Qt(),ct=!0}function Bt(e){Qt(),ht.clear();for(const{preRender_:t,shouldRender_:n,render_:A}of Ct.values())t(e),n()&&A()}function Qt(){let e=0,t=0;for(const{target_:n}of Ct.values()){const{clientWidth:A,clientHeight:o}=n;e=Math.max(e,A),t=Math.max(t,o)}const n=D();e=Math.ceil(e*n*It),t=Math.ceil(t*n*It),e===gt&&t===ut&&n===dt||(gt=e,ut=t,dt=n,ht.setSize(gt,ut,!1));for(const{updateSize_:e}of Ct.values())e()}function mt(e){e.traverse((e=>{var t;e instanceof st.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach(At):At(e.material))})),e.clear()}const wt={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},yt=Object.keys(wt);function vt(e){return wt[e]}const Rt="shopar-error";function bt(e,t,n,A){const o=document.createElement("button");o.id=e,o.type="button",o.className="shopar-btn",o.appendChild(A);{const e=document.createElement("span");e.textContent=t,o.appendChild(e)}o.ariaLabel=n;const i=o.style;return i.display="none",i.pointerEvents="auto",o}const Dt="shopar-control";const St="shopar-deepar-output";function Ut(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.pointerEvents="auto",n.userSelect="none",t}function Mt(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function Ft(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 Nt(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 kt="shopar-main";const Gt="shopar-qr-output";function xt(e){var t,n;const A=document.createElementNS("http://www.w3.org/2000/svg","svg");return A.setAttribute("width",null!==(t=e.getAttribute("width"))&&void 0!==t?t:"1rem"),A.setAttribute("height",null!==(n=e.getAttribute("height"))&&void 0!==n?n:"1rem"),A.appendChild(e),A}function Lt(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","image");return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",null!=t?t:"data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E"),n.setAttribute("width",e),n.setAttribute("height",e),n}const Tt="shopar-three-output";var Yt;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(Yt||(Yt={}));let Pt=!1;function Ht(){Pt||(!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.")}}(),Pt=!0)}function qt(){Ht();const e=function(){const e=document.createElement("div");e.id=kt;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),A=function(e,t){const n=document.createElement("div");n.id=Gt;const A=n.style;A.position="absolute",A.top="0",A.left="0",A.width="100%",A.height="100%",A.display="none",A.pointerEvents="auto",A.userSelect="none";const o=document.createElement("div");o.className="shopar-qr";const i=o.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(o),o.appendChild(e);const r=document.createElement("div");return r.appendChild(t),o.appendChild(r),n}(t,n);e.appendChild(A);const o=function(){const e=document.createElement("div");e.id=St;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",t.pointerEvents="auto",e}();e.appendChild(o);const i=function(){const e=document.createElement("canvas");e.id=Tt,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const r=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:A}=n;return A.position="absolute",A.width="100%",A.height="100%",A.opacity="0",n.appendChild(e),n.appendChild(t),n}(r,a);e.appendChild(s);const l=function(){const e=xt(Lt("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",t.appendChild(e),t}(l);e.appendChild(c);const g=Ut("shopar-ar-loading-container"),u=Mt("shopar-ar-loading-text",vt("loading.ar"));g.appendChild(u);const d=Ft("shopar-ar-loading-bar-bg"),I=Nt("shopar-ar-loading-bar-fg");d.appendChild(I),g.appendChild(d),e.appendChild(g);const h=Ut("shopar-3d-loading-container"),C=Mt("shopar-3d-loading-text",vt("loading.3d"));h.appendChild(C);const p=Ft("shopar-3d-loading-bar-bg"),f=Nt("shopar-3d-loading-bar-fg");p.appendChild(f),h.appendChild(p),e.appendChild(h);const E=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",t.backgroundSize="contain",t.backgroundRepeat="no-repeat",t.backgroundPosition="center",e}();e.appendChild(E);const B=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),Q=function(e){const t=document.createElement("div");t.id=Rt;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const A=document.createElement("div"),o=A.style;return o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",t.appendChild(A),A.appendChild(e),t}(B);e.appendChild(Q);const m=function(){const e=document.createElement("div");return e.id=Dt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(m);const w=Lt("1.75rem"),v=bt("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on",xt(w));m.appendChild(v);const R=Lt("1.75rem"),b=bt("shopar-btn-3d","3D","Launch ShopAR 3D preview",xt(R));m.appendChild(b);const D=Lt("1.75rem"),S=bt("shopar-btn-close","Close","Close ShopAR view",xt(D));m.append(S);let U,M,F=Yt.None,N=!1,k=!1,G=!1,x=!1;function L(){I.classList.remove("active"),g.style.visibility="hidden"}function T(){E.style.visibility="hidden",f.classList.remove("active"),h.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return A},getQRImage:function(){return n},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return i},getThreePrompt:function(){return c},getThreePromptImage:function(){return l},customizeDeepARPrompt:function(e,t){r.textContent=e,a.src=t},customizeCameraError:function(e){B.textContent=null!=e?e:"Please reload page and allow camera access to continue"},customizeQRPrompt:function(e){t.textContent=null!=e?e:"Scan on mobile or tablet to try on"},setVisibilityParameters:function(e,t,n,A,o,i){var r;N=e,k=t,G=n,x=A,U=o,M=i,Kt(m,N),Kt(v,N&&(G||k)&&F===Yt.None),Kt(b,N&&x&&F===Yt.None),Kt(S,N&&F!==Yt.None),L(),T(),N||""===(r=Q).style.display&&Kt(r,!1)},getUIState:function(){return F},setUIState:function(e){F=e,F===Yt.None?(L(),T(),N&&(Kt(Q,!1),Kt(S,!1),(k||G)&&Kt(v,!0),x&&Kt(b,!0))):F===Yt.QR||F===Yt.AR?N&&(Kt(Q,!1),Kt(v,!1),Kt(b,x&&"AR"===M),Kt(S,"AR"!==M)):F===Yt.Preview&&N&&(Kt(Q,!1),Kt(v,(k||G)&&"3D"===M),Kt(b,!1),Kt(S,"3D"!==M))},setDefaultUIActions:function(e,t,n){N&&((k||G)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,A=`${y}/img/icons/${n}`;w.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",A)}(U),v.onclick=e),x&&(R.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${y}/img/icons/cube.svg`),b.onclick=t),D.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${y}/img/icons/close.svg`),S.onclick=n)},startDeepARLoading:function(){I.classList.add("active"),g.style.visibility="visible"},stopDeepARLoading:L,startThreeLoading:function(){null!=E.dataset.bgSet?E.style.visibility="visible":(f.classList.add("active"),h.style.visibility="visible")},stopThreeLoading:T,setThreePosterUrl:function(e){null!=e?(E.style.backgroundImage=`url(${e})`,E.dataset.bgSet="true"):delete E.dataset.bgSet},showCameraError:function(){N&&Kt(Q,!0)}}}function Kt(e,t){e.style.display=t?"":"none"}const jt=new Map;function $t(e){let t=jt.get(e);return null==t?(t=function(){let e=0,t=null,n=null,A=null;const o=()=>(null==t&&(t=qt()),t);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>t,findUI:o,findQR:()=>{if(null==n){const{getQRTarget:e,getQRImage:t}=o();n=b(e(),t())}return n},findThree:()=>{if(null==A){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=o();A=ft(e(),t(),n())}return A}}}(),jt.set(e,t)):t.incrementSetupId_(),t}function Xt(e){for(const t of jt.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:A,setUIState:o}=n;A()===Yt.AR&&o(Yt.None)}}let Jt;const Wt=new Uint8Array(16);function Ot(){if(!Jt&&(Jt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Jt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Jt(Wt)}const _t=[];for(let e=0;e<256;++e)_t.push((e+256).toString(16).slice(1));var zt={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Vt(e,t,n){if(zt.randomUUID&&!t&&!e)return zt.randomUUID();const A=(e=e||{}).random||(e.rng||Ot)();if(A[6]=15&A[6]|64,A[8]=63&A[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=A[e];return t}return function(e,t=0){return _t[e[t+0]]+_t[e[t+1]]+_t[e[t+2]]+_t[e[t+3]]+"-"+_t[e[t+4]]+_t[e[t+5]]+"-"+_t[e[t+6]]+_t[e[t+7]]+"-"+_t[e[t+8]]+_t[e[t+9]]+"-"+_t[e[t+10]]+_t[e[t+11]]+_t[e[t+12]]+_t[e[t+13]]+_t[e[t+14]]+_t[e[t+15]]}(A)}const Zt="qrLaunch",en="arLaunch",tn="previewLaunch",nn="heartbeat";let An,on,rn=!1,an=window.navigator.userAgent||"no user agent";const sn=[];function ln(){null==An&&(on=Vt(),An=v(`${y}/shopar-analytics.js`),An.then((()=>{rn=!0,window.ShopAR__analytics.initializeImpl(),sn.forEach((e=>e()))})))}function cn(e){rn?e():sn.push(e)}function gn(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function un(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 dn=200,In=10;let hn=!1,Cn=null,pn=[],fn=[];function En(t){return e(this,void 0,void 0,(function*(){hn=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${y}/wasm/mediapipe`,t),Cn&&clearInterval(Cn);const A=[],o=[];Cn=setInterval((()=>e(this,void 0,void 0,(function*(){if(hn)return;const{error:e,faceWidth:t,ipd:i,translation:r,rotation:a}=yield n.predict(performance.now());hn||(null!=r&&null!=a&&function(e){for(let t of pn)t(e)}({translation:r,rotation:a}),null==e&&(A.push(t),o.push(i),A.length<In||(A.shift(),o.shift(),function(e,t){for(let n of fn)n({faceWidth:e,IPD:t})}(Qn(A),Qn(o)))))}))),dn)}))}function Bn(){fn=[],pn=[],hn=!0}function Qn(e){let t=0;const n=e.length;for(let A=0;A<n;A++)t+=e[A];return t/n}var mn="undefined"!=typeof Float32Array?Float32Array:Array;function wn(){var e=new mn(16);return mn!=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 yn(e,t,n){var A=t[0],o=t[1],i=t[2],r=t[3],a=t[4],s=t[5],l=t[6],c=t[7],g=t[8],u=t[9],d=t[10],I=t[11],h=t[12],C=t[13],p=t[14],f=t[15],E=n[0],B=n[1],Q=n[2],m=n[3];return e[0]=E*A+B*a+Q*g+m*h,e[1]=E*o+B*s+Q*u+m*C,e[2]=E*i+B*l+Q*d+m*p,e[3]=E*r+B*c+Q*I+m*f,E=n[4],B=n[5],Q=n[6],m=n[7],e[4]=E*A+B*a+Q*g+m*h,e[5]=E*o+B*s+Q*u+m*C,e[6]=E*i+B*l+Q*d+m*p,e[7]=E*r+B*c+Q*I+m*f,E=n[8],B=n[9],Q=n[10],m=n[11],e[8]=E*A+B*a+Q*g+m*h,e[9]=E*o+B*s+Q*u+m*C,e[10]=E*i+B*l+Q*d+m*p,e[11]=E*r+B*c+Q*I+m*f,E=n[12],B=n[13],Q=n[14],m=n[15],e[12]=E*A+B*a+Q*g+m*h,e[13]=E*o+B*s+Q*u+m*C,e[14]=E*i+B*l+Q*d+m*p,e[15]=E*r+B*c+Q*I+m*f,e}function vn(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Rn(e,t){var n=t[0],A=t[1],o=t[2],i=t[4],r=t[5],a=t[6],s=t[8],l=t[9],c=t[10];return e[0]=Math.hypot(n,A,o),e[1]=Math.hypot(i,r,a),e[2]=Math.hypot(s,l,c),e}function bn(e,t,n,A){var o=t[0],i=t[1],r=t[2],a=t[3],s=o+o,l=i+i,c=r+r,g=o*s,u=o*l,d=o*c,I=i*l,h=i*c,C=r*c,p=a*s,f=a*l,E=a*c,B=A[0],Q=A[1],m=A[2];return e[0]=(1-(I+C))*B,e[1]=(u+E)*B,e[2]=(d-f)*B,e[3]=0,e[4]=(u-E)*Q,e[5]=(1-(g+C))*Q,e[6]=(h+p)*Q,e[7]=0,e[8]=(d+f)*m,e[9]=(h-p)*m,e[10]=(1-(g+I))*m,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Dn(){var e=new mn(3);return mn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Sn(e,t,n){var A=new mn(3);return A[0]=e,A[1]=t,A[2]=n,A}function Un(e,t){var n=t[0]-e[0],A=t[1]-e[1],o=t[2]-e[2];return Math.hypot(n,A,o)}function Mn(e,t,n){var A=t[0],o=t[1],i=t[2],r=n[3]*A+n[7]*o+n[11]*i+n[15];return r=r||1,e[0]=(n[0]*A+n[4]*o+n[8]*i+n[12])/r,e[1]=(n[1]*A+n[5]*o+n[9]*i+n[13])/r,e[2]=(n[2]*A+n[6]*o+n[10]*i+n[14])/r,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Fn(){var e=new mn(4);return mn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Dn(),function(){var e,t=(e=new mn(4),mn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var Nn;Dn(),Sn(1,0,0),Sn(0,1,0),Fn(),Fn(),Nn=new mn(9),mn!=Float32Array&&(Nn[1]=0,Nn[2]=0,Nn[3]=0,Nn[5]=0,Nn[6]=0,Nn[7]=0),Nn[0]=1,Nn[4]=1,Nn[8]=1;const kn="data:application/octet-stream;base64,AGFzbQEAAAABHQZgAX8Bf2ADf39/AX9gAAF8YAF/AGAAAGACf38AAhMDAWEBYQABAWEBYgAAAWEBYwACAwYFAAMEAAUEBQFwAQEBBQYBAYICggIGCAF/AUGgmAQLBxkGAWQCAAFlAAUBZgAHAWcABAFoAQABaQAGCqc1BU8BAn9BsAgoAgAiASAAQQdqQXhxIgJqIQACQCACQQAgACABTRtFBEAgAD8AQRB0TQ0BIAAQAQ0BC0GkFEEwNgIAQX8PC0GwCCAANgIAIAELzAsBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQJxRQ0BIAMgAygCACIBayIDQbgUKAIASQ0BIAAgAWohAAJAAkACQEG8FCgCACADRwRAIAMoAgwhAiABQf8BTQRAIAIgAygCCCIERw0CQagUQagUKAIAQX4gAUEDdndxNgIADAULIAMoAhghBiACIANHBEAgAygCCCIBIAI2AgwgAiABNgIIDAQLIAMoAhQiAQR/IANBFGoFIAMoAhAiAUUNAyADQRBqCyEEA0AgBCEHIAEiAkEUaiEEIAIoAhQiAQ0AIAJBEGohBCACKAIQIgENAAsgB0EANgIADAMLIAUoAgQiAUEDcUEDRw0DQbAUIAA2AgAgBSABQX5xNgIEIAMgAEEBcjYCBCAFIAA2AgAPCyAEIAI2AgwgAiAENgIIDAILQQAhAgsgBkUNAAJAIAMoAhwiAUECdEHYFmoiBCgCACADRgRAIAQgAjYCACACDQFBrBRBrBQoAgBBfiABd3E2AgAM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AAkAgAigCHCIBQQJ0QdgWaiIFKAIAIAJGBEAgBSAANgIAIAANAUGsFCALQX4gAXdxNgIADAILIAlBEEEUIAkoAhAgAkYbaiAANgIAIABFDQELIAAgCTYCGCACKAIQIgEEQCAAIAE2AhAgASAANgIYCyACKAIUIgFFDQAgACABNgIUIAEgADYCGAsCQCADQQ9NBEAgAiADIAZqIgBBA3I2AgQgACACaiIAIAAoAgRBAXI2AgQMAQsgAiAGQQNyNgIEIAIgBmoiBSADQQFyNgIEIAMgBWogAzYCACAIBEAgCEF4cUHQFGohAEG8FCgCACEBAn9BASAIQQN2dCIHIARxRQRAQagUIAQgB3I2AgAgAAwBCyAAKAIICyEEIAAgATYCCCAEIAE2AgwgASAANgIMIAEgBDYCCAtBvBQgBTYCAEGwFCADNgIACyACQQhqIQALIApBEGokACAAC8cBAwZ/AXwBfiMAQSBrIgMkACADAn4QAkQAAAAAAECPQKMiCJlEAAAAAAAA4ENjBEAgCLAMAQtCgICAgICAgICAfwsiCTcDEEG0CEGACCADQRBqEAAhBCADIAk3AwBBzg5BgAggAxAAIQUDQCACQSBGBEAgBBAEIAUQBCADQSBqJAAFIAEgAmoiBiACIAVqIgctAAAgAiAEai0AACAAIAJqLQAAc3M6AAAgBiAHLQAAIAJBkAhqLQAAczoAICACQQFqIQIMAQsLCws3AwBBgAgLAWoAQZAICyB/bT8OSH+hRnx9UDLOjCuACx6NxKtzWvD26is8y2VImgBBsAgLAyAMAQ==";var Gn=function(e={}){var t,n,A,o,i,r,a=e,s=new Promise(((e,n)=>{t=e}));var l={1076:e=>{const t=[e,Date.now()],n=t.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame","navigator","userAgent"],i=[2,12,7,1],r=window[o[o[i[i[i.length-1]]+2].length-i[t.length]+1]][o[Math.pow(i[n],o[i.length].length)]]||"no user agent",a=c(32);for(let e=0;e<32;++e)A[a+e]=r.charCodeAt(e%r.length);return a},1870:e=>{var t,n=function(){var e;try{e=Function('return (function() {}.constructor("return this")( ));')()}catch(t){e=window}return e}(),o=Date.now();for(var i in n)if(8==i.length&&116==i.charCodeAt(7)&&101==i.charCodeAt(5)&&117==i.charCodeAt(3)&&100==i.charCodeAt(0)){o=i,t=e;break}for(var r in n[o])if(6==r.length&&110==r.charCodeAt(5)&&100==r.charCodeAt(0)){t=r;break}const a=n[o][t]||"no hostname",s=c(32);for(let e=0;e<32;++e)A[s+e]=a.charCodeAt(e%a.length);return s}};a.noExitRuntime;var c,g=[],u=(e,t,r)=>{var a=((e,t)=>{var r;for(g.length=0;r=A[e++];){var a=105!=r;t+=(a&=112!=r)&&t%8?4:0,g.push(112==r?o[t>>2]:105==r?n[t>>2]:i[t>>3]),t+=a?8:4}return g})(t,r);return l[e](...a)};var d={a:{a:(e,t,n)=>u(e,t,n),c:()=>Date.now(),b:e=>{A.length,function(e){throw"OOM"}()}}};return WebAssembly.instantiate(a.wasm,d).then((e=>{var s,l=e.instance.exports;a._magic=l.f,a._free=l.g,a._malloc=c=l.i,r=l.d,s=r.buffer,a.HEAPU8=A=new Uint8Array(s),n=new Int32Array(s),o=new Uint32Array(s),i=new Float64Array(s),function(e){e.e()}(l),t(a)})),s};function xn(){return e(this,void 0,void 0,(function*(){const t=yield function(){return e(this,void 0,void 0,(function*(){const e=yield fetch(kn);return yield Gn({wasm:yield e.arrayBuffer()})}))}();return function(e){const n=t._malloc(32);for(let A=0;A<e.size()&&A<32;A++)t.HEAPU8[n+A]=e.get(A);const A=t._malloc(64);t._magic(n,A);const o=new Uint8Array(64);for(let e=0;e<64;++e)o[e]=t.HEAPU8[A+e];return t._free(n),t._free(A),o}}))}let Ln,Tn,Yn,Pn,Hn,qn,Kn=!0,jn=null;const $n=new Set;let Xn,Jn,Wn,On,_n,zn;function Vn(){null==Ln&&(Ln=v(`${y}/shopar-deepar.js`))}function Zn(){null==Tn&&(Tn=v(`${y}/shopar-true-scale.js`))}function eA(n){return e(this,void 0,void 0,(function*(){const{licenseKey:A,truescaleUsecase:o}=n;return _n=o,null==Xn&&(Xn=(()=>e(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new t("No camera available!");var e;const n=lA(Hn),o=gn(n);Yn=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:A||"your_license_key_goes_here",previewElement:qn,rootPath:y.toString()+"/deepar",additionalOptions:{hint:zn,cameraConfig:{disableDefaultCamera:!0},onVerify:yield xn()}}),Pn=yield un(o),yield cA(Yn,Pn,"user"===n),"Glasses"===Hn&&(yield Tn,En(Pn),"DetectionLoop"!==_n&&IA((e=>{On=e.faceWidth})))})))()),Xn}))}function tA(e,t){var n,A;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===Hn&&(n=t,A=zn,n===A||null!=n&&null!=A&&n.length===A.length&&n.every((e=>A.find((t=>e===t))))&&A.every((e=>n.find((t=>t===e))))))||(null!=Yn&&(Yn.shutdown(),Yn=null,Xn=null),Hn=e,zn=t)}function nA(e){e!==qn&&(qn=e,null!=Yn&&Yn.changePreviewElement(qn))}function AA(e){jn=e}function oA(e){Yn.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(On){const e=137/(On+5);Yn.changeParameterVector("GLASSES","","scale",e,e,e,0),Yn.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const A=uA("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),o=uA("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);Yn.changeParameterVector("temple_left","","rotation",0,56.6*-A,0,0),Yn.changeParameterVector("temple_right","","rotation",0,56.6*-o,0,0)}catch(e){return}}(e),Bn(),On=null}e(),gA("Glasses")}},Yn.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),gA("Shoes"))},Yn.callbacks.onWristTracked=t=>{t.detected&&(e(),gA("Watches"))}}function iA(t,n,A){return e(this,void 0,void 0,(function*(){return null!=Jn&&Wn===A||(yield Jn,Jn=Yn.switchEffect(t,{envmap:n}),Wn=A),Jn}))}function rA(e,t){null!=e&&null!=t&&(Yn.setToneMapping(e),Yn.setExposure(t))}function aA(){return e(this,void 0,void 0,(function*(){if(null!=Yn){if(Kn=!1,null==Pn){const e=lA(Hn),t=gn(e);Pn=yield un(t),yield cA(Yn,Pn,"user"===e),"Glasses"===Hn&&(En(Pn),"DetectionLoop"!==_n&&IA((e=>{On=e.faceWidth})))}!function(){if(null==jn)return;if(null==Hn||$n.has(Hn))return;jn.style.visibility="visible",jn.style.opacity="1"}(),Yn.setPaused(Kn),qn.style.display=""}}))}function sA(){null!=Yn&&(Kn=!0,Yn.setPaused(Kn),Bn(),null!=Pn&&null!=Pn.srcObject&&Pn.srcObject instanceof MediaStream&&(Pn.srcObject.getTracks().forEach((e=>e.stop())),Pn=null),function(){if(null==jn)return;jn.style.visibility="hidden",jn.style.opacity="0"}(),Yn.stopCamera(),qn.style.display="none")}function lA(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function cA(t,n,A){return e(this,void 0,void 0,(function*(){yield new Promise((o=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,A),o()}))))}}))}))}function gA(e){null!=jn&&($n.has(e)||($n.add(e),jn.style.opacity="0"))}function uA(e,t,n,A,o,i,r){const a=Yn.getTransformationBetween(e,t),s=vn(Dn(),a),l=function(e,t){var n=new mn(3);Rn(n,t);var A=1/n[0],o=1/n[1],i=1/n[2],r=t[0]*A,a=t[1]*o,s=t[2]*i,l=t[4]*A,c=t[5]*o,g=t[6]*i,u=t[8]*A,d=t[9]*o,I=t[10]*i,h=r+c+I,C=0;return h>0?(C=2*Math.sqrt(h+1),e[3]=.25*C,e[0]=(g-d)/C,e[1]=(u-s)/C,e[2]=(a-l)/C):r>c&&r>I?(C=2*Math.sqrt(1+r-c-I),e[3]=(g-d)/C,e[0]=.25*C,e[1]=(a+l)/C,e[2]=(u+s)/C):c>I?(C=2*Math.sqrt(1+c-r-I),e[3]=(u-s)/C,e[0]=(a+l)/C,e[1]=.25*C,e[2]=(g+d)/C):(C=2*Math.sqrt(1+I-r-c),e[3]=(a-l)/C,e[0]=(u+s)/C,e[1]=(g+d)/C,e[2]=.25*C),e}(Fn(),a);bn(a,l,s,Sn(r,r,r));const c=Yn.getTransformationBetween(t,n),g=vn(Dn(),c);bn(c,Fn(),g,Rn(Dn(),c));const u=yn(wn(),a,c),d=vn(Dn(),u),I=Math.atan2(i[0]-d[0],Math.abs(i[2]-d[2]));let h;try{h=Yn.getTransformationBetween(n,A)}catch(e){return I}const C=yn(wn(),c,h),p=yn(wn(),a,C),f=Sn(d[0],i[1],i[2]),E=Mn(Dn(),f,function(e,t){var n=t[0],A=t[1],o=t[2],i=t[3],r=t[4],a=t[5],s=t[6],l=t[7],c=t[8],g=t[9],u=t[10],d=t[11],I=t[12],h=t[13],C=t[14],p=t[15],f=n*a-A*r,E=n*s-o*r,B=n*l-i*r,Q=A*s-o*a,m=A*l-i*a,w=o*l-i*s,y=c*h-g*I,v=c*C-u*I,R=c*p-d*I,b=g*C-u*h,D=g*p-d*h,S=u*p-d*C,U=f*S-E*D+B*b+Q*R-m*v+w*y;return U?(U=1/U,e[0]=(a*S-s*D+l*b)*U,e[1]=(o*D-A*S-i*b)*U,e[2]=(h*w-C*m+p*Q)*U,e[3]=(u*m-g*w-d*Q)*U,e[4]=(s*R-r*S-l*v)*U,e[5]=(n*S-o*R+i*v)*U,e[6]=(C*B-I*w-p*E)*U,e[7]=(c*w-u*B+d*E)*U,e[8]=(r*D-a*R+l*y)*U,e[9]=(A*R-n*D-i*y)*U,e[10]=(I*m-h*B+p*f)*U,e[11]=(g*B-c*m-d*f)*U,e[12]=(a*v-r*b-s*y)*U,e[13]=(n*b-A*v+o*y)*U,e[14]=(h*E-I*Q-C*f)*U,e[15]=(c*Q-g*E+u*f)*U,e):null}(wn(),p));let B=Yn.getClosestPointOnMesh(A,E);try{const e=Yn.getClosestPointOnMesh(o,E);Un(E,e)<Un(E,B)&&(B=e)}catch(e){}const Q=Mn(Dn(),B,C);return I-Math.atan2(Q[0]-g[0],Math.abs(Q[2]-g[2]))}function dA(e){!function(e){pn.push(e)}(e)}function IA(e){!function(e){fn.push(e)}(e)}var hA;function CA(){return[hA.Android,hA.iOS,hA.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],A=["Win32","Win64","Windows","WinCE"],o=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==o.indexOf(t)?hA.iOS:-1!==n.indexOf(t)?i?hA.Tablet:hA.MacOS:-1!==A.indexOf(t)?hA.Windows:/Android/.test(e)?hA.Android:/Linux/.test(t)?hA.Linux:i?hA.Tablet:hA.Unknown}return hA.Unknown}())}!function(e){e[e.Unknown=0]="Unknown",e[e.Android=1]="Android",e[e.iOS=2]="iOS",e[e.Tablet=3]="Tablet",e[e.MacOS=4]="MacOS",e[e.Windows=5]="Windows",e[e.Linux=6]="Linux"}(hA||(hA={}));const pA=["AR","3D"];function fA(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function EA(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}function BA(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}function QA(e){const{apiKey:n,sku:A,targetElement:o,initialState:i,initialAnimation:r,baseUrl:a,defaultUI:s,interactive:l,strings:c}=e;fA(n,"apiKey"),BA(n,"apiKey"),fA(A,"sku"),BA(A,"sku"),fA(o,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&function(e,n,A){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!A.includes(e))throw new t(`'${n}' must be ${A.join("' or '")}.`)}(i,"initialState",pA),null!=r&&function(e,n){if("string"!=typeof e&&!Array.isArray(e))throw new t(`'${n}' must be a string or array.`)}(r,"initialAnimation"),null!=a&&BA(a,"baseUrl"),null!=s&&EA(s,"defaultUI"),null!=l&&EA(l,"interactive"),null!=c&&function(e,n,A){for(const o of A){const A=e[o];if(null!=A&&"string"!=typeof A)throw new t(`Value for key '${o}' in '${n}' must be a string.`)}}(c,"strings",yt)}let mA=!1;function wA(n){return e(this,void 0,void 0,(function*(){const{targetElement:A}=n;y.update(n.baseUrl),ln();const{trackEvent:o}=function(e){const t=performance.now(),n=Vt();return{trackEvent:(A,o={})=>{o=Object.assign(Object.assign({},o),{pluginVersion:m,userAgent:an,sessionId:on,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),cn((()=>{window.ShopAR__analytics.trackEventImpl(A,o)}))}}}(n.apiKey);o("visionSetup");const i=yield function(n){return e(this,void 0,void 0,(function*(){const A=yield d((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:n,sid:c()})}`).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 A.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(n.apiKey);o("visionApiResponse",i);const{arKey:r}=i,a=$t(A),{getSetupId:s,findUI:l}=a,g=s();Vn(),Zn();const{setTargetElement:u,getDeepARTarget:I,setVisibilityParameters:h,getUIState:C,setUIState:p,startDeepARLoading:f,stopDeepARLoading:E,showCameraError:B}=l();if(C()!=Yt.None)throw Error("UI state is not None, this is weird..");p(Yt.AR),u(A),h(!1,!1,!0,!1,void 0,void 0),f(),yield Ln,yA(s(),g);try{o("visionArLaunch"),sA(),tA("Glasses",["faceInit"]),nA(I()),yield eA({licenseKey:r,truescaleUsecase:"DetectionLoop"}),yA(s(),g),yield aA(),yA(s(),g)}catch(e){const n=e instanceof Error;throw o("visionArLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),B(),sA(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{E()}return mA=!0,{registerFacePoseListener:e=>{mA&&(o("registerFacePoseListener"),dA(e))},registerFaceMeasurementListener:e=>{mA&&(o("registerFaceMeasurementListener"),IA(e))},switchEffect:t=>e(this,void 0,void 0,(function*(){mA&&(o("switchEffect",{arUrl:t}),function(e){Yn.switchEffect(e)}(t))})),clearEffect:()=>{mA&&(o("clearEffect"),Yn.clearEffect())},close:()=>{if(mA){if(mA=!1,o("visionClose"),C()!==Yt.AR)throw new t("AR not launched.");sA(),p(Yt.None)}}}}))}function yA(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}function vA(n){var A,o;return e(this,void 0,void 0,(function*(){QA(n);const{apiKey:i,sku:r,targetElement:a,initialState:s,initialAnimation:l}=n,g=null==n.zoomEnabled||n.zoomEnabled,u=!0===n.alwaysTransparentBackground;!function(e){const n=getComputedStyle(e);if(!["static","relative"].includes(n.position))throw new t(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${n.position}'.`)}(a),y.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(wt,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(wt[t]=n)}}(n.strings);const f=null!=l?be(l):null,E=null!=(null==f?void 0:f.theta)?ce(f.theta):null,w=null!=(null==f?void 0:f.phi)?ce(f.phi):null,v=null!=(null==f?void 0:f.fov)?ce(f.fov):null,R=function(n,A,o,i,r,a){return e(this,void 0,void 0,(function*(){const s=yield d((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:n,sku:A,sid:c()},null!=o&&{yaw:`${h(I(o))}`}),null!=i&&{pitch:`${h(I(i))}`}),null!=r&&{fov:`${h(I(r))}`}),a&&{forcedTransparency:`${a}`}))}`).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 s.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(i,r,null==E?void 0:E.get(),null==w?void 0:w.get(),null==v?void 0:v.get(),u),b=$t(a),{getSetupId:D,findUI:S,findQR:U,findThree:F}=b,N=D();ln();const{trackEvent:k,arInteracted:G,previewInteracted:x}=function(e,t){const n=performance.now(),A=Vt();let o=0,i=0,r=0,a=0,s=0,l=!1;window.setInterval((()=>{l&&(o=i+r,l=!1,c(nn,{engagementTotal:o,engagementAR:i,engagement3D:r}))}),1e3);const c=(o,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:an,pluginVersion:m,sessionId:on,setupId:A,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),cn((()=>{window.ShopAR__analytics.trackEventImpl(o,i)}))};return{trackEvent:c,arInteracted:()=>{const e=performance.now(),t=e-a;a=e,t<200&&(i+=t,l=!0)},previewInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(r+=t,l=!0)}}}(r,i);k("setup",{hostname:window.location.hostname});const L=yield R;k("apiResponse",L);const{category:T,arUrl:Y,arEnvUrl:P,arToneMapping:H,arToneMappingExposure:q,arKey:K,arPromptEnabled:j,arPromptText:$,arPromptImage:X,previewUrl:J,previewEnvUrl:W,previewToneMapping:O,previewToneMappingExposure:_,previewPosterUrl:z,cameraErrorText:V,qrPromptText:Z}=L;RA(D(),N);const ee=null!=Y&&function(e){return null!=e&&C.includes(e)}(T),te=null==(null===(A=n._internalOptions)||void 0===A?void 0:A.qrEnabled)||(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled),ne=ee&&function(e){return null!=e&&p.includes(e)}(T),Ae=te&&ne&&!CA(),oe=ee&&!Ae,ie=null!=J;RA(D(),N);const{setTargetElement:re,getDeepARTarget:ae,getDeepARPrompt:se,customizeDeepARPrompt:le,customizeCameraError:ge,customizeQRPrompt:ue,setVisibilityParameters:de,getUIState:Ie,setUIState:he,setDefaultUIActions:Ce,startDeepARLoading:pe,stopDeepARLoading:fe,startThreeLoading:Ee,stopThreeLoading:Be,setThreePosterUrl:Qe,showCameraError:me}=S();re(a);de(null==n.defaultUI||n.defaultUI,Ae,oe,ie,T,s),le(null!=$?$:"",null!=X?X:""),ge(V),ue(Z),Qe(z),function(e,n){const A=e.parentNode;if(null==A)throw new t("Parent node missing.");new MutationObserver((t=>{for(const A of t)for(const t of A.removedNodes)if(t===e)return void n()})).observe(A,{childList:!0})}(a,(()=>{Ie()!==Yt.QR||we()||ve(),Ie()!==Yt.AR||Kn||sA(),Ie()!==Yt.Preview||Ue()||Fe(),he(Yt.None),Ne(),function(e){jt.delete(e)}(a)}));const{qrPaused:we,qrDraw:ye,qrPause:ve}=U(),{threeInit:Re,threeParse:De,threeLoad:Se,threePaused:Ue,threeResume:Me,threePause:Fe,threeDestroy:Ne,threeSetZoomEnabled:ke,threeSetForcedTransparency:Ge,threeSetToneMapping:xe,threeIsInteractive:Le,threeSetInteractive:Te,threeSetOnInteracted:Ye,threeInitPromptAnimation:Pe,threeInitThetaAnimation:He,threeInitPhiAnimation:qe,threeInitFovAnimation:Ke,threeRenderOnce:je}=F(),$e=null==n.interactive||n.interactive;Te($e);let Xe=0;if(Ie()===Yt.QR){if(!we())if(Ae){k(Zt);try{yield ye(i,r)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else ve(),he(Yt.None)}else if(Ie()===Yt.AR){if(!Kn)if(oe&&!mA){k(en),Vn(),"Glasses"===T&&Zn();const e=null!=P?yield B(P):void 0;RA(D(),N);const t=yield B(Y);RA(D(),N),Xt(b),tA(T),nA(ae()),AA(j?se():null),yield iA(t,e,`${Y}${P}`),rA(H,q),oA(G),RA(D(),N)}else sA(),he(Yt.None)}else if(Ie()===Yt.Preview&&!Ue())if(ie){k(tn),pt(),Ee();const e=255,t=yield Q(J,(new Date).getTime()+e,Math.random()*e);RA(D(),N);const n=null!=W?W:`${y}/env/default.hdr`,A=yield B(n);RA(D(),N),yield ot,RA(D(),N),Re(),RA(D(),N);const o=n.endsWith(".hdr")?M.HDR:M.EXR,i=yield De(t,A,`${J}${W}`,o);RA(D(),N),Se(i,T),ke(g),Ge(u),xe(null!=O?O:"ACES",null!=_?_:1),Ye(x),Pe(),null!=f&&(He(E),qe(w),Ke(v)),je(),Me(),Be()}else Fe(),he(Yt.None);const Je=()=>e(this,void 0,void 0,(function*(){if(Ae)try{k(Zt);const e=++Xe;if(Ie()===Yt.Preview&&ie&&!Ue()&&Fe(),he(Yt.QR),yield ye(i,r),Xe!==e)return;return void RA(D(),N)}catch(e){const n=e instanceof Error;throw k("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}if(!oe)throw new t("Model does not have AR enabled.");try{k(en);const e=++Xe;Ie()===Yt.Preview&&ie&&!Ue()&&Fe(),Xt(b),he(Yt.AR),Vn(),"Glasses"===T&&Zn(),pe();const t=null!=P?yield B(P):void 0;RA(D(),N);const n=yield B(Y);if(Xe!==e)return;if(RA(D(),N),yield Ln,Xe!==e)return;if(RA(D(),N),sA(),tA(T),nA(ae()),AA(j?se():null),yield eA({licenseKey:K}),Xe!==e)return;if(RA(D(),N),yield iA(n,t,`${Y}${P}`),rA(H,q),oA(G),Xe!==e)return;if(RA(D(),N),yield aA(),Xe!==e)return;RA(D(),N)}catch(e){const n=e instanceof Error;throw k("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),me(),sA(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{fe()}})),We=()=>e(this,void 0,void 0,(function*(){if(!ie)throw new t("Model does not have 3D enabled.");try{k(tn);const e=++Xe;Ie()===Yt.AR&&(oe&&!Kn&&sA(),ve()),he(Yt.Preview),pt(),Ee();const t=255,n=yield Q(J,(new Date).getTime()+t,Math.random()*t);if(Xe!==e)return;RA(D(),N);const A=null!=W?W:`${y}/env/default.hdr`,o=yield B(A);if(Xe!==e)return;if(RA(D(),N),yield ot,Xe!==e)return;if(RA(D(),N),Re(),Xe!==e)return;RA(D(),N);const i=A.endsWith(".hdr")?M.HDR:M.EXR,r=yield De(n,o,`${J}${W}`,i);if(Xe!==e)return;RA(D(),N),Se(r,T),ke(g),Ge(u),xe(null!=O?O:"ACES",null!=_?_:1),Ye(x),Pe(),null!=f&&(He(E),qe(w),Ke(v)),je(),Me(),Be()}catch(e){const n=e instanceof Error;throw k("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}})),Oe=()=>e(this,void 0,void 0,(function*(){Ie()!==Yt.None&&("AR"!==s||Ie()!==Yt.AR&&Ie()!==Yt.QR)&&("3D"===s&&Ie()===Yt.Preview||(++Xe,Ie()===Yt.QR||Ie()===Yt.AR?(oe&&!Kn&&sA(),ve()):Ie()===Yt.Preview&&ie&&!Ue()&&Fe(),he(Yt.None),"AR"!==s?"3D"!==s||(yield We()):yield Je()))}));return Ce(Je,We,Oe),"AR"===s?(yield Je(),RA(D(),N)):"3D"===s&&(yield We(),RA(D(),N)),mA=!1,{launchAR:ee?Je:void 0,launch3D:ie?We:void 0,closeAR:ee?()=>e(this,void 0,void 0,(function*(){Ie()!==Yt.AR&&Ie()!==Yt.QR||"AR"!==s&&(++Xe,oe&&!Kn&&sA(),ve(),he(Yt.None),"3D"!==s||(yield We()))})):void 0,close3D:ie?()=>e(this,void 0,void 0,(function*(){Ie()===Yt.Preview&&"3D"!==s&&(++Xe,ie&&!Ue()&&Fe(),he(Yt.None),"AR"!==s||(yield Je()))})):void 0,close:ee||ie?Oe:void 0,isInteractive:()=>Le(),setInteractive:e=>Te(e)}}))}function RA(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const bA={setup:function(t){return e(this,void 0,void 0,(function*(){return wA(t)}))}},DA={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,A){return e(this,void 0,void 0,(function*(){try{return A()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>vA(n)))}))},version:m};export{pA as PREVIEW_STATES,t as PluginError,DA as plugin,bA as vision};