shopar-plugin 0.7.3 → 0.7.4-alpha.0
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 +2 -2
- package/dist/shopar-analytics.js +1 -1
- package/dist/shopar-plugin.esm.js +1 -1
- package/dist/shopar-plugin.js +1 -1
- package/package.json +1 -1
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@
|
|
35
|
+
<script src="https://cdn.jsdelivr.net/npm/shopar-plugin@{{VERSION}}/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@
|
|
156
|
+
- Default value: `https://cdn.jsdelivr.net/npm/shopar-plugin@{{VERSION}}/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.
|
package/dist/shopar-analytics.js
CHANGED
|
@@ -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
|
|
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 +1 @@
|
|
|
1
|
-
function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array],r=n.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],a=window[o[i[i[r]]]][o[i[i[i.length-1]]]],s=a.charCodeAt(r),l=s^s,c=new n[1]([l]);function u(){const e=(new TextEncoder).encode(a),t=o.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[o[t[2]]](String.fromCodePoint(...e))}const d=[1e3,2e3,4e3],h=d.length;function p(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=h)throw e;return yield new Promise((e=>setTimeout(e,d[n]))),p(t,n+1)}}))}function f(e){return e*(180/Math.PI)}function m(e){return Math.round(100*e)/100}const g=["Glasses","Shoes","Watches"],v=["Shoes"];const w={},y={};function b(n){return null==w[n]&&(w[n]=function(n){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(n).catch((e=>{throw console.error(e),new t("Resource unavailable.")}));if(!e.ok)throw new t(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield r.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}(n)),w[n]}function E(r,o,i){return null==y[r]&&(y[r]=function(r,o,i){return e(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const u=String.fromCharCode(a+14);s>>=2,a^=s+2;const d=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const f=String.fromCharCode(a-7),m=window[`${h}${d+u+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${f}`],g=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${r}`).catch((()=>{throw new t("Unknown error.")}));if(!e.ok)throw new t("Unknown error.");return e})))),v=new n[0](yield(yield g.blob().catch((()=>{throw new t("Unknown error.")}))).arrayBuffer().catch((()=>{throw new t("Unknown error.")})));i+=s;const w=v.byteLength;if(c[l]=Math.min(76,o)*((a>>5)-1),152===c[l]&&(c[l]=w),i==l)return v;i=l,i^=l;for(let e=0,t=v.length;e<t;e++)c[l]^=c[i]<<13,c[l]^=c[i]>>17,c[l]^=c[i]<<5,v[e]=v[e]^c[l];return i^=c[0],i^=c[1],i^=c[2],v}))}(r,o,i)),y[r]}const A="0.7.3";let S=`https://cdn.jsdelivr.net/npm/shopar-plugin@${A}/dist`;const M={update:e=>{null!=e&&(S=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>S};function R(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 x;const T=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.error('No <meta name="viewport"> detected. This might cause ShopAR to crash on iOS.\nPlease add the following line to your HTML:\n<meta name="viewport" content="width=device-width, initial-scale=1.0">'),()=>e?window.devicePixelRatio:1})();let C,P,I,k=!1;let L=!1;function $(e){const t=function(e){const t=new P.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,P.ClampToEdgeWrapping,P.ClampToEdgeWrapping,P.LinearFilter,P.LinearFilter,1,P.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(I.parse(e));return t.mapping=P.EquirectangularReflectionMapping,t.colorSpace=P.LinearSRGBColorSpace,t}const U=45,D=45,O=3,N=1.5,_=1,j=.5;let F,W,q,G,z,B=!1;const Q=4,V=.001,H=1e-7,K=10,X=11,Z=1/(X-1),Y="function"==typeof Float32Array;function J(e,t,n,r){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===r)return ie;const o=Y?new Float32Array(X):new Array(X);for(let t=0;t<X;++t)o[t]=re(t*Z,e,n);function i(t){let r=0,i=1;const a=X-1;for(;i!==a&&o[i]<=t;++i)r+=Z;--i;const s=r+(t-o[i])/(o[i+1]-o[i])*Z,l=oe(s,e,n);return l>=V?function(e,t,n,r){for(let o=0;o<Q;++o){const o=oe(t,n,r);if(0===o)return t;t-=(re(t,n,r)-e)/o}return t}(t,s,e,n):0===l?s:function(e,t,n,r,o){let i,a,s=0;do{a=t+(n-t)/2,i=re(a,r,o)-e,i>0?n=a:t=a}while(Math.abs(i)>H&&++s<K);return a}(t,r,r+Z,e,n)}return function(e){return 0===e||1===e?e:re(i(e),t,r)}}function ee(e,t){return 1-3*t+3*e}function te(e,t){return 3*t-6*e}function ne(e){return 3*e}function re(e,t,n){return((ee(t,n)*e+te(t,n))*e+ne(t))*e}function oe(e,t,n){return 3*ee(t,n)*e*e+2*te(t,n)*e+ne(t)}function ie(e){return e}function ae(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=J(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function se(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:ae(n)})));let r=0,o=n[0].value;return{reset:()=>{r=0},update:e=>{for(r+=e;r>=t;)r-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(r>=t.time&&r<i.time){const e=t.interpolate((r-t.time)/(i.time-t.time));o=t.value+e*(i.value-t.value)}}},get:()=>o}}const le="#",ce="time",ue="interpolation",de="yaw",he="pitch",pe="fov",fe=[ce,de,he,pe,ue],me="s",ge="ms",ve=1e3,we="deg",ye="rad",be=Math.PI/180,Ee="ease-in-out",Ae="cubic-bezier(",Se=")";function Me(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(le);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const r=function(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(!fe.includes(r))throw new Error(`Invalid token in header: '${r}'.`);if(t.includes(r))throw new Error(`Duplicate token in header: '${r}'.`);t.push(r)}if(!t.includes(ce))throw new Error(`Missing required token: '${ce}'.`);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}=Re(r,e);null!=t&&(null==o.theta&&(o.theta=[]),o.theta.push(t)),null!=n&&(null==o.phi&&(o.phi=[]),o.phi.push(n)),null!=i&&(null==o.fov&&(o.fov=[]),o.fov.push(i))}if(0===Object.values(o).length)throw new Error("At least one parameter should be animated.");return o}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const r of e){const{time:e,pitch:o,yaw:i,fov:a}=r;if(null==e)throw new Error("Time missing.");const s=Te(null!==(t=r.interpolation)&&void 0!==t?t:Ee);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*be,interpolation:s})),null!=o&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:o*be,interpolation:s})),null!=a&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:a*be,interpolation:s}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function Re(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const r=e.indexOf(ce),o=function(e){if(e.endsWith(ge))return Pe(e.substring(0,e.length-ge.length));if(e.endsWith(me))return Pe(e.substring(0,e.length-me.length))*ve;return Pe(e)}(n[r]),i=e.indexOf(ue),a=Te(-1===i?Ee:n[i]),s={};for(let t=0;t<n.length;t++){if(t===r||t===i)continue;const l=e[t],c=n[t];switch(l){case de:s.theta={time:o,value:xe(c),interpolation:a};break;case he:s.phi={time:o,value:xe(c),interpolation:a};break;case pe:s.fov={time:o,value:xe(c),interpolation:a};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return s}function xe(e){return e.endsWith(we)?Pe(e.substring(0,e.length-we.length))*be:e.endsWith(ye)?Pe(e.substring(0,e.length-ye.length)):Pe(e)*be}function Te(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Ce(0,0,1,1);if("sine"===e)return Ce(.37,0,.63,1);if("sine-in"===e)return Ce(.12,0,.39,0);if("sine-out"===e)return Ce(.61,1,.88,1);if("ease"===e)return Ce(.25,.1,.25,1);if("ease-in"===e)return Ce(.42,0,1,1);if("ease-out"===e)return Ce(0,0,.58,1);if("ease-in-out"===e)return Ce(.42,0,.58,1);if(e.startsWith(Ae)&&e.endsWith(Se)){const t=e.substring(Ae.length,e.length-Se.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:Pe(t[0]),y1:Pe(t[1]),x2:Pe(t[2]),y2:Pe(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Ce(e,t,n,r){return{type:"bezier",x1:e,y1:t,x2:n,y2:r}}function Pe(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const Ie=300,ke=2e3,Le=.05,$e=2*Math.PI/32,Ue=Te("hold"),De=Te("sine"),Oe=Te("sine-in"),Ne=Te("sine-out");const _e=2e3,je=8,Fe=2*Math.PI,We=Fe/12,qe=Fe/60,Ge=Fe/60,ze=60,Be=60,Qe=1e3,Ve=ze*Be,He=-1;function Ke(e){return se([{time:0,value:0,interpolation:{type:"bezier",x1:.9,y1:0,x2:.6,y2:1}},{time:_e,value:e,interpolation:{type:"hold"}}])}function Xe(e,t,n){return He*We*(e+t/ze+n/Ve)}function Ze(e,t){return He*qe*(e+t/Be)}function Ye(e,t){return He*Ge*(e+t/Qe)}const Je=["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 et(e){null!=e&&(e.dispose(),Je.forEach((t=>{var n;return null===(n=e[t])||void 0===n?void 0:n.dispose()})))}let tt;const nt=0,rt=3;let ot,it,at,st=!1,lt=1,ct=1,ut=1;const dt=1;let ht;const pt=new Map;function ft(t,n,r){const o=t.getContext("2d");null==o&&console.warn("2D context missing.");let i,a,s,l,c,u,d,h,p,f,m,g,v,w,y,b=!1,E=!1,A=!1,S=!0,M=!1,R=1,x=!0,T=!1,_=0,B=0,Q=1,V=1,H=1;const K={threeInit:()=>{b||(mt(),i=new it.Scene,a=new it.PerspectiveCamera(25,1,.5),s=new ot.OrbitControls(a,t),s.setInteractionEnabled(x),h=it.ACESFilmicToneMapping,({renderShadow:c,shadowGroup:l}=function(e){const t=new F.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new F.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const r=new F.Group;r.position.y=-.7;const o=new F.PlaneGeometry(U,D).rotateX(Math.PI/2),i=new F.MeshBasicMaterial({map:t.texture,opacity:j,transparent:!0,depthWrite:!1}),a=new F.Mesh(o,i);a.renderOrder=1,a.scale.y=-1,r.add(a);const s=new F.Mesh(o);s.visible=!1,r.add(s);const l=new F.OrthographicCamera(-U/2,U/2,D/2,-D/2,0,O);function c(e){s.visible=!0,G.uniforms.tDiffuse.value=t.texture,G.uniforms.h.value=1*e/256,s.material=G,W.setRenderTarget(n),W.render(s,l),z.uniforms.tDiffuse.value=n.texture,z.uniforms.v.value=1*e/256,s.material=z,W.setRenderTarget(t),W.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,r.add(l),{shadowGroup:r,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=q;const r=W.getClearAlpha();W.setClearAlpha(0),W.setRenderTarget(t),W.render(e,l),e.overrideMaterial=null,c(N),c(.4*N),W.setRenderTarget(null),W.setClearAlpha(r),e.background=n}}}(i)),b=!0)},threeParse:(t,n,r)=>e(this,void 0,void 0,(function*(){return null!=u&&d===r||(yield u,u=(()=>e(this,void 0,void 0,(function*(){var e,r,o;return r=ot,L||(P=r.THREE,I=new r.RGBELoader,L=!0),null===(e=i.environment)||void 0===e||e.dispose(),i.environment=$(n),function(e,t){if(k)return;const{THREE:n}=t;C=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder),k=!0}(ht,ot),o=t,C.parseAsync(o.buffer,"")})))(),d=r),u})),threeLoad:(e,t)=>{wt(i),i.add(e.scene);const n=(new it.Box3).setFromObject(e.scene);l.position.y=n.min.y-nt,i.add(l),c(),E=!1,i.traverse((e=>{if(e instanceof it.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(E=!0)})):t.transmission>0&&(E=!0)}}));const r=n.min.clone().add(n.max).divideScalar(2),o=Math.sqrt(ot.reduceVertices(e.scene,((e,t)=>Math.max(e,r.distanceToSquared(t))),0));s.reset(r,o,function(e,t){var n;const r={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?r.Glasses:null!==(n=r[e])&&void 0!==n?n:r.Glasses).normalize()}(t,it.Vector3)),_=0,y="Watches"===t?function(e){const t=e.getObjectByName("hours"),n=e.getObjectByName("minutes"),r=e.getObjectByName("seconds");if(null==t&&null==n&&null==r)return null;let o,i,a,s,l,c;return{start:()=>{o=new Date,o.setMilliseconds(o.getMilliseconds()+_e),l=!1;const e=o.getHours(),t=o.getMinutes(),n=o.getSeconds(),r=o.getMilliseconds();i=Ke(Xe(e,t,n)),a=Ke(Ze(t,n)),s=Ke(Ye(n,r)),c=new Date},update:()=>{if(null==o)return!1;const e=new Date;if(!l){if(o.getTime()-e.getTime()>0){const o=Math.abs(e.getTime()-c.getTime());return null!=t&&(i.update(o),t.rotation.y=i.get()),null!=n&&(a.update(o),n.rotation.y=a.get()),null!=r&&(s.update(o),r.rotation.y=s.get()),c=e,!0}l=!0}if(Math.abs(e.getTime()-c.getTime())<Qe/je)return!1;c=e;const u=e.getHours(),d=e.getMinutes(),h=e.getSeconds(),p=e.getMilliseconds();return null!=t&&(t.rotation.y=Xe(u,d,h)),null!=n&&(n.rotation.y=Ze(d,h)),null!=r&&(r.rotation.y=Ye(h,p)),!0}}}(e.scene):null},threePaused:()=>S,threeResume:()=>{S=!1,ht.setAnimationLoop(gt),t.style.visibility="visible",B=0,null==f||f.reset(),null==m||m.reset(),null==g||g.reset(),null==v||v.reset(),null==w||w.reset(),null==y||y.start()},threePause:()=>{S=!0,function(){for(const{threePaused:e}of pt.values())if(!e())return!1;return!0}()&&ht.setAnimationLoop(null),t.style.visibility="hidden",r.style.opacity="0",n.style.visibility="hidden"},threeDestroy:()=>{var e;wt(i),null===(e=i.environment)||void 0===e||e.dispose(),i.environment=null,i=null,u=null,y=null,pt.delete(t)},threeSetZoomEnabled:e=>{s.enableZoom=e},threeSetForcedTransparency:e=>{A=e},threeSetToneMapping:(e,t)=>{const n={ACES:it.ACESFilmicToneMapping,Linear:it.LinearToneMapping,Neutral:it.NeutralToneMapping};null!=n[e]&&(h=n[e]),R=t},threeIsInteractive:()=>x,threeSetInteractive:e=>{x=e,null==s||s.setInteractionEnabled(x)},threeSetOnInteracted:e=>{s.removeEventListener("change",p),p=e,s.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=s.getTheta(),f=se([{time:0,value:e,interpolation:Ue},{time:Ie,value:e,interpolation:Ne},{time:Ie+ke/4,value:e+$e,interpolation:De},{time:Ie+3*ke/4,value:e-$e,interpolation:Oe},{time:Ie+ke,value:e,interpolation:Ue},{time:Ie+2*ke,value:e,interpolation:Ue}]),s.setTheta(f.get()),m=null,g=null,v=se([{time:0,value:0,interpolation:Ue},{time:Ie,value:1,interpolation:Ue},{time:Ie+ke,value:0,interpolation:Ue},{time:Ie+2*ke,value:0,interpolation:Ue}]),w=se([{time:0,value:0,interpolation:Ue},{time:Ie,value:0,interpolation:Ne},{time:Ie+ke/4,value:-Le,interpolation:De},{time:Ie+3*ke/4,value:Le,interpolation:Oe},{time:Ie+ke,value:0,interpolation:Ue},{time:Ie+2*ke,value:0,interpolation:Ue}])},threeInitThetaAnimation:e=>{f=e,null!=e&&s.setTheta(e.get())},threeInitPhiAnimation:e=>{m=e,null!=e&&s.setPhi(e.get())},threeInitFovAnimation:e=>{g=e,null!=e&&s.setFovRadians(e.get())},threeRenderOnce:()=>{K.render_()},preRender_:e=>{if(!b||S||!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!==B?e-B:0;B=e,0===_?M=!0:_<rt&&(n=0),_++,T||(s.hasUserInteracted()?(T=!0,f=null,m=null,g=null,v=null,w=null):(null==f||f.update(n),null==m||m.update(n),null==g||g.update(n),null==v||v.update(n),null==w||w.update(n),null!=f&&(s.setTheta(f.get()),M=!0),null!=m&&(s.setPhi(m.get()),M=!0),null!=g&&(s.setFovRadians(g.get()),M=!0))),s.update()&&(M=!0),(null==y?void 0:y.update())&&(M=!0)},shouldRender_:()=>!(!b||S)&&M,render_:()=>{const e=ht.toneMapping,s=ht.toneMappingExposure;ht.toneMapping=h,ht.toneMappingExposure=R,ht.setViewport(0,0,t.width,t.height),ht.setClearColor(new it.Color(16777215),E&&!A?1:0),ht.render(i,a),ht.toneMapping=e,ht.toneMappingExposure=s,M=!1,null!=o&&(o.clearRect(0,0,t.width,t.height),at.width>0&&at.height>0&&o.drawImage(at,0,ct-t.height,t.width,t.height,0,0,t.width,t.height),n.style.visibility=x&&!T?"visible":"hidden",null!=v&&(r.style.opacity=`${v.get()}`),null!=w&&(r.style.transform=`translateX(${w.get()*Math.min(Q,V)}px)`))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===Q&&n===V&&ut===H||(t.width=Math.ceil(e*ut*dt),t.height=Math.ceil(n*ut*dt),Q=e,V=n,H=ut,M=!0)},target_:t};return pt.set(t,K),K}function mt(){if(st)return;ot=window.ShopAR__THREE,it=ot.THREE,at=document.createElement("canvas");var e,t;at.style.position="block",ht=new it.WebGLRenderer({powerPreference:"high-performance",canvas:at,antialias:!0,alpha:!0}),ht.outputColorSpace=it.SRGBColorSpace,ht.toneMapping=it.ACESFilmicToneMapping,ht.setClearColor(new it.Color(16777215),0),e=ht,t=ot,B||(F=t.THREE,W=e,q=new F.MeshDepthMaterial,q.userData.darkness={value:_},q.onBeforeCompile=e=>{e.uniforms.darkness=q.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}`},q.depthTest=!1,q.depthWrite=!1,G=new F.ShaderMaterial(t.HorizontalBlurShader),G.depthTest=!1,z=new F.ShaderMaterial(t.VerticalBlurShader),z.depthTest=!1,B=!0),vt(),st=!0}function gt(e){vt(),ht.clear();for(const{preRender_:t,shouldRender_:n,render_:r}of pt.values())t(e),n()&&r()}function vt(){let e=0,t=0;for(const{target_:n}of pt.values()){const{clientWidth:r,clientHeight:o}=n;e=Math.max(e,r),t=Math.max(t,o)}const n=T();e=Math.ceil(e*n*dt),t=Math.ceil(t*n*dt),e===lt&&t===ct&&n===ut||(lt=e,ct=t,ut=n,ht.setSize(lt,ct,!1));for(const{updateSize_:e}of pt.values())e()}function wt(e){e.traverse((e=>{var t;e instanceof it.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach(et):et(e.material))})),e.clear()}const yt={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},bt=Object.keys(yt);function Et(e){return yt[e]}const At="shopar-error";function St(e,t,n,r){const o=document.createElement("button");o.id=e,o.type="button",o.className="shopar-btn",o.appendChild(r);{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 Mt="shopar-control";const Rt="shopar-deepar-output";function xt(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 Tt(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function Ct(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 Pt(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 It="shopar-main";const kt="shopar-qr-output";function Lt(e){var t,n;const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("width",null!==(t=e.getAttribute("width"))&&void 0!==t?t:"1rem"),r.setAttribute("height",null!==(n=e.getAttribute("height"))&&void 0!==n?n:"1rem"),r.appendChild(e),r}function $t(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 Ut="shopar-three-output";var Dt;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(Dt||(Dt={}));let Ot=!1;function Nt(){Ot||(!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.")}}(),Ot=!0)}function _t(){Nt();const e=function(){const e=document.createElement("div");e.id=It;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),r=function(e,t){const n=document.createElement("div");n.id=kt;const r=n.style;r.position="absolute",r.top="0",r.left="0",r.width="100%",r.height="100%",r.display="none",r.pointerEvents="auto",r.userSelect="none";const o=document.createElement("div");o.className="shopar-qr";const i=o.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(o),o.appendChild(e);const a=document.createElement("div");return a.appendChild(t),o.appendChild(a),n}(t,n);e.appendChild(r);const o=function(){const e=document.createElement("div");e.id=Rt;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=Ut,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const a=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),s=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),l=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:r}=n;return r.position="absolute",r.width="100%",r.height="100%",r.opacity="0",n.appendChild(e),n.appendChild(t),n}(a,s);e.appendChild(l);const c=function(){const e=Lt($t("2rem",`${M}/img/prompt/3d-interaction.svg`)),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),u=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",t.appendChild(e),t}(c);e.appendChild(u);const d=xt("shopar-ar-loading-container"),h=Tt("shopar-ar-loading-text",Et("loading.ar"));d.appendChild(h);const p=Ct("shopar-ar-loading-bar-bg"),f=Pt("shopar-ar-loading-bar-fg");p.appendChild(f),d.appendChild(p),e.appendChild(d);const m=xt("shopar-3d-loading-container"),g=Tt("shopar-3d-loading-text",Et("loading.3d"));m.appendChild(g);const v=Ct("shopar-3d-loading-bar-bg"),w=Pt("shopar-3d-loading-bar-fg");v.appendChild(w),m.appendChild(v),e.appendChild(m);const y=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",t.backgroundSize="contain",t.backgroundRepeat="no-repeat",t.backgroundPosition="center",e}();e.appendChild(y);const b=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),E=function(e){const t=document.createElement("div");t.id=At;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const r=document.createElement("div"),o=r.style;return o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",t.appendChild(r),r.appendChild(e),t}(b);e.appendChild(E);const A=function(){const e=document.createElement("div");return e.id=Mt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(A);const S=$t("1.75rem"),R=St("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on",Lt(S));A.appendChild(R);const x=$t("1.75rem"),T=St("shopar-btn-3d","3D","Launch ShopAR 3D preview",Lt(x));A.appendChild(T);const C=$t("1.75rem"),P=St("shopar-btn-close","Close","Close ShopAR view",Lt(C));A.append(P);let I,k,L=Dt.None,$=!1,U=!1,D=!1,O=!1;function N(){f.classList.remove("active"),d.style.visibility="hidden"}function _(){y.style.visibility="hidden",w.classList.remove("active"),m.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return r},getQRImage:function(){return n},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return l},getThreeTarget:function(){return i},getThreePrompt:function(){return u},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){a.textContent=e,s.src=t},customizeCameraError:function(e){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,r,o,i){var a;$=e,U=t,D=n,O=r,I=o,k=i,jt(A,$),jt(R,$&&(D||U)&&L===Dt.None),jt(T,$&&O&&L===Dt.None),jt(P,$&&L!==Dt.None),N(),_(),$||""===(a=E).style.display&&jt(a,!1)},getUIState:function(){return L},setUIState:function(e){L=e,L===Dt.None?(N(),_(),$&&(jt(E,!1),jt(P,!1),(U||D)&&jt(R,!0),O&&jt(T,!0))):L===Dt.QR||L===Dt.AR?$&&(jt(E,!1),jt(R,!1),jt(T,O&&"AR"===k),jt(P,"AR"!==k)):L===Dt.Preview&&$&&(jt(E,!1),jt(R,(U||D)&&"3D"===k),jt(T,!1),jt(P,"3D"!==k))},setDefaultUIActions:function(e,t,n){$&&((U||D)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,r=`${M}/img/icons/${n}`;S.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r)}(I),R.onclick=e),O&&(x.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${M}/img/icons/cube.svg`),T.onclick=t),C.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${M}/img/icons/close.svg`),P.onclick=n)},startDeepARLoading:function(){f.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:N,startThreeLoading:function(){null!=y.dataset.bgSet?y.style.visibility="visible":(w.classList.add("active"),m.style.visibility="visible")},stopThreeLoading:_,setThreePosterUrl:function(e){null!=e?(y.style.backgroundImage=`url(${e})`,y.dataset.bgSet="true"):delete y.dataset.bgSet},showCameraError:function(){$&&jt(E,!0)}}}function jt(e,t){e.style.display=t?"":"none"}const Ft=new Map;function Wt(t){let n=Ft.get(t);return null==n?(n=function(){let t=0,n=null,r=null,o=null;const i=()=>(null==n&&(n=_t()),n);return{getSetupId:()=>t,incrementSetupId_:()=>t++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==r){const{getQRTarget:t,getQRImage:n}=i();r=function(t,n){let r=!0;return{qrPaused:()=>r,qrDraw:(o,i)=>e(this,void 0,void 0,(function*(){yield x;const e=`https://ar.shopar.ai/${A.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:o,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(e),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,r=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){r=!0,t.style.display="none"}))}}(t(),n())}return r},findThree:()=>{if(null==o){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();o=ft(e(),t(),n())}return o}}}(),Ft.set(t,n)):n.incrementSetupId_(),n}function qt(e){for(const t of Ft.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:r,setUIState:o}=n;r()===Dt.AR&&o(Dt.None)}}let Gt;const zt=new Uint8Array(16);function Bt(){if(!Gt&&(Gt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Gt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Gt(zt)}const Qt=[];for(let e=0;e<256;++e)Qt.push((e+256).toString(16).slice(1));var Vt={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ht(e,t,n){if(Vt.randomUUID&&!t&&!e)return Vt.randomUUID();const r=(e=e||{}).random||(e.rng||Bt)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return Qt[e[t+0]]+Qt[e[t+1]]+Qt[e[t+2]]+Qt[e[t+3]]+"-"+Qt[e[t+4]]+Qt[e[t+5]]+"-"+Qt[e[t+6]]+Qt[e[t+7]]+"-"+Qt[e[t+8]]+Qt[e[t+9]]+"-"+Qt[e[t+10]]+Qt[e[t+11]]+Qt[e[t+12]]+Qt[e[t+13]]+Qt[e[t+14]]+Qt[e[t+15]]}(r)}const Kt="qrLaunch",Xt="arLaunch",Zt="previewLaunch",Yt="heartbeat";let Jt,en,tn=!1,nn=window.navigator.userAgent||"no user agent";const rn=[];function on(){null==Jt&&(en=Ht(),Jt=R(`${M}/shopar-analytics.js`),Jt.then((()=>{tn=!0,window.ShopAR__analytics.initializeImpl(),rn.forEach((e=>e()))})))}function an(e){tn?e():rn.push(e)}function sn(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function ln(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 cn=200,un=10;let dn=!1,hn=null,pn=[],fn=[];function mn(t){return e(this,void 0,void 0,(function*(){dn=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${M}/wasm/mediapipe`,t),hn&&clearInterval(hn);const r=[],o=[];hn=setInterval((()=>e(this,void 0,void 0,(function*(){if(dn)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());dn||(null!=a&&null!=s&&function(e){for(let t of pn)t(e)}({translation:a,rotation:s}),null==e&&(r.push(t),o.push(i),r.length<un||(r.shift(),o.shift(),function(e,t){for(let n of fn)n({faceWidth:e,IPD:t})}(vn(r),vn(o)))))}))),cn)}))}function gn(){fn=[],pn=[],dn=!0}function vn(e){let t=0;const n=e.length;for(let r=0;r<n;r++)t+=e[r];return t/n}var wn="undefined"!=typeof Float32Array?Float32Array:Array;function yn(){var e=new wn(16);return wn!=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 bn(e,t,n){var r=t[0],o=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],E=n[2],A=n[3];return e[0]=y*r+b*s+E*d+A*m,e[1]=y*o+b*l+E*h+A*g,e[2]=y*i+b*c+E*p+A*v,e[3]=y*a+b*u+E*f+A*w,y=n[4],b=n[5],E=n[6],A=n[7],e[4]=y*r+b*s+E*d+A*m,e[5]=y*o+b*l+E*h+A*g,e[6]=y*i+b*c+E*p+A*v,e[7]=y*a+b*u+E*f+A*w,y=n[8],b=n[9],E=n[10],A=n[11],e[8]=y*r+b*s+E*d+A*m,e[9]=y*o+b*l+E*h+A*g,e[10]=y*i+b*c+E*p+A*v,e[11]=y*a+b*u+E*f+A*w,y=n[12],b=n[13],E=n[14],A=n[15],e[12]=y*r+b*s+E*d+A*m,e[13]=y*o+b*l+E*h+A*g,e[14]=y*i+b*c+E*p+A*v,e[15]=y*a+b*u+E*f+A*w,e}function En(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function An(e,t){var n=t[0],r=t[1],o=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.hypot(n,r,o),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,u),e}function Sn(e,t,n,r){var o=t[0],i=t[1],a=t[2],s=t[3],l=o+o,c=i+i,u=a+a,d=o*l,h=o*c,p=o*u,f=i*c,m=i*u,g=a*u,v=s*l,w=s*c,y=s*u,b=r[0],E=r[1],A=r[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*E,e[5]=(1-(d+g))*E,e[6]=(m+v)*E,e[7]=0,e[8]=(p+w)*A,e[9]=(m-v)*A,e[10]=(1-(d+f))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Mn(){var e=new wn(3);return wn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Rn(e,t,n){var r=new wn(3);return r[0]=e,r[1]=t,r[2]=n,r}function xn(e,t){var n=t[0]-e[0],r=t[1]-e[1],o=t[2]-e[2];return Math.hypot(n,r,o)}function Tn(e,t,n){var r=t[0],o=t[1],i=t[2],a=n[3]*r+n[7]*o+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*o+n[8]*i+n[12])/a,e[1]=(n[1]*r+n[5]*o+n[9]*i+n[13])/a,e[2]=(n[2]*r+n[6]*o+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Cn(){var e=new wn(4);return wn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Mn(),function(){var e,t=(e=new wn(4),wn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var Pn;let In,kn,Ln;Mn(),Rn(1,0,0),Rn(0,1,0),Cn(),Cn(),Pn=new wn(9),wn!=Float32Array&&(Pn[1]=0,Pn[2]=0,Pn[3]=0,Pn[5]=0,Pn[6]=0,Pn[7]=0),Pn[0]=1,Pn[4]=1,Pn[8]=1;let $n,Un,Dn,On,Nn=!0,_n=null;const jn=new Set;let Fn,Wn,qn,Gn,zn,Bn;function Qn(){null==In&&(In=R(`${M}/shopar-deepar.js`))}function Vn(){null==kn&&(kn=R(`${M}/shopar-true-scale.js`))}function Hn(n){return e(this,void 0,void 0,(function*(){const{licenseKey:r,truescaleUsecase:o}=n;return zn=o,null==Fn&&(Fn=(()=>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=rr(Dn),o=sn(n);$n=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:r||"your_license_key_goes_here",previewElement:On,additionalOptions:{hint:Bn,cameraConfig:{disableDefaultCamera:!0}}}),Un=yield ln(o),yield or($n,Un,"user"===n),"Glasses"===Dn&&(yield kn,mn(Un),"DetectionLoop"!==zn&&lr((e=>{Gn=e.faceWidth})))})))()),Fn}))}function Kn(e,t){var n,r;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===Dn&&(n=t,r=Bn,n===r||null!=n&&null!=r&&n.length===r.length&&n.every((e=>r.find((t=>e===t))))&&r.every((e=>n.find((t=>t===e))))))||(null!=$n&&($n.shutdown(),$n=null,Fn=null),Dn=e,Bn=t)}function Xn(e){e!==On&&(On=e,null!=$n&&$n.changePreviewElement(On))}function Zn(e){_n=e}function Yn(e){$n.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(Gn){const e=137/(Gn+5);$n.changeParameterVector("GLASSES","","scale",e,e,e,0),$n.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const r=ar("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),o=ar("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);$n.changeParameterVector("temple_left","","rotation",0,56.6*-r,0,0),$n.changeParameterVector("temple_right","","rotation",0,56.6*-o,0,0)}catch(e){return}}(e),gn(),Gn=null}e(),ir("Glasses")}},$n.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),ir("Shoes"))},$n.callbacks.onWristTracked=t=>{t.detected&&(e(),ir("Watches"))}}function Jn(t,n,r){return e(this,void 0,void 0,(function*(){return null!=Wn&&qn===r||(yield Wn,Wn=$n.switchEffect(t,{envmap:n}),qn=r),Wn}))}function er(e,t){null!=e&&null!=t&&($n.setToneMapping(e),$n.setExposure(t))}function tr(){return e(this,void 0,void 0,(function*(){if(null!=$n){if(Nn=!1,null==Un){const e=rr(Dn),t=sn(e);Un=yield ln(t),yield or($n,Un,"user"===e),"Glasses"===Dn&&(mn(Un),"DetectionLoop"!==zn&&lr((e=>{Gn=e.faceWidth})))}!function(){if(null==_n)return;if(null==Dn||jn.has(Dn))return;_n.style.visibility="visible",_n.style.opacity="1"}(),$n.setPaused(Nn),On.style.display=""}}))}function nr(){null!=$n&&(Nn=!0,$n.setPaused(Nn),gn(),null!=Un&&null!=Un.srcObject&&Un.srcObject instanceof MediaStream&&(Un.srcObject.getTracks().forEach((e=>e.stop())),Un=null),function(){if(null==_n)return;_n.style.visibility="hidden",_n.style.opacity="0"}(),$n.stopCamera(),On.style.display="none")}function rr(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function or(t,n,r){return e(this,void 0,void 0,(function*(){yield new Promise((o=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,r),o()}))))}}))}))}function ir(e){null!=_n&&(jn.has(e)||(jn.add(e),_n.style.opacity="0"))}function ar(e,t,n,r,o,i,a){const s=$n.getTransformationBetween(e,t),l=En(Mn(),s),c=function(e,t){var n=new wn(3);An(n,t);var r=1/n[0],o=1/n[1],i=1/n[2],a=t[0]*r,s=t[1]*o,l=t[2]*i,c=t[4]*r,u=t[5]*o,d=t[6]*i,h=t[8]*r,p=t[9]*o,f=t[10]*i,m=a+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>u&&a>f?(g=2*Math.sqrt(1+a-u-f),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):u>f?(g=2*Math.sqrt(1+u-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+f-a-u),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(d+p)/g,e[2]=.25*g),e}(Cn(),s);Sn(s,c,l,Rn(a,a,a));const u=$n.getTransformationBetween(t,n),d=En(Mn(),u);Sn(u,Cn(),d,An(Mn(),u));const h=bn(yn(),s,u),p=En(Mn(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=$n.getTransformationBetween(n,r)}catch(e){return f}const g=bn(yn(),u,m),v=bn(yn(),s,g),w=Rn(p[0],i[1],i[2]),y=Tn(Mn(),w,function(e,t){var n=t[0],r=t[1],o=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-r*a,y=n*l-o*a,b=n*c-i*a,E=r*l-o*s,A=r*c-i*s,S=o*c-i*l,M=u*m-d*f,R=u*g-h*f,x=u*v-p*f,T=d*g-h*m,C=d*v-p*m,P=h*v-p*g,I=w*P-y*C+b*T+E*x-A*R+S*M;return I?(I=1/I,e[0]=(s*P-l*C+c*T)*I,e[1]=(o*C-r*P-i*T)*I,e[2]=(m*S-g*A+v*E)*I,e[3]=(h*A-d*S-p*E)*I,e[4]=(l*x-a*P-c*R)*I,e[5]=(n*P-o*x+i*R)*I,e[6]=(g*b-f*S-v*y)*I,e[7]=(u*S-h*b+p*y)*I,e[8]=(a*C-s*x+c*M)*I,e[9]=(r*x-n*C-i*M)*I,e[10]=(f*A-m*b+v*w)*I,e[11]=(d*b-u*A-p*w)*I,e[12]=(s*R-a*T-l*M)*I,e[13]=(n*T-r*R+o*M)*I,e[14]=(m*y-f*E-g*w)*I,e[15]=(u*E-d*y+h*w)*I,e):null}(yn(),v));let b=$n.getClosestPointOnMesh(r,y);try{const e=$n.getClosestPointOnMesh(o,y);xn(y,e)<xn(y,b)&&(b=e)}catch(e){}const E=Tn(Mn(),b,g);return f-Math.atan2(E[0]-d[0],Math.abs(E[2]-d[2]))}function sr(e){!function(e){pn.push(e)}(e)}function lr(e){!function(e){fn.push(e)}(e)}var cr;function ur(){return[cr.Android,cr.iOS,cr.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],r=["Win32","Win64","Windows","WinCE"],o=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==o.indexOf(t)?cr.iOS:-1!==n.indexOf(t)?i?cr.Tablet:cr.MacOS:-1!==r.indexOf(t)?cr.Windows:/Android/.test(e)?cr.Android:/Linux/.test(t)?cr.Linux:i?cr.Tablet:cr.Unknown}return cr.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"}(cr||(cr={}));const dr=["AR","3D"];function hr(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function pr(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}function fr(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}function mr(e){const{apiKey:n,sku:r,targetElement:o,initialState:i,initialAnimation:a,baseUrl:s,defaultUI:l,interactive:c,strings:u}=e;hr(n,"apiKey"),fr(n,"apiKey"),hr(r,"sku"),fr(r,"sku"),hr(o,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&function(e,n,r){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!r.includes(e))throw new t(`'${n}' must be ${r.join("' or '")}.`)}(i,"initialState",dr),null!=a&&function(e,n){if("string"!=typeof e&&!Array.isArray(e))throw new t(`'${n}' must be a string or array.`)}(a,"initialAnimation"),null!=s&&fr(s,"baseUrl"),null!=l&&pr(l,"defaultUI"),null!=c&&pr(c,"interactive"),null!=u&&function(e,n,r){for(const o of r){const r=e[o];if(null!=r&&"string"!=typeof r)throw new t(`Value for key '${o}' in '${n}' must be a string.`)}}(u,"strings",bt)}let gr=!1;function vr(n){return e(this,void 0,void 0,(function*(){const{targetElement:r}=n;M.update(n.baseUrl),on();const{trackEvent:o}=function(e){const t=performance.now(),n=Ht();return{trackEvent:(r,o={})=>{o=Object.assign(Object.assign({},o),{pluginVersion:A,userAgent:nn,sessionId:en,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),an((()=>{window.ShopAR__analytics.trackEventImpl(r,o)}))}}}(n.apiKey);o("visionSetup");const i=yield function(n){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:n,sid:u()})}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield r.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(n.apiKey);o("visionApiResponse",i);const{arKey:a}=i,s=Wt(r),{getSetupId:l,findUI:c}=s,d=l();Qn(),Vn();const{setTargetElement:h,getDeepARTarget:f,setVisibilityParameters:m,getUIState:g,setUIState:v,startDeepARLoading:w,stopDeepARLoading:y,showCameraError:b}=c();if(g()!=Dt.None)throw Error("UI state is not None, this is weird..");v(Dt.AR),h(r),m(!1,!1,!0,!1,void 0,void 0),w(),yield In,wr(l(),d);try{o("visionArLaunch"),nr(),Kn("Glasses",["faceInit"]),Xn(f()),yield Hn({licenseKey:a,truescaleUsecase:"DetectionLoop"}),wr(l(),d),yield tr(),wr(l(),d)}catch(e){const n=e instanceof Error;throw o("visionArLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),b(),nr(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{y()}return gr=!0,{registerFacePoseListener:e=>{gr&&(o("registerFacePoseListener"),sr(e))},registerFaceMeasurementListener:e=>{gr&&(o("registerFaceMeasurementListener"),lr(e))},switchEffect:t=>e(this,void 0,void 0,(function*(){gr&&(o("switchEffect",{arUrl:t}),function(e){$n.switchEffect(e)}(t))})),clearEffect:()=>{gr&&(o("clearEffect"),$n.clearEffect())},close:()=>{if(gr){if(gr=!1,o("visionClose"),g()!==Dt.AR)throw new t("AR not launched.");nr(),v(Dt.None)}}}}))}function wr(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}function yr(n){var r,o;return e(this,void 0,void 0,(function*(){mr(n);const{apiKey:i,sku:a,targetElement:s,initialState:l,initialAnimation:c}=n,d=null==n.zoomEnabled||n.zoomEnabled,h=!0===n.alwaysTransparentBackground;!function(e){const n=getComputedStyle(e);if(!["static","relative"].includes(n.position))throw new t(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${n.position}'.`)}(s),M.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(yt,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(yt[t]=n)}}(n.strings);const w=null!=c?Me(c):null,y=null!=(null==w?void 0:w.theta)?se(w.theta):null,S=null!=(null==w?void 0:w.phi)?se(w.phi):null,T=null!=(null==w?void 0:w.fov)?se(w.fov):null,C=function(n,r,o,i,a,s){return e(this,void 0,void 0,(function*(){const l=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:n,sku:r,sid:u()},null!=o&&{yaw:`${m(f(o))}`}),null!=i&&{pitch:`${m(f(i))}`}),null!=a&&{fov:`${m(f(a))}`}),s&&{forcedTransparency:`${s}`}))}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield l.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(i,a,null==y?void 0:y.get(),null==S?void 0:S.get(),null==T?void 0:T.get(),h),P=Wt(s),{getSetupId:I,findUI:k,findQR:L,findThree:$}=P,U=I();on();const{trackEvent:D,arInteracted:O,previewInteracted:N}=function(e,t){const n=performance.now(),r=Ht();let o=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(o=i+a,c=!1,u(Yt,{engagementTotal:o,engagementAR:i,engagement3D:a}))}),1e3);const u=(o,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:nn,pluginVersion:A,sessionId:en,setupId:r,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),an((()=>{window.ShopAR__analytics.trackEventImpl(o,i)}))};return{trackEvent:u,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}(a,i);D("setup",{hostname:window.location.hostname});const _=yield C;D("apiResponse",_);const{category:j,arUrl:F,arEnvUrl:W,arToneMapping:q,arToneMappingExposure:G,arKey:z,arPromptEnabled:B,arPromptText:Q,arPromptImage:V,previewUrl:H,previewEnvUrl:K,previewToneMapping:X,previewToneMappingExposure:Z,previewPosterUrl:Y,cameraErrorText:J,qrPromptText:ee}=_;br(I(),U);const te=null!=F&&function(e){return null!=e&&g.includes(e)}(j),ne=null==(null===(r=n._internalOptions)||void 0===r?void 0:r.qrEnabled)||(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled),re=te&&function(e){return null!=e&&v.includes(e)}(j),oe=ne&&re&&!ur(),ie=te&&!oe,ae=null!=H;br(I(),U);const{setTargetElement:le,getDeepARTarget:ce,getDeepARPrompt:ue,customizeDeepARPrompt:de,customizeCameraError:he,customizeQRPrompt:pe,setVisibilityParameters:fe,getUIState:me,setUIState:ge,setDefaultUIActions:ve,startDeepARLoading:we,stopDeepARLoading:ye,startThreeLoading:be,stopThreeLoading:Ee,setThreePosterUrl:Ae,showCameraError:Se}=k();le(s);if(fe(null==n.defaultUI||n.defaultUI,oe,ie,ae,j,l),de(null!=Q?Q:"",null!=V?V:""),he(J),pe(ee),Ae(Y),oe&&function(){e(this,void 0,void 0,(function*(){null==x&&(x=R(`${M}/shopar-qr.js`))}))}(),ie&&(Qn(),function(e){e!==Ln&&(Ln=e,b(e),Wn=null,gn())}(F),"Glasses"===j&&Vn(),null!=W&&b(W)),ae){null==tt&&(tt=R(`${M}/shopar-three.js`));const e=255;E(H,(new Date).getTime()+e,Math.random()*e),b(null!=K?K:`${M}/env/default.hdr`)}!function(e,n){const r=e.parentNode;if(null==r)throw new t("Parent node missing.");new MutationObserver((t=>{for(const r of t)for(const t of r.removedNodes)if(t===e)return void n()})).observe(r,{childList:!0})}(s,(()=>{me()!==Dt.QR||Re()||Te(),me()!==Dt.AR||Nn||nr(),me()!==Dt.Preview||ke()||$e(),ge(Dt.None),Ue(),function(e){Ft.delete(e)}(s)}));const{qrPaused:Re,qrDraw:xe,qrPause:Te}=L(),{threeInit:Ce,threeParse:Pe,threeLoad:Ie,threePaused:ke,threeResume:Le,threePause:$e,threeDestroy:Ue,threeSetZoomEnabled:De,threeSetForcedTransparency:Oe,threeSetToneMapping:Ne,threeIsInteractive:_e,threeSetInteractive:je,threeSetOnInteracted:Fe,threeInitPromptAnimation:We,threeInitThetaAnimation:qe,threeInitPhiAnimation:Ge,threeInitFovAnimation:ze,threeRenderOnce:Be}=$(),Qe=null==n.interactive||n.interactive;je(Qe);let Ve=0;if(me()===Dt.QR){if(!Re())if(oe){D(Kt);try{yield xe(i,a)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else Te(),ge(Dt.None)}else if(me()===Dt.AR){if(!Nn)if(ie&&!gr){D(Xt);const e=null!=W?yield b(W):void 0;br(I(),U);const t=yield b(F);br(I(),U),qt(P),Kn(j),Xn(ce()),Zn(B?ue():null),yield Jn(t,e,`${F}${W}`),er(q,G),Yn(O),br(I(),U)}else nr(),ge(Dt.None)}else if(me()===Dt.Preview&&!ke())if(ae){D(Zt),be();const e=255,t=yield E(H,(new Date).getTime()+e,Math.random()*e);br(I(),U);const n=yield b(null!=K?K:`${M}/env/default.hdr`);br(I(),U);const r=yield Pe(t,n,`${H}${K}`);br(I(),U),Ie(r,j),De(d),Oe(h),Ne(null!=X?X:"ACES",null!=Z?Z:1),Fe(N),We(),null!=w&&(qe(y),Ge(S),ze(T)),Be(),Le(),Ee()}else $e(),ge(Dt.None);const He=()=>e(this,void 0,void 0,(function*(){if(oe)try{D(Kt);const e=++Ve;if(me()===Dt.Preview&&ae&&!ke()&&$e(),ge(Dt.QR),yield xe(i,a),Ve!==e)return;return void br(I(),U)}catch(e){const n=e instanceof Error;throw D("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}if(!ie)throw new t("Model does not have AR enabled.");try{D(Xt);const e=++Ve;me()===Dt.Preview&&ae&&!ke()&&$e(),qt(P),ge(Dt.AR),we();const t=null!=W?yield b(W):void 0;br(I(),U);const n=yield b(F);if(Ve!==e)return;if(br(I(),U),yield In,Ve!==e)return;if(br(I(),U),nr(),Kn(j),Xn(ce()),Zn(B?ue():null),yield Hn({licenseKey:z}),Ve!==e)return;if(br(I(),U),yield Jn(n,t,`${F}${W}`),er(q,G),Yn(O),Ve!==e)return;if(br(I(),U),yield tr(),Ve!==e)return;br(I(),U)}catch(e){const n=e instanceof Error;throw D("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),Se(),nr(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{ye()}})),Ke=()=>e(this,void 0,void 0,(function*(){if(!ae)throw new t("Model does not have 3D enabled.");try{D(Zt);const e=++Ve;me()===Dt.AR&&(ie&&!Nn&&nr(),Te()),ge(Dt.Preview),be();const t=255,n=yield E(H,(new Date).getTime()+t,Math.random()*t);if(Ve!==e)return;br(I(),U);const r=yield b(null!=K?K:`${M}/env/default.hdr`);if(Ve!==e)return;if(br(I(),U),yield tt,Ve!==e)return;if(br(I(),U),Ce(),Ve!==e)return;br(I(),U);const o=yield Pe(n,r,`${H}${K}`);if(Ve!==e)return;br(I(),U),Ie(o,j),De(d),Oe(h),Ne(null!=X?X:"ACES",null!=Z?Z:1),Fe(N),We(),null!=w&&(qe(y),Ge(S),ze(T)),Be(),Le(),Ee()}catch(e){const n=e instanceof Error;throw D("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}})),Xe=()=>e(this,void 0,void 0,(function*(){me()!==Dt.None&&("AR"!==l||me()!==Dt.AR&&me()!==Dt.QR)&&("3D"===l&&me()===Dt.Preview||(++Ve,me()===Dt.QR||me()===Dt.AR?(ie&&!Nn&&nr(),Te()):me()===Dt.Preview&&ae&&!ke()&&$e(),ge(Dt.None),"AR"!==l?"3D"!==l||(yield Ke()):yield He()))}));return ve(He,Ke,Xe),"AR"===l?(yield He(),br(I(),U)):"3D"===l&&(yield Ke(),br(I(),U)),gr=!1,{launchAR:te?He:void 0,launch3D:ae?Ke:void 0,closeAR:te?()=>e(this,void 0,void 0,(function*(){me()!==Dt.AR&&me()!==Dt.QR||"AR"!==l&&(++Ve,ie&&!Nn&&nr(),Te(),ge(Dt.None),"3D"!==l||(yield Ke()))})):void 0,close3D:ae?()=>e(this,void 0,void 0,(function*(){me()===Dt.Preview&&"3D"!==l&&(++Ve,ae&&!ke()&&$e(),ge(Dt.None),"AR"!==l||(yield He()))})):void 0,close:te||ae?Xe:void 0,isInteractive:()=>_e(),setInteractive:e=>je(e)}}))}function br(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const Er={setup:function(t){return e(this,void 0,void 0,(function*(){return vr(t)}))}},Ar={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,r){return e(this,void 0,void 0,(function*(){try{return r()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>yr(n)))}))},version:A};export{dr as PREVIEW_STATES,t as PluginError,Ar as plugin,Er as vision};
|
|
1
|
+
function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array],r=n.length-2,o=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],a=window[o[i[i[r]]]][o[i[i[i.length-1]]]],s=a.charCodeAt(r),l=s^s,c=new n[1]([l]);function u(){const e=(new TextEncoder).encode(a),t=o.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[o[t[2]]](String.fromCodePoint(...e))}const d=[1e3,2e3,4e3],h=d.length;function p(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=h)throw e;return yield new Promise((e=>setTimeout(e,d[n]))),p(t,n+1)}}))}function f(e){return e*(180/Math.PI)}function m(e){return Math.round(100*e)/100}const g=["Glasses","Shoes","Watches"],v=["Shoes"];const w={},y={};function b(n){return null==w[n]&&(w[n]=function(n){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(n).catch((e=>{throw console.error(e),new t("Resource unavailable.")}));if(!e.ok)throw new t(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield r.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}(n)),w[n]}function E(r,o,i){return null==y[r]&&(y[r]=function(r,o,i){return e(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const u=String.fromCharCode(a+14);s>>=2,a^=s+2;const d=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const f=String.fromCharCode(a-7),m=window[`${h}${d+u+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${f}`],g=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${r}`).catch((()=>{throw new t("Unknown error.")}));if(!e.ok)throw new t("Unknown error.");return e})))),v=new n[0](yield(yield g.blob().catch((()=>{throw new t("Unknown error.")}))).arrayBuffer().catch((()=>{throw new t("Unknown error.")})));i+=s;const w=v.byteLength;if(c[l]=Math.min(76,o)*((a>>5)-1),152===c[l]&&(c[l]=w),i==l)return v;i=l,i^=l;for(let e=0,t=v.length;e<t;e++)c[l]^=c[i]<<13,c[l]^=c[i]>>17,c[l]^=c[i]<<5,v[e]=v[e]^c[l];return i^=c[0],i^=c[1],i^=c[2],v}))}(r,o,i)),y[r]}const A="0.7.4-alpha.0";let S=`https://cdn.jsdelivr.net/npm/shopar-plugin@${A}/dist`;const M={update:e=>{null!=e&&(S=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>S};function R(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 x;function T(t,n){let r=!0;return{qrPaused:()=>r,qrDraw:(o,i)=>e(this,void 0,void 0,(function*(){!function(){e(this,void 0,void 0,(function*(){null==x&&(x=R(`${M}/shopar-qr.js`))}))}(),yield x;const a=`https://ar.shopar.ai/${A.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:o,s:i,h:location.href})}`,s=yield window.ShopAR__QR.toDataURL(a),l=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=s,yield l,r=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){r=!0,t.style.display="none"}))}}const C=(()=>{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 P,I,k,L=!1;let U=!1;function $(e){const t=function(e){const t=new I.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,I.ClampToEdgeWrapping,I.ClampToEdgeWrapping,I.LinearFilter,I.LinearFilter,1,I.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(k.parse(e));return t.mapping=I.EquirectangularReflectionMapping,t.colorSpace=I.LinearSRGBColorSpace,t}const D=45,O=45,N=3,_=1.5,j=1,F=.5;let W,q,G,z,B,Q=!1;const V=4,H=.001,K=1e-7,X=10,Z=11,Y=1/(Z-1),J="function"==typeof Float32Array;function ee(e,t,n,r){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===r)return ae;const o=J?new Float32Array(Z):new Array(Z);for(let t=0;t<Z;++t)o[t]=oe(t*Y,e,n);function i(t){let r=0,i=1;const a=Z-1;for(;i!==a&&o[i]<=t;++i)r+=Y;--i;const s=r+(t-o[i])/(o[i+1]-o[i])*Y,l=ie(s,e,n);return l>=H?function(e,t,n,r){for(let o=0;o<V;++o){const o=ie(t,n,r);if(0===o)return t;t-=(oe(t,n,r)-e)/o}return t}(t,s,e,n):0===l?s:function(e,t,n,r,o){let i,a,s=0;do{a=t+(n-t)/2,i=oe(a,r,o)-e,i>0?n=a:t=a}while(Math.abs(i)>K&&++s<X);return a}(t,r,r+Y,e,n)}return function(e){return 0===e||1===e?e:oe(i(e),t,r)}}function te(e,t){return 1-3*t+3*e}function ne(e,t){return 3*t-6*e}function re(e){return 3*e}function oe(e,t,n){return((te(t,n)*e+ne(t,n))*e+re(t))*e}function ie(e,t,n){return 3*te(t,n)*e*e+2*ne(t,n)*e+re(t)}function ae(e){return e}function se(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=ee(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function le(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:se(n)})));let r=0,o=n[0].value;return{reset:()=>{r=0},update:e=>{for(r+=e;r>=t;)r-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(r>=t.time&&r<i.time){const e=t.interpolate((r-t.time)/(i.time-t.time));o=t.value+e*(i.value-t.value)}}},get:()=>o}}const ce="#",ue="time",de="interpolation",he="yaw",pe="pitch",fe="fov",me=[ue,he,pe,fe,de],ge="s",ve="ms",we=1e3,ye="deg",be="rad",Ee=Math.PI/180,Ae="ease-in-out",Se="cubic-bezier(",Me=")";function Re(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(ce);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const r=function(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(!me.includes(r))throw new Error(`Invalid token in header: '${r}'.`);if(t.includes(r))throw new Error(`Duplicate token in header: '${r}'.`);t.push(r)}if(!t.includes(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}=xe(r,e);null!=t&&(null==o.theta&&(o.theta=[]),o.theta.push(t)),null!=n&&(null==o.phi&&(o.phi=[]),o.phi.push(n)),null!=i&&(null==o.fov&&(o.fov=[]),o.fov.push(i))}if(0===Object.values(o).length)throw new Error("At least one parameter should be animated.");return o}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const r of e){const{time:e,pitch:o,yaw:i,fov:a}=r;if(null==e)throw new Error("Time missing.");const s=Ce(null!==(t=r.interpolation)&&void 0!==t?t:Ae);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*Ee,interpolation:s})),null!=o&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:o*Ee,interpolation:s})),null!=a&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:a*Ee,interpolation:s}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function xe(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const r=e.indexOf(ue),o=function(e){if(e.endsWith(ve))return Ie(e.substring(0,e.length-ve.length));if(e.endsWith(ge))return Ie(e.substring(0,e.length-ge.length))*we;return Ie(e)}(n[r]),i=e.indexOf(de),a=Ce(-1===i?Ae:n[i]),s={};for(let t=0;t<n.length;t++){if(t===r||t===i)continue;const l=e[t],c=n[t];switch(l){case he:s.theta={time:o,value:Te(c),interpolation:a};break;case pe:s.phi={time:o,value:Te(c),interpolation:a};break;case fe:s.fov={time:o,value:Te(c),interpolation:a};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return s}function Te(e){return e.endsWith(ye)?Ie(e.substring(0,e.length-ye.length))*Ee:e.endsWith(be)?Ie(e.substring(0,e.length-be.length)):Ie(e)*Ee}function Ce(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Pe(0,0,1,1);if("sine"===e)return Pe(.37,0,.63,1);if("sine-in"===e)return Pe(.12,0,.39,0);if("sine-out"===e)return Pe(.61,1,.88,1);if("ease"===e)return Pe(.25,.1,.25,1);if("ease-in"===e)return Pe(.42,0,1,1);if("ease-out"===e)return Pe(0,0,.58,1);if("ease-in-out"===e)return Pe(.42,0,.58,1);if(e.startsWith(Se)&&e.endsWith(Me)){const t=e.substring(Se.length,e.length-Me.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:Ie(t[0]),y1:Ie(t[1]),x2:Ie(t[2]),y2:Ie(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Pe(e,t,n,r){return{type:"bezier",x1:e,y1:t,x2:n,y2:r}}function Ie(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const ke=300,Le=2e3,Ue=.05,$e=2*Math.PI/32,De=Ce("hold"),Oe=Ce("sine"),Ne=Ce("sine-in"),_e=Ce("sine-out");const je=2e3,Fe=8,We=2*Math.PI,qe=We/12,Ge=We/60,ze=We/60,Be=60,Qe=60,Ve=1e3,He=Be*Qe,Ke=-1;function Xe(e){return le([{time:0,value:0,interpolation:{type:"bezier",x1:.9,y1:0,x2:.6,y2:1}},{time:je,value:e,interpolation:{type:"hold"}}])}function Ze(e,t,n){return Ke*qe*(e+t/Be+n/He)}function Ye(e,t){return Ke*Ge*(e+t/Qe)}function Je(e,t){return Ke*ze*(e+t/Ve)}const et=["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 tt(e){null!=e&&(e.dispose(),et.forEach((t=>{var n;return null===(n=e[t])||void 0===n?void 0:n.dispose()})))}let nt;const rt=0,ot=3;let it,at,st,lt=!1,ct=1,ut=1,dt=1;const ht=1;let pt;const ft=new Map;function mt(){null==nt&&(nt=R(`${M}/shopar-three.js`))}function gt(t,n,r){const o=t.getContext("2d");null==o&&console.warn("2D context missing.");let i,a,s,l,c,u,d,h,p,f,m,g,v,w,y,b=!1,E=!1,A=!1,S=!0,M=!1,R=1,x=!0,T=!1,C=0,j=0,Q=1,V=1,H=1;const K={threeInit:()=>{b||(vt(),i=new at.Scene,a=new at.PerspectiveCamera(25,1,.5),s=new it.OrbitControls(a,t),s.setInteractionEnabled(x),h=at.ACESFilmicToneMapping,({renderShadow:c,shadowGroup:l}=function(e){const t=new W.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new W.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const r=new W.Group;r.position.y=-.7;const o=new W.PlaneGeometry(D,O).rotateX(Math.PI/2),i=new W.MeshBasicMaterial({map:t.texture,opacity:F,transparent:!0,depthWrite:!1}),a=new W.Mesh(o,i);a.renderOrder=1,a.scale.y=-1,r.add(a);const s=new W.Mesh(o);s.visible=!1,r.add(s);const l=new W.OrthographicCamera(-D/2,D/2,O/2,-O/2,0,N);function c(e){s.visible=!0,z.uniforms.tDiffuse.value=t.texture,z.uniforms.h.value=1*e/256,s.material=z,q.setRenderTarget(n),q.render(s,l),B.uniforms.tDiffuse.value=n.texture,B.uniforms.v.value=1*e/256,s.material=B,q.setRenderTarget(t),q.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,r.add(l),{shadowGroup:r,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=G;const r=q.getClearAlpha();q.setClearAlpha(0),q.setRenderTarget(t),q.render(e,l),e.overrideMaterial=null,c(_),c(.4*_),q.setRenderTarget(null),q.setClearAlpha(r),e.background=n}}}(i)),b=!0)},threeParse:(t,n,r)=>e(this,void 0,void 0,(function*(){return null!=u&&d===r||(yield u,u=(()=>e(this,void 0,void 0,(function*(){var e,r,o;return r=it,U||(I=r.THREE,k=new r.RGBELoader,U=!0),null===(e=i.environment)||void 0===e||e.dispose(),i.environment=$(n),function(e,t){if(L)return;const{THREE:n}=t;P=(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),L=!0}(pt,it),o=t,P.parseAsync(o.buffer,"")})))(),d=r),u})),threeLoad:(e,t)=>{bt(i),i.add(e.scene);const n=(new at.Box3).setFromObject(e.scene);l.position.y=n.min.y-rt,i.add(l),c(),E=!1,i.traverse((e=>{if(e instanceof at.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(E=!0)})):t.transmission>0&&(E=!0)}}));const r=n.min.clone().add(n.max).divideScalar(2),o=Math.sqrt(it.reduceVertices(e.scene,((e,t)=>Math.max(e,r.distanceToSquared(t))),0));s.reset(r,o,function(e,t){var n;const r={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?r.Glasses:null!==(n=r[e])&&void 0!==n?n:r.Glasses).normalize()}(t,at.Vector3)),C=0,y="Watches"===t?function(e){const t=e.getObjectByName("hours"),n=e.getObjectByName("minutes"),r=e.getObjectByName("seconds");if(null==t&&null==n&&null==r)return null;let o,i,a,s,l,c;return{start:()=>{o=new Date,o.setMilliseconds(o.getMilliseconds()+je),l=!1;const e=o.getHours(),t=o.getMinutes(),n=o.getSeconds(),r=o.getMilliseconds();i=Xe(Ze(e,t,n)),a=Xe(Ye(t,n)),s=Xe(Je(n,r)),c=new Date},update:()=>{if(null==o)return!1;const e=new Date;if(!l){if(o.getTime()-e.getTime()>0){const o=Math.abs(e.getTime()-c.getTime());return null!=t&&(i.update(o),t.rotation.y=i.get()),null!=n&&(a.update(o),n.rotation.y=a.get()),null!=r&&(s.update(o),r.rotation.y=s.get()),c=e,!0}l=!0}if(Math.abs(e.getTime()-c.getTime())<Ve/Fe)return!1;c=e;const u=e.getHours(),d=e.getMinutes(),h=e.getSeconds(),p=e.getMilliseconds();return null!=t&&(t.rotation.y=Ze(u,d,h)),null!=n&&(n.rotation.y=Ye(d,h)),null!=r&&(r.rotation.y=Je(h,p)),!0}}}(e.scene):null},threePaused:()=>S,threeResume:()=>{S=!1,pt.setAnimationLoop(wt),t.style.visibility="visible",j=0,null==f||f.reset(),null==m||m.reset(),null==g||g.reset(),null==v||v.reset(),null==w||w.reset(),null==y||y.start()},threePause:()=>{S=!0,function(){for(const{threePaused:e}of ft.values())if(!e())return!1;return!0}()&&pt.setAnimationLoop(null),t.style.visibility="hidden",r.style.opacity="0",n.style.visibility="hidden"},threeDestroy:()=>{var e;bt(i),null===(e=i.environment)||void 0===e||e.dispose(),i.environment=null,i=null,u=null,y=null,ft.delete(t)},threeSetZoomEnabled:e=>{s.enableZoom=e},threeSetForcedTransparency:e=>{A=e},threeSetToneMapping:(e,t)=>{const n={ACES:at.ACESFilmicToneMapping,Linear:at.LinearToneMapping,Neutral:at.NeutralToneMapping};null!=n[e]&&(h=n[e]),R=t},threeIsInteractive:()=>x,threeSetInteractive:e=>{x=e,null==s||s.setInteractionEnabled(x)},threeSetOnInteracted:e=>{s.removeEventListener("change",p),p=e,s.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=s.getTheta(),f=le([{time:0,value:e,interpolation:De},{time:ke,value:e,interpolation:_e},{time:ke+Le/4,value:e+$e,interpolation:Oe},{time:ke+3*Le/4,value:e-$e,interpolation:Ne},{time:ke+Le,value:e,interpolation:De},{time:ke+2*Le,value:e,interpolation:De}]),s.setTheta(f.get()),m=null,g=null,v=le([{time:0,value:0,interpolation:De},{time:ke,value:1,interpolation:De},{time:ke+Le,value:0,interpolation:De},{time:ke+2*Le,value:0,interpolation:De}]),w=le([{time:0,value:0,interpolation:De},{time:ke,value:0,interpolation:_e},{time:ke+Le/4,value:-Ue,interpolation:Oe},{time:ke+3*Le/4,value:Ue,interpolation:Ne},{time:ke+Le,value:0,interpolation:De},{time:ke+2*Le,value:0,interpolation:De}])},threeInitThetaAnimation:e=>{f=e,null!=e&&s.setTheta(e.get())},threeInitPhiAnimation:e=>{m=e,null!=e&&s.setPhi(e.get())},threeInitFovAnimation:e=>{g=e,null!=e&&s.setFovRadians(e.get())},threeRenderOnce:()=>{K.render_()},preRender_:e=>{if(!b||S||!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!==j?e-j:0;j=e,0===C?M=!0:C<ot&&(n=0),C++,T||(s.hasUserInteracted()?(T=!0,f=null,m=null,g=null,v=null,w=null):(null==f||f.update(n),null==m||m.update(n),null==g||g.update(n),null==v||v.update(n),null==w||w.update(n),null!=f&&(s.setTheta(f.get()),M=!0),null!=m&&(s.setPhi(m.get()),M=!0),null!=g&&(s.setFovRadians(g.get()),M=!0))),s.update()&&(M=!0),(null==y?void 0:y.update())&&(M=!0)},shouldRender_:()=>!(!b||S)&&M,render_:()=>{const e=pt.toneMapping,s=pt.toneMappingExposure;pt.toneMapping=h,pt.toneMappingExposure=R,pt.setViewport(0,0,t.width,t.height),pt.setClearColor(new at.Color(16777215),E&&!A?1:0),pt.render(i,a),pt.toneMapping=e,pt.toneMappingExposure=s,M=!1,null!=o&&(o.clearRect(0,0,t.width,t.height),st.width>0&&st.height>0&&o.drawImage(st,0,ut-t.height,t.width,t.height,0,0,t.width,t.height),n.style.visibility=x&&!T?"visible":"hidden",null!=v&&(r.style.opacity=`${v.get()}`),null!=w&&(r.style.transform=`translateX(${w.get()*Math.min(Q,V)}px)`))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===Q&&n===V&&dt===H||(t.width=Math.ceil(e*dt*ht),t.height=Math.ceil(n*dt*ht),Q=e,V=n,H=dt,M=!0)},target_:t};return ft.set(t,K),K}function vt(){if(lt)return;it=window.ShopAR__THREE,at=it.THREE,st=document.createElement("canvas");var e,t;st.style.position="block",pt=new at.WebGLRenderer({powerPreference:"high-performance",canvas:st,antialias:!0,alpha:!0}),pt.outputColorSpace=at.SRGBColorSpace,pt.toneMapping=at.ACESFilmicToneMapping,pt.setClearColor(new at.Color(16777215),0),e=pt,t=it,Q||(W=t.THREE,q=e,G=new W.MeshDepthMaterial,G.userData.darkness={value:j},G.onBeforeCompile=e=>{e.uniforms.darkness=G.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}`},G.depthTest=!1,G.depthWrite=!1,z=new W.ShaderMaterial(t.HorizontalBlurShader),z.depthTest=!1,B=new W.ShaderMaterial(t.VerticalBlurShader),B.depthTest=!1,Q=!0),yt(),lt=!0}function wt(e){yt(),pt.clear();for(const{preRender_:t,shouldRender_:n,render_:r}of ft.values())t(e),n()&&r()}function yt(){let e=0,t=0;for(const{target_:n}of ft.values()){const{clientWidth:r,clientHeight:o}=n;e=Math.max(e,r),t=Math.max(t,o)}const n=C();e=Math.ceil(e*n*ht),t=Math.ceil(t*n*ht),e===ct&&t===ut&&n===dt||(ct=e,ut=t,dt=n,pt.setSize(ct,ut,!1));for(const{updateSize_:e}of ft.values())e()}function bt(e){e.traverse((e=>{var t;e instanceof at.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach(tt):tt(e.material))})),e.clear()}const Et={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},At=Object.keys(Et);function St(e){return Et[e]}const Mt="shopar-error";function Rt(e,t,n,r){const o=document.createElement("button");o.id=e,o.type="button",o.className="shopar-btn",o.appendChild(r);{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 xt="shopar-control";const Tt="shopar-deepar-output";function Ct(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 Pt(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function It(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function kt(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const Lt="shopar-main";const Ut="shopar-qr-output";function $t(e){var t,n;const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("width",null!==(t=e.getAttribute("width"))&&void 0!==t?t:"1rem"),r.setAttribute("height",null!==(n=e.getAttribute("height"))&&void 0!==n?n:"1rem"),r.appendChild(e),r}function Dt(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 Ot="shopar-three-output";var Nt;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(Nt||(Nt={}));let _t=!1;function jt(){_t||(!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.")}}(),_t=!0)}function Ft(){jt();const e=function(){const e=document.createElement("div");e.id=Lt;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),r=function(e,t){const n=document.createElement("div");n.id=Ut;const r=n.style;r.position="absolute",r.top="0",r.left="0",r.width="100%",r.height="100%",r.display="none",r.pointerEvents="auto",r.userSelect="none";const o=document.createElement("div");o.className="shopar-qr";const i=o.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(o),o.appendChild(e);const a=document.createElement("div");return a.appendChild(t),o.appendChild(a),n}(t,n);e.appendChild(r);const o=function(){const e=document.createElement("div");e.id=Tt;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=Ot,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const a=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),s=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),l=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:r}=n;return r.position="absolute",r.width="100%",r.height="100%",r.opacity="0",n.appendChild(e),n.appendChild(t),n}(a,s);e.appendChild(l);const c=function(){const e=$t(Dt("2rem",`${M}/img/prompt/3d-interaction.svg`)),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),u=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",t.appendChild(e),t}(c);e.appendChild(u);const d=Ct("shopar-ar-loading-container"),h=Pt("shopar-ar-loading-text",St("loading.ar"));d.appendChild(h);const p=It("shopar-ar-loading-bar-bg"),f=kt("shopar-ar-loading-bar-fg");p.appendChild(f),d.appendChild(p),e.appendChild(d);const m=Ct("shopar-3d-loading-container"),g=Pt("shopar-3d-loading-text",St("loading.3d"));m.appendChild(g);const v=It("shopar-3d-loading-bar-bg"),w=kt("shopar-3d-loading-bar-fg");v.appendChild(w),m.appendChild(v),e.appendChild(m);const y=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",t.backgroundSize="contain",t.backgroundRepeat="no-repeat",t.backgroundPosition="center",e}();e.appendChild(y);const b=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),E=function(e){const t=document.createElement("div");t.id=Mt;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const r=document.createElement("div"),o=r.style;return o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",t.appendChild(r),r.appendChild(e),t}(b);e.appendChild(E);const A=function(){const e=document.createElement("div");return e.id=xt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(A);const S=Dt("1.75rem"),R=Rt("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on",$t(S));A.appendChild(R);const x=Dt("1.75rem"),T=Rt("shopar-btn-3d","3D","Launch ShopAR 3D preview",$t(x));A.appendChild(T);const C=Dt("1.75rem"),P=Rt("shopar-btn-close","Close","Close ShopAR view",$t(C));A.append(P);let I,k,L=Nt.None,U=!1,$=!1,D=!1,O=!1;function N(){f.classList.remove("active"),d.style.visibility="hidden"}function _(){y.style.visibility="hidden",w.classList.remove("active"),m.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return r},getQRImage:function(){return n},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return l},getThreeTarget:function(){return i},getThreePrompt:function(){return u},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){a.textContent=e,s.src=t},customizeCameraError:function(e){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,r,o,i){var a;U=e,$=t,D=n,O=r,I=o,k=i,Wt(A,U),Wt(R,U&&(D||$)&&L===Nt.None),Wt(T,U&&O&&L===Nt.None),Wt(P,U&&L!==Nt.None),N(),_(),U||""===(a=E).style.display&&Wt(a,!1)},getUIState:function(){return L},setUIState:function(e){L=e,L===Nt.None?(N(),_(),U&&(Wt(E,!1),Wt(P,!1),($||D)&&Wt(R,!0),O&&Wt(T,!0))):L===Nt.QR||L===Nt.AR?U&&(Wt(E,!1),Wt(R,!1),Wt(T,O&&"AR"===k),Wt(P,"AR"!==k)):L===Nt.Preview&&U&&(Wt(E,!1),Wt(R,($||D)&&"3D"===k),Wt(T,!1),Wt(P,"3D"!==k))},setDefaultUIActions:function(e,t,n){U&&(($||D)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,r=`${M}/img/icons/${n}`;S.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r)}(I),R.onclick=e),O&&(x.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${M}/img/icons/cube.svg`),T.onclick=t),C.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${M}/img/icons/close.svg`),P.onclick=n)},startDeepARLoading:function(){f.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:N,startThreeLoading:function(){null!=y.dataset.bgSet?y.style.visibility="visible":(w.classList.add("active"),m.style.visibility="visible")},stopThreeLoading:_,setThreePosterUrl:function(e){null!=e?(y.style.backgroundImage=`url(${e})`,y.dataset.bgSet="true"):delete y.dataset.bgSet},showCameraError:function(){U&&Wt(E,!0)}}}function Wt(e,t){e.style.display=t?"":"none"}const qt=new Map;function Gt(e){let t=qt.get(e);return null==t?(t=function(){let e=0,t=null,n=null,r=null;const o=()=>(null==t&&(t=Ft()),t);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>t,findUI:o,findQR:()=>{if(null==n){const{getQRTarget:e,getQRImage:t}=o();n=T(e(),t())}return n},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=o();r=gt(e(),t(),n())}return r}}}(),qt.set(e,t)):t.incrementSetupId_(),t}function zt(e){for(const t of qt.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:r,setUIState:o}=n;r()===Nt.AR&&o(Nt.None)}}let Bt;const Qt=new Uint8Array(16);function Vt(){if(!Bt&&(Bt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Bt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Bt(Qt)}const Ht=[];for(let e=0;e<256;++e)Ht.push((e+256).toString(16).slice(1));var Kt={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Xt(e,t,n){if(Kt.randomUUID&&!t&&!e)return Kt.randomUUID();const r=(e=e||{}).random||(e.rng||Vt)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return Ht[e[t+0]]+Ht[e[t+1]]+Ht[e[t+2]]+Ht[e[t+3]]+"-"+Ht[e[t+4]]+Ht[e[t+5]]+"-"+Ht[e[t+6]]+Ht[e[t+7]]+"-"+Ht[e[t+8]]+Ht[e[t+9]]+"-"+Ht[e[t+10]]+Ht[e[t+11]]+Ht[e[t+12]]+Ht[e[t+13]]+Ht[e[t+14]]+Ht[e[t+15]]}(r)}const Zt="qrLaunch",Yt="arLaunch",Jt="previewLaunch",en="heartbeat";let tn,nn,rn=!1,on=window.navigator.userAgent||"no user agent";const an=[];function sn(){null==tn&&(nn=Xt(),tn=R(`${M}/shopar-analytics.js`),tn.then((()=>{rn=!0,window.ShopAR__analytics.initializeImpl(),an.forEach((e=>e()))})))}function ln(e){rn?e():an.push(e)}function cn(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,hn=10;let pn=!1,fn=null,mn=[],gn=[];function vn(t){return e(this,void 0,void 0,(function*(){pn=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${M}/wasm/mediapipe`,t),fn&&clearInterval(fn);const r=[],o=[];fn=setInterval((()=>e(this,void 0,void 0,(function*(){if(pn)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());pn||(null!=a&&null!=s&&function(e){for(let t of mn)t(e)}({translation:a,rotation:s}),null==e&&(r.push(t),o.push(i),r.length<hn||(r.shift(),o.shift(),function(e,t){for(let n of gn)n({faceWidth:e,IPD:t})}(yn(r),yn(o)))))}))),dn)}))}function wn(){gn=[],mn=[],pn=!0}function yn(e){let t=0;const n=e.length;for(let r=0;r<n;r++)t+=e[r];return t/n}var bn="undefined"!=typeof Float32Array?Float32Array:Array;function En(){var e=new bn(16);return bn!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function An(e,t,n){var r=t[0],o=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],E=n[2],A=n[3];return e[0]=y*r+b*s+E*d+A*m,e[1]=y*o+b*l+E*h+A*g,e[2]=y*i+b*c+E*p+A*v,e[3]=y*a+b*u+E*f+A*w,y=n[4],b=n[5],E=n[6],A=n[7],e[4]=y*r+b*s+E*d+A*m,e[5]=y*o+b*l+E*h+A*g,e[6]=y*i+b*c+E*p+A*v,e[7]=y*a+b*u+E*f+A*w,y=n[8],b=n[9],E=n[10],A=n[11],e[8]=y*r+b*s+E*d+A*m,e[9]=y*o+b*l+E*h+A*g,e[10]=y*i+b*c+E*p+A*v,e[11]=y*a+b*u+E*f+A*w,y=n[12],b=n[13],E=n[14],A=n[15],e[12]=y*r+b*s+E*d+A*m,e[13]=y*o+b*l+E*h+A*g,e[14]=y*i+b*c+E*p+A*v,e[15]=y*a+b*u+E*f+A*w,e}function Sn(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Mn(e,t){var n=t[0],r=t[1],o=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.hypot(n,r,o),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,u),e}function Rn(e,t,n,r){var o=t[0],i=t[1],a=t[2],s=t[3],l=o+o,c=i+i,u=a+a,d=o*l,h=o*c,p=o*u,f=i*c,m=i*u,g=a*u,v=s*l,w=s*c,y=s*u,b=r[0],E=r[1],A=r[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*E,e[5]=(1-(d+g))*E,e[6]=(m+v)*E,e[7]=0,e[8]=(p+w)*A,e[9]=(m-v)*A,e[10]=(1-(d+f))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function xn(){var e=new bn(3);return bn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Tn(e,t,n){var r=new bn(3);return r[0]=e,r[1]=t,r[2]=n,r}function Cn(e,t){var n=t[0]-e[0],r=t[1]-e[1],o=t[2]-e[2];return Math.hypot(n,r,o)}function Pn(e,t,n){var r=t[0],o=t[1],i=t[2],a=n[3]*r+n[7]*o+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*r+n[4]*o+n[8]*i+n[12])/a,e[1]=(n[1]*r+n[5]*o+n[9]*i+n[13])/a,e[2]=(n[2]*r+n[6]*o+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function In(){var e=new bn(4);return bn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}xn(),function(){var e,t=(e=new bn(4),bn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var kn;let Ln,Un;xn(),Tn(1,0,0),Tn(0,1,0),In(),In(),kn=new bn(9),bn!=Float32Array&&(kn[1]=0,kn[2]=0,kn[3]=0,kn[5]=0,kn[6]=0,kn[7]=0),kn[0]=1,kn[4]=1,kn[8]=1;let $n,Dn,On,Nn,_n=!0,jn=null;const Fn=new Set;let Wn,qn,Gn,zn,Bn,Qn;function Vn(){null==Ln&&(Ln=R(`${M}/shopar-deepar.js`))}function Hn(){null==Un&&(Un=R(`${M}/shopar-true-scale.js`))}function Kn(n){return e(this,void 0,void 0,(function*(){const{licenseKey:r,truescaleUsecase:o}=n;return Bn=o,null==Wn&&(Wn=(()=>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=or(On),o=cn(n);$n=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:r||"your_license_key_goes_here",previewElement:Nn,additionalOptions:{hint:Qn,cameraConfig:{disableDefaultCamera:!0}}}),Dn=yield un(o),yield ir($n,Dn,"user"===n),"Glasses"===On&&(yield Un,vn(Dn),"DetectionLoop"!==Bn&&cr((e=>{zn=e.faceWidth})))})))()),Wn}))}function Xn(e,t){var n,r;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===On&&(n=t,r=Qn,n===r||null!=n&&null!=r&&n.length===r.length&&n.every((e=>r.find((t=>e===t))))&&r.every((e=>n.find((t=>t===e))))))||(null!=$n&&($n.shutdown(),$n=null,Wn=null),On=e,Qn=t)}function Zn(e){e!==Nn&&(Nn=e,null!=$n&&$n.changePreviewElement(Nn))}function Yn(e){jn=e}function Jn(e){$n.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(zn){const e=137/(zn+5);$n.changeParameterVector("GLASSES","","scale",e,e,e,0),$n.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const r=sr("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),o=sr("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);$n.changeParameterVector("temple_left","","rotation",0,56.6*-r,0,0),$n.changeParameterVector("temple_right","","rotation",0,56.6*-o,0,0)}catch(e){return}}(e),wn(),zn=null}e(),ar("Glasses")}},$n.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),ar("Shoes"))},$n.callbacks.onWristTracked=t=>{t.detected&&(e(),ar("Watches"))}}function er(t,n,r){return e(this,void 0,void 0,(function*(){return null!=qn&&Gn===r||(yield qn,qn=$n.switchEffect(t,{envmap:n}),Gn=r),qn}))}function tr(e,t){null!=e&&null!=t&&($n.setToneMapping(e),$n.setExposure(t))}function nr(){return e(this,void 0,void 0,(function*(){if(null!=$n){if(_n=!1,null==Dn){const e=or(On),t=cn(e);Dn=yield un(t),yield ir($n,Dn,"user"===e),"Glasses"===On&&(vn(Dn),"DetectionLoop"!==Bn&&cr((e=>{zn=e.faceWidth})))}!function(){if(null==jn)return;if(null==On||Fn.has(On))return;jn.style.visibility="visible",jn.style.opacity="1"}(),$n.setPaused(_n),Nn.style.display=""}}))}function rr(){null!=$n&&(_n=!0,$n.setPaused(_n),wn(),null!=Dn&&null!=Dn.srcObject&&Dn.srcObject instanceof MediaStream&&(Dn.srcObject.getTracks().forEach((e=>e.stop())),Dn=null),function(){if(null==jn)return;jn.style.visibility="hidden",jn.style.opacity="0"}(),$n.stopCamera(),Nn.style.display="none")}function or(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function ir(t,n,r){return e(this,void 0,void 0,(function*(){yield new Promise((o=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,r),o()}))))}}))}))}function ar(e){null!=jn&&(Fn.has(e)||(Fn.add(e),jn.style.opacity="0"))}function sr(e,t,n,r,o,i,a){const s=$n.getTransformationBetween(e,t),l=Sn(xn(),s),c=function(e,t){var n=new bn(3);Mn(n,t);var r=1/n[0],o=1/n[1],i=1/n[2],a=t[0]*r,s=t[1]*o,l=t[2]*i,c=t[4]*r,u=t[5]*o,d=t[6]*i,h=t[8]*r,p=t[9]*o,f=t[10]*i,m=a+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>u&&a>f?(g=2*Math.sqrt(1+a-u-f),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):u>f?(g=2*Math.sqrt(1+u-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+f-a-u),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(d+p)/g,e[2]=.25*g),e}(In(),s);Rn(s,c,l,Tn(a,a,a));const u=$n.getTransformationBetween(t,n),d=Sn(xn(),u);Rn(u,In(),d,Mn(xn(),u));const h=An(En(),s,u),p=Sn(xn(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=$n.getTransformationBetween(n,r)}catch(e){return f}const g=An(En(),u,m),v=An(En(),s,g),w=Tn(p[0],i[1],i[2]),y=Pn(xn(),w,function(e,t){var n=t[0],r=t[1],o=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-r*a,y=n*l-o*a,b=n*c-i*a,E=r*l-o*s,A=r*c-i*s,S=o*c-i*l,M=u*m-d*f,R=u*g-h*f,x=u*v-p*f,T=d*g-h*m,C=d*v-p*m,P=h*v-p*g,I=w*P-y*C+b*T+E*x-A*R+S*M;return I?(I=1/I,e[0]=(s*P-l*C+c*T)*I,e[1]=(o*C-r*P-i*T)*I,e[2]=(m*S-g*A+v*E)*I,e[3]=(h*A-d*S-p*E)*I,e[4]=(l*x-a*P-c*R)*I,e[5]=(n*P-o*x+i*R)*I,e[6]=(g*b-f*S-v*y)*I,e[7]=(u*S-h*b+p*y)*I,e[8]=(a*C-s*x+c*M)*I,e[9]=(r*x-n*C-i*M)*I,e[10]=(f*A-m*b+v*w)*I,e[11]=(d*b-u*A-p*w)*I,e[12]=(s*R-a*T-l*M)*I,e[13]=(n*T-r*R+o*M)*I,e[14]=(m*y-f*E-g*w)*I,e[15]=(u*E-d*y+h*w)*I,e):null}(En(),v));let b=$n.getClosestPointOnMesh(r,y);try{const e=$n.getClosestPointOnMesh(o,y);Cn(y,e)<Cn(y,b)&&(b=e)}catch(e){}const E=Pn(xn(),b,g);return f-Math.atan2(E[0]-d[0],Math.abs(E[2]-d[2]))}function lr(e){!function(e){mn.push(e)}(e)}function cr(e){!function(e){gn.push(e)}(e)}var ur;function dr(){return[ur.Android,ur.iOS,ur.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],r=["Win32","Win64","Windows","WinCE"],o=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==o.indexOf(t)?ur.iOS:-1!==n.indexOf(t)?i?ur.Tablet:ur.MacOS:-1!==r.indexOf(t)?ur.Windows:/Android/.test(e)?ur.Android:/Linux/.test(t)?ur.Linux:i?ur.Tablet:ur.Unknown}return ur.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"}(ur||(ur={}));const hr=["AR","3D"];function pr(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function fr(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}function mr(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}function gr(e){const{apiKey:n,sku:r,targetElement:o,initialState:i,initialAnimation:a,baseUrl:s,defaultUI:l,interactive:c,strings:u}=e;pr(n,"apiKey"),mr(n,"apiKey"),pr(r,"sku"),mr(r,"sku"),pr(o,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(o,"targetElement"),null!=i&&function(e,n,r){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!r.includes(e))throw new t(`'${n}' must be ${r.join("' or '")}.`)}(i,"initialState",hr),null!=a&&function(e,n){if("string"!=typeof e&&!Array.isArray(e))throw new t(`'${n}' must be a string or array.`)}(a,"initialAnimation"),null!=s&&mr(s,"baseUrl"),null!=l&&fr(l,"defaultUI"),null!=c&&fr(c,"interactive"),null!=u&&function(e,n,r){for(const o of r){const r=e[o];if(null!=r&&"string"!=typeof r)throw new t(`Value for key '${o}' in '${n}' must be a string.`)}}(u,"strings",At)}let vr=!1;function wr(n){return e(this,void 0,void 0,(function*(){const{targetElement:r}=n;M.update(n.baseUrl),sn();const{trackEvent:o}=function(e){const t=performance.now(),n=Xt();return{trackEvent:(r,o={})=>{o=Object.assign(Object.assign({},o),{pluginVersion:A,userAgent:on,sessionId:nn,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),ln((()=>{window.ShopAR__analytics.trackEventImpl(r,o)}))}}}(n.apiKey);o("visionSetup");const i=yield function(n){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:n,sid:u()})}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield r.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(n.apiKey);o("visionApiResponse",i);const{arKey:a}=i,s=Gt(r),{getSetupId:l,findUI:c}=s,d=l();Vn(),Hn();const{setTargetElement:h,getDeepARTarget:f,setVisibilityParameters:m,getUIState:g,setUIState:v,startDeepARLoading:w,stopDeepARLoading:y,showCameraError:b}=c();if(g()!=Nt.None)throw Error("UI state is not None, this is weird..");v(Nt.AR),h(r),m(!1,!1,!0,!1,void 0,void 0),w(),yield Ln,yr(l(),d);try{o("visionArLaunch"),rr(),Xn("Glasses",["faceInit"]),Zn(f()),yield Kn({licenseKey:a,truescaleUsecase:"DetectionLoop"}),yr(l(),d),yield nr(),yr(l(),d)}catch(e){const n=e instanceof Error;throw o("visionArLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),b(),rr(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{y()}return vr=!0,{registerFacePoseListener:e=>{vr&&(o("registerFacePoseListener"),lr(e))},registerFaceMeasurementListener:e=>{vr&&(o("registerFaceMeasurementListener"),cr(e))},switchEffect:t=>e(this,void 0,void 0,(function*(){vr&&(o("switchEffect",{arUrl:t}),function(e){$n.switchEffect(e)}(t))})),clearEffect:()=>{vr&&(o("clearEffect"),$n.clearEffect())},close:()=>{if(vr){if(vr=!1,o("visionClose"),g()!==Nt.AR)throw new t("AR not launched.");rr(),v(Nt.None)}}}}))}function yr(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}function br(n){var r,o;return e(this,void 0,void 0,(function*(){gr(n);const{apiKey:i,sku:a,targetElement:s,initialState:l,initialAnimation:c}=n,d=null==n.zoomEnabled||n.zoomEnabled,h=!0===n.alwaysTransparentBackground;!function(e){const n=getComputedStyle(e);if(!["static","relative"].includes(n.position))throw new t(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${n.position}'.`)}(s),M.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(Et,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(Et[t]=n)}}(n.strings);const w=null!=c?Re(c):null,y=null!=(null==w?void 0:w.theta)?le(w.theta):null,S=null!=(null==w?void 0:w.phi)?le(w.phi):null,R=null!=(null==w?void 0:w.fov)?le(w.fov):null,x=function(n,r,o,i,a,s){return e(this,void 0,void 0,(function*(){const l=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:n,sku:r,sid:u()},null!=o&&{yaw:`${m(f(o))}`}),null!=i&&{pitch:`${m(f(i))}`}),null!=a&&{fov:`${m(f(a))}`}),s&&{forcedTransparency:`${s}`}))}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield l.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(i,a,null==y?void 0:y.get(),null==S?void 0:S.get(),null==R?void 0:R.get(),h),T=Gt(s),{getSetupId:C,findUI:P,findQR:I,findThree:k}=T,L=C();sn();const{trackEvent:U,arInteracted:$,previewInteracted:D}=function(e,t){const n=performance.now(),r=Xt();let o=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(o=i+a,c=!1,u(en,{engagementTotal:o,engagementAR:i,engagement3D:a}))}),1e3);const u=(o,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:on,pluginVersion:A,sessionId:nn,setupId:r,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),ln((()=>{window.ShopAR__analytics.trackEventImpl(o,i)}))};return{trackEvent:u,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}(a,i);U("setup",{hostname:window.location.hostname});const O=yield x;U("apiResponse",O);const{category:N,arUrl:_,arEnvUrl:j,arToneMapping:F,arToneMappingExposure:W,arKey:q,arPromptEnabled:G,arPromptText:z,arPromptImage:B,previewUrl:Q,previewEnvUrl:V,previewToneMapping:H,previewToneMappingExposure:K,previewPosterUrl:X,cameraErrorText:Z,qrPromptText:Y}=O;Er(C(),L);const J=null!=_&&function(e){return null!=e&&g.includes(e)}(N),ee=null==(null===(r=n._internalOptions)||void 0===r?void 0:r.qrEnabled)||(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled),te=J&&function(e){return null!=e&&v.includes(e)}(N),ne=ee&&te&&!dr(),re=J&&!ne,oe=null!=Q;Er(C(),L);const{setTargetElement:ie,getDeepARTarget:ae,getDeepARPrompt:se,customizeDeepARPrompt:ce,customizeCameraError:ue,customizeQRPrompt:de,setVisibilityParameters:he,getUIState:pe,setUIState:fe,setDefaultUIActions:me,startDeepARLoading:ge,stopDeepARLoading:ve,startThreeLoading:we,stopThreeLoading:ye,setThreePosterUrl:be,showCameraError:Ee}=P();ie(s);he(null==n.defaultUI||n.defaultUI,ne,re,oe,N,l),ce(null!=z?z:"",null!=B?B:""),ue(Z),de(Y),be(X),function(e,n){const r=e.parentNode;if(null==r)throw new t("Parent node missing.");new MutationObserver((t=>{for(const r of t)for(const t of r.removedNodes)if(t===e)return void n()})).observe(r,{childList:!0})}(s,(()=>{pe()!==Nt.QR||Ae()||Me(),pe()!==Nt.AR||_n||rr(),pe()!==Nt.Preview||Pe()||ke(),fe(Nt.None),Le(),function(e){qt.delete(e)}(s)}));const{qrPaused:Ae,qrDraw:Se,qrPause:Me}=I(),{threeInit:xe,threeParse:Te,threeLoad:Ce,threePaused:Pe,threeResume:Ie,threePause:ke,threeDestroy:Le,threeSetZoomEnabled:Ue,threeSetForcedTransparency:$e,threeSetToneMapping:De,threeIsInteractive:Oe,threeSetInteractive:Ne,threeSetOnInteracted:_e,threeInitPromptAnimation:je,threeInitThetaAnimation:Fe,threeInitPhiAnimation:We,threeInitFovAnimation:qe,threeRenderOnce:Ge}=k(),ze=null==n.interactive||n.interactive;Ne(ze);let Be=0;if(pe()===Nt.QR){if(!Ae())if(ne){U(Zt);try{yield Se(i,a)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else Me(),fe(Nt.None)}else if(pe()===Nt.AR){if(!_n)if(re&&!vr){U(Yt),Vn(),"Glasses"===N&&Hn();const e=null!=j?yield b(j):void 0;Er(C(),L);const t=yield b(_);Er(C(),L),zt(T),Xn(N),Zn(ae()),Yn(G?se():null),yield er(t,e,`${_}${j}`),tr(F,W),Jn($),Er(C(),L)}else rr(),fe(Nt.None)}else if(pe()===Nt.Preview&&!Pe())if(oe){U(Jt),mt(),we();const e=255,t=yield E(Q,(new Date).getTime()+e,Math.random()*e);Er(C(),L);const n=yield b(null!=V?V:`${M}/env/default.hdr`);Er(C(),L),yield nt,Er(C(),L),xe(),Er(C(),L);const r=yield Te(t,n,`${Q}${V}`);Er(C(),L),Ce(r,N),Ue(d),$e(h),De(null!=H?H:"ACES",null!=K?K:1),_e(D),je(),null!=w&&(Fe(y),We(S),qe(R)),Ge(),Ie(),ye()}else ke(),fe(Nt.None);const Qe=()=>e(this,void 0,void 0,(function*(){if(ne)try{U(Zt);const e=++Be;if(pe()===Nt.Preview&&oe&&!Pe()&&ke(),fe(Nt.QR),yield Se(i,a),Be!==e)return;return void Er(C(),L)}catch(e){const n=e instanceof Error;throw U("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}if(!re)throw new t("Model does not have AR enabled.");try{U(Yt);const e=++Be;pe()===Nt.Preview&&oe&&!Pe()&&ke(),zt(T),fe(Nt.AR),Vn(),"Glasses"===N&&Hn(),ge();const t=null!=j?yield b(j):void 0;Er(C(),L);const n=yield b(_);if(Be!==e)return;if(Er(C(),L),yield Ln,Be!==e)return;if(Er(C(),L),rr(),Xn(N),Zn(ae()),Yn(G?se():null),yield Kn({licenseKey:q}),Be!==e)return;if(Er(C(),L),yield er(n,t,`${_}${j}`),tr(F,W),Jn($),Be!==e)return;if(Er(C(),L),yield nr(),Be!==e)return;Er(C(),L)}catch(e){const n=e instanceof Error;throw U("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),Ee(),rr(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{ve()}})),Ve=()=>e(this,void 0,void 0,(function*(){if(!oe)throw new t("Model does not have 3D enabled.");try{U(Jt);const e=++Be;pe()===Nt.AR&&(re&&!_n&&rr(),Me()),fe(Nt.Preview),mt(),we();const t=255,n=yield E(Q,(new Date).getTime()+t,Math.random()*t);if(Be!==e)return;Er(C(),L);const r=yield b(null!=V?V:`${M}/env/default.hdr`);if(Be!==e)return;if(Er(C(),L),yield nt,Be!==e)return;if(Er(C(),L),xe(),Be!==e)return;Er(C(),L);const o=yield Te(n,r,`${Q}${V}`);if(Be!==e)return;Er(C(),L),Ce(o,N),Ue(d),$e(h),De(null!=H?H:"ACES",null!=K?K:1),_e(D),je(),null!=w&&(Fe(y),We(S),qe(R)),Ge(),Ie(),ye()}catch(e){const n=e instanceof Error;throw U("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}})),He=()=>e(this,void 0,void 0,(function*(){pe()!==Nt.None&&("AR"!==l||pe()!==Nt.AR&&pe()!==Nt.QR)&&("3D"===l&&pe()===Nt.Preview||(++Be,pe()===Nt.QR||pe()===Nt.AR?(re&&!_n&&rr(),Me()):pe()===Nt.Preview&&oe&&!Pe()&&ke(),fe(Nt.None),"AR"!==l?"3D"!==l||(yield Ve()):yield Qe()))}));return me(Qe,Ve,He),"AR"===l?(yield Qe(),Er(C(),L)):"3D"===l&&(yield Ve(),Er(C(),L)),vr=!1,{launchAR:J?Qe:void 0,launch3D:oe?Ve:void 0,closeAR:J?()=>e(this,void 0,void 0,(function*(){pe()!==Nt.AR&&pe()!==Nt.QR||"AR"!==l&&(++Be,re&&!_n&&rr(),Me(),fe(Nt.None),"3D"!==l||(yield Ve()))})):void 0,close3D:oe?()=>e(this,void 0,void 0,(function*(){pe()===Nt.Preview&&"3D"!==l&&(++Be,oe&&!Pe()&&ke(),fe(Nt.None),"AR"!==l||(yield Qe()))})):void 0,close:J||oe?He:void 0,isInteractive:()=>Oe(),setInteractive:e=>Ne(e)}}))}function Er(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const Ar={setup:function(t){return e(this,void 0,void 0,(function*(){return wr(t)}))}},Sr={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,r){return e(this,void 0,void 0,(function*(){try{return r()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>br(n)))}))},version:A};export{hr as PREVIEW_STATES,t as PluginError,Sr as plugin,Ar as vision};
|
package/dist/shopar-plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR={})}(this,(function(e){"use strict";function t(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const o=[Uint8Array,Uint32Array],r=o.length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],a=[2,12,7,1],s=window[i[a[a[r]]]][i[a[a[a.length-1]]]],l=s.charCodeAt(r),c=l^l,u=new o[1]([c]);function d(){const e=(new TextEncoder).encode(s),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}const h=[1e3,2e3,4e3],p=h.length;function f(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=p)throw t;return yield new Promise((e=>setTimeout(e,h[n]))),f(e,n+1)}}))}function m(e){return e*(180/Math.PI)}function g(e){return Math.round(100*e)/100}const v=["Glasses","Shoes","Watches"],w=["Shoes"];const y={},b={};function E(e){return null==y[e]&&(y[e]=function(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new n("Resource unavailable.")}));if(!t.ok)throw new n(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield o.blob()).arrayBuffer()}catch(e){throw console.error(e),new n("Resource has invalid body.")}}))}(e)),y[e]}function A(e,r,i){return null==b[e]&&(b[e]=function(e,r,i){return t(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const l=String.fromCharCode(a+14);s>>=2,a^=s+2;const d=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const p=String.fromCharCode(a-7),m=window[`${h}${d+l+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${p}`],g=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield m(`${e}`).catch((()=>{throw new n("Unknown error.")}));if(!t.ok)throw new n("Unknown error.");return t})))),v=new o[0](yield(yield g.blob().catch((()=>{throw new n("Unknown error.")}))).arrayBuffer().catch((()=>{throw new n("Unknown error.")})));i+=s;const w=v.byteLength;if(u[c]=Math.min(76,r)*((a>>5)-1),152===u[c]&&(u[c]=w),i==c)return v;i=c,i^=c;for(let e=0,t=v.length;e<t;e++)u[c]^=u[i]<<13,u[c]^=u[i]>>17,u[c]^=u[i]<<5,v[e]=v[e]^u[c];return i^=u[0],i^=u[1],i^=u[2],v}))}(e,r,i)),b[e]}const S="0.7.3";let M=`https://cdn.jsdelivr.net/npm/shopar-plugin@${S}/dist`;const R={update:e=>{null!=e&&(M=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>M};function T(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}let x;const P=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.error('No <meta name="viewport"> detected. This might cause ShopAR to crash on iOS.\nPlease add the following line to your HTML:\n<meta name="viewport" content="width=device-width, initial-scale=1.0">'),()=>e?window.devicePixelRatio:1})();let C,I,k,L=!1;let $=!1;function U(e){const t=function(e){const t=new I.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,I.ClampToEdgeWrapping,I.ClampToEdgeWrapping,I.LinearFilter,I.LinearFilter,1,I.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(k.parse(e));return t.mapping=I.EquirectangularReflectionMapping,t.colorSpace=I.LinearSRGBColorSpace,t}const D=45,O=45,_=3,N=1.5,j=1,W=.5;let F,q,G,z,B,V=!1;const Q=4,H=.001,K=1e-7,X=10,Z=11,Y=1/(Z-1),J="function"==typeof Float32Array;function ee(e,t,n,o){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===o)return ae;const r=J?new Float32Array(Z):new Array(Z);for(let t=0;t<Z;++t)r[t]=re(t*Y,e,n);function i(t){let o=0,i=1;const a=Z-1;for(;i!==a&&r[i]<=t;++i)o+=Y;--i;const s=o+(t-r[i])/(r[i+1]-r[i])*Y,l=ie(s,e,n);return l>=H?function(e,t,n,o){for(let r=0;r<Q;++r){const r=ie(t,n,o);if(0===r)return t;t-=(re(t,n,o)-e)/r}return t}(t,s,e,n):0===l?s:function(e,t,n,o,r){let i,a,s=0;do{a=t+(n-t)/2,i=re(a,o,r)-e,i>0?n=a:t=a}while(Math.abs(i)>K&&++s<X);return a}(t,o,o+Y,e,n)}return function(e){return 0===e||1===e?e:re(i(e),t,o)}}function te(e,t){return 1-3*t+3*e}function ne(e,t){return 3*t-6*e}function oe(e){return 3*e}function re(e,t,n){return((te(t,n)*e+ne(t,n))*e+oe(t))*e}function ie(e,t,n){return 3*te(t,n)*e*e+2*ne(t,n)*e+oe(t)}function ae(e){return e}function se(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=ee(e.x1,e.y1,e.x2,e.y2);return e=>t(e)}throw new Error(`Unknown interpolation: ${e}`)}function le(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:se(n)})));let o=0,r=n[0].value;return{reset:()=>{o=0},update:e=>{for(o+=e;o>=t;)o-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(o>=t.time&&o<i.time){const e=t.interpolate((o-t.time)/(i.time-t.time));r=t.value+e*(i.value-t.value)}}},get:()=>r}}const ce="#",ue="time",de="interpolation",he="yaw",pe="pitch",fe="fov",me=[ue,he,pe,fe,de],ge="s",ve="ms",we=1e3,ye="deg",be="rad",Ee=Math.PI/180,Ae="ease-in-out",Se="cubic-bezier(",Me=")";function Re(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(ce);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const o=function(e){const t=[];for(let n=0;n<e.length;n++){const o=e[n];if(!me.includes(o))throw new Error(`Invalid token in header: '${o}'.`);if(t.includes(o))throw new Error(`Duplicate token in header: '${o}'.`);t.push(o)}if(!t.includes(ue))throw new Error(`Missing required token: '${ue}'.`);return t}(t.split(/\s+/)),r={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:i}=Te(o,e);null!=t&&(null==r.theta&&(r.theta=[]),r.theta.push(t)),null!=n&&(null==r.phi&&(r.phi=[]),r.phi.push(n)),null!=i&&(null==r.fov&&(r.fov=[]),r.fov.push(i))}if(0===Object.values(r).length)throw new Error("At least one parameter should be animated.");return r}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const o of e){const{time:e,pitch:r,yaw:i,fov:a}=o;if(null==e)throw new Error("Time missing.");const s=Pe(null!==(t=o.interpolation)&&void 0!==t?t:Ae);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*Ee,interpolation:s})),null!=r&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:r*Ee,interpolation:s})),null!=a&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:a*Ee,interpolation:s}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function Te(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const o=e.indexOf(ue),r=function(e){if(e.endsWith(ve))return Ie(e.substring(0,e.length-ve.length));if(e.endsWith(ge))return Ie(e.substring(0,e.length-ge.length))*we;return Ie(e)}(n[o]),i=e.indexOf(de),a=Pe(-1===i?Ae:n[i]),s={};for(let t=0;t<n.length;t++){if(t===o||t===i)continue;const l=e[t],c=n[t];switch(l){case he:s.theta={time:r,value:xe(c),interpolation:a};break;case pe:s.phi={time:r,value:xe(c),interpolation:a};break;case fe:s.fov={time:r,value:xe(c),interpolation:a};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return s}function xe(e){return e.endsWith(ye)?Ie(e.substring(0,e.length-ye.length))*Ee:e.endsWith(be)?Ie(e.substring(0,e.length-be.length)):Ie(e)*Ee}function Pe(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Ce(0,0,1,1);if("sine"===e)return Ce(.37,0,.63,1);if("sine-in"===e)return Ce(.12,0,.39,0);if("sine-out"===e)return Ce(.61,1,.88,1);if("ease"===e)return Ce(.25,.1,.25,1);if("ease-in"===e)return Ce(.42,0,1,1);if("ease-out"===e)return Ce(0,0,.58,1);if("ease-in-out"===e)return Ce(.42,0,.58,1);if(e.startsWith(Se)&&e.endsWith(Me)){const t=e.substring(Se.length,e.length-Me.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:Ie(t[0]),y1:Ie(t[1]),x2:Ie(t[2]),y2:Ie(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Ce(e,t,n,o){return{type:"bezier",x1:e,y1:t,x2:n,y2:o}}function Ie(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const ke=300,Le=2e3,$e=.05,Ue=2*Math.PI/32,De=Pe("hold"),Oe=Pe("sine"),_e=Pe("sine-in"),Ne=Pe("sine-out");const je=2e3,We=8,Fe=2*Math.PI,qe=Fe/12,Ge=Fe/60,ze=Fe/60,Be=60,Ve=60,Qe=1e3,He=Be*Ve,Ke=-1;function Xe(e){return le([{time:0,value:0,interpolation:{type:"bezier",x1:.9,y1:0,x2:.6,y2:1}},{time:je,value:e,interpolation:{type:"hold"}}])}function Ze(e,t,n){return Ke*qe*(e+t/Be+n/He)}function Ye(e,t){return Ke*Ge*(e+t/Ve)}function Je(e,t){return Ke*ze*(e+t/Qe)}const et=["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 tt(e){null!=e&&(e.dispose(),et.forEach((t=>{var n;return null===(n=e[t])||void 0===n?void 0:n.dispose()})))}let nt;const ot=0,rt=3;let it,at,st,lt=!1,ct=1,ut=1,dt=1;const ht=1;let pt;const ft=new Map;function mt(e,n,o){const r=e.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,u,d,h,p,f,m,g,v,w,y,b=!1,E=!1,A=!1,S=!0,M=!1,R=1,T=!0,x=!1,P=0,j=0,V=1,Q=1,H=1;const K={threeInit:()=>{b||(gt(),i=new at.Scene,a=new at.PerspectiveCamera(25,1,.5),s=new it.OrbitControls(a,e),s.setInteractionEnabled(T),h=at.ACESFilmicToneMapping,({renderShadow:c,shadowGroup:l}=function(e){const t=new F.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new F.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new F.Group;o.position.y=-.7;const r=new F.PlaneGeometry(D,O).rotateX(Math.PI/2),i=new F.MeshBasicMaterial({map:t.texture,opacity:W,transparent:!0,depthWrite:!1}),a=new F.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new F.Mesh(r);s.visible=!1,o.add(s);const l=new F.OrthographicCamera(-D/2,D/2,O/2,-O/2,0,_);function c(e){s.visible=!0,z.uniforms.tDiffuse.value=t.texture,z.uniforms.h.value=1*e/256,s.material=z,q.setRenderTarget(n),q.render(s,l),B.uniforms.tDiffuse.value=n.texture,B.uniforms.v.value=1*e/256,s.material=B,q.setRenderTarget(t),q.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,o.add(l),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=G;const o=q.getClearAlpha();q.setClearAlpha(0),q.setRenderTarget(t),q.render(e,l),e.overrideMaterial=null,c(N),c(.4*N),q.setRenderTarget(null),q.setClearAlpha(o),e.background=n}}}(i)),b=!0)},threeParse:(e,n,o)=>t(this,void 0,void 0,(function*(){return null!=u&&d===o||(yield u,u=(()=>t(this,void 0,void 0,(function*(){var t,o,r;return o=it,$||(I=o.THREE,k=new o.RGBELoader,$=!0),null===(t=i.environment)||void 0===t||t.dispose(),i.environment=U(n),function(e,t){if(L)return;const{THREE:n}=t;C=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder),L=!0}(pt,it),r=e,C.parseAsync(r.buffer,"")})))(),d=o),u})),threeLoad:(e,t)=>{yt(i),i.add(e.scene);const n=(new at.Box3).setFromObject(e.scene);l.position.y=n.min.y-ot,i.add(l),c(),E=!1,i.traverse((e=>{if(e instanceof at.Mesh){e.material.depthWrite=!0;const t=e.material;Array.isArray(t)?t.forEach((e=>{e.transmission>0&&(E=!0)})):t.transmission>0&&(E=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(it.reduceVertices(e.scene,((e,t)=>Math.max(e,o.distanceToSquared(t))),0));s.reset(o,r,function(e,t){var n;const o={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?o.Glasses:null!==(n=o[e])&&void 0!==n?n:o.Glasses).normalize()}(t,at.Vector3)),P=0,y="Watches"===t?function(e){const t=e.getObjectByName("hours"),n=e.getObjectByName("minutes"),o=e.getObjectByName("seconds");if(null==t&&null==n&&null==o)return null;let r,i,a,s,l,c;return{start:()=>{r=new Date,r.setMilliseconds(r.getMilliseconds()+je),l=!1;const e=r.getHours(),t=r.getMinutes(),n=r.getSeconds(),o=r.getMilliseconds();i=Xe(Ze(e,t,n)),a=Xe(Ye(t,n)),s=Xe(Je(n,o)),c=new Date},update:()=>{if(null==r)return!1;const e=new Date;if(!l){if(r.getTime()-e.getTime()>0){const r=Math.abs(e.getTime()-c.getTime());return null!=t&&(i.update(r),t.rotation.y=i.get()),null!=n&&(a.update(r),n.rotation.y=a.get()),null!=o&&(s.update(r),o.rotation.y=s.get()),c=e,!0}l=!0}if(Math.abs(e.getTime()-c.getTime())<Qe/We)return!1;c=e;const u=e.getHours(),d=e.getMinutes(),h=e.getSeconds(),p=e.getMilliseconds();return null!=t&&(t.rotation.y=Ze(u,d,h)),null!=n&&(n.rotation.y=Ye(d,h)),null!=o&&(o.rotation.y=Je(h,p)),!0}}}(e.scene):null},threePaused:()=>S,threeResume:()=>{S=!1,pt.setAnimationLoop(vt),e.style.visibility="visible",j=0,null==f||f.reset(),null==m||m.reset(),null==g||g.reset(),null==v||v.reset(),null==w||w.reset(),null==y||y.start()},threePause:()=>{S=!0,function(){for(const{threePaused:e}of ft.values())if(!e())return!1;return!0}()&&pt.setAnimationLoop(null),e.style.visibility="hidden",o.style.opacity="0",n.style.visibility="hidden"},threeDestroy:()=>{var t;yt(i),null===(t=i.environment)||void 0===t||t.dispose(),i.environment=null,i=null,u=null,y=null,ft.delete(e)},threeSetZoomEnabled:e=>{s.enableZoom=e},threeSetForcedTransparency:e=>{A=e},threeSetToneMapping:(e,t)=>{const n={ACES:at.ACESFilmicToneMapping,Linear:at.LinearToneMapping,Neutral:at.NeutralToneMapping};null!=n[e]&&(h=n[e]),R=t},threeIsInteractive:()=>T,threeSetInteractive:e=>{T=e,null==s||s.setInteractionEnabled(T)},threeSetOnInteracted:e=>{s.removeEventListener("change",p),p=e,s.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=s.getTheta(),f=le([{time:0,value:e,interpolation:De},{time:ke,value:e,interpolation:Ne},{time:ke+Le/4,value:e+Ue,interpolation:Oe},{time:ke+3*Le/4,value:e-Ue,interpolation:_e},{time:ke+Le,value:e,interpolation:De},{time:ke+2*Le,value:e,interpolation:De}]),s.setTheta(f.get()),m=null,g=null,v=le([{time:0,value:0,interpolation:De},{time:ke,value:1,interpolation:De},{time:ke+Le,value:0,interpolation:De},{time:ke+2*Le,value:0,interpolation:De}]),w=le([{time:0,value:0,interpolation:De},{time:ke,value:0,interpolation:Ne},{time:ke+Le/4,value:-$e,interpolation:Oe},{time:ke+3*Le/4,value:$e,interpolation:_e},{time:ke+Le,value:0,interpolation:De},{time:ke+2*Le,value:0,interpolation:De}])},threeInitThetaAnimation:e=>{f=e,null!=e&&s.setTheta(e.get())},threeInitPhiAnimation:e=>{m=e,null!=e&&s.setPhi(e.get())},threeInitFovAnimation:e=>{g=e,null!=e&&s.setFovRadians(e.get())},threeRenderOnce:()=>{K.render_()},preRender_:t=>{if(!b||S||!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)}(e))return;let n=0!==j?t-j:0;j=t,0===P?M=!0:P<rt&&(n=0),P++,x||(s.hasUserInteracted()?(x=!0,f=null,m=null,g=null,v=null,w=null):(null==f||f.update(n),null==m||m.update(n),null==g||g.update(n),null==v||v.update(n),null==w||w.update(n),null!=f&&(s.setTheta(f.get()),M=!0),null!=m&&(s.setPhi(m.get()),M=!0),null!=g&&(s.setFovRadians(g.get()),M=!0))),s.update()&&(M=!0),(null==y?void 0:y.update())&&(M=!0)},shouldRender_:()=>!(!b||S)&&M,render_:()=>{const t=pt.toneMapping,s=pt.toneMappingExposure;pt.toneMapping=h,pt.toneMappingExposure=R,pt.setViewport(0,0,e.width,e.height),pt.setClearColor(new at.Color(16777215),E&&!A?1:0),pt.render(i,a),pt.toneMapping=t,pt.toneMappingExposure=s,M=!1,null!=r&&(r.clearRect(0,0,e.width,e.height),st.width>0&&st.height>0&&r.drawImage(st,0,ut-e.height,e.width,e.height,0,0,e.width,e.height),n.style.visibility=T&&!x?"visible":"hidden",null!=v&&(o.style.opacity=`${v.get()}`),null!=w&&(o.style.transform=`translateX(${w.get()*Math.min(V,Q)}px)`))},updateSize_:()=>{const{clientWidth:t,clientHeight:n}=e;t===V&&n===Q&&dt===H||(e.width=Math.ceil(t*dt*ht),e.height=Math.ceil(n*dt*ht),V=t,Q=n,H=dt,M=!0)},target_:e};return ft.set(e,K),K}function gt(){if(lt)return;it=window.ShopAR__THREE,at=it.THREE,st=document.createElement("canvas");var e,t;st.style.position="block",pt=new at.WebGLRenderer({powerPreference:"high-performance",canvas:st,antialias:!0,alpha:!0}),pt.outputColorSpace=at.SRGBColorSpace,pt.toneMapping=at.ACESFilmicToneMapping,pt.setClearColor(new at.Color(16777215),0),e=pt,t=it,V||(F=t.THREE,q=e,G=new F.MeshDepthMaterial,G.userData.darkness={value:j},G.onBeforeCompile=e=>{e.uniforms.darkness=G.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}`},G.depthTest=!1,G.depthWrite=!1,z=new F.ShaderMaterial(t.HorizontalBlurShader),z.depthTest=!1,B=new F.ShaderMaterial(t.VerticalBlurShader),B.depthTest=!1,V=!0),wt(),lt=!0}function vt(e){wt(),pt.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of ft.values())t(e),n()&&o()}function wt(){let e=0,t=0;for(const{target_:n}of ft.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=P();e=Math.ceil(e*n*ht),t=Math.ceil(t*n*ht),e===ct&&t===ut&&n===dt||(ct=e,ut=t,dt=n,pt.setSize(ct,ut,!1));for(const{updateSize_:e}of ft.values())e()}function yt(e){e.traverse((e=>{var t;e instanceof at.Mesh&&(null===(t=e.geometry)||void 0===t||t.dispose(),Array.isArray(e.material)?e.material.forEach(tt):tt(e.material))})),e.clear()}const bt={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},Et=Object.keys(bt);function At(e){return bt[e]}const St="shopar-error";function Mt(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn",r.appendChild(o);{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;const i=r.style;return i.display="none",i.pointerEvents="auto",r}const Rt="shopar-control";const Tt="shopar-deepar-output";function xt(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 Pt(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function Ct(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 It(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 Lt="shopar-qr-output";function $t(e){var t,n;const o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.setAttribute("width",null!==(t=e.getAttribute("width"))&&void 0!==t?t:"1rem"),o.setAttribute("height",null!==(n=e.getAttribute("height"))&&void 0!==n?n:"1rem"),o.appendChild(e),o}function Ut(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 Dt="shopar-three-output";var Ot;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(Ot||(Ot={}));let _t=!1;function Nt(){_t||(!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.")}}(),_t=!0)}function jt(){Nt();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}(),o=function(e,t){const n=document.createElement("div");n.id=Lt;const o=n.style;o.position="absolute",o.top="0",o.left="0",o.width="100%",o.height="100%",o.display="none",o.pointerEvents="auto",o.userSelect="none";const r=document.createElement("div");r.className="shopar-qr";const i=r.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(r),r.appendChild(e);const a=document.createElement("div");return a.appendChild(t),r.appendChild(a),n}(t,n);e.appendChild(o);const r=function(){const e=document.createElement("div");e.id=Tt;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",t.pointerEvents="auto",e}();e.appendChild(r);const i=function(){const e=document.createElement("canvas");e.id=Dt,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const a=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),s=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),l=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:o}=n;return o.position="absolute",o.width="100%",o.height="100%",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(a,s);e.appendChild(l);const c=function(){const e=$t(Ut("2rem",`${R}/img/prompt/3d-interaction.svg`)),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),u=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",t.appendChild(e),t}(c);e.appendChild(u);const d=xt("shopar-ar-loading-container"),h=Pt("shopar-ar-loading-text",At("loading.ar"));d.appendChild(h);const p=Ct("shopar-ar-loading-bar-bg"),f=It("shopar-ar-loading-bar-fg");p.appendChild(f),d.appendChild(p),e.appendChild(d);const m=xt("shopar-3d-loading-container"),g=Pt("shopar-3d-loading-text",At("loading.3d"));m.appendChild(g);const v=Ct("shopar-3d-loading-bar-bg"),w=It("shopar-3d-loading-bar-fg");v.appendChild(w),m.appendChild(v),e.appendChild(m);const y=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",t.backgroundSize="contain",t.backgroundRepeat="no-repeat",t.backgroundPosition="center",e}();e.appendChild(y);const b=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),E=function(e){const t=document.createElement("div");t.id=St;const n=t.style;n.position="absolute",n.width="100%",n.height="100%",n.display="none",n.pointerEvents="auto",n.userSelect="none";const o=document.createElement("div"),r=o.style;return r.position="absolute",r.width="100%",r.height="100%",r.backgroundColor="#ffffff",r.display="flex",r.flexDirection="column",r.justifyContent="center",r.alignItems="center",t.appendChild(o),o.appendChild(e),t}(b);e.appendChild(E);const A=function(){const e=document.createElement("div");return e.id=Rt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(A);const S=Ut("1.75rem"),M=Mt("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on",$t(S));A.appendChild(M);const T=Ut("1.75rem"),x=Mt("shopar-btn-3d","3D","Launch ShopAR 3D preview",$t(T));A.appendChild(x);const P=Ut("1.75rem"),C=Mt("shopar-btn-close","Close","Close ShopAR view",$t(P));A.append(C);let I,k,L=Ot.None,$=!1,U=!1,D=!1,O=!1;function _(){f.classList.remove("active"),d.style.visibility="hidden"}function N(){y.style.visibility="hidden",w.classList.remove("active"),m.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return o},getQRImage:function(){return n},getDeepARTarget:function(){return r},getDeepARPrompt:function(){return l},getThreeTarget:function(){return i},getThreePrompt:function(){return u},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){a.textContent=e,s.src=t},customizeCameraError:function(e){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,o,r,i){var a;$=e,U=t,D=n,O=o,I=r,k=i,Wt(A,$),Wt(M,$&&(D||U)&&L===Ot.None),Wt(x,$&&O&&L===Ot.None),Wt(C,$&&L!==Ot.None),_(),N(),$||""===(a=E).style.display&&Wt(a,!1)},getUIState:function(){return L},setUIState:function(e){L=e,L===Ot.None?(_(),N(),$&&(Wt(E,!1),Wt(C,!1),(U||D)&&Wt(M,!0),O&&Wt(x,!0))):L===Ot.QR||L===Ot.AR?$&&(Wt(E,!1),Wt(M,!1),Wt(x,O&&"AR"===k),Wt(C,"AR"!==k)):L===Ot.Preview&&$&&(Wt(E,!1),Wt(M,(U||D)&&"3D"===k),Wt(x,!1),Wt(C,"3D"!==k))},setDefaultUIActions:function(e,t,n){$&&((U||D)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${R}/img/icons/${n}`;S.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(I),M.onclick=e),O&&(T.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${R}/img/icons/cube.svg`),x.onclick=t),P.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${R}/img/icons/close.svg`),C.onclick=n)},startDeepARLoading:function(){f.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:_,startThreeLoading:function(){null!=y.dataset.bgSet?y.style.visibility="visible":(w.classList.add("active"),m.style.visibility="visible")},stopThreeLoading:N,setThreePosterUrl:function(e){null!=e?(y.style.backgroundImage=`url(${e})`,y.dataset.bgSet="true"):delete y.dataset.bgSet},showCameraError:function(){$&&Wt(E,!0)}}}function Wt(e,t){e.style.display=t?"":"none"}const Ft=new Map;function qt(e){let n=Ft.get(e);return null==n?(n=function(){let e=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=jt()),n);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:e,getQRImage:n}=i();o=function(e,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>t(this,void 0,void 0,(function*(){yield x;const t=`https://ar.shopar.ai/${S.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:r,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(t),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,o=!1,e.style.display=""})),qrPause:()=>t(this,void 0,void 0,(function*(){o=!0,e.style.display="none"}))}}(e(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=mt(e(),t(),n())}return r}}}(),Ft.set(e,n)):n.incrementSetupId_(),n}function Gt(e){for(const t of Ft.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===Ot.AR&&r(Ot.None)}}let zt;const Bt=new Uint8Array(16);function Vt(){if(!zt&&(zt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!zt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return zt(Bt)}const Qt=[];for(let e=0;e<256;++e)Qt.push((e+256).toString(16).slice(1));var Ht={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Kt(e,t,n){if(Ht.randomUUID&&!t&&!e)return Ht.randomUUID();const o=(e=e||{}).random||(e.rng||Vt)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function(e,t=0){return Qt[e[t+0]]+Qt[e[t+1]]+Qt[e[t+2]]+Qt[e[t+3]]+"-"+Qt[e[t+4]]+Qt[e[t+5]]+"-"+Qt[e[t+6]]+Qt[e[t+7]]+"-"+Qt[e[t+8]]+Qt[e[t+9]]+"-"+Qt[e[t+10]]+Qt[e[t+11]]+Qt[e[t+12]]+Qt[e[t+13]]+Qt[e[t+14]]+Qt[e[t+15]]}(o)}const Xt="qrLaunch",Zt="arLaunch",Yt="previewLaunch",Jt="heartbeat";let en,tn,nn=!1,on=window.navigator.userAgent||"no user agent";const rn=[];function an(){null==en&&(tn=Kt(),en=T(`${R}/shopar-analytics.js`),en.then((()=>{nn=!0,window.ShopAR__analytics.initializeImpl(),rn.forEach((e=>e()))})))}function sn(e){nn?e():rn.push(e)}function ln(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function cn(e){return t(this,void 0,void 0,(function*(){const t=document.createElement("video");return t.setAttribute("playsinline","playsinline"),t.srcObject=yield e,t}))}const un=200,dn=10;let hn=!1,pn=null,fn=[],mn=[];function gn(e){return t(this,void 0,void 0,(function*(){hn=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${R}/wasm/mediapipe`,e),pn&&clearInterval(pn);const o=[],r=[];pn=setInterval((()=>t(this,void 0,void 0,(function*(){if(hn)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());hn||(null!=a&&null!=s&&function(e){for(let t of fn)t(e)}({translation:a,rotation:s}),null==e&&(o.push(t),r.push(i),o.length<dn||(o.shift(),r.shift(),function(e,t){for(let n of mn)n({faceWidth:e,IPD:t})}(wn(o),wn(r)))))}))),un)}))}function vn(){mn=[],fn=[],hn=!0}function wn(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}var yn="undefined"!=typeof Float32Array?Float32Array:Array;function bn(){var e=new yn(16);return yn!=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 En(e,t,n){var o=t[0],r=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],E=n[2],A=n[3];return e[0]=y*o+b*s+E*d+A*m,e[1]=y*r+b*l+E*h+A*g,e[2]=y*i+b*c+E*p+A*v,e[3]=y*a+b*u+E*f+A*w,y=n[4],b=n[5],E=n[6],A=n[7],e[4]=y*o+b*s+E*d+A*m,e[5]=y*r+b*l+E*h+A*g,e[6]=y*i+b*c+E*p+A*v,e[7]=y*a+b*u+E*f+A*w,y=n[8],b=n[9],E=n[10],A=n[11],e[8]=y*o+b*s+E*d+A*m,e[9]=y*r+b*l+E*h+A*g,e[10]=y*i+b*c+E*p+A*v,e[11]=y*a+b*u+E*f+A*w,y=n[12],b=n[13],E=n[14],A=n[15],e[12]=y*o+b*s+E*d+A*m,e[13]=y*r+b*l+E*h+A*g,e[14]=y*i+b*c+E*p+A*v,e[15]=y*a+b*u+E*f+A*w,e}function An(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Sn(e,t){var n=t[0],o=t[1],r=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,u),e}function Mn(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,u=a+a,d=r*l,h=r*c,p=r*u,f=i*c,m=i*u,g=a*u,v=s*l,w=s*c,y=s*u,b=o[0],E=o[1],A=o[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*E,e[5]=(1-(d+g))*E,e[6]=(m+v)*E,e[7]=0,e[8]=(p+w)*A,e[9]=(m-v)*A,e[10]=(1-(d+f))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Rn(){var e=new yn(3);return yn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Tn(e,t,n){var o=new yn(3);return o[0]=e,o[1]=t,o[2]=n,o}function xn(e,t){var n=t[0]-e[0],o=t[1]-e[1],r=t[2]-e[2];return Math.hypot(n,o,r)}function Pn(e,t,n){var o=t[0],r=t[1],i=t[2],a=n[3]*o+n[7]*r+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*o+n[4]*r+n[8]*i+n[12])/a,e[1]=(n[1]*o+n[5]*r+n[9]*i+n[13])/a,e[2]=(n[2]*o+n[6]*r+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Cn(){var e=new yn(4);return yn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Rn(),function(){var e,t=(e=new yn(4),yn!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var In;let kn,Ln,$n;Rn(),Tn(1,0,0),Tn(0,1,0),Cn(),Cn(),In=new yn(9),yn!=Float32Array&&(In[1]=0,In[2]=0,In[3]=0,In[5]=0,In[6]=0,In[7]=0),In[0]=1,In[4]=1,In[8]=1;let Un,Dn,On,_n,Nn=!0,jn=null;const Wn=new Set;let Fn,qn,Gn,zn,Bn,Vn;function Qn(){null==kn&&(kn=T(`${R}/shopar-deepar.js`))}function Hn(){null==Ln&&(Ln=T(`${R}/shopar-true-scale.js`))}function Kn(e){return t(this,void 0,void 0,(function*(){const{licenseKey:o,truescaleUsecase:r}=e;return Bn=r,null==Fn&&(Fn=(()=>t(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new n("No camera available!");var e;const t=ro(On),r=ln(t);Un=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:o||"your_license_key_goes_here",previewElement:_n,additionalOptions:{hint:Vn,cameraConfig:{disableDefaultCamera:!0}}}),Dn=yield cn(r),yield io(Un,Dn,"user"===t),"Glasses"===On&&(yield Ln,gn(Dn),"DetectionLoop"!==Bn&&co((e=>{zn=e.faceWidth})))})))()),Fn}))}function Xn(e,t){var n,o;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===On&&(n=t,o=Vn,n===o||null!=n&&null!=o&&n.length===o.length&&n.every((e=>o.find((t=>e===t))))&&o.every((e=>n.find((t=>t===e))))))||(null!=Un&&(Un.shutdown(),Un=null,Fn=null),On=e,Vn=t)}function Zn(e){e!==_n&&(_n=e,null!=Un&&Un.changePreviewElement(_n))}function Yn(e){jn=e}function Jn(e){Un.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(zn){const e=137/(zn+5);Un.changeParameterVector("GLASSES","","scale",e,e,e,0),Un.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const o=so("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=so("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);Un.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),Un.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return}}(e),vn(),zn=null}e(),ao("Glasses")}},Un.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),ao("Shoes"))},Un.callbacks.onWristTracked=t=>{t.detected&&(e(),ao("Watches"))}}function eo(e,n,o){return t(this,void 0,void 0,(function*(){return null!=qn&&Gn===o||(yield qn,qn=Un.switchEffect(e,{envmap:n}),Gn=o),qn}))}function to(e,t){null!=e&&null!=t&&(Un.setToneMapping(e),Un.setExposure(t))}function no(){return t(this,void 0,void 0,(function*(){if(null!=Un){if(Nn=!1,null==Dn){const e=ro(On),t=ln(e);Dn=yield cn(t),yield io(Un,Dn,"user"===e),"Glasses"===On&&(gn(Dn),"DetectionLoop"!==Bn&&co((e=>{zn=e.faceWidth})))}!function(){if(null==jn)return;if(null==On||Wn.has(On))return;jn.style.visibility="visible",jn.style.opacity="1"}(),Un.setPaused(Nn),_n.style.display=""}}))}function oo(){null!=Un&&(Nn=!0,Un.setPaused(Nn),vn(),null!=Dn&&null!=Dn.srcObject&&Dn.srcObject instanceof MediaStream&&(Dn.srcObject.getTracks().forEach((e=>e.stop())),Dn=null),function(){if(null==jn)return;jn.style.visibility="hidden",jn.style.opacity="0"}(),Un.stopCamera(),_n.style.display="none")}function ro(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function io(e,n,o){return t(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>t(this,void 0,void 0,(function*(){e.setVideoElement(n,o),r()}))))}}))}))}function ao(e){null!=jn&&(Wn.has(e)||(Wn.add(e),jn.style.opacity="0"))}function so(e,t,n,o,r,i,a){const s=Un.getTransformationBetween(e,t),l=An(Rn(),s),c=function(e,t){var n=new yn(3);Sn(n,t);var o=1/n[0],r=1/n[1],i=1/n[2],a=t[0]*o,s=t[1]*r,l=t[2]*i,c=t[4]*o,u=t[5]*r,d=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>u&&a>f?(g=2*Math.sqrt(1+a-u-f),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):u>f?(g=2*Math.sqrt(1+u-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+f-a-u),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(d+p)/g,e[2]=.25*g),e}(Cn(),s);Mn(s,c,l,Tn(a,a,a));const u=Un.getTransformationBetween(t,n),d=An(Rn(),u);Mn(u,Cn(),d,Sn(Rn(),u));const h=En(bn(),s,u),p=An(Rn(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=Un.getTransformationBetween(n,o)}catch(e){return f}const g=En(bn(),u,m),v=En(bn(),s,g),w=Tn(p[0],i[1],i[2]),y=Pn(Rn(),w,function(e,t){var n=t[0],o=t[1],r=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-o*a,y=n*l-r*a,b=n*c-i*a,E=o*l-r*s,A=o*c-i*s,S=r*c-i*l,M=u*m-d*f,R=u*g-h*f,T=u*v-p*f,x=d*g-h*m,P=d*v-p*m,C=h*v-p*g,I=w*C-y*P+b*x+E*T-A*R+S*M;return I?(I=1/I,e[0]=(s*C-l*P+c*x)*I,e[1]=(r*P-o*C-i*x)*I,e[2]=(m*S-g*A+v*E)*I,e[3]=(h*A-d*S-p*E)*I,e[4]=(l*T-a*C-c*R)*I,e[5]=(n*C-r*T+i*R)*I,e[6]=(g*b-f*S-v*y)*I,e[7]=(u*S-h*b+p*y)*I,e[8]=(a*P-s*T+c*M)*I,e[9]=(o*T-n*P-i*M)*I,e[10]=(f*A-m*b+v*w)*I,e[11]=(d*b-u*A-p*w)*I,e[12]=(s*R-a*x-l*M)*I,e[13]=(n*x-o*R+r*M)*I,e[14]=(m*y-f*E-g*w)*I,e[15]=(u*E-d*y+h*w)*I,e):null}(bn(),v));let b=Un.getClosestPointOnMesh(o,y);try{const e=Un.getClosestPointOnMesh(r,y);xn(y,e)<xn(y,b)&&(b=e)}catch(e){}const E=Pn(Rn(),b,g);return f-Math.atan2(E[0]-d[0],Math.abs(E[2]-d[2]))}function lo(e){!function(e){fn.push(e)}(e)}function co(e){!function(e){mn.push(e)}(e)}var uo;function ho(){return[uo.Android,uo.iOS,uo.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],o=["Win32","Win64","Windows","WinCE"],r=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==r.indexOf(t)?uo.iOS:-1!==n.indexOf(t)?i?uo.Tablet:uo.MacOS:-1!==o.indexOf(t)?uo.Windows:/Android/.test(e)?uo.Android:/Linux/.test(t)?uo.Linux:i?uo.Tablet:uo.Unknown}return uo.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"}(uo||(uo={}));const po=["AR","3D"];function fo(e,t){if(null==e)throw new n(`'${t}' not specified.`)}function mo(e,t){if("boolean"!=typeof e)throw new n(`'${t}' must be a boolean.`)}function go(e,t){if("string"!=typeof e)throw new n(`'${t}' must be a string.`)}function vo(e){const{apiKey:t,sku:o,targetElement:r,initialState:i,initialAnimation:a,baseUrl:s,defaultUI:l,interactive:c,strings:u}=e;fo(t,"apiKey"),go(t,"apiKey"),fo(o,"sku"),go(o,"sku"),fo(r,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new n(`'${t}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,t,o){if("string"!=typeof e)throw new n(`'${t}' must be a string.`);if(!o.includes(e))throw new n(`'${t}' must be ${o.join("' or '")}.`)}(i,"initialState",po),null!=a&&function(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new n(`'${t}' must be a string or array.`)}(a,"initialAnimation"),null!=s&&go(s,"baseUrl"),null!=l&&mo(l,"defaultUI"),null!=c&&mo(c,"interactive"),null!=u&&function(e,t,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new n(`Value for key '${r}' in '${t}' must be a string.`)}}(u,"strings",Et)}let wo=!1;function yo(e){return t(this,void 0,void 0,(function*(){const{targetElement:o}=e;R.update(e.baseUrl),an();const{trackEvent:r}=function(e){const t=performance.now(),n=Kt();return{trackEvent:(o,r={})=>{r=Object.assign(Object.assign({},r),{pluginVersion:S,userAgent:on,sessionId:tn,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),sn((()=>{window.ShopAR__analytics.trackEventImpl(o,r)}))}}}(e.apiKey);r("visionSetup");const i=yield function(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:e,sid:d()})}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield o.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(e.apiKey);r("visionApiResponse",i);const{arKey:a}=i,s=qt(o),{getSetupId:l,findUI:c}=s,u=l();Qn(),Hn();const{setTargetElement:h,getDeepARTarget:p,setVisibilityParameters:m,getUIState:g,setUIState:v,startDeepARLoading:w,stopDeepARLoading:y,showCameraError:b}=c();if(g()!=Ot.None)throw Error("UI state is not None, this is weird..");v(Ot.AR),h(o),m(!1,!1,!0,!1,void 0,void 0),w(),yield kn,bo(l(),u);try{r("visionArLaunch"),oo(),Xn("Glasses",["faceInit"]),Zn(p()),yield Kn({licenseKey:a,truescaleUsecase:"DetectionLoop"}),bo(l(),u),yield no(),bo(l(),u)}catch(e){const t=e instanceof Error;throw r("visionArLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),b(),oo(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{y()}return wo=!0,{registerFacePoseListener:e=>{wo&&(r("registerFacePoseListener"),lo(e))},registerFaceMeasurementListener:e=>{wo&&(r("registerFaceMeasurementListener"),co(e))},switchEffect:e=>t(this,void 0,void 0,(function*(){wo&&(r("switchEffect",{arUrl:e}),function(e){Un.switchEffect(e)}(e))})),clearEffect:()=>{wo&&(r("clearEffect"),Un.clearEffect())},close:()=>{if(wo){if(wo=!1,r("visionClose"),g()!==Ot.AR)throw new n("AR not launched.");oo(),v(Ot.None)}}}}))}function bo(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}function Eo(e){var o,r;return t(this,void 0,void 0,(function*(){vo(e);const{apiKey:i,sku:a,targetElement:s,initialState:l,initialAnimation:c}=e,u=null==e.zoomEnabled||e.zoomEnabled,h=!0===e.alwaysTransparentBackground;!function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new n(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(s),R.update(e.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(bt,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(bt[t]=n)}}(e.strings);const p=null!=c?Re(c):null,y=null!=(null==p?void 0:p.theta)?le(p.theta):null,b=null!=(null==p?void 0:p.phi)?le(p.phi):null,M=null!=(null==p?void 0:p.fov)?le(p.fov):null,P=function(e,o,r,i,a,s){return t(this,void 0,void 0,(function*(){const l=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:e,sku:o,sid:d()},null!=r&&{yaw:`${g(m(r))}`}),null!=i&&{pitch:`${g(m(i))}`}),null!=a&&{fov:`${g(m(a))}`}),s&&{forcedTransparency:`${s}`}))}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield l.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(i,a,null==y?void 0:y.get(),null==b?void 0:b.get(),null==M?void 0:M.get(),h),C=qt(s),{getSetupId:I,findUI:k,findQR:L,findThree:$}=C,U=I();an();const{trackEvent:D,arInteracted:O,previewInteracted:_}=function(e,t){const n=performance.now(),o=Kt();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,u(Jt,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const u=(r,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:on,pluginVersion:S,sessionId:tn,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),sn((()=>{window.ShopAR__analytics.trackEventImpl(r,i)}))};return{trackEvent:u,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}(a,i);D("setup",{hostname:window.location.hostname});const N=yield P;D("apiResponse",N);const{category:j,arUrl:W,arEnvUrl:F,arToneMapping:q,arToneMappingExposure:G,arKey:z,arPromptEnabled:B,arPromptText:V,arPromptImage:Q,previewUrl:H,previewEnvUrl:K,previewToneMapping:X,previewToneMappingExposure:Z,previewPosterUrl:Y,cameraErrorText:J,qrPromptText:ee}=N;Ao(I(),U);const te=null!=W&&function(e){return null!=e&&v.includes(e)}(j),ne=null==(null===(o=e._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=e._internalOptions)||void 0===r?void 0:r.qrEnabled),oe=te&&function(e){return null!=e&&w.includes(e)}(j),re=ne&&oe&&!ho(),ie=te&&!re,ae=null!=H;Ao(I(),U);const{setTargetElement:se,getDeepARTarget:ce,getDeepARPrompt:ue,customizeDeepARPrompt:de,customizeCameraError:he,customizeQRPrompt:pe,setVisibilityParameters:fe,getUIState:me,setUIState:ge,setDefaultUIActions:ve,startDeepARLoading:we,stopDeepARLoading:ye,startThreeLoading:be,stopThreeLoading:Ee,setThreePosterUrl:Ae,showCameraError:Se}=k();se(s);if(fe(null==e.defaultUI||e.defaultUI,re,ie,ae,j,l),de(null!=V?V:"",null!=Q?Q:""),he(J),pe(ee),Ae(Y),re&&function(){t(this,void 0,void 0,(function*(){null==x&&(x=T(`${R}/shopar-qr.js`))}))}(),ie&&(Qn(),function(e){e!==$n&&($n=e,E(e),qn=null,vn())}(W),"Glasses"===j&&Hn(),null!=F&&E(F)),ae){null==nt&&(nt=T(`${R}/shopar-three.js`));const e=255;A(H,(new Date).getTime()+e,Math.random()*e),E(null!=K?K:`${R}/env/default.hdr`)}!function(e,t){const o=e.parentNode;if(null==o)throw new n("Parent node missing.");new MutationObserver((n=>{for(const o of n)for(const n of o.removedNodes)if(n===e)return void t()})).observe(o,{childList:!0})}(s,(()=>{me()!==Ot.QR||Me()||xe(),me()!==Ot.AR||Nn||oo(),me()!==Ot.Preview||ke()||$e(),ge(Ot.None),Ue(),function(e){Ft.delete(e)}(s)}));const{qrPaused:Me,qrDraw:Te,qrPause:xe}=L(),{threeInit:Pe,threeParse:Ce,threeLoad:Ie,threePaused:ke,threeResume:Le,threePause:$e,threeDestroy:Ue,threeSetZoomEnabled:De,threeSetForcedTransparency:Oe,threeSetToneMapping:_e,threeIsInteractive:Ne,threeSetInteractive:je,threeSetOnInteracted:We,threeInitPromptAnimation:Fe,threeInitThetaAnimation:qe,threeInitPhiAnimation:Ge,threeInitFovAnimation:ze,threeRenderOnce:Be}=$(),Ve=null==e.interactive||e.interactive;je(Ve);let Qe=0;if(me()===Ot.QR){if(!Me())if(re){D(Xt);try{yield Te(i,a)}catch(e){throw new n(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else xe(),ge(Ot.None)}else if(me()===Ot.AR){if(!Nn)if(ie&&!wo){D(Zt);const e=null!=F?yield E(F):void 0;Ao(I(),U);const t=yield E(W);Ao(I(),U),Gt(C),Xn(j),Zn(ce()),Yn(B?ue():null),yield eo(t,e,`${W}${F}`),to(q,G),Jn(O),Ao(I(),U)}else oo(),ge(Ot.None)}else if(me()===Ot.Preview&&!ke())if(ae){D(Yt),be();const e=255,t=yield A(H,(new Date).getTime()+e,Math.random()*e);Ao(I(),U);const n=yield E(null!=K?K:`${R}/env/default.hdr`);Ao(I(),U);const o=yield Ce(t,n,`${H}${K}`);Ao(I(),U),Ie(o,j),De(u),Oe(h),_e(null!=X?X:"ACES",null!=Z?Z:1),We(_),Fe(),null!=p&&(qe(y),Ge(b),ze(M)),Be(),Le(),Ee()}else $e(),ge(Ot.None);const He=()=>t(this,void 0,void 0,(function*(){if(re)try{D(Xt);const e=++Qe;if(me()===Ot.Preview&&ae&&!ke()&&$e(),ge(Ot.QR),yield Te(i,a),Qe!==e)return;return void Ao(I(),U)}catch(e){const t=e instanceof Error;throw D("qrLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`QR failed: ${t?e.message:"Unknown error."}`)}if(!ie)throw new n("Model does not have AR enabled.");try{D(Zt);const e=++Qe;me()===Ot.Preview&&ae&&!ke()&&$e(),Gt(C),ge(Ot.AR),we();const t=null!=F?yield E(F):void 0;Ao(I(),U);const n=yield E(W);if(Qe!==e)return;if(Ao(I(),U),yield kn,Qe!==e)return;if(Ao(I(),U),oo(),Xn(j),Zn(ce()),Yn(B?ue():null),yield Kn({licenseKey:z}),Qe!==e)return;if(Ao(I(),U),yield eo(n,t,`${W}${F}`),to(q,G),Jn(O),Qe!==e)return;if(Ao(I(),U),yield no(),Qe!==e)return;Ao(I(),U)}catch(e){const t=e instanceof Error;throw D("arLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),Se(),oo(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{ye()}})),Ke=()=>t(this,void 0,void 0,(function*(){if(!ae)throw new n("Model does not have 3D enabled.");try{D(Yt);const e=++Qe;me()===Ot.AR&&(ie&&!Nn&&oo(),xe()),ge(Ot.Preview),be();const t=255,n=yield A(H,(new Date).getTime()+t,Math.random()*t);if(Qe!==e)return;Ao(I(),U);const o=yield E(null!=K?K:`${R}/env/default.hdr`);if(Qe!==e)return;if(Ao(I(),U),yield nt,Qe!==e)return;if(Ao(I(),U),Pe(),Qe!==e)return;Ao(I(),U);const r=yield Ce(n,o,`${H}${K}`);if(Qe!==e)return;Ao(I(),U),Ie(r,j),De(u),Oe(h),_e(null!=X?X:"ACES",null!=Z?Z:1),We(_),Fe(),null!=p&&(qe(y),Ge(b),ze(M)),Be(),Le(),Ee()}catch(e){const t=e instanceof Error;throw D("previewLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`3D failed: ${t?e.message:"Unknown error."}`)}})),Xe=()=>t(this,void 0,void 0,(function*(){me()!==Ot.None&&("AR"!==l||me()!==Ot.AR&&me()!==Ot.QR)&&("3D"===l&&me()===Ot.Preview||(++Qe,me()===Ot.QR||me()===Ot.AR?(ie&&!Nn&&oo(),xe()):me()===Ot.Preview&&ae&&!ke()&&$e(),ge(Ot.None),"AR"!==l?"3D"!==l||(yield Ke()):yield He()))}));return ve(He,Ke,Xe),"AR"===l?(yield He(),Ao(I(),U)):"3D"===l&&(yield Ke(),Ao(I(),U)),wo=!1,{launchAR:te?He:void 0,launch3D:ae?Ke:void 0,closeAR:te?()=>t(this,void 0,void 0,(function*(){me()!==Ot.AR&&me()!==Ot.QR||"AR"!==l&&(++Qe,ie&&!Nn&&oo(),xe(),ge(Ot.None),"3D"!==l||(yield Ke()))})):void 0,close3D:ae?()=>t(this,void 0,void 0,(function*(){me()===Ot.Preview&&"3D"!==l&&(++Qe,ae&&!ke()&&$e(),ge(Ot.None),"AR"!==l||(yield He()))})):void 0,close:te||ae?Xe:void 0,isInteractive:()=>Ne(),setInteractive:e=>je(e)}}))}function Ao(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}const So={setup:function(e){return t(this,void 0,void 0,(function*(){return yo(e)}))}},Mo={setup:function(e){return t(this,void 0,void 0,(function*(){return function(e,o){return t(this,void 0,void 0,(function*(){try{return o()}catch(t){throw t instanceof Error?new n(`${e} failed: ${t.message}`):(console.error(t),new n(`${e} failed.`))}}))}("setup",(()=>Eo(e)))}))},version:S};e.PREVIEW_STATES=po,e.PluginError=n,e.plugin=Mo,e.vision=So}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ShopAR={})}(this,(function(e){"use strict";function t(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}.shopar-3d{background-color:#fff}.shopar-3d-poster{background-color:#fff}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const o=[Uint8Array,Uint32Array],r=o.length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],a=[2,12,7,1],s=window[i[a[a[r]]]][i[a[a[a.length-1]]]],l=s.charCodeAt(r),c=l^l,u=new o[1]([c]);function d(){const e=(new TextEncoder).encode(s),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}const h=[1e3,2e3,4e3],p=h.length;function f(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=p)throw t;return yield new Promise((e=>setTimeout(e,h[n]))),f(e,n+1)}}))}function g(e){return e*(180/Math.PI)}function m(e){return Math.round(100*e)/100}const v=["Glasses","Shoes","Watches"],w=["Shoes"];const y={},b={};function E(e){return null==y[e]&&(y[e]=function(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new n("Resource unavailable.")}));if(!t.ok)throw new n(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield o.blob()).arrayBuffer()}catch(e){throw console.error(e),new n("Resource has invalid body.")}}))}(e)),y[e]}function A(e,r,i){return null==b[e]&&(b[e]=function(e,r,i){return t(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const l=String.fromCharCode(a+14);s>>=2,a^=s+2;const d=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const p=String.fromCharCode(a-7),g=window[`${h}${d+l+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${p}`],m=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield g(`${e}`).catch((()=>{throw new n("Unknown error.")}));if(!t.ok)throw new n("Unknown error.");return t})))),v=new o[0](yield(yield m.blob().catch((()=>{throw new n("Unknown error.")}))).arrayBuffer().catch((()=>{throw new n("Unknown error.")})));i+=s;const w=v.byteLength;if(u[c]=Math.min(76,r)*((a>>5)-1),152===u[c]&&(u[c]=w),i==c)return v;i=c,i^=c;for(let e=0,t=v.length;e<t;e++)u[c]^=u[i]<<13,u[c]^=u[i]>>17,u[c]^=u[i]<<5,v[e]=v[e]^u[c];return i^=u[0],i^=u[1],i^=u[2],v}))}(e,r,i)),b[e]}const S="0.7.4-alpha.0";let M=`https://cdn.jsdelivr.net/npm/shopar-plugin@${S}/dist`;const R={update:e=>{null!=e&&(M=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>M};function x(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}let T;function P(e,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>t(this,void 0,void 0,(function*(){!function(){t(this,void 0,void 0,(function*(){null==T&&(T=x(`${R}/shopar-qr.js`))}))}(),yield T;const a=`https://ar.shopar.ai/${S.includes("alpha")?"qr-alpha":"qr"}/?${new URLSearchParams({a:r,s:i,h:location.href})}`,s=yield window.ShopAR__QR.toDataURL(a),l=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=s,yield l,o=!1,e.style.display=""})),qrPause:()=>t(this,void 0,void 0,(function*(){o=!0,e.style.display="none"}))}}const C=(()=>{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 I,k,L,U=!1;let $=!1;function D(e){const t=function(e){const t=new k.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,k.ClampToEdgeWrapping,k.ClampToEdgeWrapping,k.LinearFilter,k.LinearFilter,1,k.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(L.parse(e));return t.mapping=k.EquirectangularReflectionMapping,t.colorSpace=k.LinearSRGBColorSpace,t}const O=45,_=45,N=3,j=1.5,W=1,F=.5;let q,G,z,B,V,Q=!1;const H=4,K=.001,X=1e-7,Z=10,Y=11,J=1/(Y-1),ee="function"==typeof Float32Array;function te(e,t,n,o){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===o)return se;const r=ee?new Float32Array(Y):new Array(Y);for(let t=0;t<Y;++t)r[t]=ie(t*J,e,n);function i(t){let o=0,i=1;const a=Y-1;for(;i!==a&&r[i]<=t;++i)o+=J;--i;const s=o+(t-r[i])/(r[i+1]-r[i])*J,l=ae(s,e,n);return l>=K?function(e,t,n,o){for(let r=0;r<H;++r){const r=ae(t,n,o);if(0===r)return t;t-=(ie(t,n,o)-e)/r}return t}(t,s,e,n):0===l?s:function(e,t,n,o,r){let i,a,s=0;do{a=t+(n-t)/2,i=ie(a,o,r)-e,i>0?n=a:t=a}while(Math.abs(i)>X&&++s<Z);return a}(t,o,o+J,e,n)}return function(e){return 0===e||1===e?e:ie(i(e),t,o)}}function ne(e,t){return 1-3*t+3*e}function oe(e,t){return 3*t-6*e}function re(e){return 3*e}function ie(e,t,n){return((ne(t,n)*e+oe(t,n))*e+re(t))*e}function ae(e,t,n){return 3*ne(t,n)*e*e+2*oe(t,n)*e+re(t)}function se(e){return e}function le(e){if("hold"===e.type)return()=>0;if("bezier"===e.type){const t=te(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 o=0,r=n[0].value;return{reset:()=>{o=0},update:e=>{for(o+=e;o>=t;)o-=t;for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(o>=t.time&&o<i.time){const e=t.interpolate((o-t.time)/(i.time-t.time));r=t.value+e*(i.value-t.value)}}},get:()=>r}}const ue="#",de="time",he="interpolation",pe="yaw",fe="pitch",ge="fov",me=[de,pe,fe,ge,he],ve="s",we="ms",ye=1e3,be="deg",Ee="rad",Ae=Math.PI/180,Se="ease-in-out",Me="cubic-bezier(",Re=")";function xe(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(ue);return(-1!==t?e.substring(0,t):e).trim()}(e))).filter((e=>""!==e))}(e);if(null==t)throw new Error("Header missing.");const o=function(e){const t=[];for(let n=0;n<e.length;n++){const o=e[n];if(!me.includes(o))throw new Error(`Invalid token in header: '${o}'.`);if(t.includes(o))throw new Error(`Duplicate token in header: '${o}'.`);t.push(o)}if(!t.includes(de))throw new Error(`Missing required token: '${de}'.`);return t}(t.split(/\s+/)),r={};if(n.length<2)throw new Error("Expected at least two key frames.");for(const e of n){const{theta:t,phi:n,fov:i}=Te(o,e);null!=t&&(null==r.theta&&(r.theta=[]),r.theta.push(t)),null!=n&&(null==r.phi&&(r.phi=[]),r.phi.push(n)),null!=i&&(null==r.fov&&(r.fov=[]),r.fov.push(i))}if(0===Object.values(r).length)throw new Error("At least one parameter should be animated.");return r}(e);if(Array.isArray(e))return function(e){var t;const n={};if(e.length<2)throw new Error("Expected at least two key frames.");for(const o of e){const{time:e,pitch:r,yaw:i,fov:a}=o;if(null==e)throw new Error("Time missing.");const s=Ce(null!==(t=o.interpolation)&&void 0!==t?t:Se);null!=i&&(null==n.theta&&(n.theta=[]),n.theta.push({time:e,value:i*Ae,interpolation:s})),null!=r&&(null==n.phi&&(n.phi=[]),n.phi.push({time:e,value:r*Ae,interpolation:s})),null!=a&&(null==n.fov&&(n.fov=[]),n.fov.push({time:e,value:a*Ae,interpolation:s}))}if(0===Object.values(n).length)throw new Error("At least one parameter should be animated.");if(Object.values(n).every((t=>t.length!==e.length)))throw new Error("All parameters should have the same key frame count.");return n}(e);throw new Error("Expected string or key frame config array.")}function Te(e,t){const n=t.match(/[^()\s]+(\(.*?\))?/g);if(null==n||n.length<e.length)throw new Error(`Missing data for fields: '${e.filter((e=>!(null==n?void 0:n.includes(e)))).join(", ")}'.`);if(n.length>e.length)throw new Error(`Excess data: '${n.filter((t=>!e.includes(t))).join(", ")}'.`);const o=e.indexOf(de),r=function(e){if(e.endsWith(we))return ke(e.substring(0,e.length-we.length));if(e.endsWith(ve))return ke(e.substring(0,e.length-ve.length))*ye;return ke(e)}(n[o]),i=e.indexOf(he),a=Ce(-1===i?Se:n[i]),s={};for(let t=0;t<n.length;t++){if(t===o||t===i)continue;const l=e[t],c=n[t];switch(l){case pe:s.theta={time:r,value:Pe(c),interpolation:a};break;case fe:s.phi={time:r,value:Pe(c),interpolation:a};break;case ge:s.fov={time:r,value:Pe(c),interpolation:a};break;default:throw new Error(`Unhandled value for header '${l}'.`)}}return s}function Pe(e){return e.endsWith(be)?ke(e.substring(0,e.length-be.length))*Ae:e.endsWith(Ee)?ke(e.substring(0,e.length-Ee.length)):ke(e)*Ae}function Ce(e){if("hold"===e)return{type:"hold"};if("linear"===e)return Ie(0,0,1,1);if("sine"===e)return Ie(.37,0,.63,1);if("sine-in"===e)return Ie(.12,0,.39,0);if("sine-out"===e)return Ie(.61,1,.88,1);if("ease"===e)return Ie(.25,.1,.25,1);if("ease-in"===e)return Ie(.42,0,1,1);if("ease-out"===e)return Ie(0,0,.58,1);if("ease-in-out"===e)return Ie(.42,0,.58,1);if(e.startsWith(Me)&&e.endsWith(Re)){const t=e.substring(Me.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:ke(t[0]),y1:ke(t[1]),x2:ke(t[2]),y2:ke(t[3])}}throw new Error(`Expected an interpolation token, but found: ${e}`)}function Ie(e,t,n,o){return{type:"bezier",x1:e,y1:t,x2:n,y2:o}}function ke(e){const t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error(`Expected a numeric value, but got: ${e}`);return t}const Le=300,Ue=2e3,$e=.05,De=2*Math.PI/32,Oe=Ce("hold"),_e=Ce("sine"),Ne=Ce("sine-in"),je=Ce("sine-out");const We=2e3,Fe=8,qe=2*Math.PI,Ge=qe/12,ze=qe/60,Be=qe/60,Ve=60,Qe=60,He=1e3,Ke=Ve*Qe,Xe=-1;function Ze(e){return ce([{time:0,value:0,interpolation:{type:"bezier",x1:.9,y1:0,x2:.6,y2:1}},{time:We,value:e,interpolation:{type:"hold"}}])}function Ye(e,t,n){return Xe*Ge*(e+t/Ve+n/Ke)}function Je(e,t){return Xe*ze*(e+t/Qe)}function et(e,t){return Xe*Be*(e+t/He)}const tt=["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 nt(e){null!=e&&(e.dispose(),tt.forEach((t=>{var n;return null===(n=e[t])||void 0===n?void 0:n.dispose()})))}let ot;const rt=0,it=3;let at,st,lt,ct=!1,ut=1,dt=1,ht=1;const pt=1;let ft;const gt=new Map;function mt(){null==ot&&(ot=x(`${R}/shopar-three.js`))}function vt(e,n,o){const r=e.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,u,d,h,p,f,g,m,v,w,y,b=!1,E=!1,A=!1,S=!0,M=!1,R=1,x=!0,T=!1,P=0,C=0,W=1,Q=1,H=1;const K={threeInit:()=>{b||(wt(),i=new st.Scene,a=new st.PerspectiveCamera(25,1,.5),s=new at.OrbitControls(a,e),s.setInteractionEnabled(x),h=st.ACESFilmicToneMapping,({renderShadow:c,shadowGroup:l}=function(e){const t=new q.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new q.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new q.Group;o.position.y=-.7;const r=new q.PlaneGeometry(O,_).rotateX(Math.PI/2),i=new q.MeshBasicMaterial({map:t.texture,opacity:F,transparent:!0,depthWrite:!1}),a=new q.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new q.Mesh(r);s.visible=!1,o.add(s);const l=new q.OrthographicCamera(-O/2,O/2,_/2,-_/2,0,N);function c(e){s.visible=!0,B.uniforms.tDiffuse.value=t.texture,B.uniforms.h.value=1*e/256,s.material=B,G.setRenderTarget(n),G.render(s,l),V.uniforms.tDiffuse.value=n.texture,V.uniforms.v.value=1*e/256,s.material=V,G.setRenderTarget(t),G.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,o.add(l),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=z;const o=G.getClearAlpha();G.setClearAlpha(0),G.setRenderTarget(t),G.render(e,l),e.overrideMaterial=null,c(j),c(.4*j),G.setRenderTarget(null),G.setClearAlpha(o),e.background=n}}}(i)),b=!0)},threeParse:(e,n,o)=>t(this,void 0,void 0,(function*(){return null!=u&&d===o||(yield u,u=(()=>t(this,void 0,void 0,(function*(){var t,o,r;return o=at,$||(k=o.THREE,L=new o.RGBELoader,$=!0),null===(t=i.environment)||void 0===t||t.dispose(),i.environment=D(n),function(e,t){if(U)return;const{THREE:n}=t;I=(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}(ft,at),r=e,I.parseAsync(r.buffer,"")})))(),d=o),u})),threeLoad:(e,t)=>{Et(i),i.add(e.scene);const n=(new st.Box3).setFromObject(e.scene);l.position.y=n.min.y-rt,i.add(l),c(),E=!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&&(E=!0)})):t.transmission>0&&(E=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(at.reduceVertices(e.scene,((e,t)=>Math.max(e,o.distanceToSquared(t))),0));s.reset(o,r,function(e,t){var n;const o={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?o.Glasses:null!==(n=o[e])&&void 0!==n?n:o.Glasses).normalize()}(t,st.Vector3)),P=0,y="Watches"===t?function(e){const t=e.getObjectByName("hours"),n=e.getObjectByName("minutes"),o=e.getObjectByName("seconds");if(null==t&&null==n&&null==o)return null;let r,i,a,s,l,c;return{start:()=>{r=new Date,r.setMilliseconds(r.getMilliseconds()+We),l=!1;const e=r.getHours(),t=r.getMinutes(),n=r.getSeconds(),o=r.getMilliseconds();i=Ze(Ye(e,t,n)),a=Ze(Je(t,n)),s=Ze(et(n,o)),c=new Date},update:()=>{if(null==r)return!1;const e=new Date;if(!l){if(r.getTime()-e.getTime()>0){const r=Math.abs(e.getTime()-c.getTime());return null!=t&&(i.update(r),t.rotation.y=i.get()),null!=n&&(a.update(r),n.rotation.y=a.get()),null!=o&&(s.update(r),o.rotation.y=s.get()),c=e,!0}l=!0}if(Math.abs(e.getTime()-c.getTime())<He/Fe)return!1;c=e;const u=e.getHours(),d=e.getMinutes(),h=e.getSeconds(),p=e.getMilliseconds();return null!=t&&(t.rotation.y=Ye(u,d,h)),null!=n&&(n.rotation.y=Je(d,h)),null!=o&&(o.rotation.y=et(h,p)),!0}}}(e.scene):null},threePaused:()=>S,threeResume:()=>{S=!1,ft.setAnimationLoop(yt),e.style.visibility="visible",C=0,null==f||f.reset(),null==g||g.reset(),null==m||m.reset(),null==v||v.reset(),null==w||w.reset(),null==y||y.start()},threePause:()=>{S=!0,function(){for(const{threePaused:e}of gt.values())if(!e())return!1;return!0}()&&ft.setAnimationLoop(null),e.style.visibility="hidden",o.style.opacity="0",n.style.visibility="hidden"},threeDestroy:()=>{var t;Et(i),null===(t=i.environment)||void 0===t||t.dispose(),i.environment=null,i=null,u=null,y=null,gt.delete(e)},threeSetZoomEnabled:e=>{s.enableZoom=e},threeSetForcedTransparency:e=>{A=e},threeSetToneMapping:(e,t)=>{const n={ACES:st.ACESFilmicToneMapping,Linear:st.LinearToneMapping,Neutral:st.NeutralToneMapping};null!=n[e]&&(h=n[e]),R=t},threeIsInteractive:()=>x,threeSetInteractive:e=>{x=e,null==s||s.setInteractionEnabled(x)},threeSetOnInteracted:e=>{s.removeEventListener("change",p),p=e,s.addEventListener("change",e)},threeInitPromptAnimation:()=>{var e;e=s.getTheta(),f=ce([{time:0,value:e,interpolation:Oe},{time:Le,value:e,interpolation:je},{time:Le+Ue/4,value:e+De,interpolation:_e},{time:Le+3*Ue/4,value:e-De,interpolation:Ne},{time:Le+Ue,value:e,interpolation:Oe},{time:Le+2*Ue,value:e,interpolation:Oe}]),s.setTheta(f.get()),g=null,m=null,v=ce([{time:0,value:0,interpolation:Oe},{time:Le,value:1,interpolation:Oe},{time:Le+Ue,value:0,interpolation:Oe},{time:Le+2*Ue,value:0,interpolation:Oe}]),w=ce([{time:0,value:0,interpolation:Oe},{time:Le,value:0,interpolation:je},{time:Le+Ue/4,value:-$e,interpolation:_e},{time:Le+3*Ue/4,value:$e,interpolation:Ne},{time:Le+Ue,value:0,interpolation:Oe},{time:Le+2*Ue,value:0,interpolation:Oe}])},threeInitThetaAnimation:e=>{f=e,null!=e&&s.setTheta(e.get())},threeInitPhiAnimation:e=>{g=e,null!=e&&s.setPhi(e.get())},threeInitFovAnimation:e=>{m=e,null!=e&&s.setFovRadians(e.get())},threeRenderOnce:()=>{K.render_()},preRender_:t=>{if(!b||S||!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)}(e))return;let n=0!==C?t-C:0;C=t,0===P?M=!0:P<it&&(n=0),P++,T||(s.hasUserInteracted()?(T=!0,f=null,g=null,m=null,v=null,w=null):(null==f||f.update(n),null==g||g.update(n),null==m||m.update(n),null==v||v.update(n),null==w||w.update(n),null!=f&&(s.setTheta(f.get()),M=!0),null!=g&&(s.setPhi(g.get()),M=!0),null!=m&&(s.setFovRadians(m.get()),M=!0))),s.update()&&(M=!0),(null==y?void 0:y.update())&&(M=!0)},shouldRender_:()=>!(!b||S)&&M,render_:()=>{const t=ft.toneMapping,s=ft.toneMappingExposure;ft.toneMapping=h,ft.toneMappingExposure=R,ft.setViewport(0,0,e.width,e.height),ft.setClearColor(new st.Color(16777215),E&&!A?1:0),ft.render(i,a),ft.toneMapping=t,ft.toneMappingExposure=s,M=!1,null!=r&&(r.clearRect(0,0,e.width,e.height),lt.width>0&<.height>0&&r.drawImage(lt,0,dt-e.height,e.width,e.height,0,0,e.width,e.height),n.style.visibility=x&&!T?"visible":"hidden",null!=v&&(o.style.opacity=`${v.get()}`),null!=w&&(o.style.transform=`translateX(${w.get()*Math.min(W,Q)}px)`))},updateSize_:()=>{const{clientWidth:t,clientHeight:n}=e;t===W&&n===Q&&ht===H||(e.width=Math.ceil(t*ht*pt),e.height=Math.ceil(n*ht*pt),W=t,Q=n,H=ht,M=!0)},target_:e};return gt.set(e,K),K}function wt(){if(ct)return;at=window.ShopAR__THREE,st=at.THREE,lt=document.createElement("canvas");var e,t;lt.style.position="block",ft=new st.WebGLRenderer({powerPreference:"high-performance",canvas:lt,antialias:!0,alpha:!0}),ft.outputColorSpace=st.SRGBColorSpace,ft.toneMapping=st.ACESFilmicToneMapping,ft.setClearColor(new st.Color(16777215),0),e=ft,t=at,Q||(q=t.THREE,G=e,z=new q.MeshDepthMaterial,z.userData.darkness={value:W},z.onBeforeCompile=e=>{e.uniforms.darkness=z.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}`},z.depthTest=!1,z.depthWrite=!1,B=new q.ShaderMaterial(t.HorizontalBlurShader),B.depthTest=!1,V=new q.ShaderMaterial(t.VerticalBlurShader),V.depthTest=!1,Q=!0),bt(),ct=!0}function yt(e){bt(),ft.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of gt.values())t(e),n()&&o()}function bt(){let e=0,t=0;for(const{target_:n}of gt.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=C();e=Math.ceil(e*n*pt),t=Math.ceil(t*n*pt),e===ut&&t===dt&&n===ht||(ut=e,dt=t,ht=n,ft.setSize(ut,dt,!1));for(const{updateSize_:e}of gt.values())e()}function Et(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(nt):nt(e.material))})),e.clear()}const At={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},St=Object.keys(At);function Mt(e){return At[e]}const Rt="shopar-error";function xt(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn",r.appendChild(o);{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;const i=r.style;return i.display="none",i.pointerEvents="auto",r}const Tt="shopar-control";const Pt="shopar-deepar-output";function Ct(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.pointerEvents="auto",n.userSelect="none",t}function It(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function kt(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 Lt(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 Ut="shopar-main";const $t="shopar-qr-output";function Dt(e){var t,n;const o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.setAttribute("width",null!==(t=e.getAttribute("width"))&&void 0!==t?t:"1rem"),o.setAttribute("height",null!==(n=e.getAttribute("height"))&&void 0!==n?n:"1rem"),o.appendChild(e),o}function Ot(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 _t="shopar-three-output";var Nt;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(Nt||(Nt={}));let jt=!1;function Wt(){jt||(!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.")}}(),jt=!0)}function Ft(){Wt();const e=function(){const e=document.createElement("div");e.id=Ut;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",t.pointerEvents="none",e}(),t=function(){const e=document.createElement("div");return e.style.textAlign="center",e}(),n=function(){const e=new Image;e.draggable=!1;const t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),o=function(e,t){const n=document.createElement("div");n.id=$t;const o=n.style;o.position="absolute",o.top="0",o.left="0",o.width="100%",o.height="100%",o.display="none",o.pointerEvents="auto",o.userSelect="none";const r=document.createElement("div");r.className="shopar-qr";const i=r.style;i.position="relative",i.top="0",i.left="0",i.width="100%",i.height="100%",n.appendChild(r),r.appendChild(e);const a=document.createElement("div");return a.appendChild(t),r.appendChild(a),n}(t,n);e.appendChild(o);const r=function(){const e=document.createElement("div");e.id=Pt;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",t.pointerEvents="auto",e}();e.appendChild(r);const i=function(){const e=document.createElement("canvas");e.id=_t,e.className="shopar-3d";const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",t.pointerEvents="auto",e}();e.appendChild(i);const a=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),s=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),l=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:o}=n;return o.position="absolute",o.width="100%",o.height="100%",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(a,s);e.appendChild(l);const c=function(){const e=Dt(Ot("2rem",`${R}/img/prompt/3d-interaction.svg`)),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),u=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",t.appendChild(e),t}(c);e.appendChild(u);const d=Ct("shopar-ar-loading-container"),h=It("shopar-ar-loading-text",Mt("loading.ar"));d.appendChild(h);const p=kt("shopar-ar-loading-bar-bg"),f=Lt("shopar-ar-loading-bar-fg");p.appendChild(f),d.appendChild(p),e.appendChild(d);const g=Ct("shopar-3d-loading-container"),m=It("shopar-3d-loading-text",Mt("loading.3d"));g.appendChild(m);const v=kt("shopar-3d-loading-bar-bg"),w=Lt("shopar-3d-loading-bar-fg");v.appendChild(w),g.appendChild(v),e.appendChild(g);const y=function(){const e=document.createElement("div");e.className="shopar-3d-poster";const{style:t}=e;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.pointerEvents="auto",t.userSelect="none",t.backgroundSize="contain",t.backgroundRepeat="no-repeat",t.backgroundPosition="center",e}();e.appendChild(y);const b=function(){const e=document.createElement("div");return e.className="shopar-error-text",e.style.textAlign="center",e}(),E=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 o=document.createElement("div"),r=o.style;return r.position="absolute",r.width="100%",r.height="100%",r.backgroundColor="#ffffff",r.display="flex",r.flexDirection="column",r.justifyContent="center",r.alignItems="center",t.appendChild(o),o.appendChild(e),t}(b);e.appendChild(E);const A=function(){const e=document.createElement("div");return e.id=Tt,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(A);const S=Ot("1.75rem"),M=xt("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on",Dt(S));A.appendChild(M);const x=Ot("1.75rem"),T=xt("shopar-btn-3d","3D","Launch ShopAR 3D preview",Dt(x));A.appendChild(T);const P=Ot("1.75rem"),C=xt("shopar-btn-close","Close","Close ShopAR view",Dt(P));A.append(C);let I,k,L=Nt.None,U=!1,$=!1,D=!1,O=!1;function _(){f.classList.remove("active"),d.style.visibility="hidden"}function N(){y.style.visibility="hidden",w.classList.remove("active"),g.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return o},getQRImage:function(){return n},getDeepARTarget:function(){return r},getDeepARPrompt:function(){return l},getThreeTarget:function(){return i},getThreePrompt:function(){return u},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){a.textContent=e,s.src=t},customizeCameraError:function(e){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,o,r,i){var a;U=e,$=t,D=n,O=o,I=r,k=i,qt(A,U),qt(M,U&&(D||$)&&L===Nt.None),qt(T,U&&O&&L===Nt.None),qt(C,U&&L!==Nt.None),_(),N(),U||""===(a=E).style.display&&qt(a,!1)},getUIState:function(){return L},setUIState:function(e){L=e,L===Nt.None?(_(),N(),U&&(qt(E,!1),qt(C,!1),($||D)&&qt(M,!0),O&&qt(T,!0))):L===Nt.QR||L===Nt.AR?U&&(qt(E,!1),qt(M,!1),qt(T,O&&"AR"===k),qt(C,"AR"!==k)):L===Nt.Preview&&U&&(qt(E,!1),qt(M,($||D)&&"3D"===k),qt(T,!1),qt(C,"3D"!==k))},setDefaultUIActions:function(e,t,n){U&&(($||D)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${R}/img/icons/${n}`;S.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(I),M.onclick=e),O&&(x.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${R}/img/icons/cube.svg`),T.onclick=t),P.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",`${R}/img/icons/close.svg`),C.onclick=n)},startDeepARLoading:function(){f.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:_,startThreeLoading:function(){null!=y.dataset.bgSet?y.style.visibility="visible":(w.classList.add("active"),g.style.visibility="visible")},stopThreeLoading:N,setThreePosterUrl:function(e){null!=e?(y.style.backgroundImage=`url(${e})`,y.dataset.bgSet="true"):delete y.dataset.bgSet},showCameraError:function(){U&&qt(E,!0)}}}function qt(e,t){e.style.display=t?"":"none"}const Gt=new Map;function zt(e){let t=Gt.get(e);return null==t?(t=function(){let e=0,t=null,n=null,o=null;const r=()=>(null==t&&(t=Ft()),t);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>t,findUI:r,findQR:()=>{if(null==n){const{getQRTarget:e,getQRImage:t}=r();n=P(e(),t())}return n},findThree:()=>{if(null==o){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=r();o=vt(e(),t(),n())}return o}}}(),Gt.set(e,t)):t.incrementSetupId_(),t}function Bt(e){for(const t of Gt.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===Nt.AR&&r(Nt.None)}}let Vt;const Qt=new Uint8Array(16);function Ht(){if(!Vt&&(Vt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Vt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Vt(Qt)}const Kt=[];for(let e=0;e<256;++e)Kt.push((e+256).toString(16).slice(1));var Xt={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Zt(e,t,n){if(Xt.randomUUID&&!t&&!e)return Xt.randomUUID();const o=(e=e||{}).random||(e.rng||Ht)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function(e,t=0){return Kt[e[t+0]]+Kt[e[t+1]]+Kt[e[t+2]]+Kt[e[t+3]]+"-"+Kt[e[t+4]]+Kt[e[t+5]]+"-"+Kt[e[t+6]]+Kt[e[t+7]]+"-"+Kt[e[t+8]]+Kt[e[t+9]]+"-"+Kt[e[t+10]]+Kt[e[t+11]]+Kt[e[t+12]]+Kt[e[t+13]]+Kt[e[t+14]]+Kt[e[t+15]]}(o)}const Yt="qrLaunch",Jt="arLaunch",en="previewLaunch",tn="heartbeat";let nn,on,rn=!1,an=window.navigator.userAgent||"no user agent";const sn=[];function ln(){null==nn&&(on=Zt(),nn=x(`${R}/shopar-analytics.js`),nn.then((()=>{rn=!0,window.ShopAR__analytics.initializeImpl(),sn.forEach((e=>e()))})))}function cn(e){rn?e():sn.push(e)}function un(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function dn(e){return t(this,void 0,void 0,(function*(){const t=document.createElement("video");return t.setAttribute("playsinline","playsinline"),t.srcObject=yield e,t}))}const hn=200,pn=10;let fn=!1,gn=null,mn=[],vn=[];function wn(e){return t(this,void 0,void 0,(function*(){fn=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${R}/wasm/mediapipe`,e),gn&&clearInterval(gn);const o=[],r=[];gn=setInterval((()=>t(this,void 0,void 0,(function*(){if(fn)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());fn||(null!=a&&null!=s&&function(e){for(let t of mn)t(e)}({translation:a,rotation:s}),null==e&&(o.push(t),r.push(i),o.length<pn||(o.shift(),r.shift(),function(e,t){for(let n of vn)n({faceWidth:e,IPD:t})}(bn(o),bn(r)))))}))),hn)}))}function yn(){vn=[],mn=[],fn=!0}function bn(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}var En="undefined"!=typeof Float32Array?Float32Array:Array;function An(){var e=new En(16);return En!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Sn(e,t,n){var o=t[0],r=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],g=t[12],m=t[13],v=t[14],w=t[15],y=n[0],b=n[1],E=n[2],A=n[3];return e[0]=y*o+b*s+E*d+A*g,e[1]=y*r+b*l+E*h+A*m,e[2]=y*i+b*c+E*p+A*v,e[3]=y*a+b*u+E*f+A*w,y=n[4],b=n[5],E=n[6],A=n[7],e[4]=y*o+b*s+E*d+A*g,e[5]=y*r+b*l+E*h+A*m,e[6]=y*i+b*c+E*p+A*v,e[7]=y*a+b*u+E*f+A*w,y=n[8],b=n[9],E=n[10],A=n[11],e[8]=y*o+b*s+E*d+A*g,e[9]=y*r+b*l+E*h+A*m,e[10]=y*i+b*c+E*p+A*v,e[11]=y*a+b*u+E*f+A*w,y=n[12],b=n[13],E=n[14],A=n[15],e[12]=y*o+b*s+E*d+A*g,e[13]=y*r+b*l+E*h+A*m,e[14]=y*i+b*c+E*p+A*v,e[15]=y*a+b*u+E*f+A*w,e}function Mn(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Rn(e,t){var n=t[0],o=t[1],r=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,u),e}function xn(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,u=a+a,d=r*l,h=r*c,p=r*u,f=i*c,g=i*u,m=a*u,v=s*l,w=s*c,y=s*u,b=o[0],E=o[1],A=o[2];return e[0]=(1-(f+m))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*E,e[5]=(1-(d+m))*E,e[6]=(g+v)*E,e[7]=0,e[8]=(p+w)*A,e[9]=(g-v)*A,e[10]=(1-(d+f))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Tn(){var e=new En(3);return En!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Pn(e,t,n){var o=new En(3);return o[0]=e,o[1]=t,o[2]=n,o}function Cn(e,t){var n=t[0]-e[0],o=t[1]-e[1],r=t[2]-e[2];return Math.hypot(n,o,r)}function In(e,t,n){var o=t[0],r=t[1],i=t[2],a=n[3]*o+n[7]*r+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*o+n[4]*r+n[8]*i+n[12])/a,e[1]=(n[1]*o+n[5]*r+n[9]*i+n[13])/a,e[2]=(n[2]*o+n[6]*r+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function kn(){var e=new En(4);return En!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Tn(),function(){var e,t=(e=new En(4),En!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var Ln;let Un,$n;Tn(),Pn(1,0,0),Pn(0,1,0),kn(),kn(),Ln=new En(9),En!=Float32Array&&(Ln[1]=0,Ln[2]=0,Ln[3]=0,Ln[5]=0,Ln[6]=0,Ln[7]=0),Ln[0]=1,Ln[4]=1,Ln[8]=1;let Dn,On,_n,Nn,jn=!0,Wn=null;const Fn=new Set;let qn,Gn,zn,Bn,Vn,Qn;function Hn(){null==Un&&(Un=x(`${R}/shopar-deepar.js`))}function Kn(){null==$n&&($n=x(`${R}/shopar-true-scale.js`))}function Xn(e){return t(this,void 0,void 0,(function*(){const{licenseKey:o,truescaleUsecase:r}=e;return Vn=r,null==qn&&(qn=(()=>t(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new n("No camera available!");var e;const t=io(_n),r=un(t);Dn=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:o||"your_license_key_goes_here",previewElement:Nn,additionalOptions:{hint:Qn,cameraConfig:{disableDefaultCamera:!0}}}),On=yield dn(r),yield ao(Dn,On,"user"===t),"Glasses"===_n&&(yield $n,wn(On),"DetectionLoop"!==Vn&&uo((e=>{Bn=e.faceWidth})))})))()),qn}))}function Zn(e,t){var n,o;(t=null!=t?t:function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(e),e===_n&&(n=t,o=Qn,n===o||null!=n&&null!=o&&n.length===o.length&&n.every((e=>o.find((t=>e===t))))&&o.every((e=>n.find((t=>t===e))))))||(null!=Dn&&(Dn.shutdown(),Dn=null,qn=null),_n=e,Qn=t)}function Yn(e){e!==Nn&&(Nn=e,null!=Dn&&Dn.changePreviewElement(Nn))}function Jn(e){Wn=e}function eo(e){Dn.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(Bn){const e=137/(Bn+5);Dn.changeParameterVector("GLASSES","","scale",e,e,e,0),Dn.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const o=lo("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=lo("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);Dn.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),Dn.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return}}(e),yn(),Bn=null}e(),so("Glasses")}},Dn.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),so("Shoes"))},Dn.callbacks.onWristTracked=t=>{t.detected&&(e(),so("Watches"))}}function to(e,n,o){return t(this,void 0,void 0,(function*(){return null!=Gn&&zn===o||(yield Gn,Gn=Dn.switchEffect(e,{envmap:n}),zn=o),Gn}))}function no(e,t){null!=e&&null!=t&&(Dn.setToneMapping(e),Dn.setExposure(t))}function oo(){return t(this,void 0,void 0,(function*(){if(null!=Dn){if(jn=!1,null==On){const e=io(_n),t=un(e);On=yield dn(t),yield ao(Dn,On,"user"===e),"Glasses"===_n&&(wn(On),"DetectionLoop"!==Vn&&uo((e=>{Bn=e.faceWidth})))}!function(){if(null==Wn)return;if(null==_n||Fn.has(_n))return;Wn.style.visibility="visible",Wn.style.opacity="1"}(),Dn.setPaused(jn),Nn.style.display=""}}))}function ro(){null!=Dn&&(jn=!0,Dn.setPaused(jn),yn(),null!=On&&null!=On.srcObject&&On.srcObject instanceof MediaStream&&(On.srcObject.getTracks().forEach((e=>e.stop())),On=null),function(){if(null==Wn)return;Wn.style.visibility="hidden",Wn.style.opacity="0"}(),Dn.stopCamera(),Nn.style.display="none")}function io(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function ao(e,n,o){return t(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>t(this,void 0,void 0,(function*(){e.setVideoElement(n,o),r()}))))}}))}))}function so(e){null!=Wn&&(Fn.has(e)||(Fn.add(e),Wn.style.opacity="0"))}function lo(e,t,n,o,r,i,a){const s=Dn.getTransformationBetween(e,t),l=Mn(Tn(),s),c=function(e,t){var n=new En(3);Rn(n,t);var o=1/n[0],r=1/n[1],i=1/n[2],a=t[0]*o,s=t[1]*r,l=t[2]*i,c=t[4]*o,u=t[5]*r,d=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,g=a+u+f,m=0;return g>0?(m=2*Math.sqrt(g+1),e[3]=.25*m,e[0]=(d-p)/m,e[1]=(h-l)/m,e[2]=(s-c)/m):a>u&&a>f?(m=2*Math.sqrt(1+a-u-f),e[3]=(d-p)/m,e[0]=.25*m,e[1]=(s+c)/m,e[2]=(h+l)/m):u>f?(m=2*Math.sqrt(1+u-a-f),e[3]=(h-l)/m,e[0]=(s+c)/m,e[1]=.25*m,e[2]=(d+p)/m):(m=2*Math.sqrt(1+f-a-u),e[3]=(s-c)/m,e[0]=(h+l)/m,e[1]=(d+p)/m,e[2]=.25*m),e}(kn(),s);xn(s,c,l,Pn(a,a,a));const u=Dn.getTransformationBetween(t,n),d=Mn(Tn(),u);xn(u,kn(),d,Rn(Tn(),u));const h=Sn(An(),s,u),p=Mn(Tn(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let g;try{g=Dn.getTransformationBetween(n,o)}catch(e){return f}const m=Sn(An(),u,g),v=Sn(An(),s,m),w=Pn(p[0],i[1],i[2]),y=In(Tn(),w,function(e,t){var n=t[0],o=t[1],r=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],g=t[13],m=t[14],v=t[15],w=n*s-o*a,y=n*l-r*a,b=n*c-i*a,E=o*l-r*s,A=o*c-i*s,S=r*c-i*l,M=u*g-d*f,R=u*m-h*f,x=u*v-p*f,T=d*m-h*g,P=d*v-p*g,C=h*v-p*m,I=w*C-y*P+b*T+E*x-A*R+S*M;return I?(I=1/I,e[0]=(s*C-l*P+c*T)*I,e[1]=(r*P-o*C-i*T)*I,e[2]=(g*S-m*A+v*E)*I,e[3]=(h*A-d*S-p*E)*I,e[4]=(l*x-a*C-c*R)*I,e[5]=(n*C-r*x+i*R)*I,e[6]=(m*b-f*S-v*y)*I,e[7]=(u*S-h*b+p*y)*I,e[8]=(a*P-s*x+c*M)*I,e[9]=(o*x-n*P-i*M)*I,e[10]=(f*A-g*b+v*w)*I,e[11]=(d*b-u*A-p*w)*I,e[12]=(s*R-a*T-l*M)*I,e[13]=(n*T-o*R+r*M)*I,e[14]=(g*y-f*E-m*w)*I,e[15]=(u*E-d*y+h*w)*I,e):null}(An(),v));let b=Dn.getClosestPointOnMesh(o,y);try{const e=Dn.getClosestPointOnMesh(r,y);Cn(y,e)<Cn(y,b)&&(b=e)}catch(e){}const E=In(Tn(),b,m);return f-Math.atan2(E[0]-d[0],Math.abs(E[2]-d[2]))}function co(e){!function(e){mn.push(e)}(e)}function uo(e){!function(e){vn.push(e)}(e)}var ho;function po(){return[ho.Android,ho.iOS,ho.Tablet].includes(function(){if("undefined"!=typeof window&&window.navigator){const e=window.navigator.userAgent,t=window.navigator.platform||"",n=["Macintosh","MacIntel","MacPPC","Mac68K"],o=["Win32","Win64","Windows","WinCE"],r=["iPhone","iPod","iPad"],i="ontouchstart"in window||navigator.maxTouchPoints>0;return-1!==r.indexOf(t)?ho.iOS:-1!==n.indexOf(t)?i?ho.Tablet:ho.MacOS:-1!==o.indexOf(t)?ho.Windows:/Android/.test(e)?ho.Android:/Linux/.test(t)?ho.Linux:i?ho.Tablet:ho.Unknown}return ho.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"}(ho||(ho={}));const fo=["AR","3D"];function go(e,t){if(null==e)throw new n(`'${t}' not specified.`)}function mo(e,t){if("boolean"!=typeof e)throw new n(`'${t}' must be a boolean.`)}function vo(e,t){if("string"!=typeof e)throw new n(`'${t}' must be a string.`)}function wo(e){const{apiKey:t,sku:o,targetElement:r,initialState:i,initialAnimation:a,baseUrl:s,defaultUI:l,interactive:c,strings:u}=e;go(t,"apiKey"),vo(t,"apiKey"),go(o,"sku"),vo(o,"sku"),go(r,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new n(`'${t}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,t,o){if("string"!=typeof e)throw new n(`'${t}' must be a string.`);if(!o.includes(e))throw new n(`'${t}' must be ${o.join("' or '")}.`)}(i,"initialState",fo),null!=a&&function(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new n(`'${t}' must be a string or array.`)}(a,"initialAnimation"),null!=s&&vo(s,"baseUrl"),null!=l&&mo(l,"defaultUI"),null!=c&&mo(c,"interactive"),null!=u&&function(e,t,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new n(`Value for key '${r}' in '${t}' must be a string.`)}}(u,"strings",St)}let yo=!1;function bo(e){return t(this,void 0,void 0,(function*(){const{targetElement:o}=e;R.update(e.baseUrl),ln();const{trackEvent:r}=function(e){const t=performance.now(),n=Zt();return{trackEvent:(o,r={})=>{r=Object.assign(Object.assign({},r),{pluginVersion:S,userAgent:an,sessionId:on,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),cn((()=>{window.ShopAR__analytics.trackEventImpl(o,r)}))}}}(e.apiKey);r("visionSetup");const i=yield function(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:e,sid:d()})}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield o.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(e.apiKey);r("visionApiResponse",i);const{arKey:a}=i,s=zt(o),{getSetupId:l,findUI:c}=s,u=l();Hn(),Kn();const{setTargetElement:h,getDeepARTarget:p,setVisibilityParameters:g,getUIState:m,setUIState:v,startDeepARLoading:w,stopDeepARLoading:y,showCameraError:b}=c();if(m()!=Nt.None)throw Error("UI state is not None, this is weird..");v(Nt.AR),h(o),g(!1,!1,!0,!1,void 0,void 0),w(),yield Un,Eo(l(),u);try{r("visionArLaunch"),ro(),Zn("Glasses",["faceInit"]),Yn(p()),yield Xn({licenseKey:a,truescaleUsecase:"DetectionLoop"}),Eo(l(),u),yield oo(),Eo(l(),u)}catch(e){const t=e instanceof Error;throw r("visionArLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),b(),ro(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{y()}return yo=!0,{registerFacePoseListener:e=>{yo&&(r("registerFacePoseListener"),co(e))},registerFaceMeasurementListener:e=>{yo&&(r("registerFaceMeasurementListener"),uo(e))},switchEffect:e=>t(this,void 0,void 0,(function*(){yo&&(r("switchEffect",{arUrl:e}),function(e){Dn.switchEffect(e)}(e))})),clearEffect:()=>{yo&&(r("clearEffect"),Dn.clearEffect())},close:()=>{if(yo){if(yo=!1,r("visionClose"),m()!==Nt.AR)throw new n("AR not launched.");ro(),v(Nt.None)}}}}))}function Eo(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}function Ao(e){var o,r;return t(this,void 0,void 0,(function*(){wo(e);const{apiKey:i,sku:a,targetElement:s,initialState:l,initialAnimation:c}=e,u=null==e.zoomEnabled||e.zoomEnabled,h=!0===e.alwaysTransparentBackground;!function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new n(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(s),R.update(e.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(At,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(At[t]=n)}}(e.strings);const p=null!=c?xe(c):null,y=null!=(null==p?void 0:p.theta)?ce(p.theta):null,b=null!=(null==p?void 0:p.phi)?ce(p.phi):null,M=null!=(null==p?void 0:p.fov)?ce(p.fov):null,x=function(e,o,r,i,a,s){return t(this,void 0,void 0,(function*(){const l=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({apiKey:e,sku:o,sid:d()},null!=r&&{yaw:`${m(g(r))}`}),null!=i&&{pitch:`${m(g(i))}`}),null!=a&&{fov:`${m(g(a))}`}),s&&{forcedTransparency:`${s}`}))}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield l.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(i,a,null==y?void 0:y.get(),null==b?void 0:b.get(),null==M?void 0:M.get(),h),T=zt(s),{getSetupId:P,findUI:C,findQR:I,findThree:k}=T,L=P();ln();const{trackEvent:U,arInteracted:$,previewInteracted:D}=function(e,t){const n=performance.now(),o=Zt();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,u(tn,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const u=(r,i={})=>{i=Object.assign(Object.assign({},i),{userAgent:an,pluginVersion:S,sessionId:on,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),cn((()=>{window.ShopAR__analytics.trackEventImpl(r,i)}))};return{trackEvent:u,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}(a,i);U("setup",{hostname:window.location.hostname});const O=yield x;U("apiResponse",O);const{category:_,arUrl:N,arEnvUrl:j,arToneMapping:W,arToneMappingExposure:F,arKey:q,arPromptEnabled:G,arPromptText:z,arPromptImage:B,previewUrl:V,previewEnvUrl:Q,previewToneMapping:H,previewToneMappingExposure:K,previewPosterUrl:X,cameraErrorText:Z,qrPromptText:Y}=O;So(P(),L);const J=null!=N&&function(e){return null!=e&&v.includes(e)}(_),ee=null==(null===(o=e._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=e._internalOptions)||void 0===r?void 0:r.qrEnabled),te=J&&function(e){return null!=e&&w.includes(e)}(_),ne=ee&&te&&!po(),oe=J&&!ne,re=null!=V;So(P(),L);const{setTargetElement:ie,getDeepARTarget:ae,getDeepARPrompt:se,customizeDeepARPrompt:le,customizeCameraError:ue,customizeQRPrompt:de,setVisibilityParameters:he,getUIState:pe,setUIState:fe,setDefaultUIActions:ge,startDeepARLoading:me,stopDeepARLoading:ve,startThreeLoading:we,stopThreeLoading:ye,setThreePosterUrl:be,showCameraError:Ee}=C();ie(s);he(null==e.defaultUI||e.defaultUI,ne,oe,re,_,l),le(null!=z?z:"",null!=B?B:""),ue(Z),de(Y),be(X),function(e,t){const o=e.parentNode;if(null==o)throw new n("Parent node missing.");new MutationObserver((n=>{for(const o of n)for(const n of o.removedNodes)if(n===e)return void t()})).observe(o,{childList:!0})}(s,(()=>{pe()!==Nt.QR||Ae()||Me(),pe()!==Nt.AR||jn||ro(),pe()!==Nt.Preview||Ce()||ke(),fe(Nt.None),Le(),function(e){Gt.delete(e)}(s)}));const{qrPaused:Ae,qrDraw:Se,qrPause:Me}=I(),{threeInit:Re,threeParse:Te,threeLoad:Pe,threePaused:Ce,threeResume:Ie,threePause:ke,threeDestroy:Le,threeSetZoomEnabled:Ue,threeSetForcedTransparency:$e,threeSetToneMapping:De,threeIsInteractive:Oe,threeSetInteractive:_e,threeSetOnInteracted:Ne,threeInitPromptAnimation:je,threeInitThetaAnimation:We,threeInitPhiAnimation:Fe,threeInitFovAnimation:qe,threeRenderOnce:Ge}=k(),ze=null==e.interactive||e.interactive;_e(ze);let Be=0;if(pe()===Nt.QR){if(!Ae())if(ne){U(Yt);try{yield Se(i,a)}catch(e){throw new n(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else Me(),fe(Nt.None)}else if(pe()===Nt.AR){if(!jn)if(oe&&!yo){U(Jt),Hn(),"Glasses"===_&&Kn();const e=null!=j?yield E(j):void 0;So(P(),L);const t=yield E(N);So(P(),L),Bt(T),Zn(_),Yn(ae()),Jn(G?se():null),yield to(t,e,`${N}${j}`),no(W,F),eo($),So(P(),L)}else ro(),fe(Nt.None)}else if(pe()===Nt.Preview&&!Ce())if(re){U(en),mt(),we();const e=255,t=yield A(V,(new Date).getTime()+e,Math.random()*e);So(P(),L);const n=yield E(null!=Q?Q:`${R}/env/default.hdr`);So(P(),L),yield ot,So(P(),L),Re(),So(P(),L);const o=yield Te(t,n,`${V}${Q}`);So(P(),L),Pe(o,_),Ue(u),$e(h),De(null!=H?H:"ACES",null!=K?K:1),Ne(D),je(),null!=p&&(We(y),Fe(b),qe(M)),Ge(),Ie(),ye()}else ke(),fe(Nt.None);const Ve=()=>t(this,void 0,void 0,(function*(){if(ne)try{U(Yt);const e=++Be;if(pe()===Nt.Preview&&re&&!Ce()&&ke(),fe(Nt.QR),yield Se(i,a),Be!==e)return;return void So(P(),L)}catch(e){const t=e instanceof Error;throw U("qrLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`QR failed: ${t?e.message:"Unknown error."}`)}if(!oe)throw new n("Model does not have AR enabled.");try{U(Jt);const e=++Be;pe()===Nt.Preview&&re&&!Ce()&&ke(),Bt(T),fe(Nt.AR),Hn(),"Glasses"===_&&Kn(),me();const t=null!=j?yield E(j):void 0;So(P(),L);const n=yield E(N);if(Be!==e)return;if(So(P(),L),yield Un,Be!==e)return;if(So(P(),L),ro(),Zn(_),Yn(ae()),Jn(G?se():null),yield Xn({licenseKey:q}),Be!==e)return;if(So(P(),L),yield to(n,t,`${N}${j}`),no(W,F),eo($),Be!==e)return;if(So(P(),L),yield oo(),Be!==e)return;So(P(),L)}catch(e){const t=e instanceof Error;throw U("arLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),Ee(),ro(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{ve()}})),Qe=()=>t(this,void 0,void 0,(function*(){if(!re)throw new n("Model does not have 3D enabled.");try{U(en);const e=++Be;pe()===Nt.AR&&(oe&&!jn&&ro(),Me()),fe(Nt.Preview),mt(),we();const t=255,n=yield A(V,(new Date).getTime()+t,Math.random()*t);if(Be!==e)return;So(P(),L);const o=yield E(null!=Q?Q:`${R}/env/default.hdr`);if(Be!==e)return;if(So(P(),L),yield ot,Be!==e)return;if(So(P(),L),Re(),Be!==e)return;So(P(),L);const r=yield Te(n,o,`${V}${Q}`);if(Be!==e)return;So(P(),L),Pe(r,_),Ue(u),$e(h),De(null!=H?H:"ACES",null!=K?K:1),Ne(D),je(),null!=p&&(We(y),Fe(b),qe(M)),Ge(),Ie(),ye()}catch(e){const t=e instanceof Error;throw U("previewLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`3D failed: ${t?e.message:"Unknown error."}`)}})),He=()=>t(this,void 0,void 0,(function*(){pe()!==Nt.None&&("AR"!==l||pe()!==Nt.AR&&pe()!==Nt.QR)&&("3D"===l&&pe()===Nt.Preview||(++Be,pe()===Nt.QR||pe()===Nt.AR?(oe&&!jn&&ro(),Me()):pe()===Nt.Preview&&re&&!Ce()&&ke(),fe(Nt.None),"AR"!==l?"3D"!==l||(yield Qe()):yield Ve()))}));return ge(Ve,Qe,He),"AR"===l?(yield Ve(),So(P(),L)):"3D"===l&&(yield Qe(),So(P(),L)),yo=!1,{launchAR:J?Ve:void 0,launch3D:re?Qe:void 0,closeAR:J?()=>t(this,void 0,void 0,(function*(){pe()!==Nt.AR&&pe()!==Nt.QR||"AR"!==l&&(++Be,oe&&!jn&&ro(),Me(),fe(Nt.None),"3D"!==l||(yield Qe()))})):void 0,close3D:re?()=>t(this,void 0,void 0,(function*(){pe()===Nt.Preview&&"3D"!==l&&(++Be,re&&!Ce()&&ke(),fe(Nt.None),"AR"!==l||(yield Ve()))})):void 0,close:J||re?He:void 0,isInteractive:()=>Oe(),setInteractive:e=>_e(e)}}))}function So(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}const Mo={setup:function(e){return t(this,void 0,void 0,(function*(){return bo(e)}))}},Ro={setup:function(e){return t(this,void 0,void 0,(function*(){return function(e,o){return t(this,void 0,void 0,(function*(){try{return o()}catch(t){throw t instanceof Error?new n(`${e} failed: ${t.message}`):(console.error(t),new n(`${e} failed.`))}}))}("setup",(()=>Ao(e)))}))},version:S};e.PREVIEW_STATES=fo,e.PluginError=n,e.plugin=Ro,e.vision=Mo}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shopar-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4-alpha.0",
|
|
4
4
|
"description": "Plugin for the Web that seamlessly integrates into your webpage to create embedded virtual try-on and 3D preview capabilities.",
|
|
5
5
|
"main": "dist/shopar-plugin.esm.js",
|
|
6
6
|
"module": "dist/shopar-plugin.esm.js",
|