shopar-plugin 0.1.1-alpha.5 → 0.1.2-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/dist/shopar-plugin.d.ts
CHANGED
|
@@ -50,7 +50,52 @@ type SetupOptions = {
|
|
|
50
50
|
strings?: Strings;
|
|
51
51
|
_internalOptions?: any;
|
|
52
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Options used for the vision plugin setup.
|
|
55
|
+
*/
|
|
56
|
+
type VisionOptions = {
|
|
57
|
+
/** API key found in the ShopAR dashboard. */
|
|
58
|
+
apiKey: string;
|
|
59
|
+
/**
|
|
60
|
+
* The element to inflate with camera canvas.
|
|
61
|
+
*/
|
|
62
|
+
targetElement: HTMLElement;
|
|
63
|
+
/**
|
|
64
|
+
* If provided, defines where the additional ShopAR plugin files are fetched from.
|
|
65
|
+
*
|
|
66
|
+
* @default `https://cdn.jsdelivr.net/npm/shopar-plugin@${version}/`
|
|
67
|
+
*/
|
|
68
|
+
baseUrl?: string;
|
|
69
|
+
};
|
|
53
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Truescale output measurements
|
|
73
|
+
*/
|
|
74
|
+
type FaceMeasurement = {
|
|
75
|
+
/**
|
|
76
|
+
* Face width in millimeters.
|
|
77
|
+
*/
|
|
78
|
+
faceWidth: number;
|
|
79
|
+
/**
|
|
80
|
+
* Interpupillary distance in millimeters.
|
|
81
|
+
*/
|
|
82
|
+
IPD: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Type that wraps face position and orientation.
|
|
86
|
+
*/
|
|
87
|
+
type FacePose = {
|
|
88
|
+
/**
|
|
89
|
+
* Face position in uncalibrated 3D space.
|
|
90
|
+
*/
|
|
91
|
+
translation: number[];
|
|
92
|
+
/**
|
|
93
|
+
* Face rotation represented as Tait-Bryan angles (nautical angles).
|
|
94
|
+
*
|
|
95
|
+
* Sequence of fields in this array is yaw, pitch, roll (heading, elevation, bank).
|
|
96
|
+
*/
|
|
97
|
+
rotation: number[];
|
|
98
|
+
};
|
|
54
99
|
/**
|
|
55
100
|
* Plugin controller.
|
|
56
101
|
*/
|
|
@@ -91,7 +136,67 @@ type Plugin = {
|
|
|
91
136
|
*/
|
|
92
137
|
close?: () => Promise<void>;
|
|
93
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* Vision plugin controller
|
|
141
|
+
*/
|
|
142
|
+
type VisionPlugin = {
|
|
143
|
+
/**
|
|
144
|
+
* Register a face pose callback which will be called if face is detected.
|
|
145
|
+
*/
|
|
146
|
+
registerFacePoseListener?: (facePoseListener: (facePose: FacePose) => void) => void;
|
|
147
|
+
/**
|
|
148
|
+
* Register a face measurement callback which will be called if face is detected.
|
|
149
|
+
*/
|
|
150
|
+
registerFaceMeasurementListener?: (faceMeasurementListener: (faceMeasurement: FaceMeasurement) => void) => void;
|
|
151
|
+
/**
|
|
152
|
+
* Switch the AR effect for preview
|
|
153
|
+
*
|
|
154
|
+
* This call is a thin wrapper around DeepAR.switchEffect API.
|
|
155
|
+
*
|
|
156
|
+
* @param arUrl A path to the AR effect file
|
|
157
|
+
* @returns Promise that resolves when an effect start rendering
|
|
158
|
+
*/
|
|
159
|
+
switchEffect?: (arUrl: string) => Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Clear the AR effect
|
|
162
|
+
*
|
|
163
|
+
* Call this after switchEffect to clear the loaded effect.
|
|
164
|
+
* @returns void
|
|
165
|
+
*/
|
|
166
|
+
clearEffect?: () => void;
|
|
167
|
+
};
|
|
94
168
|
|
|
169
|
+
/**
|
|
170
|
+
* ShopAR vision plugin.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* Using CDN:
|
|
174
|
+
* ```html
|
|
175
|
+
* <script src="../../shopar-plugin/shopar-plugin.js"></script>
|
|
176
|
+
* <script>
|
|
177
|
+
* const vision = ShopAR.vision.setup({ ... });
|
|
178
|
+
* </script>
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* Using a module bundler:
|
|
183
|
+
* ```js
|
|
184
|
+
* import { ShopAR } from 'shopar-plugin';
|
|
185
|
+
*
|
|
186
|
+
* const vision = ShopAR.vision.setup({ ... });
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare const vision: {
|
|
190
|
+
/**
|
|
191
|
+
* Initializes vision modules and renderes deepar canvas.
|
|
192
|
+
*
|
|
193
|
+
* If successful, function returns a handle to the VisionPlugin. This component alows for lower level control
|
|
194
|
+
* over DeepAR and truescale components.
|
|
195
|
+
*
|
|
196
|
+
* @param options Setup options.
|
|
197
|
+
*/
|
|
198
|
+
setup: (options: VisionOptions) => Promise<VisionPlugin>;
|
|
199
|
+
};
|
|
95
200
|
/**
|
|
96
201
|
* The ShopAR plugin.
|
|
97
202
|
*
|
|
@@ -123,4 +228,4 @@ declare const plugin: {
|
|
|
123
228
|
version: string;
|
|
124
229
|
};
|
|
125
230
|
|
|
126
|
-
export { plugin };
|
|
231
|
+
export { plugin, vision };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem;pointer-events:none}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer;pointer-events:auto}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array],o=n.length-2,r=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],a=window[r[i[i[o]]]][r[i[i[i.length-1]]]],s=a.charCodeAt(o),l=s^s,c=new n[1]([l]);function d(){const e=(new TextEncoder).encode(a),t=r.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[r[t[2]]](String.fromCodePoint(...e))}const u=[1e3,2e3,4e3],h=u.length;function p(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=h)throw e;return yield new Promise((e=>setTimeout(e,u[n]))),p(t,n+1)}}))}const f=["Glasses","Shoes","Watches"],m=["Shoes"];const g="0.1.1-alpha.5";let v=`https://cdn.jsdelivr.net/npm/shopar-plugin@${g}/dist`;const w={update:e=>{null!=e&&(v=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>v};function y(t){return e(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise((t=>{e.addEventListener("load",(()=>t()),!1),e.addEventListener("error",(()=>t()),!1),document.body.appendChild(e)}))}importScripts(t.toString())}))}let b;const R=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.warn('No <meta name="viewport"> detected; ShopAR will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})();let S,A,C;function E(e){const t=function(e){const t=new A.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,A.ClampToEdgeWrapping,A.ClampToEdgeWrapping,A.LinearFilter,A.LinearFilter,1,A.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(C.parse(e));return t.mapping=A.EquirectangularReflectionMapping,t.colorSpace=A.LinearSRGBColorSpace,t}const M=45,P=45,T=3,I=1.5,x=1,L=.5;let k,$,D,U,_,N,j=!1;const O=0,q=300,F=2e3,G=.05,W=1/(32*Math.PI);let Q,V,B,H=!1,z=1,K=1,X=1;const Z=1;let Y;const J=new Map;function ee(t,n,o){const r=t.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,d,u,h,p,f=!1,m=!0,g=!1,v=!1,w=!1,y=0,b=0,R=1,x=1,N=1;const j={threeInit:()=>{f||(te(),i=new V.Scene,a=new V.PerspectiveCamera(25,1,.5),s=new Q.OrbitControls(a,t),s.enableInteraction(),({renderShadow:c,shadowGroup:l}=function(e){const t=new k.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new k.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new k.Group;o.position.y=-.7;const r=new k.PlaneGeometry(M,P).rotateX(Math.PI/2),i=new k.MeshBasicMaterial({map:t.texture,opacity:L,transparent:!0,depthWrite:!1}),a=new k.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new k.Mesh(r);s.visible=!1,o.add(s);const l=new k.OrthographicCamera(-M/2,M/2,P/2,-P/2,0,T);function c(e){s.visible=!0,U.uniforms.tDiffuse.value=t.texture,U.uniforms.h.value=1*e/256,s.material=U,$.setRenderTarget(n),$.render(s,l),_.uniforms.tDiffuse.value=n.texture,_.uniforms.v.value=1*e/256,s.material=_,$.setRenderTarget(t),$.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,o.add(l),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=D;const o=$.getClearAlpha();$.setClearAlpha(0),$.setRenderTarget(t),$.render(e,l),e.overrideMaterial=null,c(I),c(.4*I),$.setRenderTarget(null),$.setClearAlpha(o),e.background=n}}}(i)),f=!0)},threeParse:(t,n,o)=>e(this,void 0,void 0,(function*(){return null!=d&&u===o||(yield d,d=(()=>e(this,void 0,void 0,(function*(){var e,o;return A=(e=Q).THREE,C=new e.RGBELoader,i.environment=E(n),function(e,t){const{THREE:n}=t;S=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder)}(Y,Q),o=t,S.parseAsync(o.buffer,"")})))(),u=o),d})),threeLoad:(e,t)=>{i.clear(),i.add(e.scene);const n=(new V.Box3).setFromObject(e.scene);l.position.y=n.min.y-O,i.add(l),c(),i.traverse((e=>{if(e instanceof V.Mesh){const t=e.material;t.depthWrite=!0,t instanceof V.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(Q.reduceVertices(e.scene,((e,t)=>Math.max(e,o.distanceToSquared(t))),0));s.reset(o,r,function(e,t){var n;const o={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?o.Glasses:null!==(n=o[e])&&void 0!==n?n:o.Glasses).normalize()}(t,V.Vector3)),w=!0},threePaused:()=>m,threeResume:()=>{m=!1,Y.setAnimationLoop(ne),t.style.visibility="visible",y=0,b=0},threePause:()=>{m=!0,function(){for(const{threePaused:e}of J.values())if(!e())return!1;return!0}()&&Y.setAnimationLoop(null),t.style.visibility="hidden",n.style.visibility="hidden"},threeSetToneMapping:e=>({ACES:V.ACESFilmicToneMapping,Linear:V.LinearToneMapping,Neutral:V.NeutralToneMapping}[e||"ACES"]||V.ACESFilmicToneMapping),threeSetOnInteracted:e=>{s.removeEventListener("change",h),h=e,s.addEventListener("change",e)},preRender_:e=>{if(!f||m)return;e=performance.now();const t=0!==b?e-b:0;if(b=e,!s.update()){if(v)return;if(w)return void(w=!1);if(null==p&&(p=()=>{w||(v=!0,n.style.visibility="hidden",null!=p&&(s.removeEventListener("change",p),p=null))},s.addEventListener("change",p)),y+=t,!(y>q&&y<=q+F))return o.style.opacity="0",void(y>q+2*F&&(y=0));{n.style.visibility="visible",o.style.opacity="1";const e=y-q,t=2*Math.PI/F*e,r=-Math.sin(t),i=Math.cos(t);o.style.transform=`translateX(${G*r*Math.min(R,x)}px)`,s.updateTheta(W*i)}}g=!0},shouldRender_:()=>!(!f||m)&&g,render_:()=>{const e=Y.toneMapping;Y.setViewport(0,0,t.width,t.height),Y.render(i,a),Y.toneMapping=e,g=!1,null!=r&&(r.clearRect(0,0,t.width,t.height),r.drawImage(B,0,K-t.height,t.width,t.height,0,0,t.width,t.height))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===R&&n===x&&X===N||(t.width=Math.ceil(e*X*Z),t.height=Math.ceil(n*X*Z),R=e,x=n,N=X,g=!0)},target_:t};return J.set(t,j),j}function te(){if(H)return;Q=window.ShopAR__THREE,V=Q.THREE,B=document.createElement("canvas");var e,t;B.style.position="block",Y=new V.WebGLRenderer({powerPreference:"high-performance",canvas:B,antialias:!0,alpha:!0}),Y.outputColorSpace=V.SRGBColorSpace,Y.toneMapping=V.ACESFilmicToneMapping,Y.setClearColor(new V.Color(16777215)),e=Y,t=Q,j||(k=t.THREE,$=e,D=new k.MeshDepthMaterial,D.userData.darkness={value:x},D.onBeforeCompile=e=>{e.uniforms.darkness=D.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},D.depthTest=!1,D.depthWrite=!1,U=new k.ShaderMaterial(t.HorizontalBlurShader),U.depthTest=!1,_=new k.ShaderMaterial(t.VerticalBlurShader),_.depthTest=!1,j=!0),oe(),H=!0}function ne(e){oe(),Y.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of J.values())t(e),n()&&o()}function oe(){let e=0,t=0;for(const{target_:n}of J.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=R();e=Math.ceil(e*n*Z),t=Math.ceil(t*n*Z),e===z&&t===K&&n===X||(z=e,K=t,X=n,Y.setSize(z,K,!1));for(const{updateSize_:e}of J.values())e()}const re={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},ie=Object.keys(re);function ae(e){return re[e]}function se(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const o=document.createElementNS("http://www.w3.org/2000/svg","image");o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),o.setAttribute("width",e),o.setAttribute("height",e),n.appendChild(o)}return n}const le="shopar-error";function ce(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=se("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;return r.style.display="none",r}const de="shopar-control";const ue="shopar-deepar-output";function he(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",t}function pe(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function fe(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function me(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const ge="shopar-main";const ve="shopar-qr-output";const we="shopar-three-output";var ye;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(ye||(ye={}));let be=!1;function Re(){be||(!function(){try{const e=document.createElement("style"),t=process.env.css;null!=t&&(e.innerHTML=t);const n=document.head;n.insertBefore(e,n.children[0])}catch(e){console.warn("Failed to write default ShopAR Plugin CSS.")}}(),be=!0)}function Se(){Re();const e=function(){const e=document.createElement("div");e.id=ge;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}(),t=function(){const e=new Image,t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),n=function(e){const t=document.createElement("div");t.id=ve;const n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.display="none";const o=document.createElement("div");o.className="shopar-qr";const r=o.style;r.position="relative",r.top="0",r.left="0",r.width="100%",r.height="100%",t.appendChild(o);const i=document.createElement("div");i.innerText="Scan on mobile or tablet to try on",i.style.textAlign="center",o.appendChild(i);const a=document.createElement("div");return a.appendChild(e),o.appendChild(a),t}(t);e.appendChild(n);const o=function(){const e=document.createElement("div");e.id=ue;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",e}();e.appendChild(o);const r=function(){const e=document.createElement("canvas");e.id=we;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",e}();e.appendChild(r);const i=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),a=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),s=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:o}=n;return o.position="absolute",o.width="100%",o.height="100%",o.pointerEvents="none",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(i,a);e.appendChild(s);const l=function(){const e=se("2rem",`${w}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),c=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",n.pointerEvents="none",t.appendChild(e),t}(l);e.appendChild(c);const d=he("shopar-ar-loading-container"),u=pe("shopar-ar-loading-text",ae("loading.ar"));d.appendChild(u);const h=fe("shopar-ar-loading-bar-bg"),p=me("shopar-ar-loading-bar-fg");h.appendChild(p),d.appendChild(h),e.appendChild(d);const f=he("shopar-3d-loading-container"),m=pe("shopar-3d-loading-text",ae("loading.3d"));f.appendChild(m);const g=fe("shopar-3d-loading-bar-bg"),v=me("shopar-3d-loading-bar-fg");g.appendChild(v),f.appendChild(g),e.appendChild(f);const y=function(){const e=document.createElement("div");e.id=le;const t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const r=se("4rem",`${w}/img/icons/close.svg`);n.appendChild(r);const i=document.createElement("div");i.className="shopar-error-title",i.textContent="Camera Error",n.appendChild(i);const a=document.createElement("div");return a.className="shopar-error-body",a.textContent="Please refresh the page and allow the use of camera.",n.appendChild(a),e}();e.appendChild(y);const b=function(){const e=document.createElement("div");return e.id=de,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(b);const R=ce("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");b.appendChild(R);const S=ce("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${w}/img/icons/cube.svg`);b.appendChild(S);const A=ce("shopar-btn-close","Close","Close ShopAR view",`${w}/img/icons/close.svg`);b.append(A);let C,E=ye.None,M=!1,P=!1,T=!1,I=!1;function x(){p.classList.remove("active"),d.style.visibility="hidden"}function L(){v.classList.remove("active"),f.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return n},getQRImage:function(){return t},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return r},getThreePrompt:function(){return c},getThreePromptImage:function(){return l},customizeDeepARPrompt:function(e,t){i.textContent=e,a.src=t},setVisibilityParameters:function(e,t,n,o,r){var i;M=e,P=t,T=n,I=o,C=r,Ae(b,M),Ae(R,M&&(T||P)&&E===ye.None),Ae(S,M&&I&&E===ye.None),Ae(A,M&&E!==ye.None),x(),L(),M||""===(i=y).style.display&&Ae(i,!1)},getUIState:function(){return E},setUIState:function(e){E=e,E===ye.None?(x(),L(),M&&(Ae(y,!1),Ae(A,!1),(P||T)&&Ae(R,!0),I&&Ae(S,!0))):E!==ye.QR&&E!==ye.AR&&E!==ye.Preview||M&&(Ae(y,!1),Ae(R,!1),Ae(S,!1),Ae(A,!0))},setDefaultUIActions:function(e,t,n){M&&((P||T)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${w}/img/icons/${n}`;R.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(C),R.onclick=e),I&&(S.onclick=t),A.onclick=n)},startDeepARLoading:function(){p.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:x,startThreeLoading:function(){v.classList.add("active"),f.style.visibility="visible"},stopThreeLoading:L,showCameraError:function(){M&&Ae(y,!0)}}}function Ae(e,t){e.style.display=t?"":"none"}const Ce=new Map;function Ee(t){let n=Ce.get(t);return null==n?(n=function(){let t=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Se()),n);return{getSetupId:()=>t,incrementSetupId_:()=>t++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:t,getQRImage:n}=i();o=function(t,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>e(this,void 0,void 0,(function*(){yield b;const e=`https://apps.deepar.ai/${g.includes("alpha")?"shopar-qr-alpha":"shopar-qr"}/?${new URLSearchParams({a:r,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(e),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,o=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){o=!0,t.style.display="none"}))}}(t(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=ee(e(),t(),n())}return r}}}(),Ce.set(t,n)):n.incrementSetupId_(),n}function Me(e){for(const t of Ce.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===ye.AR&&r(ye.None)}}let Pe;const Te=new Uint8Array(16);function Ie(){if(!Pe&&(Pe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pe(Te)}const xe=[];for(let e=0;e<256;++e)xe.push((e+256).toString(16).slice(1));var Le={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ke(e,t,n){if(Le.randomUUID&&!t&&!e)return Le.randomUUID();const o=(e=e||{}).random||(e.rng||Ie)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function(e,t=0){return xe[e[t+0]]+xe[e[t+1]]+xe[e[t+2]]+xe[e[t+3]]+"-"+xe[e[t+4]]+xe[e[t+5]]+"-"+xe[e[t+6]]+xe[e[t+7]]+"-"+xe[e[t+8]]+xe[e[t+9]]+"-"+xe[e[t+10]]+xe[e[t+11]]+xe[e[t+12]]+xe[e[t+13]]+xe[e[t+14]]+xe[e[t+15]]}(o)}const $e="qrLaunch",De="arLaunch",Ue="previewLaunch",_e="heartbeat";let Ne,je,Oe=!1;const qe=[];function Fe(e,t){const n=performance.now(),o=ke();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,d(_e,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const d=(r,i={})=>{var a;i=Object.assign(Object.assign({},i),{pluginVersion:g,sessionId:je,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),a=()=>{window.ShopAR__analytics.trackEventImpl(r,i)},Oe?a():qe.push(a)};return{trackEvent:d,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}function Ge(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function We(t){return e(this,void 0,void 0,(function*(){const e=document.createElement("video");return e.setAttribute("playsinline","playsinline"),e.srcObject=yield t,e}))}const Qe=200,Ve=10;let Be=!1;function He(t,n){return e(this,void 0,void 0,(function*(){Be=!1;const{ShopAR__TrueScale:o}=window;yield o.initialize(`${w}/wasm/mediapipe`,t);const r=[],i=setInterval((()=>e(this,void 0,void 0,(function*(){if(Be)return void clearInterval(i);const{error:e,faceWidth:t}=yield o.predict(performance.now());if(Be)return void clearInterval(i);if(null!=e)return void console.error(`TrueScale predict error: ${e}`);if(r.length<Ve)return void r.push(t);clearInterval(i);const a=function(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}(r);n(a)}))),Qe)}))}function ze(){Be=!0}function Ke(n){return e(this,void 0,void 0,(function*(){const o=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(n).catch((e=>{throw console.error(e),new t("Resource unavailable.")}));if(!e.ok)throw new t(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield o.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}var Xe="undefined"!=typeof Float32Array?Float32Array:Array;function Ze(){var e=new Xe(16);return Xe!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Ye(e,t,n){var o=t[0],r=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],d=t[7],u=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],R=n[2],S=n[3];return e[0]=y*o+b*s+R*u+S*m,e[1]=y*r+b*l+R*h+S*g,e[2]=y*i+b*c+R*p+S*v,e[3]=y*a+b*d+R*f+S*w,y=n[4],b=n[5],R=n[6],S=n[7],e[4]=y*o+b*s+R*u+S*m,e[5]=y*r+b*l+R*h+S*g,e[6]=y*i+b*c+R*p+S*v,e[7]=y*a+b*d+R*f+S*w,y=n[8],b=n[9],R=n[10],S=n[11],e[8]=y*o+b*s+R*u+S*m,e[9]=y*r+b*l+R*h+S*g,e[10]=y*i+b*c+R*p+S*v,e[11]=y*a+b*d+R*f+S*w,y=n[12],b=n[13],R=n[14],S=n[15],e[12]=y*o+b*s+R*u+S*m,e[13]=y*r+b*l+R*h+S*g,e[14]=y*i+b*c+R*p+S*v,e[15]=y*a+b*d+R*f+S*w,e}function Je(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function et(e,t){var n=t[0],o=t[1],r=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],d=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,d),e}function tt(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,d=a+a,u=r*l,h=r*c,p=r*d,f=i*c,m=i*d,g=a*d,v=s*l,w=s*c,y=s*d,b=o[0],R=o[1],S=o[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*R,e[5]=(1-(u+g))*R,e[6]=(m+v)*R,e[7]=0,e[8]=(p+w)*S,e[9]=(m-v)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function nt(){var e=new Xe(3);return Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ot(e,t,n){var o=new Xe(3);return o[0]=e,o[1]=t,o[2]=n,o}function rt(e,t){var n=t[0]-e[0],o=t[1]-e[1],r=t[2]-e[2];return Math.hypot(n,o,r)}function it(e,t,n){var o=t[0],r=t[1],i=t[2],a=n[3]*o+n[7]*r+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*o+n[4]*r+n[8]*i+n[12])/a,e[1]=(n[1]*o+n[5]*r+n[9]*i+n[13])/a,e[2]=(n[2]*o+n[6]*r+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function at(){var e=new Xe(4);return Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}nt(),function(){var e,t=(e=new Xe(4),Xe!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var st;let lt,ct,dt;nt(),ot(1,0,0),ot(0,1,0),at(),at(),st=new Xe(9),Xe!=Float32Array&&(st[1]=0,st[2]=0,st[3]=0,st[5]=0,st[6]=0,st[7]=0),st[0]=1,st[4]=1,st[8]=1;let ut,ht,pt,ft,mt=!0,gt=null;const vt=new Set;let wt,yt,bt,Rt,St;function At(n){return e(this,void 0,void 0,(function*(){return null==wt&&(wt=(()=>e(this,void 0,void 0,(function*(){if(null==(null===(e=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===e?void 0:e.getUserMedia))throw new t("No camera available!");var e;const o=Lt(pt),r=Ge(o),i=function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(pt);ut=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:n||"your_license_key_goes_here",previewElement:ft,additionalOptions:{hint:i,cameraConfig:{disableDefaultCamera:!0}}}),ht=yield We(r),yield kt(ut,ht,"user"===o),"Glasses"===pt&&(yield ct,He(ht,(e=>{Rt=e})))})))()),wt}))}function Ct(e){e!==pt&&(null!=ut&&(ut.shutdown(),ut=null,wt=null),pt=e)}function Et(e){e!==ft&&(ft=e,null!=ut&&ut.changePreviewElement(ft))}function Mt(e){gt=e}function Pt(e){ut.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(Rt){const e=137/(Rt+5);ut.changeParameterVector("GLASSES","","scale",e,e,e,0),ut.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const o=Dt("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Dt("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);ut.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),ut.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return void console.error(e)}}(e),Rt=null}e(),$t("Glasses")}},ut.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),$t("Shoes"))},ut.callbacks.onWristTracked=t=>{t.detected&&(e(),$t("Watches"))}}function Tt(t,n){return e(this,void 0,void 0,(function*(){return null!=yt&&bt===n||(yield yt,yt=ut.switchEffect(t),bt=n),yt}))}function It(){return e(this,void 0,void 0,(function*(){if(null!=ut){if(mt=!1,null==ht){const e=Lt(pt),t=Ge(e);ht=yield We(t),yield kt(ut,ht,"user"===e),He(ht,(e=>{Rt=e}))}!function(){if(null==gt)return;if(null==pt||vt.has(pt))return;gt.style.visibility="visible",gt.style.opacity="1"}(),ut.setPaused(mt),ft.style.display=""}}))}function xt(){null!=ut&&(mt=!0,ut.setPaused(mt),ze(),null!=ht&&null!=ht.srcObject&&ht.srcObject instanceof MediaStream&&(ht.srcObject.getTracks().forEach((e=>e.stop())),ht=null),function(){if(null==gt)return;gt.style.visibility="hidden",gt.style.opacity="0"}(),ut.stopCamera(),ft.style.display="none")}function Lt(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function kt(t,n,o){return e(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,o),r()}))))}}))}))}function $t(e){null!=gt&&(vt.has(e)||(vt.add(e),gt.style.opacity="0"))}function Dt(e,t,n,o,r,i,a){const s=ut.getTransformationBetween(e,t),l=Je(nt(),s),c=function(e,t){var n=new Xe(3);et(n,t);var o=1/n[0],r=1/n[1],i=1/n[2],a=t[0]*o,s=t[1]*r,l=t[2]*i,c=t[4]*o,d=t[5]*r,u=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+d+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(u-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>d&&a>f?(g=2*Math.sqrt(1+a-d-f),e[3]=(u-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):d>f?(g=2*Math.sqrt(1+d-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(u+p)/g):(g=2*Math.sqrt(1+f-a-d),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(u+p)/g,e[2]=.25*g),e}(at(),s);tt(s,c,l,ot(a,a,a));const d=ut.getTransformationBetween(t,n),u=Je(nt(),d);tt(d,at(),u,et(nt(),d));const h=Ye(Ze(),s,d),p=Je(nt(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=ut.getTransformationBetween(n,o)}catch(e){return console.error(e),f}const g=Ye(Ze(),d,m),v=Ye(Ze(),s,g),w=ot(p[0],i[1],i[2]),y=it(nt(),w,function(e,t){var n=t[0],o=t[1],r=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],d=t[8],u=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-o*a,y=n*l-r*a,b=n*c-i*a,R=o*l-r*s,S=o*c-i*s,A=r*c-i*l,C=d*m-u*f,E=d*g-h*f,M=d*v-p*f,P=u*g-h*m,T=u*v-p*m,I=h*v-p*g,x=w*I-y*T+b*P+R*M-S*E+A*C;return x?(x=1/x,e[0]=(s*I-l*T+c*P)*x,e[1]=(r*T-o*I-i*P)*x,e[2]=(m*A-g*S+v*R)*x,e[3]=(h*S-u*A-p*R)*x,e[4]=(l*M-a*I-c*E)*x,e[5]=(n*I-r*M+i*E)*x,e[6]=(g*b-f*A-v*y)*x,e[7]=(d*A-h*b+p*y)*x,e[8]=(a*T-s*M+c*C)*x,e[9]=(o*M-n*T-i*C)*x,e[10]=(f*S-m*b+v*w)*x,e[11]=(u*b-d*S-p*w)*x,e[12]=(s*E-a*P-l*C)*x,e[13]=(n*P-o*E+r*C)*x,e[14]=(m*y-f*R-g*w)*x,e[15]=(d*R-u*y+h*w)*x,e):null}(Ze(),v));let b=ut.getClosestPointOnMesh(o,y);try{const e=ut.getClosestPointOnMesh(r,y);rt(y,e)<rt(y,b)&&(b=e)}catch(e){console.error(e)}const R=it(nt(),b,g);return f-Math.atan2(R[0]-u[0],Math.abs(R[2]-u[2]))}function Ut(o,r,i){return e(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const d=String.fromCharCode(a+14);s>>=2,a^=s+2;const u=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const f=String.fromCharCode(a-7),m=window[`${h}${u+d+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${f}`],g=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${o}`).catch((()=>{throw new t("Unknown error.")}));if(!e.ok)throw new t("Unknown error.");return e})))),v=new n[0](yield(yield g.blob().catch((()=>{throw new t("Unknown error.")}))).arrayBuffer().catch((()=>{throw new t("Unknown error.")})));i+=s;const w=v.byteLength;if(c[l]=Math.min(76,r)*((a>>5)-1),152===c[l]&&(c[l]=w),i==l)return v;i=l,i^=l;for(let e=0,t=v.length;e<t;e++)c[l]^=c[i]<<13,c[l]^=c[i]>>17,c[l]^=c[i]<<5,v[e]=v[e]^c[l];return i^=c[0],i^=c[1],i^=c[2],v}))}function _t(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function Nt(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}const jt=["AR","3D"];function Ot(e){const{apiKey:n,sku:o,targetElement:r,initialState:i,baseUrl:a,defaultUI:s,strings:l}=e;_t(n,"apiKey"),Nt(n,"apiKey"),_t(o,"sku"),Nt(o,"sku"),_t(r,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,n,o){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!o.includes(e))throw new t(`'${n}' must be ${o.join("' or '")}.`)}(i,"initialState",jt),null!=a&&Nt(a,"baseUrl"),null!=s&&function(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}(s,"defaultUI"),null!=l&&function(e,n,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new t(`Value for key '${r}' in '${n}' must be a string.`)}}(l,"strings",ie)}function qt(n){var o,r;return e(this,void 0,void 0,(function*(){Ot(n);const{apiKey:i,sku:a,targetElement:s,initialState:l}=n;!function(e){const n=getComputedStyle(e);if(!["static","relative"].includes(n.position))throw new t(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${n.position}'.`)}(s),w.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(re,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(re[t]=n)}}(n.strings);const c=function(n,o){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams({apiKey:n,sku:o,sid:d()})}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield r.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(i,a),u=Ee(s),{getSetupId:h,findUI:g,findQR:v,findThree:R}=u,S=h();null==Ne&&(je=ke(),Ne=y(`${w}/shopar-analytics.js`),Ne.then((()=>{Oe=!0,window.ShopAR__analytics.initializeImpl(),qe.forEach((e=>e()))})));const{trackEvent:A,arInteracted:C,previewInteracted:E}=Fe(a,i);A("setup",{hostname:window.location.hostname});const M=yield c;A("apiResponse",M);const{category:P,arUrl:T,arKey:I,arPromptEnabled:x,arPromptText:L,arPromptImage:k,previewUrl:$,previewEnvUrl:D,previewToneMapping:U}=M;Ft(h(),S);const _=null!=T&&function(e){return null!=e&&f.includes(e)}(P),j=null==(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=n._internalOptions)||void 0===r?void 0:r.qrEnabled),O=_&&function(e){return null!=e&&m.includes(e)}(P),q=j&&O&&!(yield function(){var t;return e(this,void 0,void 0,(function*(){return null==St&&(St=y(`${w}/shopar-platform.js`)),yield St,["Android","iOS","Windows Phone",void 0].includes(null===(t=window.ShopAR__platform.platform.os)||void 0===t?void 0:t.family)}))}()),F=_&&!q,G=null!=$;if(Ft(h(),S),q&&function(){e(this,void 0,void 0,(function*(){null==b&&(b=y(`${w}/shopar-qr.js`))}))}(),F&&(null==lt&&(lt=y(`${w}/shopar-deepar.js`)),function(e){e!==dt&&(dt=e,Ke(e),yt=null,ze())}(T),"Glasses"===P&&null==ct&&(ct=y(`${w}/shopar-true-scale.js`))),G){null==N&&(N=y(`${w}/shopar-three.js`));const e=255;Ut($,(new Date).getTime()+e,Math.random()*e),Ke(null!=D?D:`${w}/env/default.hdr`)}const{setTargetElement:W,getDeepARTarget:Q,getDeepARPrompt:V,customizeDeepARPrompt:B,setVisibilityParameters:H,getUIState:z,setUIState:K,setDefaultUIActions:X,startDeepARLoading:Z,stopDeepARLoading:Y,startThreeLoading:J,stopThreeLoading:ee,showCameraError:te}=g();W(s);H(null==n.defaultUI||n.defaultUI,q,F,G,P),B(null!=L?L:"",null!=k?k:""),function(e,n){const o=e.parentNode;if(null==o)throw new t("Parent node missing.");new MutationObserver((t=>{for(const o of t)for(const t of o.removedNodes)if(t===e)return void n()})).observe(o,{childList:!0})}(s,(()=>{z()!==ye.QR||ne()||ie(),z()!==ye.AR||mt||xt(),z()!==ye.Preview||ce()||ue(),K(ye.None)}));const{qrPaused:ne,qrDraw:oe,qrPause:ie}=v(),{threeInit:ae,threeParse:se,threeLoad:le,threePaused:ce,threeResume:de,threePause:ue,threeSetToneMapping:he,threeSetOnInteracted:pe}=R();let fe=0;if(z()===ye.QR){if(!ne())if(q){A($e);try{yield oe(i,a)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else ie(),K(ye.None)}else if(z()===ye.AR){if(!mt)if(F){A(De);const e=yield Ke(T);Ft(h(),S),Me(u),Ct(P),Et(Q()),Mt(x?V():null),yield Tt(e,T),Pt(C),Ft(h(),S)}else xt(),K(ye.None)}else if(z()===ye.Preview&&!ce())if(G){A(Ue),J();const e=255,t=yield Ut($,(new Date).getTime()+e,Math.random()*e);Ft(h(),S);const n=yield Ke(null!=D?D:`${w}/env/default.hdr`);Ft(h(),S);const o=yield se(t,n,`${$}${D}`);Ft(h(),S),le(o,P),he(null!=U?U:"ACES"),pe(E),ee()}else ue(),K(ye.None);const me=()=>e(this,void 0,void 0,(function*(){if(q){if(z()===ye.QR||z()===ye.AR)throw new t("AR already launched.");try{A($e);const e=++fe;if(z()===ye.Preview&&G&&!ce()&&ue(),K(ye.QR),yield oe(i,a),fe!==e)return;return void Ft(h(),S)}catch(e){const n=e instanceof Error;throw A("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}}if(!F)throw new t("Model does not have AR enabled.");if(z()===ye.AR)throw new t("AR already launched.");try{A(De);const e=++fe;z()===ye.Preview&&G&&!ce()&&ue(),Me(u),K(ye.AR),Z();const t=yield Ke(T);if(fe!==e)return;if(Ft(h(),S),yield lt,fe!==e)return;if(Ft(h(),S),xt(),Ct(P),Et(Q()),Mt(x?V():null),yield At(I),fe!==e)return;if(Ft(h(),S),yield Tt(t,T),Pt(C),fe!==e)return;if(Ft(h(),S),yield It(),fe!==e)return;Ft(h(),S)}catch(e){const n=e instanceof Error;throw A("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),te(),xt(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{Y()}})),ge=()=>e(this,void 0,void 0,(function*(){if(!G)throw new t("Model does not have 3D enabled.");if(z()===ye.Preview)throw new t("3D already launched.");try{A(Ue);const e=++fe;z()===ye.AR&&(F&&!mt&&xt(),ie()),K(ye.Preview),J();const t=255,n=yield Ut($,(new Date).getTime()+t,Math.random()*t);if(fe!==e)return;Ft(h(),S);const o=yield Ke(null!=D?D:`${w}/env/default.hdr`);if(fe!==e)return;if(Ft(h(),S),yield N,fe!==e)return;if(Ft(h(),S),ae(),fe!==e)return;Ft(h(),S);const r=yield se(n,o,`${$}${D}`);if(fe!==e)return;Ft(h(),S),le(r,P),he(null!=U?U:"ACES"),pe(E),de()}catch(e){const n=e instanceof Error;throw A("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}finally{ee()}})),ve=()=>e(this,void 0,void 0,(function*(){if(z()===ye.None)throw new t("Neither AR or 3D launched.");++fe,z()===ye.QR||z()===ye.AR?(F&&!mt&&xt(),ie()):z()===ye.Preview&&G&&!ce()&&ue(),K(ye.None)}));return X(me,ge,ve),"AR"===l?(yield me(),Ft(h(),S)):"3D"===l&&(yield ge(),Ft(h(),S)),{launchAR:_?me:void 0,launch3D:G?ge:void 0,closeAR:_?()=>e(this,void 0,void 0,(function*(){if(z()!==ye.AR&&z()!==ye.QR)throw new t("AR not launched.");++fe,F&&!mt&&xt(),ie(),K(ye.None)})):void 0,close3D:G?()=>e(this,void 0,void 0,(function*(){if(z()!==ye.Preview)throw new t("3D not launched.");++fe,G&&!ce()&&ue(),K(ye.None)})):void 0,close:_||G?ve:void 0}}))}function Ft(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const Gt={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,o){return e(this,void 0,void 0,(function*(){try{return o()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>qt(n)))}))},version:g};export{Gt as plugin};
|
|
1
|
+
function e(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem;pointer-events:none}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer;pointer-events:auto}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class t extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const n=[Uint8Array,Uint32Array],o=n.length-2,r=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],i=[2,12,7,1],a=window[r[i[i[o]]]][r[i[i[i.length-1]]]],s=a.charCodeAt(o),c=s^s,l=new n[1]([c]);function d(){const e=(new TextEncoder).encode(a),t=r.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[r[t[2]]](String.fromCodePoint(...e))}const u=[1e3,2e3,4e3],h=u.length;function p(t,n=0){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(e){if(n>=h)throw e;return yield new Promise((e=>setTimeout(e,u[n]))),p(t,n+1)}}))}const f=["Glasses","Shoes","Watches"],m=["Shoes"];const g="0.1.2-alpha.0";let v=`https://cdn.jsdelivr.net/npm/shopar-plugin@${g}/dist`;const w={update:e=>{null!=e&&(v=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>v};function y(t){return e(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise((t=>{e.addEventListener("load",(()=>t()),!1),e.addEventListener("error",(()=>t()),!1),document.body.appendChild(e)}))}importScripts(t.toString())}))}let b;const S=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.warn('No <meta name="viewport"> detected; ShopAR will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})();let R,E,A;function C(e){const t=function(e){const t=new E.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,E.ClampToEdgeWrapping,E.ClampToEdgeWrapping,E.LinearFilter,E.LinearFilter,1,E.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(A.parse(e));return t.mapping=E.EquirectangularReflectionMapping,t.colorSpace=E.LinearSRGBColorSpace,t}const M=45,P=45,I=3,T=1.5,L=1,x=.5;let k,U,D,$,_,N,j=!1;const O=0,F=300,q=2e3,G=.05,W=1/(32*Math.PI);let V,K,Q,B=!1,H=1,z=1,X=1;const Z=1;let Y;const J=new Map;function ee(t,n,o){const r=t.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,c,l,d,u,h,p,f=!1,m=!0,g=!1,v=!1,w=!1,y=0,b=0,S=1,L=1,N=1;const j={threeInit:()=>{f||(te(),i=new K.Scene,a=new K.PerspectiveCamera(25,1,.5),s=new V.OrbitControls(a,t),s.enableInteraction(),({renderShadow:l,shadowGroup:c}=function(e){const t=new k.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new k.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new k.Group;o.position.y=-.7;const r=new k.PlaneGeometry(M,P).rotateX(Math.PI/2),i=new k.MeshBasicMaterial({map:t.texture,opacity:x,transparent:!0,depthWrite:!1}),a=new k.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new k.Mesh(r);s.visible=!1,o.add(s);const c=new k.OrthographicCamera(-M/2,M/2,P/2,-P/2,0,I);function l(e){s.visible=!0,$.uniforms.tDiffuse.value=t.texture,$.uniforms.h.value=1*e/256,s.material=$,U.setRenderTarget(n),U.render(s,c),_.uniforms.tDiffuse.value=n.texture,_.uniforms.v.value=1*e/256,s.material=_,U.setRenderTarget(t),U.render(s,c),s.visible=!1}return c.rotation.x=Math.PI/2,o.add(c),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=D;const o=U.getClearAlpha();U.setClearAlpha(0),U.setRenderTarget(t),U.render(e,c),e.overrideMaterial=null,l(T),l(.4*T),U.setRenderTarget(null),U.setClearAlpha(o),e.background=n}}}(i)),f=!0)},threeParse:(t,n,o)=>e(this,void 0,void 0,(function*(){return null!=d&&u===o||(yield d,d=(()=>e(this,void 0,void 0,(function*(){var e,o;return E=(e=V).THREE,A=new e.RGBELoader,i.environment=C(n),function(e,t){const{THREE:n}=t;R=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder)}(Y,V),o=t,R.parseAsync(o.buffer,"")})))(),u=o),d})),threeLoad:(e,t)=>{i.clear(),i.add(e.scene);const n=(new K.Box3).setFromObject(e.scene);c.position.y=n.min.y-O,i.add(c),l(),i.traverse((e=>{if(e instanceof K.Mesh){const t=e.material;t.depthWrite=!0,t instanceof K.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(V.reduceVertices(e.scene,((e,t)=>Math.max(e,o.distanceToSquared(t))),0));s.reset(o,r,function(e,t){var n;const o={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?o.Glasses:null!==(n=o[e])&&void 0!==n?n:o.Glasses).normalize()}(t,K.Vector3)),w=!0},threePaused:()=>m,threeResume:()=>{m=!1,Y.setAnimationLoop(ne),t.style.visibility="visible",y=0,b=0},threePause:()=>{m=!0,function(){for(const{threePaused:e}of J.values())if(!e())return!1;return!0}()&&Y.setAnimationLoop(null),t.style.visibility="hidden",n.style.visibility="hidden"},threeSetToneMapping:e=>({ACES:K.ACESFilmicToneMapping,Linear:K.LinearToneMapping,Neutral:K.NeutralToneMapping}[e||"ACES"]||K.ACESFilmicToneMapping),threeSetOnInteracted:e=>{s.removeEventListener("change",h),h=e,s.addEventListener("change",e)},preRender_:e=>{if(!f||m)return;e=performance.now();const t=0!==b?e-b:0;if(b=e,!s.update()){if(v)return;if(w)return void(w=!1);if(null==p&&(p=()=>{w||(v=!0,n.style.visibility="hidden",null!=p&&(s.removeEventListener("change",p),p=null))},s.addEventListener("change",p)),y+=t,!(y>F&&y<=F+q))return o.style.opacity="0",void(y>F+2*q&&(y=0));{n.style.visibility="visible",o.style.opacity="1";const e=y-F,t=2*Math.PI/q*e,r=-Math.sin(t),i=Math.cos(t);o.style.transform=`translateX(${G*r*Math.min(S,L)}px)`,s.updateTheta(W*i)}}g=!0},shouldRender_:()=>!(!f||m)&&g,render_:()=>{const e=Y.toneMapping;Y.setViewport(0,0,t.width,t.height),Y.render(i,a),Y.toneMapping=e,g=!1,null!=r&&(r.clearRect(0,0,t.width,t.height),r.drawImage(Q,0,z-t.height,t.width,t.height,0,0,t.width,t.height))},updateSize_:()=>{const{clientWidth:e,clientHeight:n}=t;e===S&&n===L&&X===N||(t.width=Math.ceil(e*X*Z),t.height=Math.ceil(n*X*Z),S=e,L=n,N=X,g=!0)},target_:t};return J.set(t,j),j}function te(){if(B)return;V=window.ShopAR__THREE,K=V.THREE,Q=document.createElement("canvas");var e,t;Q.style.position="block",Y=new K.WebGLRenderer({powerPreference:"high-performance",canvas:Q,antialias:!0,alpha:!0}),Y.outputColorSpace=K.SRGBColorSpace,Y.toneMapping=K.ACESFilmicToneMapping,Y.setClearColor(new K.Color(16777215)),e=Y,t=V,j||(k=t.THREE,U=e,D=new k.MeshDepthMaterial,D.userData.darkness={value:L},D.onBeforeCompile=e=>{e.uniforms.darkness=D.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},D.depthTest=!1,D.depthWrite=!1,$=new k.ShaderMaterial(t.HorizontalBlurShader),$.depthTest=!1,_=new k.ShaderMaterial(t.VerticalBlurShader),_.depthTest=!1,j=!0),oe(),B=!0}function ne(e){oe(),Y.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of J.values())t(e),n()&&o()}function oe(){let e=0,t=0;for(const{target_:n}of J.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=S();e=Math.ceil(e*n*Z),t=Math.ceil(t*n*Z),e===H&&t===z&&n===X||(H=e,z=t,X=n,Y.setSize(H,z,!1));for(const{updateSize_:e}of J.values())e()}const re={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},ie=Object.keys(re);function ae(e){return re[e]}function se(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const o=document.createElementNS("http://www.w3.org/2000/svg","image");o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),o.setAttribute("width",e),o.setAttribute("height",e),n.appendChild(o)}return n}const ce="shopar-error";function le(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=se("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;return r.style.display="none",r}const de="shopar-control";const ue="shopar-deepar-output";function he(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",t}function pe(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function fe(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function me(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const ge="shopar-main";const ve="shopar-qr-output";const we="shopar-three-output";var ye;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(ye||(ye={}));let be=!1;function Se(){be||(!function(){try{const e=document.createElement("style"),t=process.env.css;null!=t&&(e.innerHTML=t);const n=document.head;n.insertBefore(e,n.children[0])}catch(e){console.warn("Failed to write default ShopAR Plugin CSS.")}}(),be=!0)}function Re(){Se();const e=function(){const e=document.createElement("div");e.id=ge;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}(),t=function(){const e=new Image,t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),n=function(e){const t=document.createElement("div");t.id=ve;const n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.display="none";const o=document.createElement("div");o.className="shopar-qr";const r=o.style;r.position="relative",r.top="0",r.left="0",r.width="100%",r.height="100%",t.appendChild(o);const i=document.createElement("div");i.innerText="Scan on mobile or tablet to try on",i.style.textAlign="center",o.appendChild(i);const a=document.createElement("div");return a.appendChild(e),o.appendChild(a),t}(t);e.appendChild(n);const o=function(){const e=document.createElement("div");e.id=ue;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",e}();e.appendChild(o);const r=function(){const e=document.createElement("canvas");e.id=we;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",e}();e.appendChild(r);const i=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),a=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),s=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:o}=n;return o.position="absolute",o.width="100%",o.height="100%",o.pointerEvents="none",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(i,a);e.appendChild(s);const c=function(){const e=se("2rem",`${w}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),l=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",n.pointerEvents="none",t.appendChild(e),t}(c);e.appendChild(l);const d=he("shopar-ar-loading-container"),u=pe("shopar-ar-loading-text",ae("loading.ar"));d.appendChild(u);const h=fe("shopar-ar-loading-bar-bg"),p=me("shopar-ar-loading-bar-fg");h.appendChild(p),d.appendChild(h),e.appendChild(d);const f=he("shopar-3d-loading-container"),m=pe("shopar-3d-loading-text",ae("loading.3d"));f.appendChild(m);const g=fe("shopar-3d-loading-bar-bg"),v=me("shopar-3d-loading-bar-fg");g.appendChild(v),f.appendChild(g),e.appendChild(f);const y=function(){const e=document.createElement("div");e.id=ce;const t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const r=se("4rem",`${w}/img/icons/close.svg`);n.appendChild(r);const i=document.createElement("div");i.className="shopar-error-title",i.textContent="Camera Error",n.appendChild(i);const a=document.createElement("div");return a.className="shopar-error-body",a.textContent="Please refresh the page and allow the use of camera.",n.appendChild(a),e}();e.appendChild(y);const b=function(){const e=document.createElement("div");return e.id=de,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(b);const S=le("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");b.appendChild(S);const R=le("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${w}/img/icons/cube.svg`);b.appendChild(R);const E=le("shopar-btn-close","Close","Close ShopAR view",`${w}/img/icons/close.svg`);b.append(E);let A,C=ye.None,M=!1,P=!1,I=!1,T=!1;function L(){p.classList.remove("active"),d.style.visibility="hidden"}function x(){v.classList.remove("active"),f.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return n},getQRImage:function(){return t},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return r},getThreePrompt:function(){return l},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){i.textContent=e,a.src=t},setVisibilityParameters:function(e,t,n,o,r){var i;M=e,P=t,I=n,T=o,A=r,Ee(b,M),Ee(S,M&&(I||P)&&C===ye.None),Ee(R,M&&T&&C===ye.None),Ee(E,M&&C!==ye.None),L(),x(),M||""===(i=y).style.display&&Ee(i,!1)},getUIState:function(){return C},setUIState:function(e){C=e,C===ye.None?(L(),x(),M&&(Ee(y,!1),Ee(E,!1),(P||I)&&Ee(S,!0),T&&Ee(R,!0))):C!==ye.QR&&C!==ye.AR&&C!==ye.Preview||M&&(Ee(y,!1),Ee(S,!1),Ee(R,!1),Ee(E,!0))},setDefaultUIActions:function(e,t,n){M&&((P||I)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${w}/img/icons/${n}`;S.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(A),S.onclick=e),T&&(R.onclick=t),E.onclick=n)},startDeepARLoading:function(){p.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:L,startThreeLoading:function(){v.classList.add("active"),f.style.visibility="visible"},stopThreeLoading:x,showCameraError:function(){M&&Ee(y,!0)}}}function Ee(e,t){e.style.display=t?"":"none"}const Ae=new Map;function Ce(t){let n=Ae.get(t);return null==n?(n=function(){let t=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Re()),n);return{getSetupId:()=>t,incrementSetupId_:()=>t++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:t,getQRImage:n}=i();o=function(t,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>e(this,void 0,void 0,(function*(){yield b;const e=`https://apps.deepar.ai/${g.includes("alpha")?"shopar-qr-alpha":"shopar-qr"}/?${new URLSearchParams({a:r,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(e),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,o=!1,t.style.display=""})),qrPause:()=>e(this,void 0,void 0,(function*(){o=!0,t.style.display="none"}))}}(t(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=ee(e(),t(),n())}return r}}}(),Ae.set(t,n)):n.incrementSetupId_(),n}function Me(e){for(const t of Ae.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===ye.AR&&r(ye.None)}}let Pe;const Ie=new Uint8Array(16);function Te(){if(!Pe&&(Pe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pe(Ie)}const Le=[];for(let e=0;e<256;++e)Le.push((e+256).toString(16).slice(1));var xe={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ke(e,t,n){if(xe.randomUUID&&!t&&!e)return xe.randomUUID();const o=(e=e||{}).random||(e.rng||Te)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function(e,t=0){return Le[e[t+0]]+Le[e[t+1]]+Le[e[t+2]]+Le[e[t+3]]+"-"+Le[e[t+4]]+Le[e[t+5]]+"-"+Le[e[t+6]]+Le[e[t+7]]+"-"+Le[e[t+8]]+Le[e[t+9]]+"-"+Le[e[t+10]]+Le[e[t+11]]+Le[e[t+12]]+Le[e[t+13]]+Le[e[t+14]]+Le[e[t+15]]}(o)}const Ue="qrLaunch",De="arLaunch",$e="previewLaunch",_e="heartbeat";let Ne,je,Oe=!1;const Fe=[];function qe(){null==Ne&&(je=ke(),Ne=y(`${w}/shopar-analytics.js`),Ne.then((()=>{Oe=!0,window.ShopAR__analytics.initializeImpl(),Fe.forEach((e=>e()))})))}function Ge(e){Oe?e():Fe.push(e)}function We(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Ve(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 Ke=200,Qe=10;let Be=!1,He=null,ze=[],Xe=[];function Ze(t){return e(this,void 0,void 0,(function*(){Be=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${w}/wasm/mediapipe`,t),He&&(console.log("previous interval present, clearing"),clearInterval(He));const o=[],r=[];He=setInterval((()=>e(this,void 0,void 0,(function*(){if(Be)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());Be||(null!=a&&null!=s&&function(e){for(let t of ze)t(e)}({translation:a,rotation:s}),null==e?(o.push(t),r.push(i),o.length<Qe||(o.shift(),r.shift(),function(e,t){for(let n of Xe)n({faceWidth:e,IPD:t})}(Je(o),Je(r)))):console.error(`TrueScale predict error: ${e}`))}))),Ke)}))}function Ye(){Xe=[],ze=[],Be=!0}function Je(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}function et(n){return e(this,void 0,void 0,(function*(){const o=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(n).catch((e=>{throw console.error(e),new t("Resource unavailable.")}));if(!e.ok)throw new t(`Resource download failed with status ${e.status}.`);return e}))));try{return yield(yield o.blob()).arrayBuffer()}catch(e){throw console.error(e),new t("Resource has invalid body.")}}))}var tt="undefined"!=typeof Float32Array?Float32Array:Array;function nt(){var e=new tt(16);return tt!=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 ot(e,t,n){var o=t[0],r=t[1],i=t[2],a=t[3],s=t[4],c=t[5],l=t[6],d=t[7],u=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],S=n[2],R=n[3];return e[0]=y*o+b*s+S*u+R*m,e[1]=y*r+b*c+S*h+R*g,e[2]=y*i+b*l+S*p+R*v,e[3]=y*a+b*d+S*f+R*w,y=n[4],b=n[5],S=n[6],R=n[7],e[4]=y*o+b*s+S*u+R*m,e[5]=y*r+b*c+S*h+R*g,e[6]=y*i+b*l+S*p+R*v,e[7]=y*a+b*d+S*f+R*w,y=n[8],b=n[9],S=n[10],R=n[11],e[8]=y*o+b*s+S*u+R*m,e[9]=y*r+b*c+S*h+R*g,e[10]=y*i+b*l+S*p+R*v,e[11]=y*a+b*d+S*f+R*w,y=n[12],b=n[13],S=n[14],R=n[15],e[12]=y*o+b*s+S*u+R*m,e[13]=y*r+b*c+S*h+R*g,e[14]=y*i+b*l+S*p+R*v,e[15]=y*a+b*d+S*f+R*w,e}function rt(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function it(e,t){var n=t[0],o=t[1],r=t[2],i=t[4],a=t[5],s=t[6],c=t[8],l=t[9],d=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(c,l,d),e}function at(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],c=r+r,l=i+i,d=a+a,u=r*c,h=r*l,p=r*d,f=i*l,m=i*d,g=a*d,v=s*c,w=s*l,y=s*d,b=o[0],S=o[1],R=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)*S,e[5]=(1-(u+g))*S,e[6]=(m+v)*S,e[7]=0,e[8]=(p+w)*R,e[9]=(m-v)*R,e[10]=(1-(u+f))*R,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function st(){var e=new tt(3);return tt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ct(e,t,n){var o=new tt(3);return o[0]=e,o[1]=t,o[2]=n,o}function lt(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 dt(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 ut(){var e=new tt(4);return tt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}st(),function(){var e,t=(e=new tt(4),tt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var ht;let pt,ft,mt;st(),ct(1,0,0),ct(0,1,0),ut(),ut(),ht=new tt(9),tt!=Float32Array&&(ht[1]=0,ht[2]=0,ht[3]=0,ht[5]=0,ht[6]=0,ht[7]=0),ht[0]=1,ht[4]=1,ht[8]=1;let gt,vt,wt,yt,bt=!0,St=null;const Rt=new Set;let Et,At,Ct,Mt,Pt,It,Tt;function Lt(){null==pt&&(pt=y(`${w}/shopar-deepar.js`))}function xt(){null==ft&&(ft=y(`${w}/shopar-true-scale.js`))}function kt(n){return e(this,void 0,void 0,(function*(){const{licenseKey:o,truescaleUsecase:r}=n;return Pt=r,null==Et&&(Et=(()=>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=Ft(wt),r=We(n);gt=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:o||"your_license_key_goes_here",previewElement:yt,additionalOptions:{hint:It,cameraConfig:{disableDefaultCamera:!0}}}),vt=yield Ve(r),yield qt(gt,vt,"user"===n),"Glasses"===wt&&(yield ft,Ze(vt),"DetectionLoop"!==Pt&&Kt((e=>{Mt=e.faceWidth})))})))()),Et}))}function Ut(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===wt&&(n=t,o=It,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!=gt&&(gt.shutdown(),gt=null,Et=null),wt=e,It=t)}function Dt(e){e!==yt&&(yt=e,null!=gt&>.changePreviewElement(yt))}function $t(e){St=e}function _t(e){gt.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(Mt){const e=137/(Mt+5);gt.changeParameterVector("GLASSES","","scale",e,e,e,0),gt.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=Wt("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Wt("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);gt.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),gt.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return void console.error(e)}}(e),Ye(),Mt=null}e(),Gt("Glasses")}},gt.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),Gt("Shoes"))},gt.callbacks.onWristTracked=t=>{t.detected&&(e(),Gt("Watches"))}}function Nt(t,n){return e(this,void 0,void 0,(function*(){return null!=At&&Ct===n||(yield At,At=gt.switchEffect(t),Ct=n),At}))}function jt(){return e(this,void 0,void 0,(function*(){if(null!=gt){if(bt=!1,null==vt){const e=Ft(wt),t=We(e);vt=yield Ve(t),yield qt(gt,vt,"user"===e),Ze(vt),"DetectionLoop"!==Pt&&Kt((e=>{Mt=e.faceWidth}))}!function(){if(null==St)return;if(null==wt||Rt.has(wt))return;St.style.visibility="visible",St.style.opacity="1"}(),gt.setPaused(bt),yt.style.display=""}}))}function Ot(){null!=gt&&(bt=!0,gt.setPaused(bt),Ye(),null!=vt&&null!=vt.srcObject&&vt.srcObject instanceof MediaStream&&(vt.srcObject.getTracks().forEach((e=>e.stop())),vt=null),function(){if(null==St)return;St.style.visibility="hidden",St.style.opacity="0"}(),gt.stopCamera(),yt.style.display="none")}function Ft(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function qt(t,n,o){return e(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>e(this,void 0,void 0,(function*(){t.setVideoElement(n,o),r()}))))}}))}))}function Gt(e){null!=St&&(Rt.has(e)||(Rt.add(e),St.style.opacity="0"))}function Wt(e,t,n,o,r,i,a){const s=gt.getTransformationBetween(e,t),c=rt(st(),s),l=function(e,t){var n=new tt(3);it(n,t);var o=1/n[0],r=1/n[1],i=1/n[2],a=t[0]*o,s=t[1]*r,c=t[2]*i,l=t[4]*o,d=t[5]*r,u=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+d+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(u-p)/g,e[1]=(h-c)/g,e[2]=(s-l)/g):a>d&&a>f?(g=2*Math.sqrt(1+a-d-f),e[3]=(u-p)/g,e[0]=.25*g,e[1]=(s+l)/g,e[2]=(h+c)/g):d>f?(g=2*Math.sqrt(1+d-a-f),e[3]=(h-c)/g,e[0]=(s+l)/g,e[1]=.25*g,e[2]=(u+p)/g):(g=2*Math.sqrt(1+f-a-d),e[3]=(s-l)/g,e[0]=(h+c)/g,e[1]=(u+p)/g,e[2]=.25*g),e}(ut(),s);at(s,l,c,ct(a,a,a));const d=gt.getTransformationBetween(t,n),u=rt(st(),d);at(d,ut(),u,it(st(),d));const h=ot(nt(),s,d),p=rt(st(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=gt.getTransformationBetween(n,o)}catch(e){return console.error(e),f}const g=ot(nt(),d,m),v=ot(nt(),s,g),w=ct(p[0],i[1],i[2]),y=dt(st(),w,function(e,t){var n=t[0],o=t[1],r=t[2],i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],d=t[8],u=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-o*a,y=n*c-r*a,b=n*l-i*a,S=o*c-r*s,R=o*l-i*s,E=r*l-i*c,A=d*m-u*f,C=d*g-h*f,M=d*v-p*f,P=u*g-h*m,I=u*v-p*m,T=h*v-p*g,L=w*T-y*I+b*P+S*M-R*C+E*A;return L?(L=1/L,e[0]=(s*T-c*I+l*P)*L,e[1]=(r*I-o*T-i*P)*L,e[2]=(m*E-g*R+v*S)*L,e[3]=(h*R-u*E-p*S)*L,e[4]=(c*M-a*T-l*C)*L,e[5]=(n*T-r*M+i*C)*L,e[6]=(g*b-f*E-v*y)*L,e[7]=(d*E-h*b+p*y)*L,e[8]=(a*I-s*M+l*A)*L,e[9]=(o*M-n*I-i*A)*L,e[10]=(f*R-m*b+v*w)*L,e[11]=(u*b-d*R-p*w)*L,e[12]=(s*C-a*P-c*A)*L,e[13]=(n*P-o*C+r*A)*L,e[14]=(m*y-f*S-g*w)*L,e[15]=(d*S-u*y+h*w)*L,e):null}(nt(),v));let b=gt.getClosestPointOnMesh(o,y);try{const e=gt.getClosestPointOnMesh(r,y);lt(y,e)<lt(y,b)&&(b=e)}catch(e){console.error(e)}const S=dt(st(),b,g);return f-Math.atan2(S[0]-u[0],Math.abs(S[2]-u[2]))}function Vt(e){!function(e){ze.push(e)}(e)}function Kt(e){!function(e){Xe.push(e)}(e)}function Qt(o,r,i){return e(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const d=String.fromCharCode(a+14);s>>=2,a^=s+2;const u=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const f=String.fromCharCode(a-7),m=window[`${h}${u+d+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${f}`],g=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield m(`${o}`).catch((()=>{throw new t("Unknown error.")}));if(!e.ok)throw new t("Unknown error.");return e})))),v=new n[0](yield(yield g.blob().catch((()=>{throw new t("Unknown error.")}))).arrayBuffer().catch((()=>{throw new t("Unknown error.")})));i+=s;const w=v.byteLength;if(l[c]=Math.min(76,r)*((a>>5)-1),152===l[c]&&(l[c]=w),i==c)return v;i=c,i^=c;for(let e=0,t=v.length;e<t;e++)l[c]^=l[i]<<13,l[c]^=l[i]>>17,l[c]^=l[i]<<5,v[e]=v[e]^l[c];return i^=l[0],i^=l[1],i^=l[2],v}))}function Bt(e,n){if(null==e)throw new t(`'${n}' not specified.`)}function Ht(e,n){if("string"!=typeof e)throw new t(`'${n}' must be a string.`)}const zt=["AR","3D"];function Xt(e){const{apiKey:n,sku:o,targetElement:r,initialState:i,baseUrl:a,defaultUI:s,strings:c}=e;Bt(n,"apiKey"),Ht(n,"apiKey"),Bt(o,"sku"),Ht(o,"sku"),Bt(r,"targetElement"),function(e,n){if(!(e instanceof HTMLElement))throw new t(`'${n}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,n,o){if("string"!=typeof e)throw new t(`'${n}' must be a string.`);if(!o.includes(e))throw new t(`'${n}' must be ${o.join("' or '")}.`)}(i,"initialState",zt),null!=a&&Ht(a,"baseUrl"),null!=s&&function(e,n){if("boolean"!=typeof e)throw new t(`'${n}' must be a boolean.`)}(s,"defaultUI"),null!=c&&function(e,n,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new t(`Value for key '${r}' in '${n}' must be a string.`)}}(c,"strings",ie)}let Zt=!1;function Yt(n){return e(this,void 0,void 0,(function*(){const{targetElement:o}=n;w.update(n.baseUrl),qe();const{trackEvent:r}=function(e){const t=performance.now(),n=ke();return{trackEvent:(o,r={})=>{r=Object.assign(Object.assign({},r),{pluginVersion:g,sessionId:je,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),Ge((()=>{window.ShopAR__analytics.trackEventImpl(o,r)}))}}}(n.apiKey);r("visionSetup");const i=yield function(n){return e(this,void 0,void 0,(function*(){const o=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin/vision?${new URLSearchParams({apiKey:n,sid:d()})}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield o.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(n.apiKey);r("visionApiResponse",i);const{arKey:a}=i,s=Ce(o),{getSetupId:c,findUI:l}=s,u=c();Lt(),xt();const{setTargetElement:h,getDeepARTarget:f,setVisibilityParameters:m,getUIState:v,setUIState:y,startDeepARLoading:b,stopDeepARLoading:S,showCameraError:R}=l();if(v()!=ye.None)throw Error("UI state is not None, this is weird..");y(ye.AR),h(o),m(!1,!1,!0,!1,void 0),b(),yield pt,Jt(c(),u);try{r("visionArLaunch"),Ot(),Ut("Glasses",["faceInit"]),Dt(f()),yield kt({licenseKey:a,truescaleUsecase:"DetectionLoop"}),Jt(c(),u),yield jt(),Jt(c(),u)}catch(e){const n=e instanceof Error;throw r("visionArLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),R(),Ot(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{S()}return Zt=!0,{registerFacePoseListener:e=>{Zt&&(r("registerFacePoseListener"),Vt(e))},registerFaceMeasurementListener:e=>{Zt&&(r("registerFaceMeasurementListener"),Kt(e))},switchEffect:t=>e(this,void 0,void 0,(function*(){Zt&&(r("switchEffect",{arUrl:t}),function(e){gt.switchEffect(e)}(t))})),clearEffect:()=>{Zt&&(r("clearEffect"),gt.clearEffect())}}}))}function Jt(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}function en(n){var o,r;return e(this,void 0,void 0,(function*(){Xt(n);const{apiKey:i,sku:a,targetElement:s,initialState:c}=n;!function(e){const n=getComputedStyle(e);if(!["static","relative"].includes(n.position))throw new t(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${n.position}'.`)}(s),w.update(n.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(re,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(re[t]=n)}}(n.strings);const l=function(n,o){return e(this,void 0,void 0,(function*(){const r=yield p((()=>e(this,void 0,void 0,(function*(){const e=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams({apiKey:n,sku:o,sid:d()})}`).catch((e=>{throw console.error(e),new t("API unavailable.")}));if(!e.ok)throw new t(`API call failed with status ${e.status}.`);return e}))));try{return yield r.json()}catch(e){throw console.error(e),new t("API returned invalid body.")}}))}(i,a),u=Ce(s),{getSetupId:h,findUI:v,findQR:S,findThree:R}=u,E=h();qe();const{trackEvent:A,arInteracted:C,previewInteracted:M}=function(e,t){const n=performance.now(),o=ke();let r=0,i=0,a=0,s=0,c=0,l=!1;window.setInterval((()=>{l&&(r=i+a,l=!1,d(_e,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const d=(r,i={})=>{i=Object.assign(Object.assign({},i),{pluginVersion:g,sessionId:je,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),Ge((()=>{window.ShopAR__analytics.trackEventImpl(r,i)}))};return{trackEvent:d,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,l=!0)},previewInteracted:()=>{const e=performance.now(),t=e-c;c=e,t<200&&(a+=t,l=!0)}}}(a,i);A("setup",{hostname:window.location.hostname});const P=yield l;A("apiResponse",P);const{category:I,arUrl:T,arKey:L,arPromptEnabled:x,arPromptText:k,arPromptImage:U,previewUrl:D,previewEnvUrl:$,previewToneMapping:_}=P;tn(h(),E);const j=null!=T&&function(e){return null!=e&&f.includes(e)}(I),O=null==(null===(o=n._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=n._internalOptions)||void 0===r?void 0:r.qrEnabled),F=j&&function(e){return null!=e&&m.includes(e)}(I),q=O&&F&&!(yield function(){var t;return e(this,void 0,void 0,(function*(){return null==Tt&&(Tt=y(`${w}/shopar-platform.js`)),yield Tt,["Android","iOS","Windows Phone",void 0].includes(null===(t=window.ShopAR__platform.platform.os)||void 0===t?void 0:t.family)}))}()),G=j&&!q,W=null!=D;if(tn(h(),E),q&&function(){e(this,void 0,void 0,(function*(){null==b&&(b=y(`${w}/shopar-qr.js`))}))}(),G&&(Lt(),function(e){e!==mt&&(mt=e,et(e),At=null,Ye())}(T),"Glasses"===I&&xt()),W){null==N&&(N=y(`${w}/shopar-three.js`));const e=255;Qt(D,(new Date).getTime()+e,Math.random()*e),et(null!=$?$:`${w}/env/default.hdr`)}const{setTargetElement:V,getDeepARTarget:K,getDeepARPrompt:Q,customizeDeepARPrompt:B,setVisibilityParameters:H,getUIState:z,setUIState:X,setDefaultUIActions:Z,startDeepARLoading:Y,stopDeepARLoading:J,startThreeLoading:ee,stopThreeLoading:te,showCameraError:ne}=v();V(s);H(null==n.defaultUI||n.defaultUI,q,G,W,I),B(null!=k?k:"",null!=U?U:""),function(e,n){const o=e.parentNode;if(null==o)throw new t("Parent node missing.");new MutationObserver((t=>{for(const o of t)for(const t of o.removedNodes)if(t===e)return void n()})).observe(o,{childList:!0})}(s,(()=>{z()!==ye.QR||oe()||ae(),z()!==ye.AR||bt||Ot(),z()!==ye.Preview||de()||he(),X(ye.None)}));const{qrPaused:oe,qrDraw:ie,qrPause:ae}=S(),{threeInit:se,threeParse:ce,threeLoad:le,threePaused:de,threeResume:ue,threePause:he,threeSetToneMapping:pe,threeSetOnInteracted:fe}=R();let me=0;if(z()===ye.QR){if(!oe())if(q){A(Ue);try{yield ie(i,a)}catch(e){throw new t(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else ae(),X(ye.None)}else if(z()===ye.AR){if(!bt)if(G){A(De);const e=yield et(T);tn(h(),E),Me(u),Ut(I),Dt(K()),$t(x?Q():null),yield Nt(e,T),_t(C),tn(h(),E)}else Ot(),X(ye.None)}else if(z()===ye.Preview&&!de())if(W){A($e),ee();const e=255,t=yield Qt(D,(new Date).getTime()+e,Math.random()*e);tn(h(),E);const n=yield et(null!=$?$:`${w}/env/default.hdr`);tn(h(),E);const o=yield ce(t,n,`${D}${$}`);tn(h(),E),le(o,I),pe(null!=_?_:"ACES"),fe(M),te()}else he(),X(ye.None);const ge=()=>e(this,void 0,void 0,(function*(){if(q){if(z()===ye.QR||z()===ye.AR)throw new t("AR already launched.");try{A(Ue);const e=++me;if(z()===ye.Preview&&W&&!de()&&he(),X(ye.QR),yield ie(i,a),me!==e)return;return void tn(h(),E)}catch(e){const n=e instanceof Error;throw A("qrLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`QR failed: ${n?e.message:"Unknown error."}`)}}if(!G)throw new t("Model does not have AR enabled.");if(z()===ye.AR)throw new t("AR already launched.");try{A(De);const e=++me;z()===ye.Preview&&W&&!de()&&he(),Me(u),X(ye.AR),Y();const t=yield et(T);if(me!==e)return;if(tn(h(),E),yield pt,me!==e)return;if(tn(h(),E),Ot(),Ut(I),Dt(K()),$t(x?Q():null),yield kt({licenseKey:L}),me!==e)return;if(tn(h(),E),yield Nt(t,T),_t(C),me!==e)return;if(tn(h(),E),yield jt(),me!==e)return;tn(h(),E)}catch(e){const n=e instanceof Error;throw A("arLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),ne(),Ot(),new t(`AR failed: ${n?e.message:"Unknown error."}`)}finally{J()}})),ve=()=>e(this,void 0,void 0,(function*(){if(!W)throw new t("Model does not have 3D enabled.");if(z()===ye.Preview)throw new t("3D already launched.");try{A($e);const e=++me;z()===ye.AR&&(G&&!bt&&Ot(),ae()),X(ye.Preview),ee();const t=255,n=yield Qt(D,(new Date).getTime()+t,Math.random()*t);if(me!==e)return;tn(h(),E);const o=yield et(null!=$?$:`${w}/env/default.hdr`);if(me!==e)return;if(tn(h(),E),yield N,me!==e)return;if(tn(h(),E),se(),me!==e)return;tn(h(),E);const r=yield ce(n,o,`${D}${$}`);if(me!==e)return;tn(h(),E),le(r,I),pe(null!=_?_:"ACES"),fe(M),ue()}catch(e){const n=e instanceof Error;throw A("previewLaunchFailure",{errorName:n?e.name:"Unknown",errorMessage:n?e.message:""}),new t(`3D failed: ${n?e.message:"Unknown error."}`)}finally{te()}})),we=()=>e(this,void 0,void 0,(function*(){if(z()===ye.None)throw new t("Neither AR or 3D launched.");++me,z()===ye.QR||z()===ye.AR?(G&&!bt&&Ot(),ae()):z()===ye.Preview&&W&&!de()&&he(),X(ye.None)}));return Z(ge,ve,we),"AR"===c?(yield ge(),tn(h(),E)):"3D"===c&&(yield ve(),tn(h(),E)),Zt=!1,{launchAR:j?ge:void 0,launch3D:W?ve:void 0,closeAR:j?()=>e(this,void 0,void 0,(function*(){if(z()!==ye.AR&&z()!==ye.QR)throw new t("AR not launched.");++me,G&&!bt&&Ot(),ae(),X(ye.None)})):void 0,close3D:W?()=>e(this,void 0,void 0,(function*(){if(z()!==ye.Preview)throw new t("3D not launched.");++me,W&&!de()&&he(),X(ye.None)})):void 0,close:j||W?we:void 0}}))}function tn(e,n){if(e!==n)throw new t("Setup cancelled. Please ensure that setup is only called once.")}const nn={setup:function(t){return e(this,void 0,void 0,(function*(){return Yt(t)}))}},on={setup:function(n){return e(this,void 0,void 0,(function*(){return function(n,o){return e(this,void 0,void 0,(function*(){try{return o()}catch(e){throw e instanceof Error?new t(`${n} failed: ${e.message}`):(console.error(e),new t(`${n} failed.`))}}))}("setup",(()=>en(n)))}))},version:g};export{on as plugin,nn 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;pointer-events:none}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer;pointer-events:auto}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const o=[Uint8Array,Uint32Array],r=o.length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],a=[2,12,7,1],s=window[i[a[a[r]]]][i[a[a[a.length-1]]]],l=s.charCodeAt(r),c=l^l,d=new o[1]([c]);function u(){const e=(new TextEncoder).encode(s),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}const h=[1e3,2e3,4e3],p=h.length;function f(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=p)throw t;return yield new Promise((e=>setTimeout(e,h[n]))),f(e,n+1)}}))}const m=["Glasses","Shoes","Watches"],g=["Shoes"];const v="0.1.1-alpha.5";let w=`https://cdn.jsdelivr.net/npm/shopar-plugin@${v}/dist`;const y={update:e=>{null!=e&&(w=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>w};function b(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}let R;const S=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.warn('No <meta name="viewport"> detected; ShopAR will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})();let A,C,E;function M(e){const t=function(e){const t=new C.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,C.ClampToEdgeWrapping,C.ClampToEdgeWrapping,C.LinearFilter,C.LinearFilter,1,C.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(E.parse(e));return t.mapping=C.EquirectangularReflectionMapping,t.colorSpace=C.LinearSRGBColorSpace,t}const T=45,P=45,x=3,I=1.5,L=1,k=.5;let $,D,U,_,N,j,O=!1;const q=0,F=300,G=2e3,W=.05,Q=1/(32*Math.PI);let V,B,H,z=!1,K=1,X=1,Z=1;const Y=1;let J;const ee=new Map;function te(e,n,o){const r=e.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,l,c,d,u,h,p,f=!1,m=!0,g=!1,v=!1,w=!1,y=0,b=0,R=1,S=1,L=1;const j={threeInit:()=>{f||(ne(),i=new B.Scene,a=new B.PerspectiveCamera(25,1,.5),s=new V.OrbitControls(a,e),s.enableInteraction(),({renderShadow:c,shadowGroup:l}=function(e){const t=new $.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new $.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new $.Group;o.position.y=-.7;const r=new $.PlaneGeometry(T,P).rotateX(Math.PI/2),i=new $.MeshBasicMaterial({map:t.texture,opacity:k,transparent:!0,depthWrite:!1}),a=new $.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new $.Mesh(r);s.visible=!1,o.add(s);const l=new $.OrthographicCamera(-T/2,T/2,P/2,-P/2,0,x);function c(e){s.visible=!0,_.uniforms.tDiffuse.value=t.texture,_.uniforms.h.value=1*e/256,s.material=_,D.setRenderTarget(n),D.render(s,l),N.uniforms.tDiffuse.value=n.texture,N.uniforms.v.value=1*e/256,s.material=N,D.setRenderTarget(t),D.render(s,l),s.visible=!1}return l.rotation.x=Math.PI/2,o.add(l),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=U;const o=D.getClearAlpha();D.setClearAlpha(0),D.setRenderTarget(t),D.render(e,l),e.overrideMaterial=null,c(I),c(.4*I),D.setRenderTarget(null),D.setClearAlpha(o),e.background=n}}}(i)),f=!0)},threeParse:(e,n,o)=>t(this,void 0,void 0,(function*(){return null!=d&&u===o||(yield d,d=(()=>t(this,void 0,void 0,(function*(){var t,o;return C=(t=V).THREE,E=new t.RGBELoader,i.environment=M(n),function(e,t){const{THREE:n}=t;A=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder)}(J,V),o=e,A.parseAsync(o.buffer,"")})))(),u=o),d})),threeLoad:(e,t)=>{i.clear(),i.add(e.scene);const n=(new B.Box3).setFromObject(e.scene);l.position.y=n.min.y-q,i.add(l),c(),i.traverse((e=>{if(e instanceof B.Mesh){const t=e.material;t.depthWrite=!0,t instanceof B.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(V.reduceVertices(e.scene,((e,t)=>Math.max(e,o.distanceToSquared(t))),0));s.reset(o,r,function(e,t){var n;const o={Glasses:new t(67.5,15,90),Shoes:new t(-55,30,30),Watches:new t(0,-10,40),Handbags:new t(40,0,0),Rings:new t(0,0,10)};return(null==e?o.Glasses:null!==(n=o[e])&&void 0!==n?n:o.Glasses).normalize()}(t,B.Vector3)),w=!0},threePaused:()=>m,threeResume:()=>{m=!1,J.setAnimationLoop(oe),e.style.visibility="visible",y=0,b=0},threePause:()=>{m=!0,function(){for(const{threePaused:e}of ee.values())if(!e())return!1;return!0}()&&J.setAnimationLoop(null),e.style.visibility="hidden",n.style.visibility="hidden"},threeSetToneMapping:e=>({ACES:B.ACESFilmicToneMapping,Linear:B.LinearToneMapping,Neutral:B.NeutralToneMapping}[e||"ACES"]||B.ACESFilmicToneMapping),threeSetOnInteracted:e=>{s.removeEventListener("change",h),h=e,s.addEventListener("change",e)},preRender_:e=>{if(!f||m)return;e=performance.now();const t=0!==b?e-b:0;if(b=e,!s.update()){if(v)return;if(w)return void(w=!1);if(null==p&&(p=()=>{w||(v=!0,n.style.visibility="hidden",null!=p&&(s.removeEventListener("change",p),p=null))},s.addEventListener("change",p)),y+=t,!(y>F&&y<=F+G))return o.style.opacity="0",void(y>F+2*G&&(y=0));{n.style.visibility="visible",o.style.opacity="1";const e=y-F,t=2*Math.PI/G*e,r=-Math.sin(t),i=Math.cos(t);o.style.transform=`translateX(${W*r*Math.min(R,S)}px)`,s.updateTheta(Q*i)}}g=!0},shouldRender_:()=>!(!f||m)&&g,render_:()=>{const t=J.toneMapping;J.setViewport(0,0,e.width,e.height),J.render(i,a),J.toneMapping=t,g=!1,null!=r&&(r.clearRect(0,0,e.width,e.height),r.drawImage(H,0,X-e.height,e.width,e.height,0,0,e.width,e.height))},updateSize_:()=>{const{clientWidth:t,clientHeight:n}=e;t===R&&n===S&&Z===L||(e.width=Math.ceil(t*Z*Y),e.height=Math.ceil(n*Z*Y),R=t,S=n,L=Z,g=!0)},target_:e};return ee.set(e,j),j}function ne(){if(z)return;V=window.ShopAR__THREE,B=V.THREE,H=document.createElement("canvas");var e,t;H.style.position="block",J=new B.WebGLRenderer({powerPreference:"high-performance",canvas:H,antialias:!0,alpha:!0}),J.outputColorSpace=B.SRGBColorSpace,J.toneMapping=B.ACESFilmicToneMapping,J.setClearColor(new B.Color(16777215)),e=J,t=V,O||($=t.THREE,D=e,U=new $.MeshDepthMaterial,U.userData.darkness={value:L},U.onBeforeCompile=e=>{e.uniforms.darkness=U.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},U.depthTest=!1,U.depthWrite=!1,_=new $.ShaderMaterial(t.HorizontalBlurShader),_.depthTest=!1,N=new $.ShaderMaterial(t.VerticalBlurShader),N.depthTest=!1,O=!0),re(),z=!0}function oe(e){re(),J.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of ee.values())t(e),n()&&o()}function re(){let e=0,t=0;for(const{target_:n}of ee.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=S();e=Math.ceil(e*n*Y),t=Math.ceil(t*n*Y),e===K&&t===X&&n===Z||(K=e,X=t,Z=n,J.setSize(K,X,!1));for(const{updateSize_:e}of ee.values())e()}const ie={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},ae=Object.keys(ie);function se(e){return ie[e]}function le(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const o=document.createElementNS("http://www.w3.org/2000/svg","image");o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),o.setAttribute("width",e),o.setAttribute("height",e),n.appendChild(o)}return n}const ce="shopar-error";function de(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=le("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;return r.style.display="none",r}const ue="shopar-control";const he="shopar-deepar-output";function pe(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",t}function fe(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function me(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function ge(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const ve="shopar-main";const we="shopar-qr-output";const ye="shopar-three-output";var be;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(be||(be={}));let Re=!1;function Se(){Re||(!function(){try{const e=document.createElement("style"),t=process.env.css;null!=t&&(e.innerHTML=t);const n=document.head;n.insertBefore(e,n.children[0])}catch(e){console.warn("Failed to write default ShopAR Plugin CSS.")}}(),Re=!0)}function Ae(){Se();const e=function(){const e=document.createElement("div");e.id=ve;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}(),t=function(){const e=new Image,t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),n=function(e){const t=document.createElement("div");t.id=we;const n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.display="none";const o=document.createElement("div");o.className="shopar-qr";const r=o.style;r.position="relative",r.top="0",r.left="0",r.width="100%",r.height="100%",t.appendChild(o);const i=document.createElement("div");i.innerText="Scan on mobile or tablet to try on",i.style.textAlign="center",o.appendChild(i);const a=document.createElement("div");return a.appendChild(e),o.appendChild(a),t}(t);e.appendChild(n);const o=function(){const e=document.createElement("div");e.id=he;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",e}();e.appendChild(o);const r=function(){const e=document.createElement("canvas");e.id=ye;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",e}();e.appendChild(r);const i=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),a=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),s=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:o}=n;return o.position="absolute",o.width="100%",o.height="100%",o.pointerEvents="none",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(i,a);e.appendChild(s);const l=function(){const e=le("2rem",`${y}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),c=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",n.pointerEvents="none",t.appendChild(e),t}(l);e.appendChild(c);const d=pe("shopar-ar-loading-container"),u=fe("shopar-ar-loading-text",se("loading.ar"));d.appendChild(u);const h=me("shopar-ar-loading-bar-bg"),p=ge("shopar-ar-loading-bar-fg");h.appendChild(p),d.appendChild(h),e.appendChild(d);const f=pe("shopar-3d-loading-container"),m=fe("shopar-3d-loading-text",se("loading.3d"));f.appendChild(m);const g=me("shopar-3d-loading-bar-bg"),v=ge("shopar-3d-loading-bar-fg");g.appendChild(v),f.appendChild(g),e.appendChild(f);const w=function(){const e=document.createElement("div");e.id=ce;const t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const r=le("4rem",`${y}/img/icons/close.svg`);n.appendChild(r);const i=document.createElement("div");i.className="shopar-error-title",i.textContent="Camera Error",n.appendChild(i);const a=document.createElement("div");return a.className="shopar-error-body",a.textContent="Please refresh the page and allow the use of camera.",n.appendChild(a),e}();e.appendChild(w);const b=function(){const e=document.createElement("div");return e.id=ue,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(b);const R=de("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");b.appendChild(R);const S=de("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${y}/img/icons/cube.svg`);b.appendChild(S);const A=de("shopar-btn-close","Close","Close ShopAR view",`${y}/img/icons/close.svg`);b.append(A);let C,E=be.None,M=!1,T=!1,P=!1,x=!1;function I(){p.classList.remove("active"),d.style.visibility="hidden"}function L(){v.classList.remove("active"),f.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return n},getQRImage:function(){return t},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return r},getThreePrompt:function(){return c},getThreePromptImage:function(){return l},customizeDeepARPrompt:function(e,t){i.textContent=e,a.src=t},setVisibilityParameters:function(e,t,n,o,r){var i;M=e,T=t,P=n,x=o,C=r,Ce(b,M),Ce(R,M&&(P||T)&&E===be.None),Ce(S,M&&x&&E===be.None),Ce(A,M&&E!==be.None),I(),L(),M||""===(i=w).style.display&&Ce(i,!1)},getUIState:function(){return E},setUIState:function(e){E=e,E===be.None?(I(),L(),M&&(Ce(w,!1),Ce(A,!1),(T||P)&&Ce(R,!0),x&&Ce(S,!0))):E!==be.QR&&E!==be.AR&&E!==be.Preview||M&&(Ce(w,!1),Ce(R,!1),Ce(S,!1),Ce(A,!0))},setDefaultUIActions:function(e,t,n){M&&((T||P)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${y}/img/icons/${n}`;R.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(C),R.onclick=e),x&&(S.onclick=t),A.onclick=n)},startDeepARLoading:function(){p.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:I,startThreeLoading:function(){v.classList.add("active"),f.style.visibility="visible"},stopThreeLoading:L,showCameraError:function(){M&&Ce(w,!0)}}}function Ce(e,t){e.style.display=t?"":"none"}const Ee=new Map;function Me(e){let n=Ee.get(e);return null==n?(n=function(){let e=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Ae()),n);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:e,getQRImage:n}=i();o=function(e,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>t(this,void 0,void 0,(function*(){yield R;const t=`https://apps.deepar.ai/${v.includes("alpha")?"shopar-qr-alpha":"shopar-qr"}/?${new URLSearchParams({a:r,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(t),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,o=!1,e.style.display=""})),qrPause:()=>t(this,void 0,void 0,(function*(){o=!0,e.style.display="none"}))}}(e(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=te(e(),t(),n())}return r}}}(),Ee.set(e,n)):n.incrementSetupId_(),n}function Te(e){for(const t of Ee.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===be.AR&&r(be.None)}}let Pe;const xe=new Uint8Array(16);function Ie(){if(!Pe&&(Pe="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pe(xe)}const Le=[];for(let e=0;e<256;++e)Le.push((e+256).toString(16).slice(1));var ke={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $e(e,t,n){if(ke.randomUUID&&!t&&!e)return ke.randomUUID();const o=(e=e||{}).random||(e.rng||Ie)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function(e,t=0){return Le[e[t+0]]+Le[e[t+1]]+Le[e[t+2]]+Le[e[t+3]]+"-"+Le[e[t+4]]+Le[e[t+5]]+"-"+Le[e[t+6]]+Le[e[t+7]]+"-"+Le[e[t+8]]+Le[e[t+9]]+"-"+Le[e[t+10]]+Le[e[t+11]]+Le[e[t+12]]+Le[e[t+13]]+Le[e[t+14]]+Le[e[t+15]]}(o)}const De="qrLaunch",Ue="arLaunch",_e="previewLaunch",Ne="heartbeat";let je,Oe,qe=!1;const Fe=[];function Ge(e,t){const n=performance.now(),o=$e();let r=0,i=0,a=0,s=0,l=0,c=!1;window.setInterval((()=>{c&&(r=i+a,c=!1,d(Ne,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const d=(r,i={})=>{var a;i=Object.assign(Object.assign({},i),{pluginVersion:v,sessionId:Oe,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),a=()=>{window.ShopAR__analytics.trackEventImpl(r,i)},qe?a():Fe.push(a)};return{trackEvent:d,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,c=!0)},previewInteracted:()=>{const e=performance.now(),t=e-l;l=e,t<200&&(a+=t,c=!0)}}}function We(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Qe(e){return t(this,void 0,void 0,(function*(){const t=document.createElement("video");return t.setAttribute("playsinline","playsinline"),t.srcObject=yield e,t}))}const Ve=200,Be=10;let He=!1;function ze(e,n){return t(this,void 0,void 0,(function*(){He=!1;const{ShopAR__TrueScale:o}=window;yield o.initialize(`${y}/wasm/mediapipe`,e);const r=[],i=setInterval((()=>t(this,void 0,void 0,(function*(){if(He)return void clearInterval(i);const{error:e,faceWidth:t}=yield o.predict(performance.now());if(He)return void clearInterval(i);if(null!=e)return void console.error(`TrueScale predict error: ${e}`);if(r.length<Be)return void r.push(t);clearInterval(i);const a=function(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}(r);n(a)}))),Ve)}))}function Ke(){He=!0}function Xe(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new n("Resource unavailable.")}));if(!t.ok)throw new n(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield o.blob()).arrayBuffer()}catch(e){throw console.error(e),new n("Resource has invalid body.")}}))}var Ze="undefined"!=typeof Float32Array?Float32Array:Array;function Ye(){var e=new Ze(16);return Ze!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Je(e,t,n){var o=t[0],r=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],d=t[7],u=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],R=n[2],S=n[3];return e[0]=y*o+b*s+R*u+S*m,e[1]=y*r+b*l+R*h+S*g,e[2]=y*i+b*c+R*p+S*v,e[3]=y*a+b*d+R*f+S*w,y=n[4],b=n[5],R=n[6],S=n[7],e[4]=y*o+b*s+R*u+S*m,e[5]=y*r+b*l+R*h+S*g,e[6]=y*i+b*c+R*p+S*v,e[7]=y*a+b*d+R*f+S*w,y=n[8],b=n[9],R=n[10],S=n[11],e[8]=y*o+b*s+R*u+S*m,e[9]=y*r+b*l+R*h+S*g,e[10]=y*i+b*c+R*p+S*v,e[11]=y*a+b*d+R*f+S*w,y=n[12],b=n[13],R=n[14],S=n[15],e[12]=y*o+b*s+R*u+S*m,e[13]=y*r+b*l+R*h+S*g,e[14]=y*i+b*c+R*p+S*v,e[15]=y*a+b*d+R*f+S*w,e}function et(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function tt(e,t){var n=t[0],o=t[1],r=t[2],i=t[4],a=t[5],s=t[6],l=t[8],c=t[9],d=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(l,c,d),e}function nt(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],l=r+r,c=i+i,d=a+a,u=r*l,h=r*c,p=r*d,f=i*c,m=i*d,g=a*d,v=s*l,w=s*c,y=s*d,b=o[0],R=o[1],S=o[2];return e[0]=(1-(f+g))*b,e[1]=(h+y)*b,e[2]=(p-w)*b,e[3]=0,e[4]=(h-y)*R,e[5]=(1-(u+g))*R,e[6]=(m+v)*R,e[7]=0,e[8]=(p+w)*S,e[9]=(m-v)*S,e[10]=(1-(u+f))*S,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function ot(){var e=new Ze(3);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function rt(e,t,n){var o=new Ze(3);return o[0]=e,o[1]=t,o[2]=n,o}function it(e,t){var n=t[0]-e[0],o=t[1]-e[1],r=t[2]-e[2];return Math.hypot(n,o,r)}function at(e,t,n){var o=t[0],r=t[1],i=t[2],a=n[3]*o+n[7]*r+n[11]*i+n[15];return a=a||1,e[0]=(n[0]*o+n[4]*r+n[8]*i+n[12])/a,e[1]=(n[1]*o+n[5]*r+n[9]*i+n[13])/a,e[2]=(n[2]*o+n[6]*r+n[10]*i+n[14])/a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function st(){var e=new Ze(4);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}ot(),function(){var e,t=(e=new Ze(4),Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var lt;let ct,dt,ut;ot(),rt(1,0,0),rt(0,1,0),st(),st(),lt=new Ze(9),Ze!=Float32Array&&(lt[1]=0,lt[2]=0,lt[3]=0,lt[5]=0,lt[6]=0,lt[7]=0),lt[0]=1,lt[4]=1,lt[8]=1;let ht,pt,ft,mt,gt=!0,vt=null;const wt=new Set;let yt,bt,Rt,St,At;function Ct(e){return t(this,void 0,void 0,(function*(){return null==yt&&(yt=(()=>t(this,void 0,void 0,(function*(){if(null==(null===(t=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===t?void 0:t.getUserMedia))throw new n("No camera available!");var t;const o=kt(ft),r=We(o),i=function(e){const t={Glasses:["rigidFaceTrackingInit","faceInit"],Shoes:["footInit"],Watches:["wristInit"]};return null==e?void 0:t[e]}(ft);ht=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:e||"your_license_key_goes_here",previewElement:mt,additionalOptions:{hint:i,cameraConfig:{disableDefaultCamera:!0}}}),pt=yield Qe(r),yield $t(ht,pt,"user"===o),"Glasses"===ft&&(yield dt,ze(pt,(e=>{St=e})))})))()),yt}))}function Et(e){e!==ft&&(null!=ht&&(ht.shutdown(),ht=null,yt=null),ft=e)}function Mt(e){e!==mt&&(mt=e,null!=ht&&ht.changePreviewElement(mt))}function Tt(e){vt=e}function Pt(e){ht.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(St){const e=137/(St+5);ht.changeParameterVector("GLASSES","","scale",e,e,e,0),ht.changeParameterVector("shopar_glasses","","scale",e,e,e,0),function(e){const t=[-8.362421,4.549,-9.275],n=[8.362421,4.549,-9.275];try{const o=Ut("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Ut("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);ht.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),ht.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return void console.error(e)}}(e),St=null}e(),Dt("Glasses")}},ht.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),Dt("Shoes"))},ht.callbacks.onWristTracked=t=>{t.detected&&(e(),Dt("Watches"))}}function xt(e,n){return t(this,void 0,void 0,(function*(){return null!=bt&&Rt===n||(yield bt,bt=ht.switchEffect(e),Rt=n),bt}))}function It(){return t(this,void 0,void 0,(function*(){if(null!=ht){if(gt=!1,null==pt){const e=kt(ft),t=We(e);pt=yield Qe(t),yield $t(ht,pt,"user"===e),ze(pt,(e=>{St=e}))}!function(){if(null==vt)return;if(null==ft||wt.has(ft))return;vt.style.visibility="visible",vt.style.opacity="1"}(),ht.setPaused(gt),mt.style.display=""}}))}function Lt(){null!=ht&&(gt=!0,ht.setPaused(gt),Ke(),null!=pt&&null!=pt.srcObject&&pt.srcObject instanceof MediaStream&&(pt.srcObject.getTracks().forEach((e=>e.stop())),pt=null),function(){if(null==vt)return;vt.style.visibility="hidden",vt.style.opacity="0"}(),ht.stopCamera(),mt.style.display="none")}function kt(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function $t(e,n,o){return t(this,void 0,void 0,(function*(){yield new Promise((r=>{n.onloadedmetadata=()=>{n.play().then((()=>t(this,void 0,void 0,(function*(){e.setVideoElement(n,o),r()}))))}}))}))}function Dt(e){null!=vt&&(wt.has(e)||(wt.add(e),vt.style.opacity="0"))}function Ut(e,t,n,o,r,i,a){const s=ht.getTransformationBetween(e,t),l=et(ot(),s),c=function(e,t){var n=new Ze(3);tt(n,t);var o=1/n[0],r=1/n[1],i=1/n[2],a=t[0]*o,s=t[1]*r,l=t[2]*i,c=t[4]*o,d=t[5]*r,u=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+d+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(u-p)/g,e[1]=(h-l)/g,e[2]=(s-c)/g):a>d&&a>f?(g=2*Math.sqrt(1+a-d-f),e[3]=(u-p)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(h+l)/g):d>f?(g=2*Math.sqrt(1+d-a-f),e[3]=(h-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(u+p)/g):(g=2*Math.sqrt(1+f-a-d),e[3]=(s-c)/g,e[0]=(h+l)/g,e[1]=(u+p)/g,e[2]=.25*g),e}(st(),s);nt(s,c,l,rt(a,a,a));const d=ht.getTransformationBetween(t,n),u=et(ot(),d);nt(d,st(),u,tt(ot(),d));const h=Je(Ye(),s,d),p=et(ot(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=ht.getTransformationBetween(n,o)}catch(e){return console.error(e),f}const g=Je(Ye(),d,m),v=Je(Ye(),s,g),w=rt(p[0],i[1],i[2]),y=at(ot(),w,function(e,t){var n=t[0],o=t[1],r=t[2],i=t[3],a=t[4],s=t[5],l=t[6],c=t[7],d=t[8],u=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-o*a,y=n*l-r*a,b=n*c-i*a,R=o*l-r*s,S=o*c-i*s,A=r*c-i*l,C=d*m-u*f,E=d*g-h*f,M=d*v-p*f,T=u*g-h*m,P=u*v-p*m,x=h*v-p*g,I=w*x-y*P+b*T+R*M-S*E+A*C;return I?(I=1/I,e[0]=(s*x-l*P+c*T)*I,e[1]=(r*P-o*x-i*T)*I,e[2]=(m*A-g*S+v*R)*I,e[3]=(h*S-u*A-p*R)*I,e[4]=(l*M-a*x-c*E)*I,e[5]=(n*x-r*M+i*E)*I,e[6]=(g*b-f*A-v*y)*I,e[7]=(d*A-h*b+p*y)*I,e[8]=(a*P-s*M+c*C)*I,e[9]=(o*M-n*P-i*C)*I,e[10]=(f*S-m*b+v*w)*I,e[11]=(u*b-d*S-p*w)*I,e[12]=(s*E-a*T-l*C)*I,e[13]=(n*T-o*E+r*C)*I,e[14]=(m*y-f*R-g*w)*I,e[15]=(d*R-u*y+h*w)*I,e):null}(Ye(),v));let b=ht.getClosestPointOnMesh(o,y);try{const e=ht.getClosestPointOnMesh(r,y);it(y,e)<it(y,b)&&(b=e)}catch(e){console.error(e)}const R=at(ot(),b,g);return f-Math.atan2(R[0]-u[0],Math.abs(R[2]-u[2]))}function _t(e,r,i){return t(this,void 0,void 0,(function*(){let a="glb".charCodeAt(0),s="3d".charCodeAt(0);a>>=1,a+=s;const l=String.fromCharCode(a+14);s>>=2,a^=s+2;const u=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const p=String.fromCharCode(a-7),m=window[`${h}${u+l+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${p}`],g=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield m(`${e}`).catch((()=>{throw new n("Unknown error.")}));if(!t.ok)throw new n("Unknown error.");return t})))),v=new o[0](yield(yield g.blob().catch((()=>{throw new n("Unknown error.")}))).arrayBuffer().catch((()=>{throw new n("Unknown error.")})));i+=s;const w=v.byteLength;if(d[c]=Math.min(76,r)*((a>>5)-1),152===d[c]&&(d[c]=w),i==c)return v;i=c,i^=c;for(let e=0,t=v.length;e<t;e++)d[c]^=d[i]<<13,d[c]^=d[i]>>17,d[c]^=d[i]<<5,v[e]=v[e]^d[c];return i^=d[0],i^=d[1],i^=d[2],v}))}function Nt(e,t){if(null==e)throw new n(`'${t}' not specified.`)}function jt(e,t){if("string"!=typeof e)throw new n(`'${t}' must be a string.`)}const Ot=["AR","3D"];function qt(e){const{apiKey:t,sku:o,targetElement:r,initialState:i,baseUrl:a,defaultUI:s,strings:l}=e;Nt(t,"apiKey"),jt(t,"apiKey"),Nt(o,"sku"),jt(o,"sku"),Nt(r,"targetElement"),function(e,t){if(!(e instanceof HTMLElement))throw new n(`'${t}' must be an HTMLElement.`)}(r,"targetElement"),null!=i&&function(e,t,o){if("string"!=typeof e)throw new n(`'${t}' must be a string.`);if(!o.includes(e))throw new n(`'${t}' must be ${o.join("' or '")}.`)}(i,"initialState",Ot),null!=a&&jt(a,"baseUrl"),null!=s&&function(e,t){if("boolean"!=typeof e)throw new n(`'${t}' must be a boolean.`)}(s,"defaultUI"),null!=l&&function(e,t,o){for(const r of o){const o=e[r];if(null!=o&&"string"!=typeof o)throw new n(`Value for key '${r}' in '${t}' must be a string.`)}}(l,"strings",ae)}function Ft(e){var o,r;return t(this,void 0,void 0,(function*(){qt(e);const{apiKey:i,sku:a,targetElement:s,initialState:l}=e;!function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new n(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(s),y.update(e.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(ie,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(ie[t]=n)}}(e.strings);const c=function(e,o){return t(this,void 0,void 0,(function*(){const r=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams({apiKey:e,sku:o,sid:u()})}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield r.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(i,a),d=Me(s),{getSetupId:h,findUI:p,findQR:v,findThree:w}=d,S=h();null==je&&(Oe=$e(),je=b(`${y}/shopar-analytics.js`),je.then((()=>{qe=!0,window.ShopAR__analytics.initializeImpl(),Fe.forEach((e=>e()))})));const{trackEvent:A,arInteracted:C,previewInteracted:E}=Ge(a,i);A("setup",{hostname:window.location.hostname});const M=yield c;A("apiResponse",M);const{category:T,arUrl:P,arKey:x,arPromptEnabled:I,arPromptText:L,arPromptImage:k,previewUrl:$,previewEnvUrl:D,previewToneMapping:U}=M;Gt(h(),S);const _=null!=P&&function(e){return null!=e&&m.includes(e)}(T),N=null==(null===(o=e._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=e._internalOptions)||void 0===r?void 0:r.qrEnabled),O=_&&function(e){return null!=e&&g.includes(e)}(T),q=N&&O&&!(yield function(){var e;return t(this,void 0,void 0,(function*(){return null==At&&(At=b(`${y}/shopar-platform.js`)),yield At,["Android","iOS","Windows Phone",void 0].includes(null===(e=window.ShopAR__platform.platform.os)||void 0===e?void 0:e.family)}))}()),F=_&&!q,G=null!=$;if(Gt(h(),S),q&&function(){t(this,void 0,void 0,(function*(){null==R&&(R=b(`${y}/shopar-qr.js`))}))}(),F&&(null==ct&&(ct=b(`${y}/shopar-deepar.js`)),function(e){e!==ut&&(ut=e,Xe(e),bt=null,Ke())}(P),"Glasses"===T&&null==dt&&(dt=b(`${y}/shopar-true-scale.js`))),G){null==j&&(j=b(`${y}/shopar-three.js`));const e=255;_t($,(new Date).getTime()+e,Math.random()*e),Xe(null!=D?D:`${y}/env/default.hdr`)}const{setTargetElement:W,getDeepARTarget:Q,getDeepARPrompt:V,customizeDeepARPrompt:B,setVisibilityParameters:H,getUIState:z,setUIState:K,setDefaultUIActions:X,startDeepARLoading:Z,stopDeepARLoading:Y,startThreeLoading:J,stopThreeLoading:ee,showCameraError:te}=p();W(s);H(null==e.defaultUI||e.defaultUI,q,F,G,T),B(null!=L?L:"",null!=k?k:""),function(e,t){const o=e.parentNode;if(null==o)throw new n("Parent node missing.");new MutationObserver((n=>{for(const o of n)for(const n of o.removedNodes)if(n===e)return void t()})).observe(o,{childList:!0})}(s,(()=>{z()!==be.QR||ne()||re(),z()!==be.AR||gt||Lt(),z()!==be.Preview||ce()||ue(),K(be.None)}));const{qrPaused:ne,qrDraw:oe,qrPause:re}=v(),{threeInit:ae,threeParse:se,threeLoad:le,threePaused:ce,threeResume:de,threePause:ue,threeSetToneMapping:he,threeSetOnInteracted:pe}=w();let fe=0;if(z()===be.QR){if(!ne())if(q){A(De);try{yield oe(i,a)}catch(e){throw new n(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else re(),K(be.None)}else if(z()===be.AR){if(!gt)if(F){A(Ue);const e=yield Xe(P);Gt(h(),S),Te(d),Et(T),Mt(Q()),Tt(I?V():null),yield xt(e,P),Pt(C),Gt(h(),S)}else Lt(),K(be.None)}else if(z()===be.Preview&&!ce())if(G){A(_e),J();const e=255,t=yield _t($,(new Date).getTime()+e,Math.random()*e);Gt(h(),S);const n=yield Xe(null!=D?D:`${y}/env/default.hdr`);Gt(h(),S);const o=yield se(t,n,`${$}${D}`);Gt(h(),S),le(o,T),he(null!=U?U:"ACES"),pe(E),ee()}else ue(),K(be.None);const me=()=>t(this,void 0,void 0,(function*(){if(q){if(z()===be.QR||z()===be.AR)throw new n("AR already launched.");try{A(De);const e=++fe;if(z()===be.Preview&&G&&!ce()&&ue(),K(be.QR),yield oe(i,a),fe!==e)return;return void Gt(h(),S)}catch(e){const t=e instanceof Error;throw A("qrLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`QR failed: ${t?e.message:"Unknown error."}`)}}if(!F)throw new n("Model does not have AR enabled.");if(z()===be.AR)throw new n("AR already launched.");try{A(Ue);const e=++fe;z()===be.Preview&&G&&!ce()&&ue(),Te(d),K(be.AR),Z();const t=yield Xe(P);if(fe!==e)return;if(Gt(h(),S),yield ct,fe!==e)return;if(Gt(h(),S),Lt(),Et(T),Mt(Q()),Tt(I?V():null),yield Ct(x),fe!==e)return;if(Gt(h(),S),yield xt(t,P),Pt(C),fe!==e)return;if(Gt(h(),S),yield It(),fe!==e)return;Gt(h(),S)}catch(e){const t=e instanceof Error;throw A("arLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),te(),Lt(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{Y()}})),ge=()=>t(this,void 0,void 0,(function*(){if(!G)throw new n("Model does not have 3D enabled.");if(z()===be.Preview)throw new n("3D already launched.");try{A(_e);const e=++fe;z()===be.AR&&(F&&!gt&&Lt(),re()),K(be.Preview),J();const t=255,n=yield _t($,(new Date).getTime()+t,Math.random()*t);if(fe!==e)return;Gt(h(),S);const o=yield Xe(null!=D?D:`${y}/env/default.hdr`);if(fe!==e)return;if(Gt(h(),S),yield j,fe!==e)return;if(Gt(h(),S),ae(),fe!==e)return;Gt(h(),S);const r=yield se(n,o,`${$}${D}`);if(fe!==e)return;Gt(h(),S),le(r,T),he(null!=U?U:"ACES"),pe(E),de()}catch(e){const t=e instanceof Error;throw A("previewLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`3D failed: ${t?e.message:"Unknown error."}`)}finally{ee()}})),ve=()=>t(this,void 0,void 0,(function*(){if(z()===be.None)throw new n("Neither AR or 3D launched.");++fe,z()===be.QR||z()===be.AR?(F&&!gt&&Lt(),re()):z()===be.Preview&&G&&!ce()&&ue(),K(be.None)}));return X(me,ge,ve),"AR"===l?(yield me(),Gt(h(),S)):"3D"===l&&(yield ge(),Gt(h(),S)),{launchAR:_?me:void 0,launch3D:G?ge:void 0,closeAR:_?()=>t(this,void 0,void 0,(function*(){if(z()!==be.AR&&z()!==be.QR)throw new n("AR not launched.");++fe,F&&!gt&&Lt(),re(),K(be.None)})):void 0,close3D:G?()=>t(this,void 0,void 0,(function*(){if(z()!==be.Preview)throw new n("3D not launched.");++fe,G&&!ce()&&ue(),K(be.None)})):void 0,close:_||G?ve:void 0}}))}function Gt(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}const Wt={setup:function(e){return t(this,void 0,void 0,(function*(){return function(e,o){return t(this,void 0,void 0,(function*(){try{return o()}catch(t){throw t instanceof Error?new n(`${e} failed: ${t.message}`):(console.error(t),new n(`${e} failed.`))}}))}("setup",(()=>Ft(e)))}))},version:v};e.plugin=Wt}));
|
|
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{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))}!function(){const e={css:".shopar-btn-container{position:absolute;width:100%;bottom:0;padding-bottom:2rem;display:flex;justify-content:center;gap:.5rem;pointer-events:none}.shopar-btn{padding:.5rem .75rem;display:flex;justify-content:center;align-items:center;gap:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:9999px;cursor:pointer;pointer-events:auto}.shopar-btn:hover{background-color:#f5f5f5}.shopar-loading-container{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#fff}.shopar-loading-text{text-align:center}.shopar-loading-bar-bg{width:80%;height:.5rem;background-color:#e5e7eb;border-radius:9999px}.shopar-loading-bar-fg{background-color:#1434f7;border-radius:9999px;transition:none;transform:translateX(-100%);will-change:transform}.shopar-loading-bar-fg.active{transition:transform 5s cubic-bezier(0,0,.2,1);transform:none}.shopar-qr{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:#fff}.shopar-ar-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;background-color:#1e293bb2;transition:.3s ease-in-out opacity}.shopar-ar-prompt-text{text-align:center;color:#fff}.shopar-ar-prompt-img{max-width:80%;max-height:50%;object-fit:contain}"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}(),"function"==typeof SuppressedError&&SuppressedError;class n extends Error{constructor(e){super(`ShopAR Plugin: ${e}`)}}const o=[Uint8Array,Uint32Array],r=o.length-2,i=["addEventListener","alert","atob","blur","btoa","cancelAnimationFrame","localStorage","location","locationbar","hash","hasOwnProperty","host","hostname","href","requestAnimationFrame"],a=[2,12,7,1],s=window[i[a[a[r]]]][i[a[a[a.length-1]]]],c=s.charCodeAt(r),l=c^c,d=new o[1]([l]);function u(){const e=(new TextEncoder).encode(s),t=i.map((e=>e.length));for(let n=0;n<e.length;n++)e[n]^=t[n%t.length];return window[i[t[2]]](String.fromCodePoint(...e))}const h=[1e3,2e3,4e3],p=h.length;function f(e,n=0){return t(this,void 0,void 0,(function*(){try{return yield e()}catch(t){if(n>=p)throw t;return yield new Promise((e=>setTimeout(e,h[n]))),f(e,n+1)}}))}const m=["Glasses","Shoes","Watches"],g=["Shoes"];const v="0.1.2-alpha.0";let w=`https://cdn.jsdelivr.net/npm/shopar-plugin@${v}/dist`;const y={update:e=>{null!=e&&(w=e.endsWith("/")?e.substring(0,e.length-1):e)},toString:()=>w};function b(e){return t(this,void 0,void 0,(function*(){if("function"!=typeof importScripts){const t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise((e=>{t.addEventListener("load",(()=>e()),!1),t.addEventListener("error",(()=>e()),!1),document.body.appendChild(t)}))}importScripts(e.toString())}))}let S;const R=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.warn('No <meta name="viewport"> detected; ShopAR will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})();let A,E,C;function M(e){const t=function(e){const t=new E.DataTexture(e.data,e.width,e.height,void 0,e.type,void 0,E.ClampToEdgeWrapping,E.ClampToEdgeWrapping,E.LinearFilter,E.LinearFilter,1,E.LinearSRGBColorSpace);return t.flipY=!0,t.generateMipmaps=!1,t.needsUpdate=!0,t}(C.parse(e));return t.mapping=E.EquirectangularReflectionMapping,t.colorSpace=E.LinearSRGBColorSpace,t}const P=45,I=45,T=3,L=1.5,x=1,k=.5;let U,D,$,_,N,j,O=!1;const F=0,q=300,G=2e3,W=.05,V=1/(32*Math.PI);let K,Q,B,H=!1,z=1,X=1,Z=1;const Y=1;let J;const ee=new Map;function te(e,n,o){const r=e.getContext("2d");null==r&&console.warn("2D context missing.");let i,a,s,c,l,d,u,h,p,f=!1,m=!0,g=!1,v=!1,w=!1,y=0,b=0,S=1,R=1,x=1;const j={threeInit:()=>{f||(ne(),i=new Q.Scene,a=new Q.PerspectiveCamera(25,1,.5),s=new K.OrbitControls(a,e),s.enableInteraction(),({renderShadow:l,shadowGroup:c}=function(e){const t=new U.WebGLRenderTarget(512,512);t.texture.generateMipmaps=!1;const n=new U.WebGLRenderTarget(512,512);n.texture.generateMipmaps=!1;const o=new U.Group;o.position.y=-.7;const r=new U.PlaneGeometry(P,I).rotateX(Math.PI/2),i=new U.MeshBasicMaterial({map:t.texture,opacity:k,transparent:!0,depthWrite:!1}),a=new U.Mesh(r,i);a.renderOrder=1,a.scale.y=-1,o.add(a);const s=new U.Mesh(r);s.visible=!1,o.add(s);const c=new U.OrthographicCamera(-P/2,P/2,I/2,-I/2,0,T);function l(e){s.visible=!0,_.uniforms.tDiffuse.value=t.texture,_.uniforms.h.value=1*e/256,s.material=_,D.setRenderTarget(n),D.render(s,c),N.uniforms.tDiffuse.value=n.texture,N.uniforms.v.value=1*e/256,s.material=N,D.setRenderTarget(t),D.render(s,c),s.visible=!1}return c.rotation.x=Math.PI/2,o.add(c),{shadowGroup:o,renderShadow:()=>{const n=e.background;e.background=null,e.overrideMaterial=$;const o=D.getClearAlpha();D.setClearAlpha(0),D.setRenderTarget(t),D.render(e,c),e.overrideMaterial=null,l(L),l(.4*L),D.setRenderTarget(null),D.setClearAlpha(o),e.background=n}}}(i)),f=!0)},threeParse:(e,n,o)=>t(this,void 0,void 0,(function*(){return null!=d&&u===o||(yield d,d=(()=>t(this,void 0,void 0,(function*(){var t,o;return E=(t=K).THREE,C=new t.RGBELoader,i.environment=M(n),function(e,t){const{THREE:n}=t;A=(new t.GLTFLoader).setDRACOLoader((new t.DRACOLoader).setDecoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/draco/gltf/`)).setKTX2Loader((new t.KTX2Loader).setTranscoderPath(`https://cdn.jsdelivr.net/npm/three@0.${n.REVISION}.0/examples/jsm/libs/basis/`).detectSupport(e)).setMeshoptDecoder(t.MeshoptDecoder)}(J,K),o=e,A.parseAsync(o.buffer,"")})))(),u=o),d})),threeLoad:(e,t)=>{i.clear(),i.add(e.scene);const n=(new Q.Box3).setFromObject(e.scene);c.position.y=n.min.y-F,i.add(c),l(),i.traverse((e=>{if(e instanceof Q.Mesh){const t=e.material;t.depthWrite=!0,t instanceof Q.MeshPhysicalMaterial&&t.transmissionMap&&(t.transmission=1,t.toneMapped=!1,t.fog=!1,t.needsUpdate=!0)}}));const o=n.min.clone().add(n.max).divideScalar(2),r=Math.sqrt(K.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,Q.Vector3)),w=!0},threePaused:()=>m,threeResume:()=>{m=!1,J.setAnimationLoop(oe),e.style.visibility="visible",y=0,b=0},threePause:()=>{m=!0,function(){for(const{threePaused:e}of ee.values())if(!e())return!1;return!0}()&&J.setAnimationLoop(null),e.style.visibility="hidden",n.style.visibility="hidden"},threeSetToneMapping:e=>({ACES:Q.ACESFilmicToneMapping,Linear:Q.LinearToneMapping,Neutral:Q.NeutralToneMapping}[e||"ACES"]||Q.ACESFilmicToneMapping),threeSetOnInteracted:e=>{s.removeEventListener("change",h),h=e,s.addEventListener("change",e)},preRender_:e=>{if(!f||m)return;e=performance.now();const t=0!==b?e-b:0;if(b=e,!s.update()){if(v)return;if(w)return void(w=!1);if(null==p&&(p=()=>{w||(v=!0,n.style.visibility="hidden",null!=p&&(s.removeEventListener("change",p),p=null))},s.addEventListener("change",p)),y+=t,!(y>q&&y<=q+G))return o.style.opacity="0",void(y>q+2*G&&(y=0));{n.style.visibility="visible",o.style.opacity="1";const e=y-q,t=2*Math.PI/G*e,r=-Math.sin(t),i=Math.cos(t);o.style.transform=`translateX(${W*r*Math.min(S,R)}px)`,s.updateTheta(V*i)}}g=!0},shouldRender_:()=>!(!f||m)&&g,render_:()=>{const t=J.toneMapping;J.setViewport(0,0,e.width,e.height),J.render(i,a),J.toneMapping=t,g=!1,null!=r&&(r.clearRect(0,0,e.width,e.height),r.drawImage(B,0,X-e.height,e.width,e.height,0,0,e.width,e.height))},updateSize_:()=>{const{clientWidth:t,clientHeight:n}=e;t===S&&n===R&&Z===x||(e.width=Math.ceil(t*Z*Y),e.height=Math.ceil(n*Z*Y),S=t,R=n,x=Z,g=!0)},target_:e};return ee.set(e,j),j}function ne(){if(H)return;K=window.ShopAR__THREE,Q=K.THREE,B=document.createElement("canvas");var e,t;B.style.position="block",J=new Q.WebGLRenderer({powerPreference:"high-performance",canvas:B,antialias:!0,alpha:!0}),J.outputColorSpace=Q.SRGBColorSpace,J.toneMapping=Q.ACESFilmicToneMapping,J.setClearColor(new Q.Color(16777215)),e=J,t=K,O||(U=t.THREE,D=e,$=new U.MeshDepthMaterial,$.userData.darkness={value:x},$.onBeforeCompile=e=>{e.uniforms.darkness=$.userData.darkness;const t=e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );");e.fragmentShader=`uniform float darkness;\n${t}`},$.depthTest=!1,$.depthWrite=!1,_=new U.ShaderMaterial(t.HorizontalBlurShader),_.depthTest=!1,N=new U.ShaderMaterial(t.VerticalBlurShader),N.depthTest=!1,O=!0),re(),H=!0}function oe(e){re(),J.clear();for(const{preRender_:t,shouldRender_:n,render_:o}of ee.values())t(e),n()&&o()}function re(){let e=0,t=0;for(const{target_:n}of ee.values()){const{clientWidth:o,clientHeight:r}=n;e=Math.max(e,o),t=Math.max(t,r)}const n=R();e=Math.ceil(e*n*Y),t=Math.ceil(t*n*Y),e===z&&t===X&&n===Z||(z=e,X=t,Z=n,J.setSize(z,X,!1));for(const{updateSize_:e}of ee.values())e()}const ie={"loading.ar":"Loading Try On...","loading.3d":"Loading 3D..."},ae=Object.keys(ie);function se(e){return ie[e]}function ce(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",e),n.setAttribute("height",e);{const o=document.createElementNS("http://www.w3.org/2000/svg","image");o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),o.setAttribute("width",e),o.setAttribute("height",e),n.appendChild(o)}return n}const le="shopar-error";function de(e,t,n,o){const r=document.createElement("button");r.id=e,r.type="button",r.className="shopar-btn";{const e=ce("1.75rem",o);r.appendChild(e)}{const e=document.createElement("span");e.textContent=t,r.appendChild(e)}r.ariaLabel=n;return r.style.display="none",r}const ue="shopar-control";const he="shopar-deepar-output";function pe(e){const t=document.createElement("div");t.classList.add("shopar-loading-container",e);const n=t.style;return n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",t}function fe(e,t){const n=document.createElement("div");return n.classList.add("shopar-loading-text",e),n.textContent=t,n.style.textAlign="center",n}function me(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-bg",e);const n=t.style;return n.position="relative",n.overflow="hidden",t}function ge(e){const t=document.createElement("div");t.classList.add("shopar-loading-bar-fg",e);const n=t.style;return n.width="100%",n.height="100%",t}const ve="shopar-main";const we="shopar-qr-output";const ye="shopar-three-output";var be;!function(e){e[e.None=0]="None",e[e.QR=1]="QR",e[e.AR=2]="AR",e[e.Preview=3]="Preview"}(be||(be={}));let Se=!1;function Re(){Se||(!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.")}}(),Se=!0)}function Ae(){Re();const e=function(){const e=document.createElement("div");e.id=ve;const t=e.style;return t.position="absolute",t.top="0",t.bottom="0",t.left="0",t.right="0",e}(),t=function(){const e=new Image,t=e.style;return t.maxWidth="100%",t.maxHeight="100%",e}(),n=function(e){const t=document.createElement("div");t.id=we;const n=t.style;n.position="absolute",n.top="0",n.left="0",n.width="100%",n.height="100%",n.display="none";const o=document.createElement("div");o.className="shopar-qr";const r=o.style;r.position="relative",r.top="0",r.left="0",r.width="100%",r.height="100%",t.appendChild(o);const i=document.createElement("div");i.innerText="Scan on mobile or tablet to try on",i.style.textAlign="center",o.appendChild(i);const a=document.createElement("div");return a.appendChild(e),o.appendChild(a),t}(t);e.appendChild(n);const o=function(){const e=document.createElement("div");e.id=he;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.display="none",e}();e.appendChild(o);const r=function(){const e=document.createElement("canvas");e.id=ye;const t=e.style;return t.position="absolute",t.top="0",t.left="0",t.width="100%",t.height="100%",t.visibility="hidden",e}();e.appendChild(r);const i=function(){const e=document.createElement("div");return e.className="shopar-ar-prompt-text",e}(),a=function(){const e=new Image;return e.className="shopar-ar-prompt-img",e}(),s=function(e,t){const n=document.createElement("div");n.className="shopar-ar-prompt";const{style:o}=n;return o.position="absolute",o.width="100%",o.height="100%",o.pointerEvents="none",o.opacity="0",n.appendChild(e),n.appendChild(t),n}(i,a);e.appendChild(s);const c=function(){const e=ce("2rem",`${y}/img/prompt/3d-interaction.svg`),{style:t}=e;return t.transition="opacity 0.3s",t.opacity="0",e}(),l=function(e){const t=document.createElement("div"),{style:n}=t;return n.visibility="hidden",n.position="absolute",n.width="100%",n.height="100%",n.display="flex",n.justifyContent="center",n.alignItems="center",n.pointerEvents="none",t.appendChild(e),t}(c);e.appendChild(l);const d=pe("shopar-ar-loading-container"),u=fe("shopar-ar-loading-text",se("loading.ar"));d.appendChild(u);const h=me("shopar-ar-loading-bar-bg"),p=ge("shopar-ar-loading-bar-fg");h.appendChild(p),d.appendChild(h),e.appendChild(d);const f=pe("shopar-3d-loading-container"),m=fe("shopar-3d-loading-text",se("loading.3d"));f.appendChild(m);const g=me("shopar-3d-loading-bar-bg"),v=ge("shopar-3d-loading-bar-fg");g.appendChild(v),f.appendChild(g),e.appendChild(f);const w=function(){const e=document.createElement("div");e.id=le;const t=e.style;t.position="absolute",t.width="100%",t.height="100%",t.display="none";const n=document.createElement("div"),o=n.style;o.position="absolute",o.width="100%",o.height="100%",o.backgroundColor="#ffffff",o.display="flex",o.flexDirection="column",o.justifyContent="center",o.alignItems="center",e.appendChild(n);const r=ce("4rem",`${y}/img/icons/close.svg`);n.appendChild(r);const i=document.createElement("div");i.className="shopar-error-title",i.textContent="Camera Error",n.appendChild(i);const a=document.createElement("div");return a.className="shopar-error-body",a.textContent="Please refresh the page and allow the use of camera.",n.appendChild(a),e}();e.appendChild(w);const b=function(){const e=document.createElement("div");return e.id=ue,e.role="group",e.ariaLabel="Preview type chooser",e.className="shopar-btn-container",e.style.display="none",e}();e.appendChild(b);const S=de("shopar-btn-vto","Try-on","Launch ShopAR virtual try-on","data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E");b.appendChild(S);const R=de("shopar-btn-3d","3D","Launch ShopAR 3D preview",`${y}/img/icons/cube.svg`);b.appendChild(R);const A=de("shopar-btn-close","Close","Close ShopAR view",`${y}/img/icons/close.svg`);b.append(A);let E,C=be.None,M=!1,P=!1,I=!1,T=!1;function L(){p.classList.remove("active"),d.style.visibility="hidden"}function x(){v.classList.remove("active"),f.style.visibility="hidden"}return{setTargetElement:function(t){t.style.position="relative",t.appendChild(e)},getQRTarget:function(){return n},getQRImage:function(){return t},getDeepARTarget:function(){return o},getDeepARPrompt:function(){return s},getThreeTarget:function(){return r},getThreePrompt:function(){return l},getThreePromptImage:function(){return c},customizeDeepARPrompt:function(e,t){i.textContent=e,a.src=t},setVisibilityParameters:function(e,t,n,o,r){var i;M=e,P=t,I=n,T=o,E=r,Ee(b,M),Ee(S,M&&(I||P)&&C===be.None),Ee(R,M&&T&&C===be.None),Ee(A,M&&C!==be.None),L(),x(),M||""===(i=w).style.display&&Ee(i,!1)},getUIState:function(){return C},setUIState:function(e){C=e,C===be.None?(L(),x(),M&&(Ee(w,!1),Ee(A,!1),(P||I)&&Ee(S,!0),T&&Ee(R,!0))):C!==be.QR&&C!==be.AR&&C!==be.Preview||M&&(Ee(w,!1),Ee(S,!1),Ee(R,!1),Ee(A,!0))},setDefaultUIActions:function(e,t,n){M&&((P||I)&&(!function(e){const t={Glasses:"glasses.svg",Shoes:"shoe.svg",Watches:"watch.svg"},n=null!=e&&t[e]||t.Glasses,o=`${y}/img/icons/${n}`;S.firstChild.firstChild.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o)}(E),S.onclick=e),T&&(R.onclick=t),A.onclick=n)},startDeepARLoading:function(){p.classList.add("active"),d.style.visibility="visible"},stopDeepARLoading:L,startThreeLoading:function(){v.classList.add("active"),f.style.visibility="visible"},stopThreeLoading:x,showCameraError:function(){M&&Ee(w,!0)}}}function Ee(e,t){e.style.display=t?"":"none"}const Ce=new Map;function Me(e){let n=Ce.get(e);return null==n?(n=function(){let e=0,n=null,o=null,r=null;const i=()=>(null==n&&(n=Ae()),n);return{getSetupId:()=>e,incrementSetupId_:()=>e++,getUI_:()=>n,findUI:i,findQR:()=>{if(null==o){const{getQRTarget:e,getQRImage:n}=i();o=function(e,n){let o=!0;return{qrPaused:()=>o,qrDraw:(r,i)=>t(this,void 0,void 0,(function*(){yield S;const t=`https://apps.deepar.ai/${v.includes("alpha")?"shopar-qr-alpha":"shopar-qr"}/?${new URLSearchParams({a:r,s:i,h:location.href})}`,a=yield window.ShopAR__QR.toDataURL(t),s=new Promise(((e,t)=>{n.onload=e,n.onerror=t}));n.src=a,yield s,o=!1,e.style.display=""})),qrPause:()=>t(this,void 0,void 0,(function*(){o=!0,e.style.display="none"}))}}(e(),n())}return o},findThree:()=>{if(null==r){const{getThreeTarget:e,getThreePrompt:t,getThreePromptImage:n}=i();r=te(e(),t(),n())}return r}}}(),Ce.set(e,n)):n.incrementSetupId_(),n}function Pe(e){for(const t of Ce.values()){if(t===e)continue;const n=t.getUI_();if(null==n)continue;const{getUIState:o,setUIState:r}=n;o()===be.AR&&r(be.None)}}let Ie;const Te=new Uint8Array(16);function Le(){if(!Ie&&(Ie="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ie))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ie(Te)}const xe=[];for(let e=0;e<256;++e)xe.push((e+256).toString(16).slice(1));var ke={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ue(e,t,n){if(ke.randomUUID&&!t&&!e)return ke.randomUUID();const o=(e=e||{}).random||(e.rng||Le)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=o[e];return t}return function(e,t=0){return xe[e[t+0]]+xe[e[t+1]]+xe[e[t+2]]+xe[e[t+3]]+"-"+xe[e[t+4]]+xe[e[t+5]]+"-"+xe[e[t+6]]+xe[e[t+7]]+"-"+xe[e[t+8]]+xe[e[t+9]]+"-"+xe[e[t+10]]+xe[e[t+11]]+xe[e[t+12]]+xe[e[t+13]]+xe[e[t+14]]+xe[e[t+15]]}(o)}const De="qrLaunch",$e="arLaunch",_e="previewLaunch",Ne="heartbeat";let je,Oe,Fe=!1;const qe=[];function Ge(){null==je&&(Oe=Ue(),je=b(`${y}/shopar-analytics.js`),je.then((()=>{Fe=!0,window.ShopAR__analytics.initializeImpl(),qe.forEach((e=>e()))})))}function We(e){Fe?e():qe.push(e)}function Ve(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e,frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}})}function Ke(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 Qe=200,Be=10;let He=!1,ze=null,Xe=[],Ze=[];function Ye(e){return t(this,void 0,void 0,(function*(){He=!1;const{ShopAR__TrueScale:n}=window;yield n.initialize(`${y}/wasm/mediapipe`,e),ze&&(console.log("previous interval present, clearing"),clearInterval(ze));const o=[],r=[];ze=setInterval((()=>t(this,void 0,void 0,(function*(){if(He)return;const{error:e,faceWidth:t,ipd:i,translation:a,rotation:s}=yield n.predict(performance.now());He||(null!=a&&null!=s&&function(e){for(let t of Xe)t(e)}({translation:a,rotation:s}),null==e?(o.push(t),r.push(i),o.length<Be||(o.shift(),r.shift(),function(e,t){for(let n of Ze)n({faceWidth:e,IPD:t})}(et(o),et(r)))):console.error(`TrueScale predict error: ${e}`))}))),Qe)}))}function Je(){Ze=[],Xe=[],He=!0}function et(e){let t=0;const n=e.length;for(let o=0;o<n;o++)t+=e[o];return t/n}function tt(e){return t(this,void 0,void 0,(function*(){const o=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(e).catch((e=>{throw console.error(e),new n("Resource unavailable.")}));if(!t.ok)throw new n(`Resource download failed with status ${t.status}.`);return t}))));try{return yield(yield o.blob()).arrayBuffer()}catch(e){throw console.error(e),new n("Resource has invalid body.")}}))}var nt="undefined"!=typeof Float32Array?Float32Array:Array;function ot(){var e=new nt(16);return nt!=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 rt(e,t,n){var o=t[0],r=t[1],i=t[2],a=t[3],s=t[4],c=t[5],l=t[6],d=t[7],u=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],w=t[15],y=n[0],b=n[1],S=n[2],R=n[3];return e[0]=y*o+b*s+S*u+R*m,e[1]=y*r+b*c+S*h+R*g,e[2]=y*i+b*l+S*p+R*v,e[3]=y*a+b*d+S*f+R*w,y=n[4],b=n[5],S=n[6],R=n[7],e[4]=y*o+b*s+S*u+R*m,e[5]=y*r+b*c+S*h+R*g,e[6]=y*i+b*l+S*p+R*v,e[7]=y*a+b*d+S*f+R*w,y=n[8],b=n[9],S=n[10],R=n[11],e[8]=y*o+b*s+S*u+R*m,e[9]=y*r+b*c+S*h+R*g,e[10]=y*i+b*l+S*p+R*v,e[11]=y*a+b*d+S*f+R*w,y=n[12],b=n[13],S=n[14],R=n[15],e[12]=y*o+b*s+S*u+R*m,e[13]=y*r+b*c+S*h+R*g,e[14]=y*i+b*l+S*p+R*v,e[15]=y*a+b*d+S*f+R*w,e}function it(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function at(e,t){var n=t[0],o=t[1],r=t[2],i=t[4],a=t[5],s=t[6],c=t[8],l=t[9],d=t[10];return e[0]=Math.hypot(n,o,r),e[1]=Math.hypot(i,a,s),e[2]=Math.hypot(c,l,d),e}function st(e,t,n,o){var r=t[0],i=t[1],a=t[2],s=t[3],c=r+r,l=i+i,d=a+a,u=r*c,h=r*l,p=r*d,f=i*l,m=i*d,g=a*d,v=s*c,w=s*l,y=s*d,b=o[0],S=o[1],R=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)*S,e[5]=(1-(u+g))*S,e[6]=(m+v)*S,e[7]=0,e[8]=(p+w)*R,e[9]=(m-v)*R,e[10]=(1-(u+f))*R,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function ct(){var e=new nt(3);return nt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function lt(e,t,n){var o=new nt(3);return o[0]=e,o[1]=t,o[2]=n,o}function dt(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 ut(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 ht(){var e=new nt(4);return nt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}ct(),function(){var e,t=(e=new nt(4),nt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var pt;let ft,mt,gt;ct(),lt(1,0,0),lt(0,1,0),ht(),ht(),pt=new nt(9),nt!=Float32Array&&(pt[1]=0,pt[2]=0,pt[3]=0,pt[5]=0,pt[6]=0,pt[7]=0),pt[0]=1,pt[4]=1,pt[8]=1;let vt,wt,yt,bt,St=!0,Rt=null;const At=new Set;let Et,Ct,Mt,Pt,It,Tt,Lt;function xt(){null==ft&&(ft=b(`${y}/shopar-deepar.js`))}function kt(){null==mt&&(mt=b(`${y}/shopar-true-scale.js`))}function Ut(e){return t(this,void 0,void 0,(function*(){const{licenseKey:o,truescaleUsecase:r}=e;return It=r,null==Et&&(Et=(()=>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=qt(yt),r=Ve(t);vt=yield window.ShopAR__DeepAR.deepar.initialize({licenseKey:o||"your_license_key_goes_here",previewElement:bt,additionalOptions:{hint:Tt,cameraConfig:{disableDefaultCamera:!0}}}),wt=yield Ke(r),yield Gt(vt,wt,"user"===t),"Glasses"===yt&&(yield mt,Ye(wt),"DetectionLoop"!==It&&Qt((e=>{Pt=e.faceWidth})))})))()),Et}))}function Dt(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===yt&&(n=t,o=Tt,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!=vt&&(vt.shutdown(),vt=null,Et=null),yt=e,Tt=t)}function $t(e){e!==bt&&(bt=e,null!=vt&&vt.changePreviewElement(bt))}function _t(e){Rt=e}function Nt(e){vt.callbacks.onFaceTracked=t=>{if(t.some((e=>e.detected))){if(Pt){const e=137/(Pt+5);vt.changeParameterVector("GLASSES","","scale",e,e,e,0),vt.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=Vt("face_position","model","temple_left","temple_left_outer","temple_tip_outer_left",n,e),r=Vt("face_position","model","temple_right","temple_right_outer","temple_tip_outer_right",t,e);vt.changeParameterVector("temple_left","","rotation",0,56.6*-o,0,0),vt.changeParameterVector("temple_right","","rotation",0,56.6*-r,0,0)}catch(e){return void console.error(e)}}(e),Je(),Pt=null}e(),Wt("Glasses")}},vt.callbacks.onFeetTracked=(t,n)=>{(t.detected||n.detected)&&(e(),Wt("Shoes"))},vt.callbacks.onWristTracked=t=>{t.detected&&(e(),Wt("Watches"))}}function jt(e,n){return t(this,void 0,void 0,(function*(){return null!=Ct&&Mt===n||(yield Ct,Ct=vt.switchEffect(e),Mt=n),Ct}))}function Ot(){return t(this,void 0,void 0,(function*(){if(null!=vt){if(St=!1,null==wt){const e=qt(yt),t=Ve(e);wt=yield Ke(t),yield Gt(vt,wt,"user"===e),Ye(wt),"DetectionLoop"!==It&&Qt((e=>{Pt=e.faceWidth}))}!function(){if(null==Rt)return;if(null==yt||At.has(yt))return;Rt.style.visibility="visible",Rt.style.opacity="1"}(),vt.setPaused(St),bt.style.display=""}}))}function Ft(){null!=vt&&(St=!0,vt.setPaused(St),Je(),null!=wt&&null!=wt.srcObject&&wt.srcObject instanceof MediaStream&&(wt.srcObject.getTracks().forEach((e=>e.stop())),wt=null),function(){if(null==Rt)return;Rt.style.visibility="hidden",Rt.style.opacity="0"}(),vt.stopCamera(),bt.style.display="none")}function qt(e){var t;return null==e?"user":null!==(t={Glasses:"user",Shoes:"environment",Watches:"environment"}[e])&&void 0!==t?t:"user"}function Gt(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 Wt(e){null!=Rt&&(At.has(e)||(At.add(e),Rt.style.opacity="0"))}function Vt(e,t,n,o,r,i,a){const s=vt.getTransformationBetween(e,t),c=it(ct(),s),l=function(e,t){var n=new nt(3);at(n,t);var o=1/n[0],r=1/n[1],i=1/n[2],a=t[0]*o,s=t[1]*r,c=t[2]*i,l=t[4]*o,d=t[5]*r,u=t[6]*i,h=t[8]*o,p=t[9]*r,f=t[10]*i,m=a+d+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(u-p)/g,e[1]=(h-c)/g,e[2]=(s-l)/g):a>d&&a>f?(g=2*Math.sqrt(1+a-d-f),e[3]=(u-p)/g,e[0]=.25*g,e[1]=(s+l)/g,e[2]=(h+c)/g):d>f?(g=2*Math.sqrt(1+d-a-f),e[3]=(h-c)/g,e[0]=(s+l)/g,e[1]=.25*g,e[2]=(u+p)/g):(g=2*Math.sqrt(1+f-a-d),e[3]=(s-l)/g,e[0]=(h+c)/g,e[1]=(u+p)/g,e[2]=.25*g),e}(ht(),s);st(s,l,c,lt(a,a,a));const d=vt.getTransformationBetween(t,n),u=it(ct(),d);st(d,ht(),u,at(ct(),d));const h=rt(ot(),s,d),p=it(ct(),h),f=Math.atan2(i[0]-p[0],Math.abs(i[2]-p[2]));let m;try{m=vt.getTransformationBetween(n,o)}catch(e){return console.error(e),f}const g=rt(ot(),d,m),v=rt(ot(),s,g),w=lt(p[0],i[1],i[2]),y=ut(ct(),w,function(e,t){var n=t[0],o=t[1],r=t[2],i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],d=t[8],u=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=n*s-o*a,y=n*c-r*a,b=n*l-i*a,S=o*c-r*s,R=o*l-i*s,A=r*l-i*c,E=d*m-u*f,C=d*g-h*f,M=d*v-p*f,P=u*g-h*m,I=u*v-p*m,T=h*v-p*g,L=w*T-y*I+b*P+S*M-R*C+A*E;return L?(L=1/L,e[0]=(s*T-c*I+l*P)*L,e[1]=(r*I-o*T-i*P)*L,e[2]=(m*A-g*R+v*S)*L,e[3]=(h*R-u*A-p*S)*L,e[4]=(c*M-a*T-l*C)*L,e[5]=(n*T-r*M+i*C)*L,e[6]=(g*b-f*A-v*y)*L,e[7]=(d*A-h*b+p*y)*L,e[8]=(a*I-s*M+l*E)*L,e[9]=(o*M-n*I-i*E)*L,e[10]=(f*R-m*b+v*w)*L,e[11]=(u*b-d*R-p*w)*L,e[12]=(s*C-a*P-c*E)*L,e[13]=(n*P-o*C+r*E)*L,e[14]=(m*y-f*S-g*w)*L,e[15]=(d*S-u*y+h*w)*L,e):null}(ot(),v));let b=vt.getClosestPointOnMesh(o,y);try{const e=vt.getClosestPointOnMesh(r,y);dt(y,e)<dt(y,b)&&(b=e)}catch(e){console.error(e)}const S=ut(ct(),b,g);return f-Math.atan2(S[0]-u[0],Math.abs(S[2]-u[2]))}function Kt(e){!function(e){Xe.push(e)}(e)}function Qt(e){!function(e){Ze.push(e)}(e)}function Bt(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 c=String.fromCharCode(a+14);s>>=2,a^=s+2;const u=String.fromCharCode(a-3);a^=5;const h=String.fromCharCode(a-7);a^=2;const p=String.fromCharCode(a-7),m=window[`${h}${u+c+(typeof[])[(+!+[]+ +!+[])*(+!+[]+ +!+[])]}${p}`],g=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield m(`${e}`).catch((()=>{throw new n("Unknown error.")}));if(!t.ok)throw new n("Unknown error.");return t})))),v=new o[0](yield(yield g.blob().catch((()=>{throw new n("Unknown error.")}))).arrayBuffer().catch((()=>{throw new n("Unknown error.")})));i+=s;const w=v.byteLength;if(d[l]=Math.min(76,r)*((a>>5)-1),152===d[l]&&(d[l]=w),i==l)return v;i=l,i^=l;for(let e=0,t=v.length;e<t;e++)d[l]^=d[i]<<13,d[l]^=d[i]>>17,d[l]^=d[i]<<5,v[e]=v[e]^d[l];return i^=d[0],i^=d[1],i^=d[2],v}))}function Ht(e,t){if(null==e)throw new n(`'${t}' not specified.`)}function zt(e,t){if("string"!=typeof e)throw new n(`'${t}' must be a string.`)}const Xt=["AR","3D"];function Zt(e){const{apiKey:t,sku:o,targetElement:r,initialState:i,baseUrl:a,defaultUI:s,strings:c}=e;Ht(t,"apiKey"),zt(t,"apiKey"),Ht(o,"sku"),zt(o,"sku"),Ht(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",Xt),null!=a&&zt(a,"baseUrl"),null!=s&&function(e,t){if("boolean"!=typeof e)throw new n(`'${t}' must be a boolean.`)}(s,"defaultUI"),null!=c&&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.`)}}(c,"strings",ae)}let Yt=!1;function Jt(e){return t(this,void 0,void 0,(function*(){const{targetElement:o}=e;y.update(e.baseUrl),Ge();const{trackEvent:r}=function(e){const t=performance.now(),n=Ue();return{trackEvent:(o,r={})=>{r=Object.assign(Object.assign({},r),{pluginVersion:v,sessionId:Oe,setupId:n,timeSinceSetup:performance.now()-t,apiKey:e}),We((()=>{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:u()})}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield o.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(e.apiKey);r("visionApiResponse",i);const{arKey:a}=i,s=Me(o),{getSetupId:c,findUI:l}=s,d=c();xt(),kt();const{setTargetElement:h,getDeepARTarget:p,setVisibilityParameters:m,getUIState:g,setUIState:w,startDeepARLoading:b,stopDeepARLoading:S,showCameraError:R}=l();if(g()!=be.None)throw Error("UI state is not None, this is weird..");w(be.AR),h(o),m(!1,!1,!0,!1,void 0),b(),yield ft,en(c(),d);try{r("visionArLaunch"),Ft(),Dt("Glasses",["faceInit"]),$t(p()),yield Ut({licenseKey:a,truescaleUsecase:"DetectionLoop"}),en(c(),d),yield Ot(),en(c(),d)}catch(e){const t=e instanceof Error;throw r("visionArLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),R(),Ft(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{S()}return Yt=!0,{registerFacePoseListener:e=>{Yt&&(r("registerFacePoseListener"),Kt(e))},registerFaceMeasurementListener:e=>{Yt&&(r("registerFaceMeasurementListener"),Qt(e))},switchEffect:e=>t(this,void 0,void 0,(function*(){Yt&&(r("switchEffect",{arUrl:e}),function(e){vt.switchEffect(e)}(e))})),clearEffect:()=>{Yt&&(r("clearEffect"),vt.clearEffect())}}}))}function en(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}function tn(e){var o,r;return t(this,void 0,void 0,(function*(){Zt(e);const{apiKey:i,sku:a,targetElement:s,initialState:c}=e;!function(e){const t=getComputedStyle(e);if(!["static","relative"].includes(t.position))throw new n(`Invalid targetElement's position. Expected 'static' or 'relative', but found '${t.position}'.`)}(s),y.update(e.baseUrl),function(e){if(null!=e)for(const t of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(ie,t)){console.warn(`String for key '${t}' will be ignored.`);continue}const n=e[t];null!=n&&(ie[t]=n)}}(e.strings);const l=function(e,o){return t(this,void 0,void 0,(function*(){const r=yield f((()=>t(this,void 0,void 0,(function*(){const t=yield fetch(`https://dashboard.shopar.ai/plugin?${new URLSearchParams({apiKey:e,sku:o,sid:u()})}`).catch((e=>{throw console.error(e),new n("API unavailable.")}));if(!t.ok)throw new n(`API call failed with status ${t.status}.`);return t}))));try{return yield r.json()}catch(e){throw console.error(e),new n("API returned invalid body.")}}))}(i,a),d=Me(s),{getSetupId:h,findUI:p,findQR:w,findThree:R}=d,A=h();Ge();const{trackEvent:E,arInteracted:C,previewInteracted:M}=function(e,t){const n=performance.now(),o=Ue();let r=0,i=0,a=0,s=0,c=0,l=!1;window.setInterval((()=>{l&&(r=i+a,l=!1,d(Ne,{engagementTotal:r,engagementAR:i,engagement3D:a}))}),1e3);const d=(r,i={})=>{i=Object.assign(Object.assign({},i),{pluginVersion:v,sessionId:Oe,setupId:o,timeSinceSetup:performance.now()-n,sku:e,apiKey:t}),We((()=>{window.ShopAR__analytics.trackEventImpl(r,i)}))};return{trackEvent:d,arInteracted:()=>{const e=performance.now(),t=e-s;s=e,t<200&&(i+=t,l=!0)},previewInteracted:()=>{const e=performance.now(),t=e-c;c=e,t<200&&(a+=t,l=!0)}}}(a,i);E("setup",{hostname:window.location.hostname});const P=yield l;E("apiResponse",P);const{category:I,arUrl:T,arKey:L,arPromptEnabled:x,arPromptText:k,arPromptImage:U,previewUrl:D,previewEnvUrl:$,previewToneMapping:_}=P;nn(h(),A);const N=null!=T&&function(e){return null!=e&&m.includes(e)}(I),O=null==(null===(o=e._internalOptions)||void 0===o?void 0:o.qrEnabled)||(null===(r=e._internalOptions)||void 0===r?void 0:r.qrEnabled),F=N&&function(e){return null!=e&&g.includes(e)}(I),q=O&&F&&!(yield function(){var e;return t(this,void 0,void 0,(function*(){return null==Lt&&(Lt=b(`${y}/shopar-platform.js`)),yield Lt,["Android","iOS","Windows Phone",void 0].includes(null===(e=window.ShopAR__platform.platform.os)||void 0===e?void 0:e.family)}))}()),G=N&&!q,W=null!=D;if(nn(h(),A),q&&function(){t(this,void 0,void 0,(function*(){null==S&&(S=b(`${y}/shopar-qr.js`))}))}(),G&&(xt(),function(e){e!==gt&&(gt=e,tt(e),Ct=null,Je())}(T),"Glasses"===I&&kt()),W){null==j&&(j=b(`${y}/shopar-three.js`));const e=255;Bt(D,(new Date).getTime()+e,Math.random()*e),tt(null!=$?$:`${y}/env/default.hdr`)}const{setTargetElement:V,getDeepARTarget:K,getDeepARPrompt:Q,customizeDeepARPrompt:B,setVisibilityParameters:H,getUIState:z,setUIState:X,setDefaultUIActions:Z,startDeepARLoading:Y,stopDeepARLoading:J,startThreeLoading:ee,stopThreeLoading:te,showCameraError:ne}=p();V(s);H(null==e.defaultUI||e.defaultUI,q,G,W,I),B(null!=k?k:"",null!=U?U:""),function(e,t){const o=e.parentNode;if(null==o)throw new n("Parent node missing.");new MutationObserver((n=>{for(const o of n)for(const n of o.removedNodes)if(n===e)return void t()})).observe(o,{childList:!0})}(s,(()=>{z()!==be.QR||oe()||ae(),z()!==be.AR||St||Ft(),z()!==be.Preview||de()||he(),X(be.None)}));const{qrPaused:oe,qrDraw:re,qrPause:ae}=w(),{threeInit:se,threeParse:ce,threeLoad:le,threePaused:de,threeResume:ue,threePause:he,threeSetToneMapping:pe,threeSetOnInteracted:fe}=R();let me=0;if(z()===be.QR){if(!oe())if(q){E(De);try{yield re(i,a)}catch(e){throw new n(`QR failed: ${e instanceof Error?e.message:"Unknown error."}`)}}else ae(),X(be.None)}else if(z()===be.AR){if(!St)if(G){E($e);const e=yield tt(T);nn(h(),A),Pe(d),Dt(I),$t(K()),_t(x?Q():null),yield jt(e,T),Nt(C),nn(h(),A)}else Ft(),X(be.None)}else if(z()===be.Preview&&!de())if(W){E(_e),ee();const e=255,t=yield Bt(D,(new Date).getTime()+e,Math.random()*e);nn(h(),A);const n=yield tt(null!=$?$:`${y}/env/default.hdr`);nn(h(),A);const o=yield ce(t,n,`${D}${$}`);nn(h(),A),le(o,I),pe(null!=_?_:"ACES"),fe(M),te()}else he(),X(be.None);const ge=()=>t(this,void 0,void 0,(function*(){if(q){if(z()===be.QR||z()===be.AR)throw new n("AR already launched.");try{E(De);const e=++me;if(z()===be.Preview&&W&&!de()&&he(),X(be.QR),yield re(i,a),me!==e)return;return void nn(h(),A)}catch(e){const t=e instanceof Error;throw E("qrLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`QR failed: ${t?e.message:"Unknown error."}`)}}if(!G)throw new n("Model does not have AR enabled.");if(z()===be.AR)throw new n("AR already launched.");try{E($e);const e=++me;z()===be.Preview&&W&&!de()&&he(),Pe(d),X(be.AR),Y();const t=yield tt(T);if(me!==e)return;if(nn(h(),A),yield ft,me!==e)return;if(nn(h(),A),Ft(),Dt(I),$t(K()),_t(x?Q():null),yield Ut({licenseKey:L}),me!==e)return;if(nn(h(),A),yield jt(t,T),Nt(C),me!==e)return;if(nn(h(),A),yield Ot(),me!==e)return;nn(h(),A)}catch(e){const t=e instanceof Error;throw E("arLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),ne(),Ft(),new n(`AR failed: ${t?e.message:"Unknown error."}`)}finally{J()}})),ve=()=>t(this,void 0,void 0,(function*(){if(!W)throw new n("Model does not have 3D enabled.");if(z()===be.Preview)throw new n("3D already launched.");try{E(_e);const e=++me;z()===be.AR&&(G&&!St&&Ft(),ae()),X(be.Preview),ee();const t=255,n=yield Bt(D,(new Date).getTime()+t,Math.random()*t);if(me!==e)return;nn(h(),A);const o=yield tt(null!=$?$:`${y}/env/default.hdr`);if(me!==e)return;if(nn(h(),A),yield j,me!==e)return;if(nn(h(),A),se(),me!==e)return;nn(h(),A);const r=yield ce(n,o,`${D}${$}`);if(me!==e)return;nn(h(),A),le(r,I),pe(null!=_?_:"ACES"),fe(M),ue()}catch(e){const t=e instanceof Error;throw E("previewLaunchFailure",{errorName:t?e.name:"Unknown",errorMessage:t?e.message:""}),new n(`3D failed: ${t?e.message:"Unknown error."}`)}finally{te()}})),we=()=>t(this,void 0,void 0,(function*(){if(z()===be.None)throw new n("Neither AR or 3D launched.");++me,z()===be.QR||z()===be.AR?(G&&!St&&Ft(),ae()):z()===be.Preview&&W&&!de()&&he(),X(be.None)}));return Z(ge,ve,we),"AR"===c?(yield ge(),nn(h(),A)):"3D"===c&&(yield ve(),nn(h(),A)),Yt=!1,{launchAR:N?ge:void 0,launch3D:W?ve:void 0,closeAR:N?()=>t(this,void 0,void 0,(function*(){if(z()!==be.AR&&z()!==be.QR)throw new n("AR not launched.");++me,G&&!St&&Ft(),ae(),X(be.None)})):void 0,close3D:W?()=>t(this,void 0,void 0,(function*(){if(z()!==be.Preview)throw new n("3D not launched.");++me,W&&!de()&&he(),X(be.None)})):void 0,close:N||W?we:void 0}}))}function nn(e,t){if(e!==t)throw new n("Setup cancelled. Please ensure that setup is only called once.")}const on={setup:function(e){return t(this,void 0,void 0,(function*(){return Jt(e)}))}},rn={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",(()=>tn(e)))}))},version:v};e.plugin=rn,e.vision=on}));
|
|
@@ -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__TrueScale={})}(this,(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(s,i){function o(t){try{h(r.next(t))}catch(t){i(t)}}function a(t){try{h(r.throw(t))}catch(t){i(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var n=self;function r(){throw Error("Invalid UTF8")}function s(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}let i,o;const a="undefined"!=typeof TextDecoder;let h;const c="undefined"!=typeof TextEncoder;function u(t){if(c)t=(h||=new TextEncoder).encode(t);else{let n=0;const r=new Uint8Array(3*t.length);for(let s=0;s<t.length;s++){var e=t.charCodeAt(s);if(128>e)r[n++]=e;else{if(2048>e)r[n++]=e>>6|192;else{if(55296<=e&&57343>=e){if(56319>=e&&s<t.length){const i=t.charCodeAt(++s);if(56320<=i&&57343>=i){e=1024*(e-55296)+i-56320+65536,r[n++]=e>>18|240,r[n++]=e>>12&63|128,r[n++]=e>>6&63|128,r[n++]=63&e|128;continue}s--}e=65533}r[n++]=e>>12|224,r[n++]=e>>6&63|128}r[n++]=63&e|128}}t=n===r.length?r:r.subarray(0,n)}return t}var l,f;t:{for(var d=["CLOSURE_FLAGS"],p=n,g=0;g<d.length;g++)if(null==(p=p[d[g]])){f=null;break t}f=p}var m,y=f&&f[610401301];l=null!=y&&y;const v=n.navigator;function _(t){return!!l&&!!m&&m.brands.some((({brand:e})=>e&&-1!=e.indexOf(t)))}function w(t){var e;return(e=n.navigator)&&(e=e.userAgent)||(e=""),-1!=e.indexOf(t)}function A(){return!!l&&!!m&&0<m.brands.length}function b(){return A()?_("Chromium"):(w("Chrome")||w("CriOS"))&&!(!A()&&w("Edge"))||w("Silk")}m=v&&v.userAgentData||null;var E=!A()&&(w("Trident")||w("MSIE"));!w("Android")||b(),b(),w("Safari")&&(b()||!A()&&w("Coast")||!A()&&w("Opera")||!A()&&w("Edge")||(A()?_("Microsoft Edge"):w("Edg/"))||A()&&_("Opera"));var T={},k=null;function x(){if(!k){k={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=t.concat(e[n].split(""));T[n]=r;for(var s=0;s<r.length;s++){var i=r[s];void 0===k[i]&&(k[i]=s)}}}}var L="undefined"!=typeof Uint8Array,F=!E&&"function"==typeof btoa;function S(t){if(!F){var e;void 0===e&&(e=0),x(),e=T[e];var n=Array(Math.floor(t.length/3)),r=e[64]||"";let h=0,c=0;for(;h<t.length-2;h+=3){var s=t[h],i=t[h+1],o=t[h+2],a=e[s>>2];s=e[(3&s)<<4|i>>4],i=e[(15&i)<<2|o>>6],o=e[63&o],n[c++]=a+s+i+o}switch(a=0,o=r,t.length-h){case 2:o=e[(15&(a=t[h+1]))<<2]||r;case 1:t=t[h],n[c]=e[t>>2]+e[(3&t)<<4|a>>4]+o+r}return n.join("")}for(e="",n=0,r=t.length-10240;n<r;)e+=String.fromCharCode.apply(null,t.subarray(n,n+=10240));return e+=String.fromCharCode.apply(null,n?t.subarray(n):t),btoa(e)}const O=/[-_.]/g,M={"-":"+",_:"/",".":"="};function P(t){return M[t]||""}function C(t){if(!F)return function(t){var e=t.length,n=3*e/4;n%3?n=Math.floor(n):-1!="=.".indexOf(t[e-1])&&(n=-1!="=.".indexOf(t[e-2])?n-2:n-1);var r=new Uint8Array(n),s=0;return function(t,e){function n(e){for(;r<t.length;){var n=t.charAt(r++),s=k[n];if(null!=s)return s;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}x();for(var r=0;;){var s=n(-1),i=n(0),o=n(64),a=n(64);if(64===a&&-1===s)break;e(s<<2|i>>4),64!=o&&(e(i<<4&240|o>>2),64!=a&&e(o<<6&192|a))}}(t,(function(t){r[s++]=t})),s!==n?r.subarray(0,s):r}(t);O.test(t)&&(t=t.replace(O,P)),t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function R(t){return L&&null!=t&&t instanceof Uint8Array}let I;function D(){return I||=new Uint8Array(0)}var U={};let B;function N(t){if(t!==U)throw Error("illegal external caller")}function G(){return B||=new V(null,U)}function j(t){N(U);var e=t.N;return null==(e=null==e||R(e)?e:"string"==typeof e?C(e):null)?e:t.N=e}var V=class{constructor(t,e){if(N(e),this.N=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}ha(){const t=j(this);return t?new Uint8Array(t):D()}};function z(t,e){return Error(`Invalid wire type: ${t} (at position ${e})`)}function W(){return Error("Failed to read varint, encoding is invalid.")}function X(t,e){return Error(`Tried to read past the end of the data ${e} > ${t}`)}function H(t){return 0==t.length?G():new V(t,U)}function $(t){if("string"==typeof t)return{buffer:C(t),H:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),H:!1};if(t.constructor===Uint8Array)return{buffer:t,H:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),H:!1};if(t.constructor===V)return{buffer:j(t)||D(),H:!0};if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),H:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}const q="function"==typeof Uint8Array.prototype.slice;let K,Y=0,J=0;function Z(t){const e=0>t;let n=(t=Math.abs(t))>>>0;if(t=Math.floor((t-n)/4294967296),e){const[e,r]=rt(n,t);t=r,n=e}Y=n>>>0,J=t>>>0}function Q(t){const e=K||=new DataView(new ArrayBuffer(8));e.setFloat32(0,+t,!0),J=0,Y=e.getUint32(0,!0)}function tt(t,e){return 4294967296*e+(t>>>0)}function et(t,e){const n=2147483648&e;return n&&(e=~e>>>0,0==(t=1+~t>>>0)&&(e=e+1>>>0)),t=tt(t,e),n?-t:t}function nt(t){if(16>t.length)Z(Number(t));else if("function"==typeof BigInt)t=BigInt(t),Y=Number(t&BigInt(4294967295))>>>0,J=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);J=Y=0;const n=t.length;for(let r=e,s=(n-e)%6+e;s<=n;r=s,s+=6){const e=Number(t.slice(r,s));J*=1e6,Y=1e6*Y+e,4294967296<=Y&&(J+=Math.trunc(Y/4294967296),J>>>=0,Y>>>=0)}if(e){const[t,e]=rt(Y,J);Y=t,J=e}}}function rt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function st(t,e,{R:n=!1}={}){t.R=n,e&&(e=$(e),t.h=e.buffer,t.s=e.H,t.v=0,t.l=t.h.length,t.g=t.v)}function it(t,e){if(t.g=e,e>t.l)throw X(t.l,e)}function ot(t,e){let n,r=0,s=0,i=0;const o=t.h;let a=t.g;do{n=o[a++],r|=(127&n)<<i,i+=7}while(32>i&&128&n);for(32<i&&(s|=(127&n)>>4),i=3;32>i&&128&n;i+=7)n=o[a++],s|=(127&n)<<i;if(it(t,a),128>n)return e(r>>>0,s>>>0);throw W()}function at(t){let e=0,n=t.g;const r=n+10,s=t.h;for(;n<r;){const r=s[n++];if(e|=r,0==(128&r))return it(t,n),!!(127&e)}throw W()}function ht(t){var e=t.h;const n=t.g,r=e[n],s=e[n+1],i=e[n+2];return e=e[n+3],it(t,t.g+4),(r<<0|s<<8|i<<16|e<<24)>>>0}function ct(t,e){if(0>e)throw Error(`Tried to read a negative byte length: ${e}`);const n=t.g,r=n+e;if(r>t.l)throw X(e,t.l-n);return t.g=r,n}function ut(t,e){if(0==e)return G();var n=ct(t,e);return t.R&&t.s?n=t.h.subarray(n,n+e):(t=t.h,n=n===(e=n+e)?D():q?t.slice(n,e):new Uint8Array(t.subarray(n,e))),H(n)}var lt=class{constructor(t,e){this.h=null,this.s=!1,this.g=this.l=this.v=0,st(this,t,e)}m(){const t=this.h;let e=this.g,n=t[e++],r=127&n;if(128&n&&(n=t[e++],r|=(127&n)<<7,128&n&&(n=t[e++],r|=(127&n)<<14,128&n&&(n=t[e++],r|=(127&n)<<21,128&n&&(n=t[e++],r|=n<<28,128&n&&128&t[e++]&&128&t[e++]&&128&t[e++]&&128&t[e++]&&128&t[e++])))))throw W();return it(this,e),r}j(){return this.m()>>>0}A(){var t=ht(this);const e=2*(t>>31)+1,n=t>>>23&255;return t&=8388607,255==n?t?NaN:1/0*e:0==n?e*Math.pow(2,-149)*t:e*Math.pow(2,n-150)*(t+Math.pow(2,23))}C(){return this.m()}},ft=[];function dt(t){var e=t.g;if(e.g==e.l)return!1;t.l=t.g.g;var n=t.g.j();if(e=n>>>3,!(0<=(n&=7)&&5>=n))throw z(n,t.l);if(1>e)throw Error(`Invalid field number: ${e} (at position ${t.l})`);return t.m=e,t.h=n,!0}function pt(t){switch(t.h){case 0:0!=t.h?pt(t):at(t.g);break;case 1:it(t=t.g,t.g+8);break;case 2:if(2!=t.h)pt(t);else{var e=t.g.j();it(t=t.g,t.g+e)}break;case 5:it(t=t.g,t.g+4);break;case 3:for(e=t.m;;){if(!dt(t))throw Error("Unmatched start-group tag: stream EOF");if(4==t.h){if(t.m!=e)throw Error("Unmatched end-group tag");break}pt(t)}break;default:throw z(t.h,t.l)}}function gt(t,e,n){const r=t.g.l,s=t.g.j(),i=t.g.g+s;let o=i-r;if(0>=o&&(t.g.l=i,n(e,t,void 0,void 0,void 0),o=i-t.g.g),o)throw Error(`Message parsing ended unexpectedly. Expected to read ${s} bytes, instead read ${s-o} bytes, either the data ended unexpectedly or the message misreported its own length`);return t.g.g=i,t.g.l=r,e}function mt(t){var e=t.g.j(),n=ct(t=t.g,e);if(t=t.h,a){var h,c=t;(h=o)||(h=o=new TextDecoder("utf-8",{fatal:!0})),t=n+e,c=0===n&&t===c.length?c:c.subarray(n,t);try{var u=h.decode(c)}catch(t){if(void 0===i){try{h.decode(new Uint8Array([128]))}catch(t){}try{h.decode(new Uint8Array([97])),i=!0}catch(t){i=!1}}throw!i&&(o=void 0),t}}else{e=(u=n)+e,n=[];let i,o=null;for(;u<e;){var l=t[u++];128>l?n.push(l):224>l?u>=e?r():(i=t[u++],194>l||128!=(192&i)?(u--,r()):n.push((31&l)<<6|63&i)):240>l?u>=e-1?r():(i=t[u++],128!=(192&i)||224===l&&160>i||237===l&&160<=i||128!=(192&(c=t[u++]))?(u--,r()):n.push((15&l)<<12|(63&i)<<6|63&c)):244>=l?u>=e-2?r():(i=t[u++],128!=(192&i)||0!=i-144+(l<<28)>>30||128!=(192&(c=t[u++]))||128!=(192&(h=t[u++]))?(u--,r()):(l=(7&l)<<18|(63&i)<<12|(63&c)<<6|63&h,l-=65536,n.push(55296+(l>>10&1023),56320+(1023&l)))):r(),8192<=n.length&&(o=s(o,n),n.length=0)}u=s(o,n)}return u}function yt(t){const e=t.g.j();return ut(t.g,e)}function vt(t,e,n){var r=t.g.j();for(r=t.g.g+r;t.g.g<r;)n.push(e.call(t.g))}var _t=[];function wt(t){return t?/^\d+$/.test(t)?(nt(t),new At(Y,J)):null:bt||=new At(0,0)}var At=class{constructor(t,e){this.h=t>>>0,this.g=e>>>0}};let bt;function Et(t){return t?/^-?\d+$/.test(t)?(nt(t),new Tt(Y,J)):null:kt||=new Tt(0,0)}var Tt=class{constructor(t,e){this.h=t>>>0,this.g=e>>>0}};let kt;function xt(t,e,n){for(;0<n||127<e;)t.g.push(127&e|128),e=(e>>>7|n<<25)>>>0,n>>>=7;t.g.push(e)}function Lt(t,e){for(;127<e;)t.g.push(127&e|128),e>>>=7;t.g.push(e)}function Ft(t,e){if(0<=e)Lt(t,e);else{for(let n=0;9>n;n++)t.g.push(127&e|128),e>>=7;t.g.push(1)}}function St(t,e){t.g.push(e>>>0&255),t.g.push(e>>>8&255),t.g.push(e>>>16&255),t.g.push(e>>>24&255)}function Ot(t,e){0!==e.length&&(t.l.push(e),t.h+=e.length)}function Mt(t,e,n){Lt(t.g,8*e+n)}function Pt(t,e){return Mt(t,e,2),e=t.g.end(),Ot(t,e),e.push(t.h),e}function Ct(t,e){var n=e.pop();for(n=t.h+t.g.length()-n;127<n;)e.push(127&n|128),n>>>=7,t.h++;e.push(n),t.h++}function Rt(t,e,n){Mt(t,e,2),Lt(t.g,n.length),Ot(t,t.g.end()),Ot(t,n)}function It(t,e,n,r){null!=n&&(e=Pt(t,e),r(n,t),Ct(t,e))}class Dt{constructor(t,e,n){this.g=t,this.h=e,this.l=n}}function Ut(t){return Array.prototype.slice.call(t)}const Bt="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;var Nt=Bt?(t,e)=>{t[Bt]|=e}:(t,e)=>{void 0!==t.D?t.D|=e:Object.defineProperties(t,{D:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function Gt(t){const e=Vt(t);1!=(1&e)&&(Object.isFrozen(t)&&(t=Ut(t)),Wt(t,1|e))}var jt=Bt?(t,e)=>{t[Bt]&=~e}:(t,e)=>{void 0!==t.D&&(t.D&=~e)},Vt=Bt?t=>0|t[Bt]:t=>0|t.D,zt=Bt?t=>t[Bt]:t=>t.D,Wt=Bt?(t,e)=>{t[Bt]=e}:(t,e)=>{void 0!==t.D?t.D=e:Object.defineProperties(t,{D:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function Xt(){var t=[];return Nt(t,1),t}function Ht(t){return Nt(t,34),t}function $t(t,e){Wt(e,-255&(0|t))}function qt(t,e){Wt(e,-221&(34|t))}function Kt(t){return 0==(t=t>>11&1023)?536870912:t}var Yt,Jt={};function Zt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function Qt(t,e,n){if(null!=t)if("string"==typeof t)t=t?new V(t,U):G();else if(t.constructor!==V)if(R(t))t=n?H(t):t.length?new V(new Uint8Array(t),U):G();else{if(!e)throw Error();t=void 0}return t}const te=[];function ee(t){if(2&t)throw Error()}Wt(te,55),Yt=Object.freeze(te);class ne{constructor(t,e,n){this.l=0,this.g=t,this.h=e,this.m=n}next(){if(this.l<this.g.length){const t=this.g[this.l++];return{done:!1,value:this.h?this.h.call(this.m,t):t}}return{done:!0,value:void 0}}[Symbol.iterator](){return new ne(this.g,this.h,this.m)}}var re={};let se,ie;function oe(t,e){(e=se?e[se]:void 0)&&(t[se]=Ut(e))}function ae(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}function he(t){return null==t?t:"number"==typeof t||"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}function ce(t){return null==t?t:"boolean"==typeof t||"number"==typeof t?!!t:void 0}function ue(t){return"number"==typeof t&&Number.isFinite(t)||!!t&&"string"==typeof t&&isFinite(t)}function le(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t?t:void 0}function fe(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t?t:void 0}function de(t){if("string"!=typeof t)throw Error();return t}function pe(t){if(null!=t&&"string"!=typeof t)throw Error();return t}function ge(t){return null==t||"string"==typeof t?t:void 0}function me(t,e,n,r){var s=!1;return null==t||"object"!=typeof t||(s=Array.isArray(t))||t.M!==Jt?s?(0===(s=n=Vt(t))&&(s|=32&r),(s|=2&r)!==n&&Wt(t,s),new e(t)):(n?2&r?(t=e[ye])?e=t:(Ht((t=new e).u),e=e[ye]=t):e=new e:e=void 0,e):t}const ye="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():"di";function ve(t){return t}function _e(t,e,n){return"string"==typeof(t="number"==(e=typeof t)||"string"===e?t:n?0:void 0)&&(n=+t,Number.isSafeInteger(n))?n:t}let we,Ae,be;function Ee(t){switch(typeof t){case"boolean":return Ae||=[0,void 0,!0];case"number":return 0<t?void 0:0===t?be||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}function Te(t,e){return ke(t,e[0],e[1])}function ke(t,e,n){if(null==t&&(t=we),we=void 0,null==t){var r=96;n?(t=[n],r|=512):t=[],e&&(r=-2095105&r|(1023&e)<<11)}else{if(!Array.isArray(t))throw Error();if(64&(r=Vt(t)))return ie&&delete t[ie],t;if(r|=64,n&&(r|=512,n!==t[0]))throw Error();t:{var s=(n=t).length;if(s){const t=s-1;var i=n[t];if(Zt(i)){1024<=(s=t-(e=+!!(512&(r|=256))-1))&&(xe(n,e,i),s=1023),r=-2095105&r|(1023&s)<<11;break t}}e&&(i=+!!(512&r)-1,1024<(e=Math.max(e,s-i))&&(xe(n,i,{}),r|=256,e=1023),r=-2095105&r|(1023&e)<<11)}}return Wt(t,r),t}function xe(t,e,n){const r=1023+e,s=t.length;for(let i=r;i<s;i++){const r=t[i];null!=r&&r!==n&&(n[i-e]=r)}t.length=r+1,t[r]=n}function Le(t){if(2&t.g)throw Error("Cannot mutate an immutable Map")}var Fe=class extends Map{constructor(t,e,n=ve,r=ve){super();let s=Vt(t);s|=64,Wt(t,s),this.g=s,this.l=e,this.h=n||ve,this.j=this.l?Se:r||ve;for(let i=0;i<t.length;i++){const o=t[i],a=n(o[0],!1,!0);let h=o[1];e?void 0===h&&(h=null):h=r(o[1],!1,!0,void 0,void 0,s),super.set(a,h)}}s(t=Oe){return this.m(t)}m(t=Oe){const e=[],n=super.entries();for(var r;!(r=n.next()).done;)(r=r.value)[0]=t(r[0]),r[1]=t(r[1]),e.push(r);return e}clear(){Le(this),super.clear()}delete(t){return Le(this),super.delete(this.h(t,!0,!1))}entries(){var t=this.A();return new ne(t,Me,this)}keys(){return this.C()}values(){var t=this.A();return new ne(t,Fe.prototype.get,this)}forEach(t,e){super.forEach(((n,r)=>{t.call(e,this.get(r),r,this)}))}set(t,e){return Le(this),null==(t=this.h(t,!0,!1))?this:null==e?(super.delete(t),this):super.set(t,this.j(e,!0,!0,this.l,!1,this.g))}I(t){const e=this.h(t[0],!1,!0);t=t[1],t=this.l?void 0===t?null:t:this.j(t,!1,!0,void 0,!1,this.g),super.set(e,t)}has(t){return super.has(this.h(t,!1,!1))}get(t){t=this.h(t,!1,!1);const e=super.get(t);if(void 0!==e){var n=this.l;return n?((n=this.j(e,!1,!0,n,this.v,this.g))!==e&&super.set(t,n),n):e}}A(){return Array.from(super.keys())}C(){return super.keys()}[Symbol.iterator](){return this.entries()}};function Se(t,e,n,r,s,i){return t=me(t,r,n,i),s&&(t=Ne(t)),t}function Oe(t){return t}function Me(t){return[t,this.get(t)]}function Pe(t,e,n,r,s,i){if(null!=t){if(Array.isArray(t))t=s&&0==t.length&&1&Vt(t)?void 0:i&&2&Vt(t)?t:Ce(t,e,n,void 0!==r,s,i);else if(Zt(t)){const o={};for(let a in t)o[a]=Pe(t[a],e,n,r,s,i);t=o}else t=e(t,r);return t}}function Ce(t,e,n,r,s,i){const o=r||n?Vt(t):0;r=r?!!(32&o):void 0;const a=Ut(t);for(let t=0;t<a.length;t++)a[t]=Pe(a[t],e,n,r,s,i);return n&&(oe(a,t),n(o,a)),a}function Re(t){return Pe(t,Ie,void 0,void 0,!1,!1)}function Ie(t){return t.M===Jt?t.toJSON():t instanceof Fe?t.s(Re):function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"boolean":return t?1:0;case"object":if(t&&!Array.isArray(t)){if(R(t))return S(t);if(t instanceof V){const e=t.N;return null==e?"":"string"==typeof e?e:t.N=S(e)}if(t instanceof Fe)return t.s()}}return t}(t)}function De(t,e,n=qt){if(null!=t){if(L&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var r=Vt(t);return 2&r?t:(e&&=0===r||!!(32&r)&&!(64&r||!(16&r)),e?(Wt(t,34|r),4&r&&Object.freeze(t),t):Ce(t,De,4&r?qt:n,!0,!1,!0))}return t.M===Jt?(n=t.u,t=2&(r=zt(n))?t:Ue(t,n,r,!0)):t instanceof Fe&&(n=Ht(t.m(De)),t=new Fe(n,t.l,t.h,t.j)),t}}function Ue(t,e,n,r){return t=t.constructor,we=e=Be(e,n,r),e=new t(e),we=void 0,e}function Be(t,e,n){const r=n||2&e?qt:$t,s=!!(32&e);return t=function(t,e,n){const r=Ut(t);var s=r.length;const i=256&e?r[s-1]:void 0;for(s+=i?-1:0,e=512&e?1:0;e<s;e++)r[e]=n(r[e]);if(i){e=r[e]={};for(const t in i)e[t]=n(i[t])}return oe(r,t),r}(t,e,(t=>De(t,s,r))),Nt(t,32|(n?2:0)),t}function Ne(t){const e=t.u,n=zt(e);return 2&n?Ue(t,e,n,!1):t}function Ge(t,e){return je(t=t.u,zt(t),e)}function je(t,e,n,r){if(-1===n)return null;if(n>=Kt(e)){if(256&e)return t[t.length-1][n]}else{var s=t.length;if(r&&256&e&&null!=(r=t[s-1][n]))return r;if((e=n+(+!!(512&e)-1))<s)return t[e]}}function Ve(t,e,n,r){const s=t.u,i=zt(s);return ee(i),ze(s,i,e,n,r),t}function ze(t,e,n,r,s){var i=Kt(e);if(n>=i||s){if(s=e,256&e)i=t[t.length-1];else{if(null==r)return;i=t[i+(+!!(512&e)-1)]={},s|=256}i[n]=r,s!==e&&Wt(t,s)}else t[n+(+!!(512&e)-1)]=r,256&e&&n in(t=t[t.length-1])&&delete t[n]}function We(t,e,n,r,s){var i=2&e;let o=je(t,e,n,s);Array.isArray(o)||(o=Yt);const a=!(2&r),h=!(1&r);r=!!(32&e);let c=Vt(o);return 0!==c||!r||i||a?1&c||(c|=1,Wt(o,c)):(c|=33,Wt(o,c)),i?(2&c||Ht(o),h&&Object.freeze(o)):(i=2&c,h&&i?(o=Ut(o),i=1,r&&!a&&(i|=32),Wt(o,i),ze(t,e,n,o,s)):a&&32&c&&!i&&jt(o,32)),o}function Xe(t,e){t=t.u;const n=zt(t),r=je(t,n,e),s=he(r);return null!=s&&s!==r&&ze(t,n,e,s),s}function He(t){t=t.u;const e=zt(t),n=je(t,e,1),r=Qt(n,!0,!!(34&e));return null!=r&&r!==n&&ze(t,e,1,r),r}function $e(t,e,n){t=t.u;const r=zt(t),s=2&r;let i=We(t,r,e,1),o=Vt(i);if(!(4&o)){Object.isFrozen(i)&&(i=Ut(i),Wt(i,o=-3&o|32),ze(t,r,e,i));let a=0,h=0;for(;a<i.length;a++){const t=n(i[a]);null!=t&&(i[h++]=t)}h<a&&(i.length=h),o|=21,s?o|=34:o&=-33,Wt(i,o),2&o&&Object.freeze(i)}return!s&&(2&o||Object.isFrozen(i))&&(i=Ut(i),Wt(i,-35&o),ze(t,r,e,i)),i}let qe;function Ke(){return qe??=new Fe(Ht([]),void 0,void 0,void 0,re)}function Ye(t){t=Ut(t);for(let e=0;e<t.length;e++){const n=t[e]=Ut(t[e]);Array.isArray(n[1])&&(n[1]=Ht(n[1]))}return t}function Je(t,e,n){{t=t.u;const r=zt(t);if(ee(r),null==n)ze(t,r,e);else{if(!(4&Vt(n))){Object.isFrozen(n)&&(n=Ut(n));for(let t=0;t<n.length;t++)n[t]=de(n[t]);Wt(n,5)}ze(t,r,e,n)}}}function Ze(t,e){return Qe(t=t.u,zt(t),zs)===e?e:-1}function Qe(t,e,n){let r=0;for(let s=0;s<n.length;s++){const i=n[s];null!=je(t,e,i)&&(0!==r&&ze(t,e,r),r=i)}return r}function tn(t,e,n,r){const s=zt(t);ee(s);const i=je(t,s,n,r);let o;if(null!=i&&i.M===Jt)return(e=Ne(i))!==i&&ze(t,s,n,e,r),e.u;if(Array.isArray(i)){const t=Vt(i);o=2&t?Be(i,t,!1):i,o=Te(o,e)}else o=Te(void 0,e);return o!==i&&ze(t,s,n,o,r),o}function en(t,e,n,r){t=t.u;const s=zt(t),i=je(t,s,n,r);return(e=me(i,e,!1,s))!==i&&null!=e&&ze(t,s,n,e,r),e}function nn(t,e,n,r=!1){if(null==(e=en(t,e,n,r)))return e;t=t.u;const s=zt(t);if(!(2&s)){const i=Ne(e);i!==e&&ze(t,s,n,e=i,r)}return e}function rn(t,e,n,r,s){var i=!!(2&e),o=We(t,e,r,1),a=o===Yt;if(a&&2!==s)return o;if(a||!(4&Vt(o))){var h=o;o=!!(2&e),a=!!(2&Vt(h)),i=h,!o&&a&&(h=Ut(h));var c=e|((a=a||void 0)?2:0),u=a;a=!1;let l=0,f=0;for(;l<h.length;l++){const t=me(h[l],n,!1,c);if(null==t)continue;const e=!!(2&Vt(t.u));u=u||e,a=a||!e,h[f++]=t}return f<l&&(h.length=f),c=5|(h=Vt(n=h)),u=u?-9&c:8|c,h!=(u=a?-17&u:16|u)&&(Object.isFrozen(n)&&(n=Ut(n)),Wt(n,u)),i!==(h=n)&&ze(t,e,r,h),(o&&2!==s||1===s)&&Object.freeze(h),h}return 3===s||(i?2===s&&(s=Vt(o),o=Ut(o),Wt(o,s),ze(t,e,r,o)):(i=Object.isFrozen(o),1===s?i||Object.freeze(o):(n=-33&(s=Vt(o)),i||2&s?(o=Ut(o),Wt(o,-3&n),ze(t,e,r,o)):s!==n&&Wt(o,n)))),o}function sn(t,e,n){var r=t.u;const s=zt(r);if(e=rn(r,s,e,n,(t=!!(2&s))?1:2),!(t||8&Vt(e))){for(n=0;n<e.length;n++)(t=e[n])!==(r=Ne(t))&&(e[n]=r);Nt(e,8)}return e}function on(t,e,n,r,s){return null==r&&(r=void 0),Ve(t,n,r,s)}function an(t,e,n,r){null==r&&(r=void 0),t=t.u;const s=zt(t);ee(s),(n=Qe(t,s,n))&&n!==e&&null!=r&&ze(t,s,n),ze(t,s,e,r)}function hn(t,e,n){t=t.u;const r=zt(t);ee(r),t=rn(t,r,e,1,2),e=null!=n?n:new e,t.push(e),2&Vt(e.u)?jt(t,8):jt(t,16)}function cn(t,e){return le(Ge(t,e))}function un(t){return null==(t=Ge(t,2))||ue(t)?t:void 0}function ln(t,e){return ge(Ge(t,e))}function fn(t){return t??0}function dn(t,e){return fn(Xe(t,e))}function pn(t,e,n){if(null!=n){if("boolean"!=typeof n)throw t=typeof n,Error(`Expected boolean but got ${"object"!=t?t:n?Array.isArray(n)?"array":t:"null"}: ${n}`);n=!!n}Ve(t,e,n)}function gn(t,e,r){if(null!=r){if("number"!=typeof r)throw ae(t=Error(),"warning"),t;if(!Number.isFinite(r)){const t=Error();ae(t,"incident"),function(t){n.setTimeout((()=>{throw t}),0)}(t)}}Ve(t,e,r)}function mn(t,e,n){if(null!=n&&"number"!=typeof n)throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);Ve(t,e,n)}function yn(t,e,n){n=de(n),t=t.u;const r=zt(t);ee(r),We(t,r,e,2).push(n)}function vn(t,e,n){e.g?e.m(t,e.g,e.h,n,!0):e.m(t,e.h,n,!0)}Fe.prototype.toJSON=void 0;var _n=class{constructor(t,e){this.u=ke(t,e)}toJSON(){return wn(this,Ce(this.u,Ie,void 0,void 0,!1,!1),!0)}l(){var t=Ni;return t.g?t.l(this,t.g,t.h,!0):t.l(this,t.h,t.defaultValue,!0)}clone(){const t=this.u;return Ue(this,t,zt(t),!1)}H(){return!!(2&Vt(this.u))}};function wn(t,e,n){var r=t.constructor.B,s=Kt(zt(n?t.u:e)),i=!1;if(r){if(!n){var o;if((e=Ut(e)).length&&Zt(o=e[e.length-1]))for(i=0;i<r.length;i++)if(r[i]>=s){Object.assign(e[e.length-1]={},o);break}i=!0}var a;s=e,n=!n,t=Kt(o=zt(t.u)),o=+!!(512&o)-1;for(let e=0;e<r.length;e++){var h=r[e];if(h<t){var c=s[h+=o];null==c?s[h]=n?Yt:Xt():n&&c!==Yt&&Gt(c)}else{if(!a){var u=void 0;s.length&&Zt(u=s[s.length-1])?a=u:s.push(a={})}c=a[h],null==a[h]?a[h]=n?Yt:Xt():n&&c!==Yt&&Gt(c)}}}if(!(r=e.length))return e;let l,f;if(Zt(a=e[r-1])){t:{var d=a;u={},s=!1;for(let t in d)n=d[t],Array.isArray(n)&&n!=n&&(s=!0),null!=n?u[t]=n:s=!0;if(s){for(let t in u){d=u;break t}d=null}}d!=a&&(l=!0),r--}for(;0<r&&null==(a=e[r-1]);r--)f=!0;return l||f?(e=i?e:Array.prototype.slice.call(e,0,r),i&&(e.length=r),d&&e.push(d),e):e}function An(t){return{ca:mr,U:t}}function bn(t,e){if(Array.isArray(e)){var n=Vt(e);if(4&n)return e;for(var r=0,s=0;r<e.length;r++){const n=t(e[r]);null!=n&&(e[s++]=n)}return s<r&&(e.length=s),Wt(e,5|n),2&n&&Object.freeze(e),e}}_n.prototype.M=Jt,_n.prototype.toString=function(){return wn(this,this.u,!1).toString()};const En=Symbol();function Tn(t){let e=t[En];if(!e){const n=On(t),r=jn(t),s=r.h;e=s?(t,e)=>s(t,e,r):(t,e)=>{for(;dt(e)&&4!=e.h;){var s=e.m,i=r[s];if(!i){var o=r.g;o&&(o=o[s])&&(i=r[s]=kn(o))}i&&i(e,t,s)||(s=(i=e).l,pt(i),i.aa?i=void 0:(o=i.g.g-s,i.g.g=s,i=ut(i.g,o)),s=t,i&&(se||=Symbol(),(o=s[se])?o.push(i):s[se]=[i]))}for(const e in n){t[ie||=Symbol()]=n;break}},t[En]=e}return e}function kn(t){const e=function(t){if(t=t.U)return Tn(t)}(t),n=t.ca.g;if(e){const r=jn(t.U).L;return(t,s,i)=>n(t,s,i,r,e)}return(t,e,r)=>n(t,e,r)}const xn=Symbol();function Ln(t,e,n,r){let s;if(r){const e=r[xn];s=e?e.L:Ee(r[0]),n[t]=e??r}s&&s===Ae?((e=n.xa)||(n.xa=e=[]),e.push(t)):e.l&&((e=n.Ba)||(n.Ba=e=[]),e.push(t))}function Fn(t,e,n,r){Ln(t,e,r)}function Sn(t,e,n,r,s){Ln(t,e,s,n)}function On(t){let e=t[xn];return e||(e=t[xn]={},Mn(t,e,Fn,Sn,e))}function Mn(t,e,n,r,s){e.L=Ee(t[0]);let i=1;if(t.length>i&&!(t[i]instanceof Dt)){var o=t[i++];if(Array.isArray(o))return e.h=o[0],e.g=o[1],e;e.g=o}for(o=0;i<t.length;){var a=t[i++],h=t[i];for("number"==typeof h?(i++,o+=h):o++,h=i;h<t.length&&!(t[h]instanceof Dt);)h++;if(h-=i){var c=t,u=i,l=c[u];if("function"==typeof l&&(l=l(),c[u]=l),(c=Array.isArray(l))&&!(c=Bn in l||Rn in l)&&(c=0<l.length)){const t=Ee(u=(c=l)[0]);null!=t&&t!==u&&(c[0]=t),c=null!=t}(l=c?l:void 0)?(i++,1===h?void 0!==(a=r(o,a,l,void 0,s))&&(e[o]=a):void 0!==(a=r(o,a,l,t[i++],s))&&(e[o]=a)):void 0!==(a=n(o,a,t[i++],s))&&(e[o]=a)}else void 0!==(a=n(o,a,void 0,s))&&(e[o]=a)}return e}const Pn=Symbol();function Cn(t){let e=t[Pn];if(!e){const n=Un(t);e=(t,e)=>zn(t,e,n),t[Pn]=e}return e}const Rn=Symbol();function In(t,e){return e.h}function Dn(t,e,n){let r,s;const i=e.h;return(t,e,o)=>i(t,e,o,s||=Un(n).L,r||=Cn(n))}function Un(t){let e=t[Rn];return e||(e=Mn(t,t[Rn]={},In,Dn),Bn in t&&Rn in t&&(t.length=0),e)}const Bn=Symbol();function Nn(t,e,n){const r=e.g;return n?(t,e,s)=>r(t,e,s,n):r}function Gn(t,e,n,r){const s=e.g;let i,o;return(t,e,a)=>s(t,e,a,o||=jn(n).L,i||=Tn(n),r)}function jn(t){let e=t[Bn];return e||(On(t),e=Mn(t,t[Bn]={},Nn,Gn),Bn in t&&Rn in t&&(t.length=0),e)}function Vn(t,e){var n=t[e];if(n)return n;if((n=t.g)&&(n=n[e])){var r=n.U,s=n.ca.h;if(r){const t=Cn(r),e=Un(r).L;n=(n,r,i)=>s(n,r,i,e,t)}else n=s;return t[e]=n}}function zn(t,e,n){for(var r=zt(t),s=+!!(512&r)-1,i=t.length,o=512&r?1:0,a=i+(256&r?-1:0);o<a;o++){const r=t[o];if(null==r)continue;const i=o-s,a=Vn(n,i);a&&a(e,r,i)}if(256&r){r=t[i-1];for(let t in r)s=+t,Number.isNaN(s)||null!=(i=r[t])&&(a=Vn(n,s))&&a(e,i,s)}if(t=se?t[se]:void 0)for(Ot(e,e.g.end()),n=0;n<t.length;n++)Ot(e,j(t[n])||D())}function Wn(t,e){return new Dt(t,e,!1)}function Xn(t,e){return new Dt(t,e,!0)}function Hn(t,e,n){ze(t,zt(t),e,n)}var $n=Wn((function(t,e,n,r,s){return 2===t.h&&(t=gt(t,Te([void 0,void 0],r),s),ee(r=zt(e)),(s=je(e,r,n))instanceof Fe?0!=(2&s.g)?((s=s.m()).push(t),ze(e,r,n,s)):s.I(t):Array.isArray(s)?(2&Vt(s)&&ze(e,r,n,s=Ye(s)),s.push(t)):ze(e,r,n,[t]),!0)}),(function(t,e,n,r,s){if(e instanceof Fe)e.forEach(((e,i)=>{It(t,n,Te([i,e],r),s)}));else if(Array.isArray(e))for(let i=0;i<e.length;i++){const o=e[i];Array.isArray(o)&&It(t,n,Te(o,r),s)}}));function qn(t,e,n){t:if(null!=e){if(ue(e)){if("string"==typeof e)break t;if("number"==typeof e)break t}e=void 0}null!=e&&("string"==typeof e&&Et(e),null!=e&&(Mt(t,n,0),"number"==typeof e?(t=t.g,Z(e),xt(t,Y,J)):(n=Et(e),xt(t.g,n.h,n.g))))}function Kn(t,e,n){null!=(e=le(e))&&null!=e&&(Mt(t,n,0),Ft(t.g,e))}function Yn(t,e,n){null!=(e=ce(e))&&(Mt(t,n,0),t.g.g.push(e?1:0))}function Jn(t,e,n){null!=(e=ge(e))&&Rt(t,n,u(e))}function Zn(t,e,n,r,s){It(t,n,e instanceof _n?e.u:Array.isArray(e)?Te(e,r):void 0,s)}function Qn(t,e,n){null!=(e=null==e||"string"==typeof e||R(e)||e instanceof V?e:void 0)&&Rt(t,n,$(e).buffer)}function tr(t,e,n){return(5===t.h||2===t.h)&&(e=We(e,zt(e),n,2,!1),2==t.h?vt(t,lt.prototype.A,e):e.push(t.g.A()),!0)}var er=Wn((function(t,e,n){if(1!==t.h)return!1;var r=t.g;t=ht(r);const s=ht(r);r=2*(s>>31)+1;const i=s>>>20&2047;return t=4294967296*(1048575&s)+t,Hn(e,n,2047==i?t?NaN:1/0*r:0==i?r*Math.pow(2,-1074)*t:r*Math.pow(2,i-1075)*(t+4503599627370496)),!0}),(function(t,e,n){null!=(e=he(e))&&(Mt(t,n,1),t=t.g,(n=K||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),Y=n.getUint32(0,!0),J=n.getUint32(4,!0),St(t,Y),St(t,J))})),nr=Wn((function(t,e,n){return 5===t.h&&(Hn(e,n,t.g.A()),!0)}),(function(t,e,n){null!=(e=he(e))&&(Mt(t,n,5),t=t.g,Q(e),St(t,Y))})),rr=Xn(tr,(function(t,e,n){if(null!=(e=bn(he,e)))for(let i=0;i<e.length;i++){var r=t,s=e[i];null!=s&&(Mt(r,n,5),r=r.g,Q(s),St(r,Y))}})),sr=Xn(tr,(function(t,e,n){if(null!=(e=bn(he,e))&&e.length){Mt(t,n,2),Lt(t.g,4*e.length);for(let r=0;r<e.length;r++)n=t.g,Q(e[r]),St(n,Y)}})),ir=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,ot(t.g,et)),!0)}),qn),or=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,0===(t=ot(t.g,et))?void 0:t),!0)}),qn),ar=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,ot(t.g,tt)),!0)}),(function(t,e,n){t:if(null!=e){if(ue(e)){if("string"==typeof e)break t;if("number"==typeof e)break t}e=void 0}null!=e&&("string"==typeof e&&wt(e),null!=e&&(Mt(t,n,0),"number"==typeof e?(t=t.g,Z(e),xt(t,Y,J)):(n=wt(e),xt(t.g,n.h,n.g))))})),hr=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,t.g.m()),!0)}),Kn),cr=Xn((function(t,e,n){return(0===t.h||2===t.h)&&(e=We(e,zt(e),n,2,!1),2==t.h?vt(t,lt.prototype.m,e):e.push(t.g.m()),!0)}),(function(t,e,n){if(null!=(e=bn(le,e))&&e.length){n=Pt(t,n);for(let n=0;n<e.length;n++)Ft(t.g,e[n]);Ct(t,n)}})),ur=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,0===(t=t.g.m())?void 0:t),!0)}),Kn),lr=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,at(t.g)),!0)}),Yn),fr=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,!1===(t=at(t.g))?void 0:t),!0)}),Yn),dr=Xn((function(t,e,n){if(2!==t.h)return!1;t=mt(t);const r=zt(e);return ee(r),We(e,r,n,2).push(t),!0}),(function(t,e,n){if(null!=(e=bn(ge,e)))for(let s=0;s<e.length;s++){var r=e[s];null!=r&&Rt(t,n,u(r))}})),pr=Wn((function(t,e,n){return 2===t.h&&(Hn(e,n,""===(t=mt(t))?void 0:t),!0)}),Jn),gr=Wn((function(t,e,n){return 2===t.h&&(Hn(e,n,mt(t)),!0)}),Jn),mr=Wn((function(t,e,n,r,s){return 2===t.h&&(gt(t,tn(e,r,n,!0),s),!0)}),Zn),yr=Wn((function(t,e,n,r,s){return 2===t.h&&(gt(t,tn(e,r,n),s),!0)}),Zn),vr=Xn((function(t,e,n,r,s){if(2!==t.h)return!1;r=Te(void 0,r);const i=zt(e);ee(i);let o=We(e,i,n,3);return(Object.isFrozen(o)||4&Vt(o))&&(o=Ut(o),ze(e,i,n,o)),o.push(r),gt(t,r,s),!0}),(function(t,e,n,r,s){if(Array.isArray(e))for(let i=0;i<e.length;i++)Zn(t,e[i],n,r,s)})),_r=Wn((function(t,e,n,r,s,i){if(2!==t.h)return!1;const o=zt(e);return ee(o),(i=Qe(e,o,i))&&n!==i&&ze(e,o,i),gt(t,e=tn(e,r,n),s),!0}),Zn),wr=Wn((function(t,e,n){return 2===t.h&&(Hn(e,n,yt(t)),!0)}),Qn),Ar=Xn((function(t,e,n){return(0===t.h||2===t.h)&&(e=We(e,zt(e),n,2,!1),2==t.h?vt(t,lt.prototype.j,e):e.push(t.g.j()),!0)}),(function(t,e,n){if(null!=(e=bn(fe,e)))for(let i=0;i<e.length;i++){var r=t,s=e[i];null!=s&&(Mt(r,n,0),Lt(r.g,s))}})),br=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,t.g.m()),!0)}),(function(t,e,n){null!=(e=le(e))&&(e=parseInt(e,10),Mt(t,n,0),Ft(t.g,e))})),Er=Xn((function(t,e,n){return(0===t.h||2===t.h)&&(e=We(e,zt(e),n,2,!1),2==t.h?vt(t,lt.prototype.C,e):e.push(t.g.m()),!0)}),(function(t,e,n){if(null!=(e=bn(le,e))&&e.length){n=Pt(t,n);for(let n=0;n<e.length;n++)Ft(t.g,e[n]);Ct(t,n)}}));class Tr{constructor(t,e){this.h=t,this.g=e,this.l=nn,this.m=on,this.defaultValue=void 0}}function kr(t,e){return new Tr(t,e)}function xr(t,e){return(n,r)=>{t:{if(_t.length){const t=_t.pop();t.o(r),st(t.g,n,r),n=t}else n=new class{constructor(t,e){if(ft.length){const n=ft.pop();st(n,t,e),t=n}else t=new lt(t,e);this.g=t,this.l=this.g.g,this.h=this.m=-1,this.o(e)}o({aa:t=!1}={}){this.aa=t}}(n,r);try{var s=new t;const r=s.u;Tn(e)(r,n),ie&&delete r[ie];var i=s;break t}finally{(s=n.g).h=null,s.s=!1,s.v=0,s.l=0,s.g=0,s.R=!1,n.m=-1,n.h=-1,100>_t.length&&_t.push(n)}i=void 0}return i}}function Lr(t){return function(){const e=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const t=this.g;return this.g=[],t}}}};zn(this.u,e,Un(t)),Ot(e,e.g.end());const n=new Uint8Array(e.h),r=e.l,s=r.length;let i=0;for(let t=0;t<s;t++){const e=r[t];n.set(e,i),i+=e.length}return e.l=[n],n}}var Fr=[0,pr,Wn((function(t,e,n){return 2===t.h&&(Hn(e,n,(t=yt(t))===G()?void 0:t),!0)}),(function(t,e,n){if(null!=e){if(e instanceof _n){const r=e.Ea;return void(r&&(e=r(e),null!=e&&Rt(t,n,$(e).buffer)))}if(Array.isArray(e))return}Qn(t,e,n)}))],Sr=[0,gr],Or=[0,hr,br,lr,lr,cr,br,br],Mr=[0,lr,lr],Pr=class extends _n{constructor(){super()}};Pr.B=[6];var Cr=[0,lr,gr,lr,br,br,Er,gr,gr,yr,Mr,br],Rr=[0,gr,gr,gr],Ir=class extends _n{constructor(){super()}},Dr=[0],Ur=[0,hr],Br=[1,2,3,4,5],Nr=class extends _n{constructor(t){super(t,2)}},Gr={},jr=[-2,Gr,lr];Gr[336783863]=An([0,gr,lr,lr,hr,yr,[0,_r,Dr,Br,_r,Cr,Br,_r,Rr,Br,_r,Ur,Br,_r,Or,Br],yr,Sr]);var Vr=[0,pr,fr],zr=[0,or,or,fr,fr,fr,fr,or,cr,pr,ur,or,or,fr,ur,fr,fr,fr,pr],Wr=[-1,{}],Xr=[0,gr,yr,2,Wr],Hr=[0,gr,dr,yr,Wr];function $r(t,e){e=pe(e),t=t.u;const n=zt(t);ee(n),ze(t,n,2,""===e?void 0:e)}function qr(t,e){yn(t,3,e)}function Kr(t,e){yn(t,4,e)}var Yr=class extends _n{constructor(t){super(t,500)}o(t){return on(this,0,7,t)}};Yr.B=[3,4,5,6,8,13,17,1005];var Jr=[-500,pr,pr,dr,dr,dr,dr,yr,jr,vr,Fr,ur,ur,yr,Xr,yr,Hr,vr,Vr,pr,yr,zr,ur,dr,dr,988],Zr=[0,pr,pr,yr,Wr],Qr=[-500,gr,gr,yr,[-1,{}],gr,999],ts=[-500,gr,dr,dr,yr,[-2,{},lr],dr,998,dr],es=[-500,gr,dr,yr,Wr,dr,999];function ns(t,e){hn(t,Yr,e)}function rs(t,e){yn(t,10,e)}function ss(t,e){yn(t,15,e)}var is=class extends _n{constructor(t){super(t,500)}o(t){return on(this,0,1001,t)}};is.B=[1,6,7,9,10,15,16,17,14,1002];var os=[-500,vr,Jr,vr,5,Qr,vr,ts,ur,vr,es,dr,ur,yr,Xr,yr,Hr,vr,Zr,dr,dr,dr,yr,zr,pr,pr,fr,yr,980,Wr,vr,Fr],as=xr(is,os);is.prototype.g=Lr(os);var hs=[0,vr,[0,hr,hr,hr]],cs=class extends _n{constructor(t){super(t)}},us=[0,hr,nr,gr,gr],ls=class extends _n{constructor(t){super(t)}g(){return sn(this,cs,1)}};ls.B=[1];var fs=[0,vr,us],ds=xr(ls,fs),ps=[0,hr,nr],gs=[0,hr,hr,yr,hs],ms=class extends _n{constructor(t){super(t)}},ys=[0,hr,hr,hr,hr],vs=[0,nr,nr,nr,nr],_s=class extends _n{constructor(t){super(t)}},ws=[0,nr,nr,gr,nr],As=class extends _n{constructor(t){super(t)}h(){return nn(this,ms,2)}g(){return sn(this,_s,5)}};As.B=[5];var bs=[0,br,yr,ys,yr,vs,yr,gs,vr,ws],Es=class extends _n{constructor(t){super(t)}};Es.B=[1,2,3,8,9];var Ts=xr(Es,[0,dr,cr,sr,yr,bs,gr,gr,ir,vr,ps,dr,ir]),ks=class extends _n{constructor(t){super(t)}},xs=[0,nr,nr,nr,nr,nr],Ls=class extends _n{constructor(t){super(t)}};Ls.B=[1];var Fs=xr(Ls,[0,vr,xs]),Ss=class extends _n{constructor(t){super(t)}},Os=[0,nr,nr,nr,nr,nr],Ms=class extends _n{constructor(t){super(t)}};Ms.B=[1];var Ps=xr(Ms,[0,vr,Os]),Cs=class extends _n{constructor(t){super(t)}};Cs.B=[3];var Rs=[0,hr,hr,sr,br],Is=class extends _n{constructor(){super()}};Is.prototype.g=Lr([0,nr,nr,nr,nr,nr,ir]);var Ds=class extends _n{constructor(t){super(t)}},Us=[0,hr,2,gr,yr,fs],Bs=class extends _n{constructor(t){super(t)}};Bs.B=[1];var Ns=xr(Bs,[0,vr,Us,ir]),Gs=class extends _n{constructor(t){super(t)}};Gs.B=[1];var js=class extends _n{constructor(t){super(t)}fa(){const t=He(this);return null==t?G():t}},Vs=class extends _n{constructor(t){super(t)}},zs=[1,2],Ws=[0,_r,[0,sr],zs,_r,[0,wr],zs,hr,gr],Xs=class extends _n{constructor(t){super(t)}};Xs.B=[1];var Hs=xr(Xs,[0,vr,Ws,ir]),$s=class extends _n{constructor(t){super(t)}};$s.B=[4,5];var qs=[0,gr,hr,nr,dr,dr],Ks=class extends _n{constructor(t){super(t)}},Ys=[0,lr,lr],Js=class extends _n{constructor(t){super(t)}},Zs=[1,2,3,4,5],Qs=class extends _n{constructor(t){super(t)}g(){return null!=He(this)}h(){return null!=ln(this,2)}},ti=[0,wr,gr,yr,[0,hr,ir,ir],yr,[0,ar,ir]],ei=class extends _n{constructor(t){super(t)}g(){return ce(Ge(this,2))??!1}},ni=[0,yr,ti,lr,yr,[0,_r,Ur,Zs,_r,Cr,Zs,_r,Or,Zs,_r,Dr,Zs,_r,Rr,Zs]],ri=class extends _n{constructor(t){super(t)}},si=[0,yr,ni,nr,nr,hr],ii=kr(502141897,ri);Gr[502141897]=An(si);var oi=[0,yr,ti];Gr[512499200]=An(oi);var ai=[0,yr,oi];Gr[515723506]=An(ai);var hi=xr(class extends _n{constructor(t){super(t)}},[0,yr,[0,br,br,rr,Ar],yr,Rs]),ci=[0,yr,ni];Gr[508981768]=An(ci);var ui=class extends _n{constructor(t){super(t)}},li=[0,yr,ni,nr,yr,ci,lr],fi=class extends _n{constructor(t){super(t)}},di=[0,yr,ni,yr,si,yr,li,nr,yr,ai];Gr[508968149]=An(li);var pi=kr(508968150,fi);Gr[508968150]=An(di);var gi=class extends _n{constructor(t){super(t)}},mi=kr(513916220,gi);Gr[513916220]=An([0,yr,ni,yr,di,hr]);var yi=class extends _n{constructor(t){super(t)}h(){return nn(this,$s,2)}g(){Ve(this,2)}},vi=[0,yr,ni,yr,qs];Gr[478825465]=An(vi);var _i=[0,yr,ni];Gr[478825422]=An(_i);var wi=class extends _n{constructor(t){super(t)}},Ai=[0,yr,ni,yr,_i,yr,vi,yr,vi],bi=class extends _n{constructor(t){super(t)}},Ei=[0,yr,ni,nr,hr],Ti=class extends _n{constructor(t){super(t)}},ki=[0,yr,ni,nr],xi=class extends _n{constructor(t){super(t)}},Li=[0,yr,ni,yr,Ei,yr,ki,nr],Fi=class extends _n{constructor(t){super(t)}},Si=[0,yr,ni,yr,Li,yr,Ai];Gr[463370452]=An(Ai),Gr[464864288]=An(Ei),Gr[474472470]=An(ki);var Oi=kr(462713202,xi);Gr[462713202]=An(Li);var Mi=kr(479097054,Fi);Gr[479097054]=An(Si);var Pi=class extends _n{constructor(t){super(t)}},Ci=kr(456383383,Pi);Gr[456383383]=An([0,yr,ni,yr,qs]);var Ri=class extends _n{constructor(t){super(t)}},Ii=kr(476348187,Ri);Gr[476348187]=An([0,yr,ni,yr,Ys]);var Di=class extends _n{constructor(t){super(t)}},Ui=[0,br,br],Bi=class extends _n{constructor(t){super(t)}};Bi.B=[3];var Ni=kr(458105876,class extends _n{constructor(t){super(t)}g(){var t=this.u;const e=zt(t);var n=2&e;return t=function(t,e,n){var r=Bi;const s=2&e;let i=!1;if(null==n){if(s)return Ke();n=[]}else if(n.constructor===Fe){if(0==(2&n.g)||s)return n;n=n.m()}else Array.isArray(n)?i=!!(2&Vt(n)):n=[];if(s){if(!n.length)return Ke();i||(i=!0,Ht(n))}else i&&(i=!1,n=Ye(n));return i||(64&Vt(n)?jt(n,32):32&e&&Nt(n,32)),ze(t,e,2,r=new Fe(n,r,_e,void 0),!1),r}(t,e,je(t,e,2)),null==t||!n&&Bi&&(t.v=!0),t}});Gr[458105876]=An([0,yr,Ui,$n,[!0,ir,yr,[0,gr,gr,dr]]]);var Gi=class extends _n{constructor(t){super(t)}},ji=kr(458105758,Gi);Gr[458105758]=An([0,yr,ni,gr,yr,Ui]);var Vi=class extends _n{constructor(t){super(t)}};Vi.B=[5,6];var zi=kr(443442058,Vi);Gr[443442058]=An([0,yr,ni,gr,hr,nr,dr,dr]);var Wi=class extends _n{constructor(t){super(t)}},Xi=[0,yr,ni,nr,nr,hr];Gr[514774813]=An(Xi);var Hi=class extends _n{constructor(t){super(t)}},$i=[0,yr,ni,nr,lr],qi=class extends _n{constructor(t){super(t)}},Ki=[0,yr,ni,yr,Xi,yr,$i,nr];Gr[518928384]=An($i);var Yi=kr(516587230,qi);function Ji(t,e){return e=e?e.clone():new $s,void 0!==t.displayNamesLocale?Ve(e,1,pe(t.displayNamesLocale)):void 0===t.displayNamesLocale&&Ve(e,1),void 0!==t.maxResults?gn(e,2,t.maxResults):"maxResults"in t&&Ve(e,2),void 0!==t.scoreThreshold?mn(e,3,t.scoreThreshold):"scoreThreshold"in t&&Ve(e,3),void 0!==t.categoryAllowlist?Je(e,4,t.categoryAllowlist):"categoryAllowlist"in t&&Ve(e,4),void 0!==t.categoryDenylist?Je(e,5,t.categoryDenylist):"categoryDenylist"in t&&Ve(e,5),e}function Zi(t,e=-1,n=""){return{categories:t.map((t=>({index:fn(cn(t,1))??-1,score:dn(t,2)??0,categoryName:ln(t,3)??""??"",displayName:ln(t,4)??""??""}))),headIndex:e,headName:n}}function Qi(t){var e=$e(t,3,he),n=$e(t,2,le);const r=$e(t,1,ge),s=$e(t,9,ge),i={categories:[],keypoints:[]};for(let t=0;t<e.length;t++)i.categories.push({score:e[t],index:n[t]??-1,categoryName:r[t]??"",displayName:s[t]??""});if((e=nn(t,As,4)?.h())&&(i.boundingBox={originX:cn(e,1)??0,originY:cn(e,2)??0,width:cn(e,3)??0,height:cn(e,4)??0,angle:0}),nn(t,As,4)?.g().length)for(const e of nn(t,As,4).g())i.keypoints.push({x:Xe(e,1)??0,y:Xe(e,2)??0,score:Xe(e,4)??0,label:ln(e,3)??""});return i}function to(t){const e=[];for(const n of sn(t,Ss,1))e.push({x:dn(n,1)??0,y:dn(n,2)??0,z:dn(n,3)??0});return e}function eo(t){const e=[];for(const n of sn(t,ks,1))e.push({x:dn(n,1)??0,y:dn(n,2)??0,z:dn(n,3)??0});return e}function no(t){return Array.from(t,(t=>127<t?t-256:t))}function ro(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);let n=0,r=0,s=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i],r+=t[i]*t[i],s+=e[i]*e[i];if(0>=r||0>=s)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(r*s)}let so;Gr[516587230]=An(Ki);const io=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function oo(){if(void 0===so)try{await WebAssembly.instantiate(io),so=!0}catch{so=!1}return so}async function ao(t,e=""){const n=await oo()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var ho=class{};function co(){const t=navigator.userAgent;return t.includes("Safari")&&!t.includes("Chrome")}async function uo(t){if("function"!=typeof importScripts){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise(((t,n)=>{e.addEventListener("load",(()=>{t()}),!1),e.addEventListener("error",(t=>{n(t)}),!1),document.body.appendChild(e)}))}importScripts(t.toString())}function lo(t,e,n){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(e=t.i.stringToNewUTF8(e)),t.i._free(e)}function fo(t,e,n){if(!t.i.canvas)throw Error("No OpenGL canvas configured.");if(n?t.i._bindTextureToStream(n):t.i._bindTextureToCanvas(),!(n=t.i.canvas.getContext("webgl2")||t.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");return t.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),t.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),e.videoWidth?(n=e.videoWidth,e=e.videoHeight):e.naturalWidth?(n=e.naturalWidth,e=e.naturalHeight):(n=e.width,e=e.height),!t.l||n===t.i.canvas.width&&e===t.i.canvas.height||(t.i.canvas.width=n,t.i.canvas.height=e),[n,e]}function po(t,e,n){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const r=new Uint32Array(e.length);for(let n=0;n<e.length;n++)r[n]=t.i.stringToNewUTF8(e[n]);e=t.i._malloc(4*r.length),t.i.HEAPU32.set(r,e>>2),n(e);for(const e of r)t.i._free(e);t.i._free(e)}function go(t,e,n){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[e]=n}function mo(t,e,n){let r=[];t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[e]=(t,e,s)=>{e?(n(r,s),r=[]):r.push(t)}}function yo(t,e){const n=nn(t.baseOptions,Qs,1)||new Qs;"string"==typeof e?(Ve(n,2,pe(e)),Ve(n,1)):e instanceof Uint8Array&&(Ve(n,1,Qt(e,!1,!1)),Ve(n,2)),on(t.baseOptions,0,1,n)}function vo(t){try{const e=t.J.length;if(1===e)throw Error(t.J[0].message);if(1<e)throw Error("Encountered multiple errors: "+t.J.map((t=>t.message)).join(", "))}finally{t.J=[]}}function _o(t,e){t.I=Math.max(t.I,e)}function wo(t,e){t.A=new Yr,$r(t.A,"PassThroughCalculator"),qr(t.A,"free_memory"),Kr(t.A,"free_memory_unused_out"),rs(e,"free_memory"),ns(e,t.A)}function Ao(t,e){qr(t.A,e),Kr(t.A,e+"_unused_out")}function bo(t){t.g.addBoolToStream(!0,"free_memory",t.I)}ho.forVisionTasks=function(t){return ao("vision",t)},ho.forTextTasks=function(t){return ao("text",t)},ho.forAudioTasks=function(t){return ao("audio",t)},ho.isSimdSupported=function(){return oo()};var Eo=class{constructor(t){this.g=t,this.J=[],this.I=0,this.g.setAutoRenderToScreen(!1)}l(t,e=!0){if(e){const e=t.baseOptions||{};if(t.baseOptions?.modelAssetBuffer&&t.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(nn(this.baseOptions,Qs,1)?.g()||nn(this.baseOptions,Qs,1)?.h()||t.baseOptions?.modelAssetBuffer||t.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(t,e){let n=nn(t.baseOptions,Js,3);if(!n){var r=n=new Js,s=new Ir;an(r,4,Zs,s)}"delegate"in e&&("GPU"===e.delegate?(e=n,r=new Pr,an(e,2,Zs,r)):(e=n,r=new Ir,an(e,4,Zs,r))),on(t.baseOptions,0,3,n)}(this,e),e.modelAssetPath)return fetch(e.modelAssetPath.toString()).then((t=>{if(t.ok)return t.arrayBuffer();throw Error(`Failed to fetch model: ${e.modelAssetPath} (${t.status})`)})).then((t=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(t),!0,!1,!1),yo(this,"/model.dat"),this.m(),this.P()}));yo(this,e.modelAssetBuffer)}return this.m(),this.P(),Promise.resolve()}P(){}W(){let t;if(this.g.W((e=>{t=as(e)})),!t)throw Error("Failed to retrieve CalculatorGraphConfig");return t}setGraph(t,e){this.g.attachErrorListener(((t,e)=>{this.J.push(Error(e))})),this.g.Aa(),this.g.setGraph(t,e),this.A=void 0,vo(this)}finishProcessing(){this.g.finishProcessing(),vo(this)}close(){this.A=void 0,this.g.closeGraph()}};function To(t,e){if(null===t)throw Error(`Unable to obtain required WebGL resource: ${e}`);return t}Eo.prototype.close=Eo.prototype.close;class ko{constructor(t,e,n,r){this.g=t,this.h=e,this.m=n,this.l=r}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function xo(t,e,n){const r=t.h;if(n=To(r.createShader(n),"Failed to create WebGL shader"),r.shaderSource(n,e),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${r.getShaderInfoLog(n)}`);return r.attachShader(t.g,n),n}function Lo(t,e){const n=t.h,r=To(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(r);const s=To(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,s),n.enableVertexAttribArray(t.s),n.vertexAttribPointer(t.s,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const i=To(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,i),n.enableVertexAttribArray(t.A),n.vertexAttribPointer(t.A,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(e?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindVertexArray(null),new ko(n,r,s,i)}function Fo(t,e){if(t.h){if(e!==t.h)throw Error("Cannot change GL context once initialized")}else t.h=e}function So(t,e,n,r){if(Fo(t,e),!t.g){const e=t.h;if(t.g=To(e.createProgram(),"Failed to create WebGL program"),t.C=xo(t,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",e.VERTEX_SHADER),t.v=xo(t,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D inputTexture;\n void main() {\n gl_FragColor = texture2D(inputTexture, vTex);\n }\n ",e.FRAGMENT_SHADER),e.linkProgram(t.g),!e.getProgramParameter(t.g,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(t.g)}`);t.s=e.getAttribLocation(t.g,"aVertex"),t.A=e.getAttribLocation(t.g,"aTex")}return n?(t.m||(t.m=Lo(t,!0)),n=t.m):(t.j||(t.j=Lo(t,!1)),n=t.j),e.useProgram(t.g),n.bind(),t=r(),n.g.bindVertexArray(null),t}function Oo(t,e,n){Fo(t,e),t.l||(t.l=To(e.createFramebuffer(),"Failed to create framebuffe.")),e.bindFramebuffer(e.FRAMEBUFFER,t.l),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0)}function Mo(t){t.h?.bindFramebuffer(t.h.FRAMEBUFFER,null)}var Po=class{close(){if(this.g){const t=this.h;t.deleteProgram(this.g),t.deleteShader(this.C),t.deleteShader(this.v)}this.l&&this.h.deleteFramebuffer(this.l),this.j&&this.j.close(),this.m&&this.m.close()}};function Co(t,e){switch(e){case 0:return t.g.find((t=>t instanceof ImageData));case 1:return t.g.find((t=>"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap));case 2:return t.g.find((t=>"undefined"!=typeof WebGLTexture&&t instanceof WebGLTexture));default:throw Error(`Type is not supported: ${e}`)}}function Ro(t){var e=Co(t,0);if(!e){e=Do(t);const n=Uo(t),r=new Uint8Array(t.width*t.height*4);Oo(n,e,Io(t)),e.readPixels(0,0,t.width,t.height,e.RGBA,e.UNSIGNED_BYTE,r),Mo(n),e=new ImageData(new Uint8ClampedArray(r.buffer),t.width,t.height),t.g.push(e)}return e}function Io(t){let e=Co(t,2);if(!e){const n=Do(t);e=No(t);const r=Co(t,1)||Ro(t);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,r),Go(t)}return e}function Do(t){if(!t.canvas)throw Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");return t.h||(t.h=To(t.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),t.h}function Uo(t){return t.l||(t.l=new Po),t.l}function Bo(t){(t=Do(t)).texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)}function No(t){const e=Do(t);e.viewport(0,0,t.width,t.height),e.activeTexture(e.TEXTURE0);let n=Co(t,2);return n?e.bindTexture(e.TEXTURE_2D,n):(n=To(e.createTexture(),"Failed to create texture"),t.g.push(n),t.m=!0,e.bindTexture(e.TEXTURE_2D,n),Bo(t)),n}function Go(t){t.h.bindTexture(t.h.TEXTURE_2D,null)}function jo(t){const e=Do(t);return So(Uo(t),e,!0,(()=>function(t,e){const n=t.canvas;if(n.width===t.width&&n.height===t.height)return e();const r=n.width,s=n.height;return n.width=t.width,n.height=t.height,t=e(),n.width=r,n.height=s,t}(t,(()=>{if(e.bindFramebuffer(e.FRAMEBUFFER,null),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),!(t.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return t.canvas.transferToImageBitmap()}))))}var Vo=class{constructor(t,e,n,r,s,i,o){this.g=t,this.j=e,this.m=n,this.canvas=r,this.l=s,this.width=i,this.height=o,(this.j||this.m)&&0==--zo&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}va(){return!!Co(this,0)}ba(){return!!Co(this,1)}K(){return!!Co(this,2)}ra(){return Ro(this)}qa(){var t=Co(this,1);return t||(Io(this),No(this),t=jo(this),Go(this),this.g.push(t),this.j=!0),t}V(){return Io(this)}clone(){const t=[];for(const e of this.g){let n;if(e instanceof ImageData)n=new ImageData(e.data,this.width,this.height);else if(e instanceof WebGLTexture){const t=Do(this),e=Uo(this);t.activeTexture(t.TEXTURE1),n=To(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,n),Bo(this),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.width,this.height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.bindTexture(t.TEXTURE_2D,null),Oo(e,t,n),So(e,t,!1,(()=>{No(this),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),Go(this)})),Mo(e),Go(this)}else{if(!(e instanceof ImageBitmap))throw Error(`Type is not supported: ${e}`);Io(this),No(this),n=jo(this),Go(this)}t.push(n)}return new Vo(t,this.ba(),this.K(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Co(this,1).close(),this.m&&Do(this).deleteTexture(Co(this,2)),zo=-1}};Vo.prototype.close=Vo.prototype.close,Vo.prototype.clone=Vo.prototype.clone,Vo.prototype.getAsWebGLTexture=Vo.prototype.V,Vo.prototype.getAsImageBitmap=Vo.prototype.qa,Vo.prototype.getAsImageData=Vo.prototype.ra,Vo.prototype.hasWebGLTexture=Vo.prototype.K,Vo.prototype.hasImageBitmap=Vo.prototype.ba,Vo.prototype.hasImageData=Vo.prototype.va;var zo=250;function Wo(t,e){switch(e){case 0:return t.g.find((t=>t instanceof Uint8Array));case 1:return t.g.find((t=>t instanceof Float32Array));case 2:return t.g.find((t=>"undefined"!=typeof WebGLTexture&&t instanceof WebGLTexture));default:throw Error(`Type is not supported: ${e}`)}}function Xo(t){var e=Wo(t,1);if(!e){if(e=Wo(t,0))e=new Float32Array(e).map((t=>t/255));else{e=new Float32Array(t.width*t.height);const r=$o(t);var n=Ko(t);if(Oo(n,r,Ho(t)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document){n=new Float32Array(t.width*t.height*4),r.readPixels(0,0,t.width,t.height,r.RGBA,r.FLOAT,n);for(let t=0,r=0;t<e.length;++t,r+=4)e[t]=n[r]}else r.readPixels(0,0,t.width,t.height,r.RED,r.FLOAT,e)}t.g.push(e)}return e}function Ho(t){let e=Wo(t,2);if(!e){const n=$o(t);e=Jo(t);const r=Xo(t),s=qo(t);n.texImage2D(n.TEXTURE_2D,0,s,t.width,t.height,0,n.RED,n.FLOAT,r),Zo(t)}return e}function $o(t){if(!t.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return t.h||(t.h=To(t.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),t.h}function qo(t){if(t=$o(t),!Qo)if(t.getExtension("EXT_color_buffer_float")&&t.getExtension("OES_texture_float_linear")&&t.getExtension("EXT_float_blend"))Qo=t.R32F;else{if(!t.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Qo=t.R16F}return Qo}function Ko(t){return t.l||(t.l=new Po),t.l}function Yo(t){(t=$o(t)).texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)}function Jo(t){const e=$o(t);e.viewport(0,0,t.width,t.height),e.activeTexture(e.TEXTURE0);let n=Wo(t,2);return n?e.bindTexture(e.TEXTURE_2D,n):(n=To(e.createTexture(),"Failed to create texture"),t.g.push(n),t.m=!0,e.bindTexture(e.TEXTURE_2D,n),Yo(t)),n}function Zo(t){t.h.bindTexture(t.h.TEXTURE_2D,null)}var Qo,ta=class{constructor(t,e,n,r,s,i){this.g=t,this.m=e,this.canvas=n,this.l=r,this.width=s,this.height=i,this.m&&0==--ea&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}wa(){return!!Wo(this,0)}ua(){return!!Wo(this,1)}K(){return!!Wo(this,2)}sa(){return(t=Wo(this,0))||(t=Xo(this),t=new Uint8Array(t.map((t=>255*t))),this.g.push(t)),t;var t}pa(){return Xo(this)}V(){return Ho(this)}clone(){const t=[];for(const e of this.g){let n;if(e instanceof Uint8Array)n=new Uint8Array(e);else if(e instanceof Float32Array)n=new Float32Array(e);else{if(!(e instanceof WebGLTexture))throw Error(`Type is not supported: ${e}`);{const t=$o(this),e=Ko(this);t.activeTexture(t.TEXTURE1),n=To(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,n),Yo(this);const r=qo(this);t.texImage2D(t.TEXTURE_2D,0,r,this.width,this.height,0,t.RED,t.FLOAT,null),t.bindTexture(t.TEXTURE_2D,null),Oo(e,t,n),So(e,t,!1,(()=>{Jo(this),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),Zo(this)})),Mo(e),Zo(this)}}t.push(n)}return new ta(t,this.K(),this.canvas,this.l,this.width,this.height)}close(){this.m&&$o(this).deleteTexture(Wo(this,2)),ea=-1}};ta.prototype.close=ta.prototype.close,ta.prototype.clone=ta.prototype.clone,ta.prototype.getAsWebGLTexture=ta.prototype.V,ta.prototype.getAsFloat32Array=ta.prototype.pa,ta.prototype.getAsUint8Array=ta.prototype.sa,ta.prototype.hasWebGLTexture=ta.prototype.K,ta.prototype.hasFloat32Array=ta.prototype.ua,ta.prototype.hasUint8Array=ta.prototype.wa;var ea=250;function na(...t){return t.map((([t,e])=>({start:t,end:e})))}const ra=function(t){return class extends t{Aa(){this.i._registerModelResourcesGraphService()}}}((sa=class{constructor(t,e){this.l=!0,this.i=t,this.g=null,this.h=0,this.m="function"==typeof this.i._addIntToInputStream,void 0!==e?this.i.canvas=e:"undefined"==typeof OffscreenCanvas||co()?(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas")):this.i.canvas=new OffscreenCanvas(1,1)}async initializeGraph(t){const e=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(e),t)}setGraphFromString(t){this.setGraph((new TextEncoder).encode(t),!1)}setGraph(t,e){const n=t.length,r=this.i._malloc(n);this.i.HEAPU8.set(t,r),e?this.i._changeBinaryGraph(n,r):this.i._changeTextGraph(n,r),this.i._free(r)}configureAudio(t,e,n,r,s){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),lo(this,r||"input_audio",(r=>{lo(this,s=s||"audio_header",(s=>{this.i._configureAudio(r,s,t,e,n)}))}))}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.i._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.i.gpuOriginForWebTexturesIsBottomLeft=t}W(t){go(this,"__graph_config__",(e=>{t(e)})),lo(this,"__graph_config__",(t=>{this.i._getGraphConfig(t,void 0)})),delete this.i.simpleListeners.__graph_config__}attachErrorListener(t){this.i.errorListener=t}attachEmptyPacketListener(t,e){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[t]=e}addAudioToStream(t,e,n){this.addAudioToStreamWithShape(t,0,0,e,n)}addAudioToStreamWithShape(t,e,n,r,s){const i=4*t.length;this.h!==i&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(i),this.h=i),this.i.HEAPF32.set(t,this.g/4),lo(this,r,(t=>{this.i._addAudioToInputStream(this.g,e,n,t,s)}))}addGpuBufferToStream(t,e,n){lo(this,e,(e=>{const[r,s]=fo(this,t,e);this.i._addBoundTextureToStream(e,r,s,n)}))}addBoolToStream(t,e,n){lo(this,e,(e=>{this.i._addBoolToInputStream(t,e,n)}))}addDoubleToStream(t,e,n){lo(this,e,(e=>{this.i._addDoubleToInputStream(t,e,n)}))}addFloatToStream(t,e,n){lo(this,e,(e=>{this.i._addFloatToInputStream(t,e,n)}))}addIntToStream(t,e,n){lo(this,e,(e=>{this.i._addIntToInputStream(t,e,n)}))}addStringToStream(t,e,n){lo(this,e,(e=>{lo(this,t,(t=>{this.i._addStringToInputStream(t,e,n)}))}))}addStringRecordToStream(t,e,n){lo(this,e,(e=>{po(this,Object.keys(t),(r=>{po(this,Object.values(t),(s=>{this.i._addFlatHashMapToInputStream(r,s,Object.keys(t).length,e,n)}))}))}))}addProtoToStream(t,e,n,r){lo(this,n,(n=>{lo(this,e,(e=>{const s=this.i._malloc(t.length);this.i.HEAPU8.set(t,s),this.i._addProtoToInputStream(s,t.length,e,n,r),this.i._free(s)}))}))}addEmptyPacketToStream(t,e){lo(this,t,(t=>{this.i._addEmptyPacketToInputStream(t,e)}))}addBoolToInputSidePacket(t,e){lo(this,e,(e=>{this.i._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){lo(this,e,(e=>{this.i._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){lo(this,e,(e=>{this.i._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){lo(this,e,(e=>{this.i._addIntToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){lo(this,e,(e=>{lo(this,t,(t=>{this.i._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,n){lo(this,n,(n=>{lo(this,e,(e=>{const r=this.i._malloc(t.length);this.i.HEAPU8.set(t,r),this.i._addProtoToInputSidePacket(r,t.length,e,n),this.i._free(r)}))}))}attachBoolListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachBoolListener(t)}))}attachBoolVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachBoolVectorListener(t)}))}attachIntListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachIntListener(t)}))}attachIntVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachIntVectorListener(t)}))}attachDoubleListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachFloatListener(t)}))}attachFloatVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachFloatVectorListener(t)}))}attachStringListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachStringListener(t)}))}attachStringVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachStringVectorListener(t)}))}attachProtoListener(t,e,n){go(this,t,e),lo(this,t,(t=>{this.i._attachProtoListener(t,n||!1)}))}attachProtoVectorListener(t,e,n){mo(this,t,e),lo(this,t,(t=>{this.i._attachProtoVectorListener(t,n||!1)}))}attachAudioListener(t,e,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),go(this,t,((t,n)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,n)})),lo(this,t,(t=>{this.i._attachAudioListener(t,n||!1)}))}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends sa{get Y(){return this.i}ga(t,e,n){lo(this,e,(e=>{const[r,s]=fo(this,t,e);this.Y._addBoundTextureAsImageToStream(e,r,s,n)}))}S(t,e){go(this,t,e),lo(this,t,(t=>{this.Y._attachImageListener(t)}))}T(t,e){mo(this,t,e),lo(this,t,(t=>{this.Y._attachImageVectorListener(t)}))}}));var sa,ia=class extends ra{};async function oa(t,e,n){return async function(t,e,n,r){return async function(t,e,n,r){return t=await(async(t,e,n,r,s)=>{if(e&&await uo(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await uo(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&s&&((e=self.Module).locateFile=s.locateFile,s.mainScriptUrlOrBlob&&(e.mainScriptUrlOrBlob=s.mainScriptUrlOrBlob)),s=await self.ModuleFactory(self.Module||s),self.ModuleFactory=self.Module=void 0,new t(s,r)})(t,n.wasmLoaderPath,n.assetLoaderPath,e,{locateFile:t=>t.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&t.endsWith(".data")?n.assetBinaryPath.toString():t}),await t.o(r),t}(t,e,n,r)}(t,n.canvas??("undefined"==typeof OffscreenCanvas||co()?document.createElement("canvas"):void 0),e,n)}function aa(t,e,n,r){if(t.Z){const i=new Is;if(n?.regionOfInterest){if(!t.ea)throw Error("This task doesn't support region-of-interest.");var s=n.regionOfInterest;if(s.left>=s.right||s.top>=s.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>s.left||0>s.top||1<s.right||1<s.bottom)throw Error("Expected RectF values to be in [0,1].");mn(i,1,(s.left+s.right)/2),mn(i,2,(s.top+s.bottom)/2),mn(i,4,s.right-s.left),mn(i,3,s.bottom-s.top)}else mn(i,1,.5),mn(i,2,.5),mn(i,4,1),mn(i,3,1);if(n?.rotationDegrees){if(0!=n?.rotationDegrees%90)throw Error("Expected rotation to be a multiple of 90°.");if(mn(i,5,-Math.PI*n.rotationDegrees/180),0!=n?.rotationDegrees%180){const[t,r]=void 0!==e.videoWidth?[e.videoWidth,e.videoHeight]:void 0!==e.naturalWidth?[e.naturalWidth,e.naturalHeight]:[e.width,e.height];n=dn(i,3)*r/t,s=dn(i,4)*t/r,mn(i,4,n),mn(i,3,s)}}t.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",t.Z,r)}t.g.ga(e,t.da,r??performance.now()),t.finishProcessing()}function ha(t,e,n){if(t.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");aa(t,e,n,t.I+1)}function ca(t,e,n,r){if(!t.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");aa(t,e,n,r)}function ua(t,e,n){var r=e.data;const s=e.width,i=s*(e=e.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==i)throw Error("Unsupported channel count: "+r.length/i);return t=new ta([r],!1,t.g.i.canvas,t.O,s,e),n?t.clone():t}var la=class extends Eo{constructor(t,e,n,r){super(t),this.g=t,this.da=e,this.Z=n,this.ea=r,this.O=new Po}l(t,e=!0){if("runningMode"in t&&pn(this.baseOptions,2,!!t.runningMode&&"IMAGE"!==t.runningMode),void 0!==t.canvas&&this.g.i.canvas!==t.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(t,e)}close(){this.O.close(),super.close()}};la.prototype.close=la.prototype.close;var fa=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect_in",!1),this.j={detections:[]},this.h=new ri,t=new ei,on(this.h,0,1,t),mn(this.h,2,.5),mn(this.h,3,.3)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&mn(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&mn(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,e){return this.j={detections:[]},ha(this,t,e),this.j}G(t,e,n){return this.j={detections:[]},ca(this,t,n,e),this.j}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect_in"),ss(t,"detections");const e=new Nr;vn(e,ii,this.h);const n=new Yr;$r(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),qr(n,"IMAGE:image_in"),qr(n,"NORM_RECT:norm_rect_in"),Kr(n,"DETECTIONS:detections"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("detections",((t,e)=>{for(const e of t)t=Ts(e),this.j.detections.push(Qi(t));_o(this,e)})),this.g.attachEmptyPacketListener("detections",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};fa.prototype.detectForVideo=fa.prototype.G,fa.prototype.detect=fa.prototype.F,fa.prototype.setOptions=fa.prototype.o,fa.createFromModelPath=async function(t,e){return oa(fa,t,{baseOptions:{modelAssetPath:e}})},fa.createFromModelBuffer=function(t,e){return oa(fa,t,{baseOptions:{modelAssetBuffer:e}})},fa.createFromOptions=function(t,e){return oa(fa,t,e)};var da=na([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),pa=na([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),ga=na([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),ma=na([474,475],[475,476],[476,477],[477,474]),ya=na([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),va=na([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),_a=na([469,470],[470,471],[471,472],[472,469]),wa=na([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Aa=[...da,...pa,...ga,...ya,...va,...wa],ba=na([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Ea(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Ta=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,this.h=new fi,t=new ei,on(this.h,0,1,t),this.v=new ui,on(this.h,0,3,this.v),this.s=new ri,on(this.h,0,2,this.s),gn(this.s,4,1),mn(this.s,2,.5),mn(this.v,2,.5),mn(this.h,4,.5)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return"numFaces"in t&&gn(this.s,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&mn(this.s,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&mn(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&mn(this.v,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in t&&(this.outputFacialTransformationMatrixes=!!t.outputFacialTransformationMatrixes),this.l(t)}F(t,e){return Ea(this),ha(this,t,e),this.j}G(t,e,n){return Ea(this),ca(this,t,n,e),this.j}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"face_landmarks");const e=new Nr;vn(e,pi,this.h);const n=new Yr;$r(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),qr(n,"IMAGE:image_in"),qr(n,"NORM_RECT:norm_rect"),Kr(n,"NORM_LANDMARKS:face_landmarks"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("face_landmarks",((t,e)=>{for(const e of t)t=Ps(e),this.j.faceLandmarks.push(to(t));_o(this,e)})),this.g.attachEmptyPacketListener("face_landmarks",(t=>{_o(this,t)})),this.outputFaceBlendshapes&&(ss(t,"blendshapes"),Kr(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((t,e)=>{if(this.outputFaceBlendshapes)for(const e of t)t=ds(e),this.j.faceBlendshapes.push(Zi(t.g()??[]));_o(this,e)})),this.g.attachEmptyPacketListener("blendshapes",(t=>{_o(this,t)}))),this.outputFacialTransformationMatrixes&&(ss(t,"face_geometry"),Kr(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((t,e)=>{if(this.outputFacialTransformationMatrixes)for(const e of t)(t=nn(hi(e),Cs,2))&&this.j.facialTransformationMatrixes.push({rows:fn(cn(t,1))??0,columns:fn(cn(t,2))??0,data:$e(t,3,he)??[]});_o(this,e)})),this.g.attachEmptyPacketListener("face_geometry",(t=>{_o(this,t)}))),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ta.prototype.detectForVideo=Ta.prototype.G,Ta.prototype.detect=Ta.prototype.F,Ta.prototype.setOptions=Ta.prototype.o,Ta.createFromModelPath=function(t,e){return oa(Ta,t,{baseOptions:{modelAssetPath:e}})},Ta.createFromModelBuffer=function(t,e){return oa(Ta,t,{baseOptions:{modelAssetBuffer:e}})},Ta.createFromOptions=function(t,e){return oa(Ta,t,e)},Ta.FACE_LANDMARKS_LIPS=da,Ta.FACE_LANDMARKS_LEFT_EYE=pa,Ta.FACE_LANDMARKS_LEFT_EYEBROW=ga,Ta.FACE_LANDMARKS_LEFT_IRIS=ma,Ta.FACE_LANDMARKS_RIGHT_EYE=ya,Ta.FACE_LANDMARKS_RIGHT_EYEBROW=va,Ta.FACE_LANDMARKS_RIGHT_IRIS=_a,Ta.FACE_LANDMARKS_FACE_OVAL=wa,Ta.FACE_LANDMARKS_CONTOURS=Aa,Ta.FACE_LANDMARKS_TESSELATION=ba;var ka=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!0),this.j=new gi,t=new ei,on(this.j,0,1,t)}get baseOptions(){return nn(this.j,ei,1)}set baseOptions(t){on(this.j,0,1,t)}o(t){return super.l(t)}Da(t,e,n){const r="function"!=typeof e?e:{};if(this.h="function"==typeof e?e:n,ha(this,t,r??{}),!this.h)return this.s}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"stylized_image");const e=new Nr;vn(e,mi,this.j);const n=new Yr;$r(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),qr(n,"IMAGE:image_in"),qr(n,"NORM_RECT:norm_rect"),Kr(n,"STYLIZED_IMAGE:stylized_image"),n.o(e),ns(t,n),this.g.S("stylized_image",((t,e)=>{var n=!this.h,r=t.data,s=t.width;const i=s*(t=t.height);if(r instanceof Uint8Array)if(r.length===3*i){const e=new Uint8ClampedArray(4*i);for(let t=0;t<i;++t)e[4*t]=r[3*t],e[4*t+1]=r[3*t+1],e[4*t+2]=r[3*t+2],e[4*t+3]=255;r=new ImageData(e,s,t)}else{if(r.length!==4*i)throw Error("Unsupported channel count: "+r.length/i);r=new ImageData(new Uint8ClampedArray(r.buffer,r.byteOffset,r.length),s,t)}else if(!(r instanceof WebGLTexture))throw Error(`Unsupported format: ${r.constructor.name}`);s=new Vo([r],!1,!1,this.g.i.canvas,this.O,s,t),this.s=n=n?s.clone():s,this.h&&this.h(n),_o(this,e)})),this.g.attachEmptyPacketListener("stylized_image",(t=>{this.s=null,this.h&&this.h(null),_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ka.prototype.stylize=ka.prototype.Da,ka.prototype.setOptions=ka.prototype.o,ka.createFromModelPath=function(t,e){return oa(ka,t,{baseOptions:{modelAssetPath:e}})},ka.createFromModelBuffer=function(t,e){return oa(ka,t,{baseOptions:{modelAssetBuffer:e}})},ka.createFromOptions=function(t,e){return oa(ka,t,e)};var xa=na([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function La(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function Fa(t){return 0===t.gestures.length?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:t.gestures,landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handedness:t.handedness,handednesses:t.handedness}}function Sa(t,e=!0){const n=[];for(const s of t){var r=ds(s);t=[];for(const n of r.g())r=e&&null!=cn(n,1)?fn(cn(n,1)):-1,t.push({score:dn(n,2)??0,index:r,categoryName:ln(n,3)??""??"",displayName:ln(n,4)??""??""});n.push(t)}return n}var Oa=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.v=new Fi,t=new ei,on(this.v,0,1,t),this.C=new xi,on(this.v,0,2,this.C),this.s=new Ti,on(this.C,0,3,this.s),this.h=new bi,on(this.C,0,2,this.h),this.j=new wi,on(this.v,0,3,this.j),mn(this.h,2,.5),mn(this.C,4,.5),mn(this.s,2,.5)}get baseOptions(){return nn(this.v,ei,1)}set baseOptions(t){on(this.v,0,1,t)}o(t){if(gn(this.h,3,t.numHands??1),"minHandDetectionConfidence"in t&&mn(this.h,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&mn(this.C,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&mn(this.s,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var e=new yi,n=Ji(t.cannedGesturesClassifierOptions,nn(this.j,yi,3)?.h());on(e,0,2,n),on(this.j,0,3,e)}else void 0===t.cannedGesturesClassifierOptions&&nn(this.j,yi,3)?.g();return t.customGesturesClassifierOptions?(on(e=new yi,0,2,n=Ji(t.customGesturesClassifierOptions,nn(this.j,yi,4)?.h())),on(this.j,0,4,e)):void 0===t.customGesturesClassifierOptions&&nn(this.j,yi,4)?.g(),this.l(t)}ya(t,e){return La(this),ha(this,t,e),Fa(this)}za(t,e,n){return La(this),ca(this,t,n,e),Fa(this)}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"hand_gestures"),ss(t,"hand_landmarks"),ss(t,"world_hand_landmarks"),ss(t,"handedness");const e=new Nr;vn(e,Mi,this.v);const n=new Yr;$r(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),qr(n,"IMAGE:image_in"),qr(n,"NORM_RECT:norm_rect"),Kr(n,"HAND_GESTURES:hand_gestures"),Kr(n,"LANDMARKS:hand_landmarks"),Kr(n,"WORLD_LANDMARKS:world_hand_landmarks"),Kr(n,"HANDEDNESS:handedness"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("hand_landmarks",((t,e)=>{for(const e of t){t=Ps(e);const n=[];for(const e of sn(t,Ss,1))n.push({x:dn(e,1)??0,y:dn(e,2)??0,z:dn(e,3)??0});this.landmarks.push(n)}_o(this,e)})),this.g.attachEmptyPacketListener("hand_landmarks",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("world_hand_landmarks",((t,e)=>{for(const e of t){t=Fs(e);const n=[];for(const e of sn(t,ks,1))n.push({x:dn(e,1)??0,y:dn(e,2)??0,z:dn(e,3)??0});this.worldLandmarks.push(n)}_o(this,e)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("hand_gestures",((t,e)=>{this.gestures.push(...Sa(t,!1)),_o(this,e)})),this.g.attachEmptyPacketListener("hand_gestures",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("handedness",((t,e)=>{this.handedness.push(...Sa(t)),_o(this,e)})),this.g.attachEmptyPacketListener("handedness",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function Ma(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Oa.prototype.recognizeForVideo=Oa.prototype.za,Oa.prototype.recognize=Oa.prototype.ya,Oa.prototype.setOptions=Oa.prototype.o,Oa.createFromModelPath=function(t,e){return oa(Oa,t,{baseOptions:{modelAssetPath:e}})},Oa.createFromModelBuffer=function(t,e){return oa(Oa,t,{baseOptions:{modelAssetBuffer:e}})},Oa.createFromOptions=function(t,e){return oa(Oa,t,e)},Oa.HAND_CONNECTIONS=xa;var Pa=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.j=new xi,t=new ei,on(this.j,0,1,t),this.s=new Ti,on(this.j,0,3,this.s),this.h=new bi,on(this.j,0,2,this.h),gn(this.h,3,1),mn(this.h,2,.5),mn(this.s,2,.5),mn(this.j,4,.5)}get baseOptions(){return nn(this.j,ei,1)}set baseOptions(t){on(this.j,0,1,t)}o(t){return"numHands"in t&&gn(this.h,3,t.numHands??1),"minHandDetectionConfidence"in t&&mn(this.h,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&mn(this.j,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&mn(this.s,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,e){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ha(this,t,e),Ma(this)}G(t,e,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ca(this,t,n,e),Ma(this)}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"hand_landmarks"),ss(t,"world_hand_landmarks"),ss(t,"handedness");const e=new Nr;vn(e,Oi,this.j);const n=new Yr;$r(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),qr(n,"IMAGE:image_in"),qr(n,"NORM_RECT:norm_rect"),Kr(n,"LANDMARKS:hand_landmarks"),Kr(n,"WORLD_LANDMARKS:world_hand_landmarks"),Kr(n,"HANDEDNESS:handedness"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("hand_landmarks",((t,e)=>{for(const e of t)t=Ps(e),this.landmarks.push(to(t));_o(this,e)})),this.g.attachEmptyPacketListener("hand_landmarks",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("world_hand_landmarks",((t,e)=>{for(const e of t)t=Fs(e),this.worldLandmarks.push(eo(t));_o(this,e)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("handedness",((t,e)=>{var n=this.handedness,r=n.push;const s=[];for(const e of t){t=ds(e);const n=[];for(const e of t.g())n.push({score:dn(e,2)??0,index:fn(cn(e,1))??-1,categoryName:ln(e,3)??""??"",displayName:ln(e,4)??""??""});s.push(n)}r.call(n,...s),_o(this,e)})),this.g.attachEmptyPacketListener("handedness",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Pa.prototype.detectForVideo=Pa.prototype.G,Pa.prototype.detect=Pa.prototype.F,Pa.prototype.setOptions=Pa.prototype.o,Pa.createFromModelPath=function(t,e){return oa(Pa,t,{baseOptions:{modelAssetPath:e}})},Pa.createFromModelBuffer=function(t,e){return oa(Pa,t,{baseOptions:{modelAssetBuffer:e}})},Pa.createFromOptions=function(t,e){return oa(Pa,t,e)},Pa.HAND_CONNECTIONS=xa;var Ca=class extends la{constructor(t,e){super(new ia(t,e),"input_image","norm_rect",!0),this.j={classifications:[]},this.h=new Pi,t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){var e=Ji(t,nn(this.h,$s,2));return on(this.h,0,2,e),this.l(t)}ia(t,e){return this.j={classifications:[]},ha(this,t,e),this.j}ja(t,e,n){return this.j={classifications:[]},ca(this,t,n,e),this.j}m(){var t=new is;rs(t,"input_image"),rs(t,"norm_rect"),ss(t,"classifications");const e=new Nr;vn(e,Ci,this.h);const n=new Yr;$r(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),qr(n,"IMAGE:input_image"),qr(n,"NORM_RECT:norm_rect"),Kr(n,"CLASSIFICATIONS:classifications"),n.o(e),ns(t,n),this.g.attachProtoListener("classifications",((t,e)=>{this.j=function(t){const e={classifications:sn(t,Ds,1).map((t=>Zi(nn(t,ls,4)?.g()??[],fn(cn(t,2)),ln(t,3)??"")))};return null!=un(t)&&(e.timestampMs=fn(un(t))),e}(Ns(t)),_o(this,e)})),this.g.attachEmptyPacketListener("classifications",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ca.prototype.classifyForVideo=Ca.prototype.ja,Ca.prototype.classify=Ca.prototype.ia,Ca.prototype.setOptions=Ca.prototype.o,Ca.createFromModelPath=function(t,e){return oa(Ca,t,{baseOptions:{modelAssetPath:e}})},Ca.createFromModelBuffer=function(t,e){return oa(Ca,t,{baseOptions:{modelAssetBuffer:e}})},Ca.createFromOptions=function(t,e){return oa(Ca,t,e)};var Ra=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!0),this.h=new Ri,this.embeddings={embeddings:[]},t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){var e=this.h,n=nn(this.h,Ks,2);return n=n?n.clone():new Ks,void 0!==t.l2Normalize?pn(n,1,t.l2Normalize):"l2Normalize"in t&&Ve(n,1),void 0!==t.quantize?pn(n,2,t.quantize):"quantize"in t&&Ve(n,2),on(e,0,2,n),this.l(t)}na(t,e){return ha(this,t,e),this.embeddings}oa(t,e,n){return ca(this,t,n,e),this.embeddings}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"embeddings_out");const e=new Nr;vn(e,Ii,this.h);const n=new Yr;$r(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),qr(n,"IMAGE:image_in"),qr(n,"NORM_RECT:norm_rect"),Kr(n,"EMBEDDINGS:embeddings_out"),n.o(e),ns(t,n),this.g.attachProtoListener("embeddings_out",((t,e)=>{t=Hs(t),this.embeddings=function(t){return{embeddings:sn(t,Vs,1).map((t=>{const e={headIndex:fn(cn(t,3))??-1,headName:ln(t,4)??""??""};if(void 0!==en(t,Gs,Ze(t,1)))t=$e(t=nn(t,Gs,Ze(t,1)),1,he),e.floatEmbedding=t;else{const n=new Uint8Array(0);e.quantizedEmbedding=nn(t,js,Ze(t,2))?.fa()?.ha()??n}return e})),timestampMs:fn(un(t))}}(t),_o(this,e)})),this.g.attachEmptyPacketListener("embeddings_out",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ra.cosineSimilarity=function(t,e){if(t.floatEmbedding&&e.floatEmbedding)t=ro(t.floatEmbedding,e.floatEmbedding);else{if(!t.quantizedEmbedding||!e.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=ro(no(t.quantizedEmbedding),no(e.quantizedEmbedding))}return t},Ra.prototype.embedForVideo=Ra.prototype.oa,Ra.prototype.embed=Ra.prototype.na,Ra.prototype.setOptions=Ra.prototype.o,Ra.createFromModelPath=function(t,e){return oa(Ra,t,{baseOptions:{modelAssetPath:e}})},Ra.createFromModelBuffer=function(t,e){return oa(Ra,t,{baseOptions:{modelAssetBuffer:e}})},Ra.createFromOptions=function(t,e){return oa(Ra,t,e)};var Ia=class{constructor(t,e,n){this.confidenceMasks=t,this.categoryMask=e,this.qualityScores=n}close(){this.confidenceMasks?.forEach((t=>{t.close()})),this.categoryMask?.close()}};function Da(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function Ua(t){try{const e=new Ia(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return e;t.j(e)}finally{bo(t)}}Ia.prototype.close=Ia.prototype.close;var Ba=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Gi,this.v=new Di,on(this.h,0,3,this.v),t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return void 0!==t.displayNamesLocale?Ve(this.h,2,pe(t.displayNamesLocale)):"displayNamesLocale"in t&&Ve(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}P(){!function(t){const e=sn(t.W(),Yr,1).filter((t=>(ln(t,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator")));if(t.s=[],1<e.length)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");1===e.length&&(nn(e[0],Nr,7)?.l()?.g()??new Map).forEach(((e,n)=>{t.s[Number(n)]=ln(e,1)??""}))}(this)}X(t,e,n){const r="function"!=typeof e?e:{};return this.j="function"==typeof e?e:n,Da(this),ha(this,t,r),Ua(this)}Ca(t,e,n,r){const s="function"!=typeof n?n:{};return this.j="function"==typeof n?n:r,Da(this),ca(this,t,s,e),Ua(this)}ta(){return this.s}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect");const e=new Nr;vn(e,ji,this.h);const n=new Yr;$r(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),qr(n,"IMAGE:image_in"),qr(n,"NORM_RECT:norm_rect"),n.o(e),ns(t,n),wo(this,t),this.outputConfidenceMasks&&(ss(t,"confidence_masks"),Kr(n,"CONFIDENCE_MASKS:confidence_masks"),Ao(this,"confidence_masks"),this.g.T("confidence_masks",((t,e)=>{this.confidenceMasks=t.map((t=>ua(this,t,!this.j))),_o(this,e)})),this.g.attachEmptyPacketListener("confidence_masks",(t=>{this.confidenceMasks=[],_o(this,t)}))),this.outputCategoryMask&&(ss(t,"category_mask"),Kr(n,"CATEGORY_MASK:category_mask"),Ao(this,"category_mask"),this.g.S("category_mask",((t,e)=>{this.categoryMask=ua(this,t,!this.j),_o(this,e)})),this.g.attachEmptyPacketListener("category_mask",(t=>{this.categoryMask=void 0,_o(this,t)}))),ss(t,"quality_scores"),Kr(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((t,e)=>{this.qualityScores=t,_o(this,e)})),this.g.attachEmptyPacketListener("quality_scores",(t=>{this.categoryMask=void 0,_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ba.prototype.getLabels=Ba.prototype.ta,Ba.prototype.segmentForVideo=Ba.prototype.Ca,Ba.prototype.segment=Ba.prototype.X,Ba.prototype.setOptions=Ba.prototype.o,Ba.createFromModelPath=function(t,e){return oa(Ba,t,{baseOptions:{modelAssetPath:e}})},Ba.createFromModelBuffer=function(t,e){return oa(Ba,t,{baseOptions:{modelAssetBuffer:e}})},Ba.createFromOptions=function(t,e){return oa(Ba,t,e)};var Na=class{constructor(t,e,n){this.confidenceMasks=t,this.categoryMask=e,this.qualityScores=n}close(){this.confidenceMasks?.forEach((t=>{t.close()})),this.categoryMask?.close()}};Na.prototype.close=Na.prototype.close;var Ga=class extends _n{constructor(t){super(t)}},ja=[0,hr,hr,hr],Va=[0,er,er,er,er,lr],za=[0,er,er,er,er,lr,er,er],Wa=[0,yr,za],Xa=[0,yr,Wa,yr,ja],Ha=[0,yr,za,yr,ja],$a=[0,yr,za,hr,hr],qa=[0,yr,$a,yr,ja],Ka=[0,er,er,er,er,lr,yr,ja,yr,ja],Ya=[0,er,er,er,er,lr,br],Ja=class extends _n{constructor(t){super(t)}},Za=[0,er,er,lr],Qa=class extends _n{constructor(){super()}};Qa.B=[1];var th=class extends _n{constructor(t){super(t)}},eh=[1,2,3,4,5,6,7,8,9,10,14,15],nh=[0,_r,za,eh,_r,Ha,eh,_r,Wa,eh,_r,Xa,eh,_r,Za,eh,_r,Ya,eh,_r,Va,eh,_r,[0,gr,er,er,er,lr,hr,lr,lr,er,3,yr,ja],eh,_r,$a,eh,_r,qa,eh,er,yr,ja,gr,_r,Ka,eh,_r,[0,vr,Za],eh],rh=[0,gr,hr,hr,lr],sh=class extends _n{constructor(){super()}};sh.B=[1],sh.prototype.g=Lr([0,vr,nh,gr,yr,rh]);var ih=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Gi,this.v=new Di,on(this.h,0,3,this.v),t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}X(t,e,n,r){const s="function"!=typeof n?n:{};this.j="function"==typeof n?n:r,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.I+1,r=new sh;const i=new th;var o=new Ga;if(gn(o,1,255),on(i,0,12,o),e.keypoint&&e.scribble)throw Error("Cannot provide both keypoint and scribble.");if(e.keypoint){var a=new Ja;pn(a,3,!0),mn(a,1,e.keypoint.x),mn(a,2,e.keypoint.y),an(i,5,eh,a)}else{if(!e.scribble)throw Error("Must provide either a keypoint or a scribble.");for(a of(o=new Qa,e.scribble))pn(e=new Ja,3,!0),mn(e,1,a.x),mn(e,2,a.y),hn(o,Ja,e);an(i,15,eh,o)}hn(r,th,i),this.g.addProtoToStream(r.g(),"drishti.RenderData","roi_in",n),ha(this,t,s);t:{try{const t=new Na(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var h=t;break t}this.j(t)}finally{bo(this)}h=void 0}return h}m(){var t=new is;rs(t,"image_in"),rs(t,"roi_in"),rs(t,"norm_rect_in");const e=new Nr;vn(e,ji,this.h);const n=new Yr;$r(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),qr(n,"IMAGE:image_in"),qr(n,"ROI:roi_in"),qr(n,"NORM_RECT:norm_rect_in"),n.o(e),ns(t,n),wo(this,t),this.outputConfidenceMasks&&(ss(t,"confidence_masks"),Kr(n,"CONFIDENCE_MASKS:confidence_masks"),Ao(this,"confidence_masks"),this.g.T("confidence_masks",((t,e)=>{this.confidenceMasks=t.map((t=>ua(this,t,!this.j))),_o(this,e)})),this.g.attachEmptyPacketListener("confidence_masks",(t=>{this.confidenceMasks=[],_o(this,t)}))),this.outputCategoryMask&&(ss(t,"category_mask"),Kr(n,"CATEGORY_MASK:category_mask"),Ao(this,"category_mask"),this.g.S("category_mask",((t,e)=>{this.categoryMask=ua(this,t,!this.j),_o(this,e)})),this.g.attachEmptyPacketListener("category_mask",(t=>{this.categoryMask=void 0,_o(this,t)}))),ss(t,"quality_scores"),Kr(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((t,e)=>{this.qualityScores=t,_o(this,e)})),this.g.attachEmptyPacketListener("quality_scores",(t=>{this.categoryMask=void 0,_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ih.prototype.segment=ih.prototype.X,ih.prototype.setOptions=ih.prototype.o,ih.createFromModelPath=function(t,e){return oa(ih,t,{baseOptions:{modelAssetPath:e}})},ih.createFromModelBuffer=function(t,e){return oa(ih,t,{baseOptions:{modelAssetBuffer:e}})},ih.createFromOptions=function(t,e){return oa(ih,t,e)};var oh=class extends la{constructor(t,e){super(new ia(t,e),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},this.h=new Vi,t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return void 0!==t.displayNamesLocale?Ve(this.h,2,pe(t.displayNamesLocale)):"displayNamesLocale"in t&&Ve(this.h,2),void 0!==t.maxResults?gn(this.h,3,t.maxResults):"maxResults"in t&&Ve(this.h,3),void 0!==t.scoreThreshold?mn(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&Ve(this.h,4),void 0!==t.categoryAllowlist?Je(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&Ve(this.h,5),void 0!==t.categoryDenylist?Je(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&Ve(this.h,6),this.l(t)}F(t,e){return this.j={detections:[]},ha(this,t,e),this.j}G(t,e,n){return this.j={detections:[]},ca(this,t,n,e),this.j}m(){var t=new is;rs(t,"input_frame_gpu"),rs(t,"norm_rect"),ss(t,"detections");const e=new Nr;vn(e,zi,this.h);const n=new Yr;$r(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),qr(n,"IMAGE:input_frame_gpu"),qr(n,"NORM_RECT:norm_rect"),Kr(n,"DETECTIONS:detections"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("detections",((t,e)=>{for(const e of t)t=Ts(e),this.j.detections.push(Qi(t));_o(this,e)})),this.g.attachEmptyPacketListener("detections",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function ah(t){t.landmarks=[],t.worldLandmarks=[],t.v=void 0}function hh(t){try{const e=new class{constructor(t,e,n){this.landmarks=t,this.worldLandmarks=e,this.g=n}close(){this.g?.forEach((t=>{t.close()}))}}(t.landmarks,t.worldLandmarks,t.v);if(!t.s)return e;t.s(e)}finally{bo(t)}}oh.prototype.detectForVideo=oh.prototype.G,oh.prototype.detect=oh.prototype.F,oh.prototype.setOptions=oh.prototype.o,oh.createFromModelPath=async function(t,e){return oa(oh,t,{baseOptions:{modelAssetPath:e}})},oh.createFromModelBuffer=function(t,e){return oa(oh,t,{baseOptions:{modelAssetBuffer:e}})},oh.createFromOptions=function(t,e){return oa(oh,t,e)};var ch=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,this.h=new qi,t=new ei,on(this.h,0,1,t),this.C=new Hi,on(this.h,0,3,this.C),this.j=new Wi,on(this.h,0,2,this.j),gn(this.j,4,1),mn(this.j,2,.5),mn(this.C,2,.5),mn(this.h,4,.5)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return"numPoses"in t&&gn(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&mn(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&mn(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&mn(this.C,2,t.minPosePresenceConfidence??.5),"outputSegmentationMasks"in t&&(this.outputSegmentationMasks=t.outputSegmentationMasks??!1),this.l(t)}F(t,e,n){const r="function"!=typeof e?e:{};return this.s="function"==typeof e?e:n,ah(this),ha(this,t,r),hh(this)}G(t,e,n,r){const s="function"!=typeof n?n:{};return this.s="function"==typeof n?n:r,ah(this),ca(this,t,s,e),hh(this)}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"normalized_landmarks"),ss(t,"world_landmarks"),ss(t,"segmentation_masks");const e=new Nr;vn(e,Yi,this.h);const n=new Yr;$r(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),qr(n,"IMAGE:image_in"),qr(n,"NORM_RECT:norm_rect"),Kr(n,"NORM_LANDMARKS:normalized_landmarks"),Kr(n,"WORLD_LANDMARKS:world_landmarks"),n.o(e),ns(t,n),wo(this,t),this.g.attachProtoVectorListener("normalized_landmarks",((t,e)=>{this.landmarks=[];for(const e of t)t=Ps(e),this.landmarks.push(to(t));_o(this,e)})),this.g.attachEmptyPacketListener("normalized_landmarks",(t=>{this.landmarks=[],_o(this,t)})),this.g.attachProtoVectorListener("world_landmarks",((t,e)=>{this.worldLandmarks=[];for(const e of t)t=Fs(e),this.worldLandmarks.push(eo(t));_o(this,e)})),this.g.attachEmptyPacketListener("world_landmarks",(t=>{this.worldLandmarks=[],_o(this,t)})),this.outputSegmentationMasks&&(Kr(n,"SEGMENTATION_MASK:segmentation_masks"),Ao(this,"segmentation_masks"),this.g.T("segmentation_masks",((t,e)=>{this.v=t.map((t=>ua(this,t,!this.s))),_o(this,e)})),this.g.attachEmptyPacketListener("segmentation_masks",(t=>{this.v=[],_o(this,t)}))),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};let uh;ch.prototype.detectForVideo=ch.prototype.G,ch.prototype.detect=ch.prototype.F,ch.prototype.setOptions=ch.prototype.o,ch.createFromModelPath=function(t,e){return oa(ch,t,{baseOptions:{modelAssetPath:e}})},ch.createFromModelBuffer=function(t,e){return oa(ch,t,{baseOptions:{modelAssetBuffer:e}})},ch.createFromOptions=function(t,e){return oa(ch,t,e)},ch.POSE_CONNECTIONS=na([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);const lh=10;let fh;function dh(t,e,n){return{x:t.x*e,y:t.y*n,z:t.z}}function ph(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}t.initialize=function(t,n=null){return e(this,void 0,void 0,(function*(){const e=yield ho.forVisionTasks(t);uh=yield Ta.createFromOptions(e,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task",delegate:"CPU"},runningMode:"VIDEO"}),n&&(fh=n)}))},t.predict=function(t){return e(this,void 0,void 0,(function*(){return function(t,e,n){if(null==(null==t?void 0:t.faceLandmarks)||null==(null==t?void 0:t.faceLandmarks[0]))return{error:"No landmarks detected!",ipd:0,faceWidth:0};const r=t.faceLandmarks[0],s=ph(dh(r[468],e,n),dh(r[473],e,n));if(s<lh)return{error:"User is too far!",ipd:0,faceWidth:0};const i=dh(r[469],e,n),o=dh(r[470],e,n),a=dh(r[471],e,n),h=dh(r[472],e,n),c=dh(r[474],e,n),u=dh(r[475],e,n),l=dh(r[476],e,n),f=dh(r[477],e,n),d=[ph(i,a),ph(o,h),ph(c,l),ph(u,f)],p=.5*(d[0]+d[2]);if(Math.abs(d[0]-d[2])>1.5)return{error:"User is not aligned, iris diff: "+(d[0]-d[2]),ipd:0,faceWidth:0};const g=dh(r[34],e,n),m=ph(dh(r[264],e,n),g);let y=0;const v=m/Math.max(e,n);return v<.12?y=58*(.12-v):v>.2&&(y=58*(v-.2)),{ipd:11.7/p*s,faceWidth:11.7/p*m+y}}(null==uh?void 0:uh.detectForVideo(fh,t),null==fh?void 0:fh.videoWidth,null==fh?void 0:fh.videoHeight)}))},t.setVideoElement=function(t){return e(this,void 0,void 0,(function*(){fh=t}))}}));
|
|
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__TrueScale={})}(this,(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(s,i){function o(t){try{h(r.next(t))}catch(t){i(t)}}function a(t){try{h(r.throw(t))}catch(t){i(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var n=self;function r(){throw Error("Invalid UTF8")}function s(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}let i,o;const a="undefined"!=typeof TextDecoder;let h;const c="undefined"!=typeof TextEncoder;function u(t){if(c)t=(h||=new TextEncoder).encode(t);else{let n=0;const r=new Uint8Array(3*t.length);for(let s=0;s<t.length;s++){var e=t.charCodeAt(s);if(128>e)r[n++]=e;else{if(2048>e)r[n++]=e>>6|192;else{if(55296<=e&&57343>=e){if(56319>=e&&s<t.length){const i=t.charCodeAt(++s);if(56320<=i&&57343>=i){e=1024*(e-55296)+i-56320+65536,r[n++]=e>>18|240,r[n++]=e>>12&63|128,r[n++]=e>>6&63|128,r[n++]=63&e|128;continue}s--}e=65533}r[n++]=e>>12|224,r[n++]=e>>6&63|128}r[n++]=63&e|128}}t=n===r.length?r:r.subarray(0,n)}return t}var l,f;t:{for(var d=["CLOSURE_FLAGS"],p=n,g=0;g<d.length;g++)if(null==(p=p[d[g]])){f=null;break t}f=p}var m,y=f&&f[610401301];l=null!=y&&y;const v=n.navigator;function _(t){return!!l&&!!m&&m.brands.some((({brand:e})=>e&&-1!=e.indexOf(t)))}function w(t){var e;return(e=n.navigator)&&(e=e.userAgent)||(e=""),-1!=e.indexOf(t)}function A(){return!!l&&!!m&&0<m.brands.length}function b(){return A()?_("Chromium"):(w("Chrome")||w("CriOS"))&&!(!A()&&w("Edge"))||w("Silk")}m=v&&v.userAgentData||null;var E=!A()&&(w("Trident")||w("MSIE"));!w("Android")||b(),b(),w("Safari")&&(b()||!A()&&w("Coast")||!A()&&w("Opera")||!A()&&w("Edge")||(A()?_("Microsoft Edge"):w("Edg/"))||A()&&_("Opera"));var T={},k=null;function x(){if(!k){k={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=t.concat(e[n].split(""));T[n]=r;for(var s=0;s<r.length;s++){var i=r[s];void 0===k[i]&&(k[i]=s)}}}}var M="undefined"!=typeof Uint8Array,F=!E&&"function"==typeof btoa;function L(t){if(!F){var e;void 0===e&&(e=0),x(),e=T[e];var n=Array(Math.floor(t.length/3)),r=e[64]||"";let h=0,c=0;for(;h<t.length-2;h+=3){var s=t[h],i=t[h+1],o=t[h+2],a=e[s>>2];s=e[(3&s)<<4|i>>4],i=e[(15&i)<<2|o>>6],o=e[63&o],n[c++]=a+s+i+o}switch(a=0,o=r,t.length-h){case 2:o=e[(15&(a=t[h+1]))<<2]||r;case 1:t=t[h],n[c]=e[t>>2]+e[(3&t)<<4|a>>4]+o+r}return n.join("")}for(e="",n=0,r=t.length-10240;n<r;)e+=String.fromCharCode.apply(null,t.subarray(n,n+=10240));return e+=String.fromCharCode.apply(null,n?t.subarray(n):t),btoa(e)}const S=/[-_.]/g,O={"-":"+",_:"/",".":"="};function P(t){return O[t]||""}function C(t){if(!F)return function(t){var e=t.length,n=3*e/4;n%3?n=Math.floor(n):-1!="=.".indexOf(t[e-1])&&(n=-1!="=.".indexOf(t[e-2])?n-2:n-1);var r=new Uint8Array(n),s=0;return function(t,e){function n(e){for(;r<t.length;){var n=t.charAt(r++),s=k[n];if(null!=s)return s;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}x();for(var r=0;;){var s=n(-1),i=n(0),o=n(64),a=n(64);if(64===a&&-1===s)break;e(s<<2|i>>4),64!=o&&(e(i<<4&240|o>>2),64!=a&&e(o<<6&192|a))}}(t,(function(t){r[s++]=t})),s!==n?r.subarray(0,s):r}(t);S.test(t)&&(t=t.replace(S,P)),t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function R(t){return M&&null!=t&&t instanceof Uint8Array}let I;function D(){return I||=new Uint8Array(0)}var B={};let U;function N(t){if(t!==B)throw Error("illegal external caller")}function G(){return U||=new V(null,B)}function j(t){N(B);var e=t.N;return null==(e=null==e||R(e)?e:"string"==typeof e?C(e):null)?e:t.N=e}var V=class{constructor(t,e){if(N(e),this.N=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}ha(){const t=j(this);return t?new Uint8Array(t):D()}};function z(t,e){return Error(`Invalid wire type: ${t} (at position ${e})`)}function W(){return Error("Failed to read varint, encoding is invalid.")}function X(t,e){return Error(`Tried to read past the end of the data ${e} > ${t}`)}function H(t){return 0==t.length?G():new V(t,B)}function q(t){if("string"==typeof t)return{buffer:C(t),H:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),H:!1};if(t.constructor===Uint8Array)return{buffer:t,H:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),H:!1};if(t.constructor===V)return{buffer:j(t)||D(),H:!0};if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),H:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}const $="function"==typeof Uint8Array.prototype.slice;let K,Y=0,J=0;function Z(t){const e=0>t;let n=(t=Math.abs(t))>>>0;if(t=Math.floor((t-n)/4294967296),e){const[e,r]=rt(n,t);t=r,n=e}Y=n>>>0,J=t>>>0}function Q(t){const e=K||=new DataView(new ArrayBuffer(8));e.setFloat32(0,+t,!0),J=0,Y=e.getUint32(0,!0)}function tt(t,e){return 4294967296*e+(t>>>0)}function et(t,e){const n=2147483648&e;return n&&(e=~e>>>0,0==(t=1+~t>>>0)&&(e=e+1>>>0)),t=tt(t,e),n?-t:t}function nt(t){if(16>t.length)Z(Number(t));else if("function"==typeof BigInt)t=BigInt(t),Y=Number(t&BigInt(4294967295))>>>0,J=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);J=Y=0;const n=t.length;for(let r=e,s=(n-e)%6+e;s<=n;r=s,s+=6){const e=Number(t.slice(r,s));J*=1e6,Y=1e6*Y+e,4294967296<=Y&&(J+=Math.trunc(Y/4294967296),J>>>=0,Y>>>=0)}if(e){const[t,e]=rt(Y,J);Y=t,J=e}}}function rt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function st(t,e,{R:n=!1}={}){t.R=n,e&&(e=q(e),t.h=e.buffer,t.s=e.H,t.v=0,t.l=t.h.length,t.g=t.v)}function it(t,e){if(t.g=e,e>t.l)throw X(t.l,e)}function ot(t,e){let n,r=0,s=0,i=0;const o=t.h;let a=t.g;do{n=o[a++],r|=(127&n)<<i,i+=7}while(32>i&&128&n);for(32<i&&(s|=(127&n)>>4),i=3;32>i&&128&n;i+=7)n=o[a++],s|=(127&n)<<i;if(it(t,a),128>n)return e(r>>>0,s>>>0);throw W()}function at(t){let e=0,n=t.g;const r=n+10,s=t.h;for(;n<r;){const r=s[n++];if(e|=r,0==(128&r))return it(t,n),!!(127&e)}throw W()}function ht(t){var e=t.h;const n=t.g,r=e[n],s=e[n+1],i=e[n+2];return e=e[n+3],it(t,t.g+4),(r<<0|s<<8|i<<16|e<<24)>>>0}function ct(t,e){if(0>e)throw Error(`Tried to read a negative byte length: ${e}`);const n=t.g,r=n+e;if(r>t.l)throw X(e,t.l-n);return t.g=r,n}function ut(t,e){if(0==e)return G();var n=ct(t,e);return t.R&&t.s?n=t.h.subarray(n,n+e):(t=t.h,n=n===(e=n+e)?D():$?t.slice(n,e):new Uint8Array(t.subarray(n,e))),H(n)}var lt=class{constructor(t,e){this.h=null,this.s=!1,this.g=this.l=this.v=0,st(this,t,e)}m(){const t=this.h;let e=this.g,n=t[e++],r=127&n;if(128&n&&(n=t[e++],r|=(127&n)<<7,128&n&&(n=t[e++],r|=(127&n)<<14,128&n&&(n=t[e++],r|=(127&n)<<21,128&n&&(n=t[e++],r|=n<<28,128&n&&128&t[e++]&&128&t[e++]&&128&t[e++]&&128&t[e++]&&128&t[e++])))))throw W();return it(this,e),r}j(){return this.m()>>>0}A(){var t=ht(this);const e=2*(t>>31)+1,n=t>>>23&255;return t&=8388607,255==n?t?NaN:1/0*e:0==n?e*Math.pow(2,-149)*t:e*Math.pow(2,n-150)*(t+Math.pow(2,23))}C(){return this.m()}},ft=[];function dt(t){var e=t.g;if(e.g==e.l)return!1;t.l=t.g.g;var n=t.g.j();if(e=n>>>3,!(0<=(n&=7)&&5>=n))throw z(n,t.l);if(1>e)throw Error(`Invalid field number: ${e} (at position ${t.l})`);return t.m=e,t.h=n,!0}function pt(t){switch(t.h){case 0:0!=t.h?pt(t):at(t.g);break;case 1:it(t=t.g,t.g+8);break;case 2:if(2!=t.h)pt(t);else{var e=t.g.j();it(t=t.g,t.g+e)}break;case 5:it(t=t.g,t.g+4);break;case 3:for(e=t.m;;){if(!dt(t))throw Error("Unmatched start-group tag: stream EOF");if(4==t.h){if(t.m!=e)throw Error("Unmatched end-group tag");break}pt(t)}break;default:throw z(t.h,t.l)}}function gt(t,e,n){const r=t.g.l,s=t.g.j(),i=t.g.g+s;let o=i-r;if(0>=o&&(t.g.l=i,n(e,t,void 0,void 0,void 0),o=i-t.g.g),o)throw Error(`Message parsing ended unexpectedly. Expected to read ${s} bytes, instead read ${s-o} bytes, either the data ended unexpectedly or the message misreported its own length`);return t.g.g=i,t.g.l=r,e}function mt(t){var e=t.g.j(),n=ct(t=t.g,e);if(t=t.h,a){var h,c=t;(h=o)||(h=o=new TextDecoder("utf-8",{fatal:!0})),t=n+e,c=0===n&&t===c.length?c:c.subarray(n,t);try{var u=h.decode(c)}catch(t){if(void 0===i){try{h.decode(new Uint8Array([128]))}catch(t){}try{h.decode(new Uint8Array([97])),i=!0}catch(t){i=!1}}throw!i&&(o=void 0),t}}else{e=(u=n)+e,n=[];let i,o=null;for(;u<e;){var l=t[u++];128>l?n.push(l):224>l?u>=e?r():(i=t[u++],194>l||128!=(192&i)?(u--,r()):n.push((31&l)<<6|63&i)):240>l?u>=e-1?r():(i=t[u++],128!=(192&i)||224===l&&160>i||237===l&&160<=i||128!=(192&(c=t[u++]))?(u--,r()):n.push((15&l)<<12|(63&i)<<6|63&c)):244>=l?u>=e-2?r():(i=t[u++],128!=(192&i)||0!=i-144+(l<<28)>>30||128!=(192&(c=t[u++]))||128!=(192&(h=t[u++]))?(u--,r()):(l=(7&l)<<18|(63&i)<<12|(63&c)<<6|63&h,l-=65536,n.push(55296+(l>>10&1023),56320+(1023&l)))):r(),8192<=n.length&&(o=s(o,n),n.length=0)}u=s(o,n)}return u}function yt(t){const e=t.g.j();return ut(t.g,e)}function vt(t,e,n){var r=t.g.j();for(r=t.g.g+r;t.g.g<r;)n.push(e.call(t.g))}var _t=[];function wt(t){return t?/^\d+$/.test(t)?(nt(t),new At(Y,J)):null:bt||=new At(0,0)}var At=class{constructor(t,e){this.h=t>>>0,this.g=e>>>0}};let bt;function Et(t){return t?/^-?\d+$/.test(t)?(nt(t),new Tt(Y,J)):null:kt||=new Tt(0,0)}var Tt=class{constructor(t,e){this.h=t>>>0,this.g=e>>>0}};let kt;function xt(t,e,n){for(;0<n||127<e;)t.g.push(127&e|128),e=(e>>>7|n<<25)>>>0,n>>>=7;t.g.push(e)}function Mt(t,e){for(;127<e;)t.g.push(127&e|128),e>>>=7;t.g.push(e)}function Ft(t,e){if(0<=e)Mt(t,e);else{for(let n=0;9>n;n++)t.g.push(127&e|128),e>>=7;t.g.push(1)}}function Lt(t,e){t.g.push(e>>>0&255),t.g.push(e>>>8&255),t.g.push(e>>>16&255),t.g.push(e>>>24&255)}function St(t,e){0!==e.length&&(t.l.push(e),t.h+=e.length)}function Ot(t,e,n){Mt(t.g,8*e+n)}function Pt(t,e){return Ot(t,e,2),e=t.g.end(),St(t,e),e.push(t.h),e}function Ct(t,e){var n=e.pop();for(n=t.h+t.g.length()-n;127<n;)e.push(127&n|128),n>>>=7,t.h++;e.push(n),t.h++}function Rt(t,e,n){Ot(t,e,2),Mt(t.g,n.length),St(t,t.g.end()),St(t,n)}function It(t,e,n,r){null!=n&&(e=Pt(t,e),r(n,t),Ct(t,e))}class Dt{constructor(t,e,n){this.g=t,this.h=e,this.l=n}}function Bt(t){return Array.prototype.slice.call(t)}const Ut="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;var Nt=Ut?(t,e)=>{t[Ut]|=e}:(t,e)=>{void 0!==t.D?t.D|=e:Object.defineProperties(t,{D:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function Gt(t){const e=Vt(t);1!=(1&e)&&(Object.isFrozen(t)&&(t=Bt(t)),Wt(t,1|e))}var jt=Ut?(t,e)=>{t[Ut]&=~e}:(t,e)=>{void 0!==t.D&&(t.D&=~e)},Vt=Ut?t=>0|t[Ut]:t=>0|t.D,zt=Ut?t=>t[Ut]:t=>t.D,Wt=Ut?(t,e)=>{t[Ut]=e}:(t,e)=>{void 0!==t.D?t.D=e:Object.defineProperties(t,{D:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function Xt(){var t=[];return Nt(t,1),t}function Ht(t){return Nt(t,34),t}function qt(t,e){Wt(e,-255&(0|t))}function $t(t,e){Wt(e,-221&(34|t))}function Kt(t){return 0==(t=t>>11&1023)?536870912:t}var Yt,Jt={};function Zt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function Qt(t,e,n){if(null!=t)if("string"==typeof t)t=t?new V(t,B):G();else if(t.constructor!==V)if(R(t))t=n?H(t):t.length?new V(new Uint8Array(t),B):G();else{if(!e)throw Error();t=void 0}return t}const te=[];function ee(t){if(2&t)throw Error()}Wt(te,55),Yt=Object.freeze(te);class ne{constructor(t,e,n){this.l=0,this.g=t,this.h=e,this.m=n}next(){if(this.l<this.g.length){const t=this.g[this.l++];return{done:!1,value:this.h?this.h.call(this.m,t):t}}return{done:!0,value:void 0}}[Symbol.iterator](){return new ne(this.g,this.h,this.m)}}var re={};let se,ie;function oe(t,e){(e=se?e[se]:void 0)&&(t[se]=Bt(e))}function ae(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}function he(t){return null==t?t:"number"==typeof t||"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}function ce(t){return null==t?t:"boolean"==typeof t||"number"==typeof t?!!t:void 0}function ue(t){return"number"==typeof t&&Number.isFinite(t)||!!t&&"string"==typeof t&&isFinite(t)}function le(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t?t:void 0}function fe(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t?t:void 0}function de(t){if("string"!=typeof t)throw Error();return t}function pe(t){if(null!=t&&"string"!=typeof t)throw Error();return t}function ge(t){return null==t||"string"==typeof t?t:void 0}function me(t,e,n,r){var s=!1;return null==t||"object"!=typeof t||(s=Array.isArray(t))||t.M!==Jt?s?(0===(s=n=Vt(t))&&(s|=32&r),(s|=2&r)!==n&&Wt(t,s),new e(t)):(n?2&r?(t=e[ye])?e=t:(Ht((t=new e).u),e=e[ye]=t):e=new e:e=void 0,e):t}const ye="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():"di";function ve(t){return t}function _e(t,e,n){return"string"==typeof(t="number"==(e=typeof t)||"string"===e?t:n?0:void 0)&&(n=+t,Number.isSafeInteger(n))?n:t}let we,Ae,be;function Ee(t){switch(typeof t){case"boolean":return Ae||=[0,void 0,!0];case"number":return 0<t?void 0:0===t?be||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}function Te(t,e){return ke(t,e[0],e[1])}function ke(t,e,n){if(null==t&&(t=we),we=void 0,null==t){var r=96;n?(t=[n],r|=512):t=[],e&&(r=-2095105&r|(1023&e)<<11)}else{if(!Array.isArray(t))throw Error();if(64&(r=Vt(t)))return ie&&delete t[ie],t;if(r|=64,n&&(r|=512,n!==t[0]))throw Error();t:{var s=(n=t).length;if(s){const t=s-1;var i=n[t];if(Zt(i)){1024<=(s=t-(e=+!!(512&(r|=256))-1))&&(xe(n,e,i),s=1023),r=-2095105&r|(1023&s)<<11;break t}}e&&(i=+!!(512&r)-1,1024<(e=Math.max(e,s-i))&&(xe(n,i,{}),r|=256,e=1023),r=-2095105&r|(1023&e)<<11)}}return Wt(t,r),t}function xe(t,e,n){const r=1023+e,s=t.length;for(let i=r;i<s;i++){const r=t[i];null!=r&&r!==n&&(n[i-e]=r)}t.length=r+1,t[r]=n}function Me(t){if(2&t.g)throw Error("Cannot mutate an immutable Map")}var Fe=class extends Map{constructor(t,e,n=ve,r=ve){super();let s=Vt(t);s|=64,Wt(t,s),this.g=s,this.l=e,this.h=n||ve,this.j=this.l?Le:r||ve;for(let i=0;i<t.length;i++){const o=t[i],a=n(o[0],!1,!0);let h=o[1];e?void 0===h&&(h=null):h=r(o[1],!1,!0,void 0,void 0,s),super.set(a,h)}}s(t=Se){return this.m(t)}m(t=Se){const e=[],n=super.entries();for(var r;!(r=n.next()).done;)(r=r.value)[0]=t(r[0]),r[1]=t(r[1]),e.push(r);return e}clear(){Me(this),super.clear()}delete(t){return Me(this),super.delete(this.h(t,!0,!1))}entries(){var t=this.A();return new ne(t,Oe,this)}keys(){return this.C()}values(){var t=this.A();return new ne(t,Fe.prototype.get,this)}forEach(t,e){super.forEach(((n,r)=>{t.call(e,this.get(r),r,this)}))}set(t,e){return Me(this),null==(t=this.h(t,!0,!1))?this:null==e?(super.delete(t),this):super.set(t,this.j(e,!0,!0,this.l,!1,this.g))}I(t){const e=this.h(t[0],!1,!0);t=t[1],t=this.l?void 0===t?null:t:this.j(t,!1,!0,void 0,!1,this.g),super.set(e,t)}has(t){return super.has(this.h(t,!1,!1))}get(t){t=this.h(t,!1,!1);const e=super.get(t);if(void 0!==e){var n=this.l;return n?((n=this.j(e,!1,!0,n,this.v,this.g))!==e&&super.set(t,n),n):e}}A(){return Array.from(super.keys())}C(){return super.keys()}[Symbol.iterator](){return this.entries()}};function Le(t,e,n,r,s,i){return t=me(t,r,n,i),s&&(t=Ne(t)),t}function Se(t){return t}function Oe(t){return[t,this.get(t)]}function Pe(t,e,n,r,s,i){if(null!=t){if(Array.isArray(t))t=s&&0==t.length&&1&Vt(t)?void 0:i&&2&Vt(t)?t:Ce(t,e,n,void 0!==r,s,i);else if(Zt(t)){const o={};for(let a in t)o[a]=Pe(t[a],e,n,r,s,i);t=o}else t=e(t,r);return t}}function Ce(t,e,n,r,s,i){const o=r||n?Vt(t):0;r=r?!!(32&o):void 0;const a=Bt(t);for(let t=0;t<a.length;t++)a[t]=Pe(a[t],e,n,r,s,i);return n&&(oe(a,t),n(o,a)),a}function Re(t){return Pe(t,Ie,void 0,void 0,!1,!1)}function Ie(t){return t.M===Jt?t.toJSON():t instanceof Fe?t.s(Re):function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"boolean":return t?1:0;case"object":if(t&&!Array.isArray(t)){if(R(t))return L(t);if(t instanceof V){const e=t.N;return null==e?"":"string"==typeof e?e:t.N=L(e)}if(t instanceof Fe)return t.s()}}return t}(t)}function De(t,e,n=$t){if(null!=t){if(M&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var r=Vt(t);return 2&r?t:(e&&=0===r||!!(32&r)&&!(64&r||!(16&r)),e?(Wt(t,34|r),4&r&&Object.freeze(t),t):Ce(t,De,4&r?$t:n,!0,!1,!0))}return t.M===Jt?(n=t.u,t=2&(r=zt(n))?t:Be(t,n,r,!0)):t instanceof Fe&&(n=Ht(t.m(De)),t=new Fe(n,t.l,t.h,t.j)),t}}function Be(t,e,n,r){return t=t.constructor,we=e=Ue(e,n,r),e=new t(e),we=void 0,e}function Ue(t,e,n){const r=n||2&e?$t:qt,s=!!(32&e);return t=function(t,e,n){const r=Bt(t);var s=r.length;const i=256&e?r[s-1]:void 0;for(s+=i?-1:0,e=512&e?1:0;e<s;e++)r[e]=n(r[e]);if(i){e=r[e]={};for(const t in i)e[t]=n(i[t])}return oe(r,t),r}(t,e,(t=>De(t,s,r))),Nt(t,32|(n?2:0)),t}function Ne(t){const e=t.u,n=zt(e);return 2&n?Be(t,e,n,!1):t}function Ge(t,e){return je(t=t.u,zt(t),e)}function je(t,e,n,r){if(-1===n)return null;if(n>=Kt(e)){if(256&e)return t[t.length-1][n]}else{var s=t.length;if(r&&256&e&&null!=(r=t[s-1][n]))return r;if((e=n+(+!!(512&e)-1))<s)return t[e]}}function Ve(t,e,n,r){const s=t.u,i=zt(s);return ee(i),ze(s,i,e,n,r),t}function ze(t,e,n,r,s){var i=Kt(e);if(n>=i||s){if(s=e,256&e)i=t[t.length-1];else{if(null==r)return;i=t[i+(+!!(512&e)-1)]={},s|=256}i[n]=r,s!==e&&Wt(t,s)}else t[n+(+!!(512&e)-1)]=r,256&e&&n in(t=t[t.length-1])&&delete t[n]}function We(t,e,n,r,s){var i=2&e;let o=je(t,e,n,s);Array.isArray(o)||(o=Yt);const a=!(2&r),h=!(1&r);r=!!(32&e);let c=Vt(o);return 0!==c||!r||i||a?1&c||(c|=1,Wt(o,c)):(c|=33,Wt(o,c)),i?(2&c||Ht(o),h&&Object.freeze(o)):(i=2&c,h&&i?(o=Bt(o),i=1,r&&!a&&(i|=32),Wt(o,i),ze(t,e,n,o,s)):a&&32&c&&!i&&jt(o,32)),o}function Xe(t,e){t=t.u;const n=zt(t),r=je(t,n,e),s=he(r);return null!=s&&s!==r&&ze(t,n,e,s),s}function He(t){t=t.u;const e=zt(t),n=je(t,e,1),r=Qt(n,!0,!!(34&e));return null!=r&&r!==n&&ze(t,e,1,r),r}function qe(t,e,n){t=t.u;const r=zt(t),s=2&r;let i=We(t,r,e,1),o=Vt(i);if(!(4&o)){Object.isFrozen(i)&&(i=Bt(i),Wt(i,o=-3&o|32),ze(t,r,e,i));let a=0,h=0;for(;a<i.length;a++){const t=n(i[a]);null!=t&&(i[h++]=t)}h<a&&(i.length=h),o|=21,s?o|=34:o&=-33,Wt(i,o),2&o&&Object.freeze(i)}return!s&&(2&o||Object.isFrozen(i))&&(i=Bt(i),Wt(i,-35&o),ze(t,r,e,i)),i}let $e;function Ke(){return $e??=new Fe(Ht([]),void 0,void 0,void 0,re)}function Ye(t){t=Bt(t);for(let e=0;e<t.length;e++){const n=t[e]=Bt(t[e]);Array.isArray(n[1])&&(n[1]=Ht(n[1]))}return t}function Je(t,e,n){{t=t.u;const r=zt(t);if(ee(r),null==n)ze(t,r,e);else{if(!(4&Vt(n))){Object.isFrozen(n)&&(n=Bt(n));for(let t=0;t<n.length;t++)n[t]=de(n[t]);Wt(n,5)}ze(t,r,e,n)}}}function Ze(t,e){return Qe(t=t.u,zt(t),zs)===e?e:-1}function Qe(t,e,n){let r=0;for(let s=0;s<n.length;s++){const i=n[s];null!=je(t,e,i)&&(0!==r&&ze(t,e,r),r=i)}return r}function tn(t,e,n,r){const s=zt(t);ee(s);const i=je(t,s,n,r);let o;if(null!=i&&i.M===Jt)return(e=Ne(i))!==i&&ze(t,s,n,e,r),e.u;if(Array.isArray(i)){const t=Vt(i);o=2&t?Ue(i,t,!1):i,o=Te(o,e)}else o=Te(void 0,e);return o!==i&&ze(t,s,n,o,r),o}function en(t,e,n,r){t=t.u;const s=zt(t),i=je(t,s,n,r);return(e=me(i,e,!1,s))!==i&&null!=e&&ze(t,s,n,e,r),e}function nn(t,e,n,r=!1){if(null==(e=en(t,e,n,r)))return e;t=t.u;const s=zt(t);if(!(2&s)){const i=Ne(e);i!==e&&ze(t,s,n,e=i,r)}return e}function rn(t,e,n,r,s){var i=!!(2&e),o=We(t,e,r,1),a=o===Yt;if(a&&2!==s)return o;if(a||!(4&Vt(o))){var h=o;o=!!(2&e),a=!!(2&Vt(h)),i=h,!o&&a&&(h=Bt(h));var c=e|((a=a||void 0)?2:0),u=a;a=!1;let l=0,f=0;for(;l<h.length;l++){const t=me(h[l],n,!1,c);if(null==t)continue;const e=!!(2&Vt(t.u));u=u||e,a=a||!e,h[f++]=t}return f<l&&(h.length=f),c=5|(h=Vt(n=h)),u=u?-9&c:8|c,h!=(u=a?-17&u:16|u)&&(Object.isFrozen(n)&&(n=Bt(n)),Wt(n,u)),i!==(h=n)&&ze(t,e,r,h),(o&&2!==s||1===s)&&Object.freeze(h),h}return 3===s||(i?2===s&&(s=Vt(o),o=Bt(o),Wt(o,s),ze(t,e,r,o)):(i=Object.isFrozen(o),1===s?i||Object.freeze(o):(n=-33&(s=Vt(o)),i||2&s?(o=Bt(o),Wt(o,-3&n),ze(t,e,r,o)):s!==n&&Wt(o,n)))),o}function sn(t,e,n){var r=t.u;const s=zt(r);if(e=rn(r,s,e,n,(t=!!(2&s))?1:2),!(t||8&Vt(e))){for(n=0;n<e.length;n++)(t=e[n])!==(r=Ne(t))&&(e[n]=r);Nt(e,8)}return e}function on(t,e,n,r,s){return null==r&&(r=void 0),Ve(t,n,r,s)}function an(t,e,n,r){null==r&&(r=void 0),t=t.u;const s=zt(t);ee(s),(n=Qe(t,s,n))&&n!==e&&null!=r&&ze(t,s,n),ze(t,s,e,r)}function hn(t,e,n){t=t.u;const r=zt(t);ee(r),t=rn(t,r,e,1,2),e=null!=n?n:new e,t.push(e),2&Vt(e.u)?jt(t,8):jt(t,16)}function cn(t,e){return le(Ge(t,e))}function un(t){return null==(t=Ge(t,2))||ue(t)?t:void 0}function ln(t,e){return ge(Ge(t,e))}function fn(t){return t??0}function dn(t,e){return fn(Xe(t,e))}function pn(t,e,n){if(null!=n){if("boolean"!=typeof n)throw t=typeof n,Error(`Expected boolean but got ${"object"!=t?t:n?Array.isArray(n)?"array":t:"null"}: ${n}`);n=!!n}Ve(t,e,n)}function gn(t,e,r){if(null!=r){if("number"!=typeof r)throw ae(t=Error(),"warning"),t;if(!Number.isFinite(r)){const t=Error();ae(t,"incident"),function(t){n.setTimeout((()=>{throw t}),0)}(t)}}Ve(t,e,r)}function mn(t,e,n){if(null!=n&&"number"!=typeof n)throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);Ve(t,e,n)}function yn(t,e,n){n=de(n),t=t.u;const r=zt(t);ee(r),We(t,r,e,2).push(n)}function vn(t,e,n){e.g?e.m(t,e.g,e.h,n,!0):e.m(t,e.h,n,!0)}Fe.prototype.toJSON=void 0;var _n=class{constructor(t,e){this.u=ke(t,e)}toJSON(){return wn(this,Ce(this.u,Ie,void 0,void 0,!1,!1),!0)}l(){var t=Ni;return t.g?t.l(this,t.g,t.h,!0):t.l(this,t.h,t.defaultValue,!0)}clone(){const t=this.u;return Be(this,t,zt(t),!1)}H(){return!!(2&Vt(this.u))}};function wn(t,e,n){var r=t.constructor.B,s=Kt(zt(n?t.u:e)),i=!1;if(r){if(!n){var o;if((e=Bt(e)).length&&Zt(o=e[e.length-1]))for(i=0;i<r.length;i++)if(r[i]>=s){Object.assign(e[e.length-1]={},o);break}i=!0}var a;s=e,n=!n,t=Kt(o=zt(t.u)),o=+!!(512&o)-1;for(let e=0;e<r.length;e++){var h=r[e];if(h<t){var c=s[h+=o];null==c?s[h]=n?Yt:Xt():n&&c!==Yt&&Gt(c)}else{if(!a){var u=void 0;s.length&&Zt(u=s[s.length-1])?a=u:s.push(a={})}c=a[h],null==a[h]?a[h]=n?Yt:Xt():n&&c!==Yt&&Gt(c)}}}if(!(r=e.length))return e;let l,f;if(Zt(a=e[r-1])){t:{var d=a;u={},s=!1;for(let t in d)n=d[t],Array.isArray(n)&&n!=n&&(s=!0),null!=n?u[t]=n:s=!0;if(s){for(let t in u){d=u;break t}d=null}}d!=a&&(l=!0),r--}for(;0<r&&null==(a=e[r-1]);r--)f=!0;return l||f?(e=i?e:Array.prototype.slice.call(e,0,r),i&&(e.length=r),d&&e.push(d),e):e}function An(t){return{ca:mr,U:t}}function bn(t,e){if(Array.isArray(e)){var n=Vt(e);if(4&n)return e;for(var r=0,s=0;r<e.length;r++){const n=t(e[r]);null!=n&&(e[s++]=n)}return s<r&&(e.length=s),Wt(e,5|n),2&n&&Object.freeze(e),e}}_n.prototype.M=Jt,_n.prototype.toString=function(){return wn(this,this.u,!1).toString()};const En=Symbol();function Tn(t){let e=t[En];if(!e){const n=Sn(t),r=jn(t),s=r.h;e=s?(t,e)=>s(t,e,r):(t,e)=>{for(;dt(e)&&4!=e.h;){var s=e.m,i=r[s];if(!i){var o=r.g;o&&(o=o[s])&&(i=r[s]=kn(o))}i&&i(e,t,s)||(s=(i=e).l,pt(i),i.aa?i=void 0:(o=i.g.g-s,i.g.g=s,i=ut(i.g,o)),s=t,i&&(se||=Symbol(),(o=s[se])?o.push(i):s[se]=[i]))}for(const e in n){t[ie||=Symbol()]=n;break}},t[En]=e}return e}function kn(t){const e=function(t){if(t=t.U)return Tn(t)}(t),n=t.ca.g;if(e){const r=jn(t.U).L;return(t,s,i)=>n(t,s,i,r,e)}return(t,e,r)=>n(t,e,r)}const xn=Symbol();function Mn(t,e,n,r){let s;if(r){const e=r[xn];s=e?e.L:Ee(r[0]),n[t]=e??r}s&&s===Ae?((e=n.xa)||(n.xa=e=[]),e.push(t)):e.l&&((e=n.Ba)||(n.Ba=e=[]),e.push(t))}function Fn(t,e,n,r){Mn(t,e,r)}function Ln(t,e,n,r,s){Mn(t,e,s,n)}function Sn(t){let e=t[xn];return e||(e=t[xn]={},On(t,e,Fn,Ln,e))}function On(t,e,n,r,s){e.L=Ee(t[0]);let i=1;if(t.length>i&&!(t[i]instanceof Dt)){var o=t[i++];if(Array.isArray(o))return e.h=o[0],e.g=o[1],e;e.g=o}for(o=0;i<t.length;){var a=t[i++],h=t[i];for("number"==typeof h?(i++,o+=h):o++,h=i;h<t.length&&!(t[h]instanceof Dt);)h++;if(h-=i){var c=t,u=i,l=c[u];if("function"==typeof l&&(l=l(),c[u]=l),(c=Array.isArray(l))&&!(c=Un in l||Rn in l)&&(c=0<l.length)){const t=Ee(u=(c=l)[0]);null!=t&&t!==u&&(c[0]=t),c=null!=t}(l=c?l:void 0)?(i++,1===h?void 0!==(a=r(o,a,l,void 0,s))&&(e[o]=a):void 0!==(a=r(o,a,l,t[i++],s))&&(e[o]=a)):void 0!==(a=n(o,a,t[i++],s))&&(e[o]=a)}else void 0!==(a=n(o,a,void 0,s))&&(e[o]=a)}return e}const Pn=Symbol();function Cn(t){let e=t[Pn];if(!e){const n=Bn(t);e=(t,e)=>zn(t,e,n),t[Pn]=e}return e}const Rn=Symbol();function In(t,e){return e.h}function Dn(t,e,n){let r,s;const i=e.h;return(t,e,o)=>i(t,e,o,s||=Bn(n).L,r||=Cn(n))}function Bn(t){let e=t[Rn];return e||(e=On(t,t[Rn]={},In,Dn),Un in t&&Rn in t&&(t.length=0),e)}const Un=Symbol();function Nn(t,e,n){const r=e.g;return n?(t,e,s)=>r(t,e,s,n):r}function Gn(t,e,n,r){const s=e.g;let i,o;return(t,e,a)=>s(t,e,a,o||=jn(n).L,i||=Tn(n),r)}function jn(t){let e=t[Un];return e||(Sn(t),e=On(t,t[Un]={},Nn,Gn),Un in t&&Rn in t&&(t.length=0),e)}function Vn(t,e){var n=t[e];if(n)return n;if((n=t.g)&&(n=n[e])){var r=n.U,s=n.ca.h;if(r){const t=Cn(r),e=Bn(r).L;n=(n,r,i)=>s(n,r,i,e,t)}else n=s;return t[e]=n}}function zn(t,e,n){for(var r=zt(t),s=+!!(512&r)-1,i=t.length,o=512&r?1:0,a=i+(256&r?-1:0);o<a;o++){const r=t[o];if(null==r)continue;const i=o-s,a=Vn(n,i);a&&a(e,r,i)}if(256&r){r=t[i-1];for(let t in r)s=+t,Number.isNaN(s)||null!=(i=r[t])&&(a=Vn(n,s))&&a(e,i,s)}if(t=se?t[se]:void 0)for(St(e,e.g.end()),n=0;n<t.length;n++)St(e,j(t[n])||D())}function Wn(t,e){return new Dt(t,e,!1)}function Xn(t,e){return new Dt(t,e,!0)}function Hn(t,e,n){ze(t,zt(t),e,n)}var qn=Wn((function(t,e,n,r,s){return 2===t.h&&(t=gt(t,Te([void 0,void 0],r),s),ee(r=zt(e)),(s=je(e,r,n))instanceof Fe?0!=(2&s.g)?((s=s.m()).push(t),ze(e,r,n,s)):s.I(t):Array.isArray(s)?(2&Vt(s)&&ze(e,r,n,s=Ye(s)),s.push(t)):ze(e,r,n,[t]),!0)}),(function(t,e,n,r,s){if(e instanceof Fe)e.forEach(((e,i)=>{It(t,n,Te([i,e],r),s)}));else if(Array.isArray(e))for(let i=0;i<e.length;i++){const o=e[i];Array.isArray(o)&&It(t,n,Te(o,r),s)}}));function $n(t,e,n){t:if(null!=e){if(ue(e)){if("string"==typeof e)break t;if("number"==typeof e)break t}e=void 0}null!=e&&("string"==typeof e&&Et(e),null!=e&&(Ot(t,n,0),"number"==typeof e?(t=t.g,Z(e),xt(t,Y,J)):(n=Et(e),xt(t.g,n.h,n.g))))}function Kn(t,e,n){null!=(e=le(e))&&null!=e&&(Ot(t,n,0),Ft(t.g,e))}function Yn(t,e,n){null!=(e=ce(e))&&(Ot(t,n,0),t.g.g.push(e?1:0))}function Jn(t,e,n){null!=(e=ge(e))&&Rt(t,n,u(e))}function Zn(t,e,n,r,s){It(t,n,e instanceof _n?e.u:Array.isArray(e)?Te(e,r):void 0,s)}function Qn(t,e,n){null!=(e=null==e||"string"==typeof e||R(e)||e instanceof V?e:void 0)&&Rt(t,n,q(e).buffer)}function tr(t,e,n){return(5===t.h||2===t.h)&&(e=We(e,zt(e),n,2,!1),2==t.h?vt(t,lt.prototype.A,e):e.push(t.g.A()),!0)}var er=Wn((function(t,e,n){if(1!==t.h)return!1;var r=t.g;t=ht(r);const s=ht(r);r=2*(s>>31)+1;const i=s>>>20&2047;return t=4294967296*(1048575&s)+t,Hn(e,n,2047==i?t?NaN:1/0*r:0==i?r*Math.pow(2,-1074)*t:r*Math.pow(2,i-1075)*(t+4503599627370496)),!0}),(function(t,e,n){null!=(e=he(e))&&(Ot(t,n,1),t=t.g,(n=K||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),Y=n.getUint32(0,!0),J=n.getUint32(4,!0),Lt(t,Y),Lt(t,J))})),nr=Wn((function(t,e,n){return 5===t.h&&(Hn(e,n,t.g.A()),!0)}),(function(t,e,n){null!=(e=he(e))&&(Ot(t,n,5),t=t.g,Q(e),Lt(t,Y))})),rr=Xn(tr,(function(t,e,n){if(null!=(e=bn(he,e)))for(let i=0;i<e.length;i++){var r=t,s=e[i];null!=s&&(Ot(r,n,5),r=r.g,Q(s),Lt(r,Y))}})),sr=Xn(tr,(function(t,e,n){if(null!=(e=bn(he,e))&&e.length){Ot(t,n,2),Mt(t.g,4*e.length);for(let r=0;r<e.length;r++)n=t.g,Q(e[r]),Lt(n,Y)}})),ir=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,ot(t.g,et)),!0)}),$n),or=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,0===(t=ot(t.g,et))?void 0:t),!0)}),$n),ar=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,ot(t.g,tt)),!0)}),(function(t,e,n){t:if(null!=e){if(ue(e)){if("string"==typeof e)break t;if("number"==typeof e)break t}e=void 0}null!=e&&("string"==typeof e&&wt(e),null!=e&&(Ot(t,n,0),"number"==typeof e?(t=t.g,Z(e),xt(t,Y,J)):(n=wt(e),xt(t.g,n.h,n.g))))})),hr=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,t.g.m()),!0)}),Kn),cr=Xn((function(t,e,n){return(0===t.h||2===t.h)&&(e=We(e,zt(e),n,2,!1),2==t.h?vt(t,lt.prototype.m,e):e.push(t.g.m()),!0)}),(function(t,e,n){if(null!=(e=bn(le,e))&&e.length){n=Pt(t,n);for(let n=0;n<e.length;n++)Ft(t.g,e[n]);Ct(t,n)}})),ur=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,0===(t=t.g.m())?void 0:t),!0)}),Kn),lr=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,at(t.g)),!0)}),Yn),fr=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,!1===(t=at(t.g))?void 0:t),!0)}),Yn),dr=Xn((function(t,e,n){if(2!==t.h)return!1;t=mt(t);const r=zt(e);return ee(r),We(e,r,n,2).push(t),!0}),(function(t,e,n){if(null!=(e=bn(ge,e)))for(let s=0;s<e.length;s++){var r=e[s];null!=r&&Rt(t,n,u(r))}})),pr=Wn((function(t,e,n){return 2===t.h&&(Hn(e,n,""===(t=mt(t))?void 0:t),!0)}),Jn),gr=Wn((function(t,e,n){return 2===t.h&&(Hn(e,n,mt(t)),!0)}),Jn),mr=Wn((function(t,e,n,r,s){return 2===t.h&&(gt(t,tn(e,r,n,!0),s),!0)}),Zn),yr=Wn((function(t,e,n,r,s){return 2===t.h&&(gt(t,tn(e,r,n),s),!0)}),Zn),vr=Xn((function(t,e,n,r,s){if(2!==t.h)return!1;r=Te(void 0,r);const i=zt(e);ee(i);let o=We(e,i,n,3);return(Object.isFrozen(o)||4&Vt(o))&&(o=Bt(o),ze(e,i,n,o)),o.push(r),gt(t,r,s),!0}),(function(t,e,n,r,s){if(Array.isArray(e))for(let i=0;i<e.length;i++)Zn(t,e[i],n,r,s)})),_r=Wn((function(t,e,n,r,s,i){if(2!==t.h)return!1;const o=zt(e);return ee(o),(i=Qe(e,o,i))&&n!==i&&ze(e,o,i),gt(t,e=tn(e,r,n),s),!0}),Zn),wr=Wn((function(t,e,n){return 2===t.h&&(Hn(e,n,yt(t)),!0)}),Qn),Ar=Xn((function(t,e,n){return(0===t.h||2===t.h)&&(e=We(e,zt(e),n,2,!1),2==t.h?vt(t,lt.prototype.j,e):e.push(t.g.j()),!0)}),(function(t,e,n){if(null!=(e=bn(fe,e)))for(let i=0;i<e.length;i++){var r=t,s=e[i];null!=s&&(Ot(r,n,0),Mt(r.g,s))}})),br=Wn((function(t,e,n){return 0===t.h&&(Hn(e,n,t.g.m()),!0)}),(function(t,e,n){null!=(e=le(e))&&(e=parseInt(e,10),Ot(t,n,0),Ft(t.g,e))})),Er=Xn((function(t,e,n){return(0===t.h||2===t.h)&&(e=We(e,zt(e),n,2,!1),2==t.h?vt(t,lt.prototype.C,e):e.push(t.g.m()),!0)}),(function(t,e,n){if(null!=(e=bn(le,e))&&e.length){n=Pt(t,n);for(let n=0;n<e.length;n++)Ft(t.g,e[n]);Ct(t,n)}}));class Tr{constructor(t,e){this.h=t,this.g=e,this.l=nn,this.m=on,this.defaultValue=void 0}}function kr(t,e){return new Tr(t,e)}function xr(t,e){return(n,r)=>{t:{if(_t.length){const t=_t.pop();t.o(r),st(t.g,n,r),n=t}else n=new class{constructor(t,e){if(ft.length){const n=ft.pop();st(n,t,e),t=n}else t=new lt(t,e);this.g=t,this.l=this.g.g,this.h=this.m=-1,this.o(e)}o({aa:t=!1}={}){this.aa=t}}(n,r);try{var s=new t;const r=s.u;Tn(e)(r,n),ie&&delete r[ie];var i=s;break t}finally{(s=n.g).h=null,s.s=!1,s.v=0,s.l=0,s.g=0,s.R=!1,n.m=-1,n.h=-1,100>_t.length&&_t.push(n)}i=void 0}return i}}function Mr(t){return function(){const e=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const t=this.g;return this.g=[],t}}}};zn(this.u,e,Bn(t)),St(e,e.g.end());const n=new Uint8Array(e.h),r=e.l,s=r.length;let i=0;for(let t=0;t<s;t++){const e=r[t];n.set(e,i),i+=e.length}return e.l=[n],n}}var Fr=[0,pr,Wn((function(t,e,n){return 2===t.h&&(Hn(e,n,(t=yt(t))===G()?void 0:t),!0)}),(function(t,e,n){if(null!=e){if(e instanceof _n){const r=e.Ea;return void(r&&(e=r(e),null!=e&&Rt(t,n,q(e).buffer)))}if(Array.isArray(e))return}Qn(t,e,n)}))],Lr=[0,gr],Sr=[0,hr,br,lr,lr,cr,br,br],Or=[0,lr,lr],Pr=class extends _n{constructor(){super()}};Pr.B=[6];var Cr=[0,lr,gr,lr,br,br,Er,gr,gr,yr,Or,br],Rr=[0,gr,gr,gr],Ir=class extends _n{constructor(){super()}},Dr=[0],Br=[0,hr],Ur=[1,2,3,4,5],Nr=class extends _n{constructor(t){super(t,2)}},Gr={},jr=[-2,Gr,lr];Gr[336783863]=An([0,gr,lr,lr,hr,yr,[0,_r,Dr,Ur,_r,Cr,Ur,_r,Rr,Ur,_r,Br,Ur,_r,Sr,Ur],yr,Lr]);var Vr=[0,pr,fr],zr=[0,or,or,fr,fr,fr,fr,or,cr,pr,ur,or,or,fr,ur,fr,fr,fr,pr],Wr=[-1,{}],Xr=[0,gr,yr,2,Wr],Hr=[0,gr,dr,yr,Wr];function qr(t,e){e=pe(e),t=t.u;const n=zt(t);ee(n),ze(t,n,2,""===e?void 0:e)}function $r(t,e){yn(t,3,e)}function Kr(t,e){yn(t,4,e)}var Yr=class extends _n{constructor(t){super(t,500)}o(t){return on(this,0,7,t)}};Yr.B=[3,4,5,6,8,13,17,1005];var Jr=[-500,pr,pr,dr,dr,dr,dr,yr,jr,vr,Fr,ur,ur,yr,Xr,yr,Hr,vr,Vr,pr,yr,zr,ur,dr,dr,988],Zr=[0,pr,pr,yr,Wr],Qr=[-500,gr,gr,yr,[-1,{}],gr,999],ts=[-500,gr,dr,dr,yr,[-2,{},lr],dr,998,dr],es=[-500,gr,dr,yr,Wr,dr,999];function ns(t,e){hn(t,Yr,e)}function rs(t,e){yn(t,10,e)}function ss(t,e){yn(t,15,e)}var is=class extends _n{constructor(t){super(t,500)}o(t){return on(this,0,1001,t)}};is.B=[1,6,7,9,10,15,16,17,14,1002];var os=[-500,vr,Jr,vr,5,Qr,vr,ts,ur,vr,es,dr,ur,yr,Xr,yr,Hr,vr,Zr,dr,dr,dr,yr,zr,pr,pr,fr,yr,980,Wr,vr,Fr],as=xr(is,os);is.prototype.g=Mr(os);var hs=[0,vr,[0,hr,hr,hr]],cs=class extends _n{constructor(t){super(t)}},us=[0,hr,nr,gr,gr],ls=class extends _n{constructor(t){super(t)}g(){return sn(this,cs,1)}};ls.B=[1];var fs=[0,vr,us],ds=xr(ls,fs),ps=[0,hr,nr],gs=[0,hr,hr,yr,hs],ms=class extends _n{constructor(t){super(t)}},ys=[0,hr,hr,hr,hr],vs=[0,nr,nr,nr,nr],_s=class extends _n{constructor(t){super(t)}},ws=[0,nr,nr,gr,nr],As=class extends _n{constructor(t){super(t)}h(){return nn(this,ms,2)}g(){return sn(this,_s,5)}};As.B=[5];var bs=[0,br,yr,ys,yr,vs,yr,gs,vr,ws],Es=class extends _n{constructor(t){super(t)}};Es.B=[1,2,3,8,9];var Ts=xr(Es,[0,dr,cr,sr,yr,bs,gr,gr,ir,vr,ps,dr,ir]),ks=class extends _n{constructor(t){super(t)}},xs=[0,nr,nr,nr,nr,nr],Ms=class extends _n{constructor(t){super(t)}};Ms.B=[1];var Fs=xr(Ms,[0,vr,xs]),Ls=class extends _n{constructor(t){super(t)}},Ss=[0,nr,nr,nr,nr,nr],Os=class extends _n{constructor(t){super(t)}};Os.B=[1];var Ps=xr(Os,[0,vr,Ss]),Cs=class extends _n{constructor(t){super(t)}};Cs.B=[3];var Rs=[0,hr,hr,sr,br],Is=class extends _n{constructor(){super()}};Is.prototype.g=Mr([0,nr,nr,nr,nr,nr,ir]);var Ds=class extends _n{constructor(t){super(t)}},Bs=[0,hr,2,gr,yr,fs],Us=class extends _n{constructor(t){super(t)}};Us.B=[1];var Ns=xr(Us,[0,vr,Bs,ir]),Gs=class extends _n{constructor(t){super(t)}};Gs.B=[1];var js=class extends _n{constructor(t){super(t)}fa(){const t=He(this);return null==t?G():t}},Vs=class extends _n{constructor(t){super(t)}},zs=[1,2],Ws=[0,_r,[0,sr],zs,_r,[0,wr],zs,hr,gr],Xs=class extends _n{constructor(t){super(t)}};Xs.B=[1];var Hs=xr(Xs,[0,vr,Ws,ir]),qs=class extends _n{constructor(t){super(t)}};qs.B=[4,5];var $s=[0,gr,hr,nr,dr,dr],Ks=class extends _n{constructor(t){super(t)}},Ys=[0,lr,lr],Js=class extends _n{constructor(t){super(t)}},Zs=[1,2,3,4,5],Qs=class extends _n{constructor(t){super(t)}g(){return null!=He(this)}h(){return null!=ln(this,2)}},ti=[0,wr,gr,yr,[0,hr,ir,ir],yr,[0,ar,ir]],ei=class extends _n{constructor(t){super(t)}g(){return ce(Ge(this,2))??!1}},ni=[0,yr,ti,lr,yr,[0,_r,Br,Zs,_r,Cr,Zs,_r,Sr,Zs,_r,Dr,Zs,_r,Rr,Zs]],ri=class extends _n{constructor(t){super(t)}},si=[0,yr,ni,nr,nr,hr],ii=kr(502141897,ri);Gr[502141897]=An(si);var oi=[0,yr,ti];Gr[512499200]=An(oi);var ai=[0,yr,oi];Gr[515723506]=An(ai);var hi=xr(class extends _n{constructor(t){super(t)}},[0,yr,[0,br,br,rr,Ar],yr,Rs]),ci=[0,yr,ni];Gr[508981768]=An(ci);var ui=class extends _n{constructor(t){super(t)}},li=[0,yr,ni,nr,yr,ci,lr],fi=class extends _n{constructor(t){super(t)}},di=[0,yr,ni,yr,si,yr,li,nr,yr,ai];Gr[508968149]=An(li);var pi=kr(508968150,fi);Gr[508968150]=An(di);var gi=class extends _n{constructor(t){super(t)}},mi=kr(513916220,gi);Gr[513916220]=An([0,yr,ni,yr,di,hr]);var yi=class extends _n{constructor(t){super(t)}h(){return nn(this,qs,2)}g(){Ve(this,2)}},vi=[0,yr,ni,yr,$s];Gr[478825465]=An(vi);var _i=[0,yr,ni];Gr[478825422]=An(_i);var wi=class extends _n{constructor(t){super(t)}},Ai=[0,yr,ni,yr,_i,yr,vi,yr,vi],bi=class extends _n{constructor(t){super(t)}},Ei=[0,yr,ni,nr,hr],Ti=class extends _n{constructor(t){super(t)}},ki=[0,yr,ni,nr],xi=class extends _n{constructor(t){super(t)}},Mi=[0,yr,ni,yr,Ei,yr,ki,nr],Fi=class extends _n{constructor(t){super(t)}},Li=[0,yr,ni,yr,Mi,yr,Ai];Gr[463370452]=An(Ai),Gr[464864288]=An(Ei),Gr[474472470]=An(ki);var Si=kr(462713202,xi);Gr[462713202]=An(Mi);var Oi=kr(479097054,Fi);Gr[479097054]=An(Li);var Pi=class extends _n{constructor(t){super(t)}},Ci=kr(456383383,Pi);Gr[456383383]=An([0,yr,ni,yr,$s]);var Ri=class extends _n{constructor(t){super(t)}},Ii=kr(476348187,Ri);Gr[476348187]=An([0,yr,ni,yr,Ys]);var Di=class extends _n{constructor(t){super(t)}},Bi=[0,br,br],Ui=class extends _n{constructor(t){super(t)}};Ui.B=[3];var Ni=kr(458105876,class extends _n{constructor(t){super(t)}g(){var t=this.u;const e=zt(t);var n=2&e;return t=function(t,e,n){var r=Ui;const s=2&e;let i=!1;if(null==n){if(s)return Ke();n=[]}else if(n.constructor===Fe){if(0==(2&n.g)||s)return n;n=n.m()}else Array.isArray(n)?i=!!(2&Vt(n)):n=[];if(s){if(!n.length)return Ke();i||(i=!0,Ht(n))}else i&&(i=!1,n=Ye(n));return i||(64&Vt(n)?jt(n,32):32&e&&Nt(n,32)),ze(t,e,2,r=new Fe(n,r,_e,void 0),!1),r}(t,e,je(t,e,2)),null==t||!n&&Ui&&(t.v=!0),t}});Gr[458105876]=An([0,yr,Bi,qn,[!0,ir,yr,[0,gr,gr,dr]]]);var Gi=class extends _n{constructor(t){super(t)}},ji=kr(458105758,Gi);Gr[458105758]=An([0,yr,ni,gr,yr,Bi]);var Vi=class extends _n{constructor(t){super(t)}};Vi.B=[5,6];var zi=kr(443442058,Vi);Gr[443442058]=An([0,yr,ni,gr,hr,nr,dr,dr]);var Wi=class extends _n{constructor(t){super(t)}},Xi=[0,yr,ni,nr,nr,hr];Gr[514774813]=An(Xi);var Hi=class extends _n{constructor(t){super(t)}},qi=[0,yr,ni,nr,lr],$i=class extends _n{constructor(t){super(t)}},Ki=[0,yr,ni,yr,Xi,yr,qi,nr];Gr[518928384]=An(qi);var Yi=kr(516587230,$i);function Ji(t,e){return e=e?e.clone():new qs,void 0!==t.displayNamesLocale?Ve(e,1,pe(t.displayNamesLocale)):void 0===t.displayNamesLocale&&Ve(e,1),void 0!==t.maxResults?gn(e,2,t.maxResults):"maxResults"in t&&Ve(e,2),void 0!==t.scoreThreshold?mn(e,3,t.scoreThreshold):"scoreThreshold"in t&&Ve(e,3),void 0!==t.categoryAllowlist?Je(e,4,t.categoryAllowlist):"categoryAllowlist"in t&&Ve(e,4),void 0!==t.categoryDenylist?Je(e,5,t.categoryDenylist):"categoryDenylist"in t&&Ve(e,5),e}function Zi(t,e=-1,n=""){return{categories:t.map((t=>({index:fn(cn(t,1))??-1,score:dn(t,2)??0,categoryName:ln(t,3)??""??"",displayName:ln(t,4)??""??""}))),headIndex:e,headName:n}}function Qi(t){var e=qe(t,3,he),n=qe(t,2,le);const r=qe(t,1,ge),s=qe(t,9,ge),i={categories:[],keypoints:[]};for(let t=0;t<e.length;t++)i.categories.push({score:e[t],index:n[t]??-1,categoryName:r[t]??"",displayName:s[t]??""});if((e=nn(t,As,4)?.h())&&(i.boundingBox={originX:cn(e,1)??0,originY:cn(e,2)??0,width:cn(e,3)??0,height:cn(e,4)??0,angle:0}),nn(t,As,4)?.g().length)for(const e of nn(t,As,4).g())i.keypoints.push({x:Xe(e,1)??0,y:Xe(e,2)??0,score:Xe(e,4)??0,label:ln(e,3)??""});return i}function to(t){const e=[];for(const n of sn(t,Ls,1))e.push({x:dn(n,1)??0,y:dn(n,2)??0,z:dn(n,3)??0});return e}function eo(t){const e=[];for(const n of sn(t,ks,1))e.push({x:dn(n,1)??0,y:dn(n,2)??0,z:dn(n,3)??0});return e}function no(t){return Array.from(t,(t=>127<t?t-256:t))}function ro(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);let n=0,r=0,s=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i],r+=t[i]*t[i],s+=e[i]*e[i];if(0>=r||0>=s)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(r*s)}let so;Gr[516587230]=An(Ki);const io=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function oo(){if(void 0===so)try{await WebAssembly.instantiate(io),so=!0}catch{so=!1}return so}async function ao(t,e=""){const n=await oo()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var ho=class{};function co(){const t=navigator.userAgent;return t.includes("Safari")&&!t.includes("Chrome")}async function uo(t){if("function"!=typeof importScripts){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise(((t,n)=>{e.addEventListener("load",(()=>{t()}),!1),e.addEventListener("error",(t=>{n(t)}),!1),document.body.appendChild(e)}))}importScripts(t.toString())}function lo(t,e,n){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(e=t.i.stringToNewUTF8(e)),t.i._free(e)}function fo(t,e,n){if(!t.i.canvas)throw Error("No OpenGL canvas configured.");if(n?t.i._bindTextureToStream(n):t.i._bindTextureToCanvas(),!(n=t.i.canvas.getContext("webgl2")||t.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");return t.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),t.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),e.videoWidth?(n=e.videoWidth,e=e.videoHeight):e.naturalWidth?(n=e.naturalWidth,e=e.naturalHeight):(n=e.width,e=e.height),!t.l||n===t.i.canvas.width&&e===t.i.canvas.height||(t.i.canvas.width=n,t.i.canvas.height=e),[n,e]}function po(t,e,n){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const r=new Uint32Array(e.length);for(let n=0;n<e.length;n++)r[n]=t.i.stringToNewUTF8(e[n]);e=t.i._malloc(4*r.length),t.i.HEAPU32.set(r,e>>2),n(e);for(const e of r)t.i._free(e);t.i._free(e)}function go(t,e,n){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[e]=n}function mo(t,e,n){let r=[];t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[e]=(t,e,s)=>{e?(n(r,s),r=[]):r.push(t)}}function yo(t,e){const n=nn(t.baseOptions,Qs,1)||new Qs;"string"==typeof e?(Ve(n,2,pe(e)),Ve(n,1)):e instanceof Uint8Array&&(Ve(n,1,Qt(e,!1,!1)),Ve(n,2)),on(t.baseOptions,0,1,n)}function vo(t){try{const e=t.J.length;if(1===e)throw Error(t.J[0].message);if(1<e)throw Error("Encountered multiple errors: "+t.J.map((t=>t.message)).join(", "))}finally{t.J=[]}}function _o(t,e){t.I=Math.max(t.I,e)}function wo(t,e){t.A=new Yr,qr(t.A,"PassThroughCalculator"),$r(t.A,"free_memory"),Kr(t.A,"free_memory_unused_out"),rs(e,"free_memory"),ns(e,t.A)}function Ao(t,e){$r(t.A,e),Kr(t.A,e+"_unused_out")}function bo(t){t.g.addBoolToStream(!0,"free_memory",t.I)}ho.forVisionTasks=function(t){return ao("vision",t)},ho.forTextTasks=function(t){return ao("text",t)},ho.forAudioTasks=function(t){return ao("audio",t)},ho.isSimdSupported=function(){return oo()};var Eo=class{constructor(t){this.g=t,this.J=[],this.I=0,this.g.setAutoRenderToScreen(!1)}l(t,e=!0){if(e){const e=t.baseOptions||{};if(t.baseOptions?.modelAssetBuffer&&t.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(nn(this.baseOptions,Qs,1)?.g()||nn(this.baseOptions,Qs,1)?.h()||t.baseOptions?.modelAssetBuffer||t.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(t,e){let n=nn(t.baseOptions,Js,3);if(!n){var r=n=new Js,s=new Ir;an(r,4,Zs,s)}"delegate"in e&&("GPU"===e.delegate?(e=n,r=new Pr,an(e,2,Zs,r)):(e=n,r=new Ir,an(e,4,Zs,r))),on(t.baseOptions,0,3,n)}(this,e),e.modelAssetPath)return fetch(e.modelAssetPath.toString()).then((t=>{if(t.ok)return t.arrayBuffer();throw Error(`Failed to fetch model: ${e.modelAssetPath} (${t.status})`)})).then((t=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(t),!0,!1,!1),yo(this,"/model.dat"),this.m(),this.P()}));yo(this,e.modelAssetBuffer)}return this.m(),this.P(),Promise.resolve()}P(){}W(){let t;if(this.g.W((e=>{t=as(e)})),!t)throw Error("Failed to retrieve CalculatorGraphConfig");return t}setGraph(t,e){this.g.attachErrorListener(((t,e)=>{this.J.push(Error(e))})),this.g.Aa(),this.g.setGraph(t,e),this.A=void 0,vo(this)}finishProcessing(){this.g.finishProcessing(),vo(this)}close(){this.A=void 0,this.g.closeGraph()}};function To(t,e){if(null===t)throw Error(`Unable to obtain required WebGL resource: ${e}`);return t}Eo.prototype.close=Eo.prototype.close;class ko{constructor(t,e,n,r){this.g=t,this.h=e,this.m=n,this.l=r}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function xo(t,e,n){const r=t.h;if(n=To(r.createShader(n),"Failed to create WebGL shader"),r.shaderSource(n,e),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${r.getShaderInfoLog(n)}`);return r.attachShader(t.g,n),n}function Mo(t,e){const n=t.h,r=To(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(r);const s=To(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,s),n.enableVertexAttribArray(t.s),n.vertexAttribPointer(t.s,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const i=To(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,i),n.enableVertexAttribArray(t.A),n.vertexAttribPointer(t.A,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(e?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindVertexArray(null),new ko(n,r,s,i)}function Fo(t,e){if(t.h){if(e!==t.h)throw Error("Cannot change GL context once initialized")}else t.h=e}function Lo(t,e,n,r){if(Fo(t,e),!t.g){const e=t.h;if(t.g=To(e.createProgram(),"Failed to create WebGL program"),t.C=xo(t,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",e.VERTEX_SHADER),t.v=xo(t,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D inputTexture;\n void main() {\n gl_FragColor = texture2D(inputTexture, vTex);\n }\n ",e.FRAGMENT_SHADER),e.linkProgram(t.g),!e.getProgramParameter(t.g,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(t.g)}`);t.s=e.getAttribLocation(t.g,"aVertex"),t.A=e.getAttribLocation(t.g,"aTex")}return n?(t.m||(t.m=Mo(t,!0)),n=t.m):(t.j||(t.j=Mo(t,!1)),n=t.j),e.useProgram(t.g),n.bind(),t=r(),n.g.bindVertexArray(null),t}function So(t,e,n){Fo(t,e),t.l||(t.l=To(e.createFramebuffer(),"Failed to create framebuffe.")),e.bindFramebuffer(e.FRAMEBUFFER,t.l),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0)}function Oo(t){t.h?.bindFramebuffer(t.h.FRAMEBUFFER,null)}var Po=class{close(){if(this.g){const t=this.h;t.deleteProgram(this.g),t.deleteShader(this.C),t.deleteShader(this.v)}this.l&&this.h.deleteFramebuffer(this.l),this.j&&this.j.close(),this.m&&this.m.close()}};function Co(t,e){switch(e){case 0:return t.g.find((t=>t instanceof ImageData));case 1:return t.g.find((t=>"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap));case 2:return t.g.find((t=>"undefined"!=typeof WebGLTexture&&t instanceof WebGLTexture));default:throw Error(`Type is not supported: ${e}`)}}function Ro(t){var e=Co(t,0);if(!e){e=Do(t);const n=Bo(t),r=new Uint8Array(t.width*t.height*4);So(n,e,Io(t)),e.readPixels(0,0,t.width,t.height,e.RGBA,e.UNSIGNED_BYTE,r),Oo(n),e=new ImageData(new Uint8ClampedArray(r.buffer),t.width,t.height),t.g.push(e)}return e}function Io(t){let e=Co(t,2);if(!e){const n=Do(t);e=No(t);const r=Co(t,1)||Ro(t);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,r),Go(t)}return e}function Do(t){if(!t.canvas)throw Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");return t.h||(t.h=To(t.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),t.h}function Bo(t){return t.l||(t.l=new Po),t.l}function Uo(t){(t=Do(t)).texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)}function No(t){const e=Do(t);e.viewport(0,0,t.width,t.height),e.activeTexture(e.TEXTURE0);let n=Co(t,2);return n?e.bindTexture(e.TEXTURE_2D,n):(n=To(e.createTexture(),"Failed to create texture"),t.g.push(n),t.m=!0,e.bindTexture(e.TEXTURE_2D,n),Uo(t)),n}function Go(t){t.h.bindTexture(t.h.TEXTURE_2D,null)}function jo(t){const e=Do(t);return Lo(Bo(t),e,!0,(()=>function(t,e){const n=t.canvas;if(n.width===t.width&&n.height===t.height)return e();const r=n.width,s=n.height;return n.width=t.width,n.height=t.height,t=e(),n.width=r,n.height=s,t}(t,(()=>{if(e.bindFramebuffer(e.FRAMEBUFFER,null),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),!(t.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return t.canvas.transferToImageBitmap()}))))}var Vo=class{constructor(t,e,n,r,s,i,o){this.g=t,this.j=e,this.m=n,this.canvas=r,this.l=s,this.width=i,this.height=o,(this.j||this.m)&&0==--zo&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}va(){return!!Co(this,0)}ba(){return!!Co(this,1)}K(){return!!Co(this,2)}ra(){return Ro(this)}qa(){var t=Co(this,1);return t||(Io(this),No(this),t=jo(this),Go(this),this.g.push(t),this.j=!0),t}V(){return Io(this)}clone(){const t=[];for(const e of this.g){let n;if(e instanceof ImageData)n=new ImageData(e.data,this.width,this.height);else if(e instanceof WebGLTexture){const t=Do(this),e=Bo(this);t.activeTexture(t.TEXTURE1),n=To(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,n),Uo(this),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.width,this.height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.bindTexture(t.TEXTURE_2D,null),So(e,t,n),Lo(e,t,!1,(()=>{No(this),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),Go(this)})),Oo(e),Go(this)}else{if(!(e instanceof ImageBitmap))throw Error(`Type is not supported: ${e}`);Io(this),No(this),n=jo(this),Go(this)}t.push(n)}return new Vo(t,this.ba(),this.K(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Co(this,1).close(),this.m&&Do(this).deleteTexture(Co(this,2)),zo=-1}};Vo.prototype.close=Vo.prototype.close,Vo.prototype.clone=Vo.prototype.clone,Vo.prototype.getAsWebGLTexture=Vo.prototype.V,Vo.prototype.getAsImageBitmap=Vo.prototype.qa,Vo.prototype.getAsImageData=Vo.prototype.ra,Vo.prototype.hasWebGLTexture=Vo.prototype.K,Vo.prototype.hasImageBitmap=Vo.prototype.ba,Vo.prototype.hasImageData=Vo.prototype.va;var zo=250;function Wo(t,e){switch(e){case 0:return t.g.find((t=>t instanceof Uint8Array));case 1:return t.g.find((t=>t instanceof Float32Array));case 2:return t.g.find((t=>"undefined"!=typeof WebGLTexture&&t instanceof WebGLTexture));default:throw Error(`Type is not supported: ${e}`)}}function Xo(t){var e=Wo(t,1);if(!e){if(e=Wo(t,0))e=new Float32Array(e).map((t=>t/255));else{e=new Float32Array(t.width*t.height);const r=qo(t);var n=Ko(t);if(So(n,r,Ho(t)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document){n=new Float32Array(t.width*t.height*4),r.readPixels(0,0,t.width,t.height,r.RGBA,r.FLOAT,n);for(let t=0,r=0;t<e.length;++t,r+=4)e[t]=n[r]}else r.readPixels(0,0,t.width,t.height,r.RED,r.FLOAT,e)}t.g.push(e)}return e}function Ho(t){let e=Wo(t,2);if(!e){const n=qo(t);e=Jo(t);const r=Xo(t),s=$o(t);n.texImage2D(n.TEXTURE_2D,0,s,t.width,t.height,0,n.RED,n.FLOAT,r),Zo(t)}return e}function qo(t){if(!t.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return t.h||(t.h=To(t.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),t.h}function $o(t){if(t=qo(t),!Qo)if(t.getExtension("EXT_color_buffer_float")&&t.getExtension("OES_texture_float_linear")&&t.getExtension("EXT_float_blend"))Qo=t.R32F;else{if(!t.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Qo=t.R16F}return Qo}function Ko(t){return t.l||(t.l=new Po),t.l}function Yo(t){(t=qo(t)).texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)}function Jo(t){const e=qo(t);e.viewport(0,0,t.width,t.height),e.activeTexture(e.TEXTURE0);let n=Wo(t,2);return n?e.bindTexture(e.TEXTURE_2D,n):(n=To(e.createTexture(),"Failed to create texture"),t.g.push(n),t.m=!0,e.bindTexture(e.TEXTURE_2D,n),Yo(t)),n}function Zo(t){t.h.bindTexture(t.h.TEXTURE_2D,null)}var Qo,ta=class{constructor(t,e,n,r,s,i){this.g=t,this.m=e,this.canvas=n,this.l=r,this.width=s,this.height=i,this.m&&0==--ea&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}wa(){return!!Wo(this,0)}ua(){return!!Wo(this,1)}K(){return!!Wo(this,2)}sa(){return(t=Wo(this,0))||(t=Xo(this),t=new Uint8Array(t.map((t=>255*t))),this.g.push(t)),t;var t}pa(){return Xo(this)}V(){return Ho(this)}clone(){const t=[];for(const e of this.g){let n;if(e instanceof Uint8Array)n=new Uint8Array(e);else if(e instanceof Float32Array)n=new Float32Array(e);else{if(!(e instanceof WebGLTexture))throw Error(`Type is not supported: ${e}`);{const t=qo(this),e=Ko(this);t.activeTexture(t.TEXTURE1),n=To(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,n),Yo(this);const r=$o(this);t.texImage2D(t.TEXTURE_2D,0,r,this.width,this.height,0,t.RED,t.FLOAT,null),t.bindTexture(t.TEXTURE_2D,null),So(e,t,n),Lo(e,t,!1,(()=>{Jo(this),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),Zo(this)})),Oo(e),Zo(this)}}t.push(n)}return new ta(t,this.K(),this.canvas,this.l,this.width,this.height)}close(){this.m&&qo(this).deleteTexture(Wo(this,2)),ea=-1}};ta.prototype.close=ta.prototype.close,ta.prototype.clone=ta.prototype.clone,ta.prototype.getAsWebGLTexture=ta.prototype.V,ta.prototype.getAsFloat32Array=ta.prototype.pa,ta.prototype.getAsUint8Array=ta.prototype.sa,ta.prototype.hasWebGLTexture=ta.prototype.K,ta.prototype.hasFloat32Array=ta.prototype.ua,ta.prototype.hasUint8Array=ta.prototype.wa;var ea=250;function na(...t){return t.map((([t,e])=>({start:t,end:e})))}const ra=function(t){return class extends t{Aa(){this.i._registerModelResourcesGraphService()}}}((sa=class{constructor(t,e){this.l=!0,this.i=t,this.g=null,this.h=0,this.m="function"==typeof this.i._addIntToInputStream,void 0!==e?this.i.canvas=e:"undefined"==typeof OffscreenCanvas||co()?(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas")):this.i.canvas=new OffscreenCanvas(1,1)}async initializeGraph(t){const e=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(e),t)}setGraphFromString(t){this.setGraph((new TextEncoder).encode(t),!1)}setGraph(t,e){const n=t.length,r=this.i._malloc(n);this.i.HEAPU8.set(t,r),e?this.i._changeBinaryGraph(n,r):this.i._changeTextGraph(n,r),this.i._free(r)}configureAudio(t,e,n,r,s){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),lo(this,r||"input_audio",(r=>{lo(this,s=s||"audio_header",(s=>{this.i._configureAudio(r,s,t,e,n)}))}))}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.i._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.i.gpuOriginForWebTexturesIsBottomLeft=t}W(t){go(this,"__graph_config__",(e=>{t(e)})),lo(this,"__graph_config__",(t=>{this.i._getGraphConfig(t,void 0)})),delete this.i.simpleListeners.__graph_config__}attachErrorListener(t){this.i.errorListener=t}attachEmptyPacketListener(t,e){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[t]=e}addAudioToStream(t,e,n){this.addAudioToStreamWithShape(t,0,0,e,n)}addAudioToStreamWithShape(t,e,n,r,s){const i=4*t.length;this.h!==i&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(i),this.h=i),this.i.HEAPF32.set(t,this.g/4),lo(this,r,(t=>{this.i._addAudioToInputStream(this.g,e,n,t,s)}))}addGpuBufferToStream(t,e,n){lo(this,e,(e=>{const[r,s]=fo(this,t,e);this.i._addBoundTextureToStream(e,r,s,n)}))}addBoolToStream(t,e,n){lo(this,e,(e=>{this.i._addBoolToInputStream(t,e,n)}))}addDoubleToStream(t,e,n){lo(this,e,(e=>{this.i._addDoubleToInputStream(t,e,n)}))}addFloatToStream(t,e,n){lo(this,e,(e=>{this.i._addFloatToInputStream(t,e,n)}))}addIntToStream(t,e,n){lo(this,e,(e=>{this.i._addIntToInputStream(t,e,n)}))}addStringToStream(t,e,n){lo(this,e,(e=>{lo(this,t,(t=>{this.i._addStringToInputStream(t,e,n)}))}))}addStringRecordToStream(t,e,n){lo(this,e,(e=>{po(this,Object.keys(t),(r=>{po(this,Object.values(t),(s=>{this.i._addFlatHashMapToInputStream(r,s,Object.keys(t).length,e,n)}))}))}))}addProtoToStream(t,e,n,r){lo(this,n,(n=>{lo(this,e,(e=>{const s=this.i._malloc(t.length);this.i.HEAPU8.set(t,s),this.i._addProtoToInputStream(s,t.length,e,n,r),this.i._free(s)}))}))}addEmptyPacketToStream(t,e){lo(this,t,(t=>{this.i._addEmptyPacketToInputStream(t,e)}))}addBoolToInputSidePacket(t,e){lo(this,e,(e=>{this.i._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){lo(this,e,(e=>{this.i._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){lo(this,e,(e=>{this.i._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){lo(this,e,(e=>{this.i._addIntToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){lo(this,e,(e=>{lo(this,t,(t=>{this.i._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,n){lo(this,n,(n=>{lo(this,e,(e=>{const r=this.i._malloc(t.length);this.i.HEAPU8.set(t,r),this.i._addProtoToInputSidePacket(r,t.length,e,n),this.i._free(r)}))}))}attachBoolListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachBoolListener(t)}))}attachBoolVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachBoolVectorListener(t)}))}attachIntListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachIntListener(t)}))}attachIntVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachIntVectorListener(t)}))}attachDoubleListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachFloatListener(t)}))}attachFloatVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachFloatVectorListener(t)}))}attachStringListener(t,e){go(this,t,e),lo(this,t,(t=>{this.i._attachStringListener(t)}))}attachStringVectorListener(t,e){mo(this,t,e),lo(this,t,(t=>{this.i._attachStringVectorListener(t)}))}attachProtoListener(t,e,n){go(this,t,e),lo(this,t,(t=>{this.i._attachProtoListener(t,n||!1)}))}attachProtoVectorListener(t,e,n){mo(this,t,e),lo(this,t,(t=>{this.i._attachProtoVectorListener(t,n||!1)}))}attachAudioListener(t,e,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),go(this,t,((t,n)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,n)})),lo(this,t,(t=>{this.i._attachAudioListener(t,n||!1)}))}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends sa{get Y(){return this.i}ga(t,e,n){lo(this,e,(e=>{const[r,s]=fo(this,t,e);this.Y._addBoundTextureAsImageToStream(e,r,s,n)}))}S(t,e){go(this,t,e),lo(this,t,(t=>{this.Y._attachImageListener(t)}))}T(t,e){mo(this,t,e),lo(this,t,(t=>{this.Y._attachImageVectorListener(t)}))}}));var sa,ia=class extends ra{};async function oa(t,e,n){return async function(t,e,n,r){return async function(t,e,n,r){return t=await(async(t,e,n,r,s)=>{if(e&&await uo(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await uo(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&s&&((e=self.Module).locateFile=s.locateFile,s.mainScriptUrlOrBlob&&(e.mainScriptUrlOrBlob=s.mainScriptUrlOrBlob)),s=await self.ModuleFactory(self.Module||s),self.ModuleFactory=self.Module=void 0,new t(s,r)})(t,n.wasmLoaderPath,n.assetLoaderPath,e,{locateFile:t=>t.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&t.endsWith(".data")?n.assetBinaryPath.toString():t}),await t.o(r),t}(t,e,n,r)}(t,n.canvas??("undefined"==typeof OffscreenCanvas||co()?document.createElement("canvas"):void 0),e,n)}function aa(t,e,n,r){if(t.Z){const i=new Is;if(n?.regionOfInterest){if(!t.ea)throw Error("This task doesn't support region-of-interest.");var s=n.regionOfInterest;if(s.left>=s.right||s.top>=s.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>s.left||0>s.top||1<s.right||1<s.bottom)throw Error("Expected RectF values to be in [0,1].");mn(i,1,(s.left+s.right)/2),mn(i,2,(s.top+s.bottom)/2),mn(i,4,s.right-s.left),mn(i,3,s.bottom-s.top)}else mn(i,1,.5),mn(i,2,.5),mn(i,4,1),mn(i,3,1);if(n?.rotationDegrees){if(0!=n?.rotationDegrees%90)throw Error("Expected rotation to be a multiple of 90°.");if(mn(i,5,-Math.PI*n.rotationDegrees/180),0!=n?.rotationDegrees%180){const[t,r]=void 0!==e.videoWidth?[e.videoWidth,e.videoHeight]:void 0!==e.naturalWidth?[e.naturalWidth,e.naturalHeight]:[e.width,e.height];n=dn(i,3)*r/t,s=dn(i,4)*t/r,mn(i,4,n),mn(i,3,s)}}t.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",t.Z,r)}t.g.ga(e,t.da,r??performance.now()),t.finishProcessing()}function ha(t,e,n){if(t.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");aa(t,e,n,t.I+1)}function ca(t,e,n,r){if(!t.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");aa(t,e,n,r)}function ua(t,e,n){var r=e.data;const s=e.width,i=s*(e=e.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==i)throw Error("Unsupported channel count: "+r.length/i);return t=new ta([r],!1,t.g.i.canvas,t.O,s,e),n?t.clone():t}var la=class extends Eo{constructor(t,e,n,r){super(t),this.g=t,this.da=e,this.Z=n,this.ea=r,this.O=new Po}l(t,e=!0){if("runningMode"in t&&pn(this.baseOptions,2,!!t.runningMode&&"IMAGE"!==t.runningMode),void 0!==t.canvas&&this.g.i.canvas!==t.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(t,e)}close(){this.O.close(),super.close()}};la.prototype.close=la.prototype.close;var fa=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect_in",!1),this.j={detections:[]},this.h=new ri,t=new ei,on(this.h,0,1,t),mn(this.h,2,.5),mn(this.h,3,.3)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&mn(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&mn(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,e){return this.j={detections:[]},ha(this,t,e),this.j}G(t,e,n){return this.j={detections:[]},ca(this,t,n,e),this.j}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect_in"),ss(t,"detections");const e=new Nr;vn(e,ii,this.h);const n=new Yr;qr(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),$r(n,"IMAGE:image_in"),$r(n,"NORM_RECT:norm_rect_in"),Kr(n,"DETECTIONS:detections"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("detections",((t,e)=>{for(const e of t)t=Ts(e),this.j.detections.push(Qi(t));_o(this,e)})),this.g.attachEmptyPacketListener("detections",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};fa.prototype.detectForVideo=fa.prototype.G,fa.prototype.detect=fa.prototype.F,fa.prototype.setOptions=fa.prototype.o,fa.createFromModelPath=async function(t,e){return oa(fa,t,{baseOptions:{modelAssetPath:e}})},fa.createFromModelBuffer=function(t,e){return oa(fa,t,{baseOptions:{modelAssetBuffer:e}})},fa.createFromOptions=function(t,e){return oa(fa,t,e)};var da=na([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),pa=na([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),ga=na([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),ma=na([474,475],[475,476],[476,477],[477,474]),ya=na([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),va=na([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),_a=na([469,470],[470,471],[471,472],[472,469]),wa=na([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Aa=[...da,...pa,...ga,...ya,...va,...wa],ba=na([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Ea(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Ta=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,this.h=new fi,t=new ei,on(this.h,0,1,t),this.v=new ui,on(this.h,0,3,this.v),this.s=new ri,on(this.h,0,2,this.s),gn(this.s,4,1),mn(this.s,2,.5),mn(this.v,2,.5),mn(this.h,4,.5)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return"numFaces"in t&&gn(this.s,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&mn(this.s,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&mn(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&mn(this.v,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in t&&(this.outputFacialTransformationMatrixes=!!t.outputFacialTransformationMatrixes),this.l(t)}F(t,e){return Ea(this),ha(this,t,e),this.j}G(t,e,n){return Ea(this),ca(this,t,n,e),this.j}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"face_landmarks");const e=new Nr;vn(e,pi,this.h);const n=new Yr;qr(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),$r(n,"IMAGE:image_in"),$r(n,"NORM_RECT:norm_rect"),Kr(n,"NORM_LANDMARKS:face_landmarks"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("face_landmarks",((t,e)=>{for(const e of t)t=Ps(e),this.j.faceLandmarks.push(to(t));_o(this,e)})),this.g.attachEmptyPacketListener("face_landmarks",(t=>{_o(this,t)})),this.outputFaceBlendshapes&&(ss(t,"blendshapes"),Kr(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((t,e)=>{if(this.outputFaceBlendshapes)for(const e of t)t=ds(e),this.j.faceBlendshapes.push(Zi(t.g()??[]));_o(this,e)})),this.g.attachEmptyPacketListener("blendshapes",(t=>{_o(this,t)}))),this.outputFacialTransformationMatrixes&&(ss(t,"face_geometry"),Kr(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((t,e)=>{if(this.outputFacialTransformationMatrixes)for(const e of t)(t=nn(hi(e),Cs,2))&&this.j.facialTransformationMatrixes.push({rows:fn(cn(t,1))??0,columns:fn(cn(t,2))??0,data:qe(t,3,he)??[]});_o(this,e)})),this.g.attachEmptyPacketListener("face_geometry",(t=>{_o(this,t)}))),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ta.prototype.detectForVideo=Ta.prototype.G,Ta.prototype.detect=Ta.prototype.F,Ta.prototype.setOptions=Ta.prototype.o,Ta.createFromModelPath=function(t,e){return oa(Ta,t,{baseOptions:{modelAssetPath:e}})},Ta.createFromModelBuffer=function(t,e){return oa(Ta,t,{baseOptions:{modelAssetBuffer:e}})},Ta.createFromOptions=function(t,e){return oa(Ta,t,e)},Ta.FACE_LANDMARKS_LIPS=da,Ta.FACE_LANDMARKS_LEFT_EYE=pa,Ta.FACE_LANDMARKS_LEFT_EYEBROW=ga,Ta.FACE_LANDMARKS_LEFT_IRIS=ma,Ta.FACE_LANDMARKS_RIGHT_EYE=ya,Ta.FACE_LANDMARKS_RIGHT_EYEBROW=va,Ta.FACE_LANDMARKS_RIGHT_IRIS=_a,Ta.FACE_LANDMARKS_FACE_OVAL=wa,Ta.FACE_LANDMARKS_CONTOURS=Aa,Ta.FACE_LANDMARKS_TESSELATION=ba;var ka=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!0),this.j=new gi,t=new ei,on(this.j,0,1,t)}get baseOptions(){return nn(this.j,ei,1)}set baseOptions(t){on(this.j,0,1,t)}o(t){return super.l(t)}Da(t,e,n){const r="function"!=typeof e?e:{};if(this.h="function"==typeof e?e:n,ha(this,t,r??{}),!this.h)return this.s}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"stylized_image");const e=new Nr;vn(e,mi,this.j);const n=new Yr;qr(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),$r(n,"IMAGE:image_in"),$r(n,"NORM_RECT:norm_rect"),Kr(n,"STYLIZED_IMAGE:stylized_image"),n.o(e),ns(t,n),this.g.S("stylized_image",((t,e)=>{var n=!this.h,r=t.data,s=t.width;const i=s*(t=t.height);if(r instanceof Uint8Array)if(r.length===3*i){const e=new Uint8ClampedArray(4*i);for(let t=0;t<i;++t)e[4*t]=r[3*t],e[4*t+1]=r[3*t+1],e[4*t+2]=r[3*t+2],e[4*t+3]=255;r=new ImageData(e,s,t)}else{if(r.length!==4*i)throw Error("Unsupported channel count: "+r.length/i);r=new ImageData(new Uint8ClampedArray(r.buffer,r.byteOffset,r.length),s,t)}else if(!(r instanceof WebGLTexture))throw Error(`Unsupported format: ${r.constructor.name}`);s=new Vo([r],!1,!1,this.g.i.canvas,this.O,s,t),this.s=n=n?s.clone():s,this.h&&this.h(n),_o(this,e)})),this.g.attachEmptyPacketListener("stylized_image",(t=>{this.s=null,this.h&&this.h(null),_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ka.prototype.stylize=ka.prototype.Da,ka.prototype.setOptions=ka.prototype.o,ka.createFromModelPath=function(t,e){return oa(ka,t,{baseOptions:{modelAssetPath:e}})},ka.createFromModelBuffer=function(t,e){return oa(ka,t,{baseOptions:{modelAssetBuffer:e}})},ka.createFromOptions=function(t,e){return oa(ka,t,e)};var xa=na([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function Ma(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function Fa(t){return 0===t.gestures.length?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:t.gestures,landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handedness:t.handedness,handednesses:t.handedness}}function La(t,e=!0){const n=[];for(const s of t){var r=ds(s);t=[];for(const n of r.g())r=e&&null!=cn(n,1)?fn(cn(n,1)):-1,t.push({score:dn(n,2)??0,index:r,categoryName:ln(n,3)??""??"",displayName:ln(n,4)??""??""});n.push(t)}return n}var Sa=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.v=new Fi,t=new ei,on(this.v,0,1,t),this.C=new xi,on(this.v,0,2,this.C),this.s=new Ti,on(this.C,0,3,this.s),this.h=new bi,on(this.C,0,2,this.h),this.j=new wi,on(this.v,0,3,this.j),mn(this.h,2,.5),mn(this.C,4,.5),mn(this.s,2,.5)}get baseOptions(){return nn(this.v,ei,1)}set baseOptions(t){on(this.v,0,1,t)}o(t){if(gn(this.h,3,t.numHands??1),"minHandDetectionConfidence"in t&&mn(this.h,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&mn(this.C,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&mn(this.s,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var e=new yi,n=Ji(t.cannedGesturesClassifierOptions,nn(this.j,yi,3)?.h());on(e,0,2,n),on(this.j,0,3,e)}else void 0===t.cannedGesturesClassifierOptions&&nn(this.j,yi,3)?.g();return t.customGesturesClassifierOptions?(on(e=new yi,0,2,n=Ji(t.customGesturesClassifierOptions,nn(this.j,yi,4)?.h())),on(this.j,0,4,e)):void 0===t.customGesturesClassifierOptions&&nn(this.j,yi,4)?.g(),this.l(t)}ya(t,e){return Ma(this),ha(this,t,e),Fa(this)}za(t,e,n){return Ma(this),ca(this,t,n,e),Fa(this)}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"hand_gestures"),ss(t,"hand_landmarks"),ss(t,"world_hand_landmarks"),ss(t,"handedness");const e=new Nr;vn(e,Oi,this.v);const n=new Yr;qr(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),$r(n,"IMAGE:image_in"),$r(n,"NORM_RECT:norm_rect"),Kr(n,"HAND_GESTURES:hand_gestures"),Kr(n,"LANDMARKS:hand_landmarks"),Kr(n,"WORLD_LANDMARKS:world_hand_landmarks"),Kr(n,"HANDEDNESS:handedness"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("hand_landmarks",((t,e)=>{for(const e of t){t=Ps(e);const n=[];for(const e of sn(t,Ls,1))n.push({x:dn(e,1)??0,y:dn(e,2)??0,z:dn(e,3)??0});this.landmarks.push(n)}_o(this,e)})),this.g.attachEmptyPacketListener("hand_landmarks",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("world_hand_landmarks",((t,e)=>{for(const e of t){t=Fs(e);const n=[];for(const e of sn(t,ks,1))n.push({x:dn(e,1)??0,y:dn(e,2)??0,z:dn(e,3)??0});this.worldLandmarks.push(n)}_o(this,e)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("hand_gestures",((t,e)=>{this.gestures.push(...La(t,!1)),_o(this,e)})),this.g.attachEmptyPacketListener("hand_gestures",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("handedness",((t,e)=>{this.handedness.push(...La(t)),_o(this,e)})),this.g.attachEmptyPacketListener("handedness",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function Oa(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Sa.prototype.recognizeForVideo=Sa.prototype.za,Sa.prototype.recognize=Sa.prototype.ya,Sa.prototype.setOptions=Sa.prototype.o,Sa.createFromModelPath=function(t,e){return oa(Sa,t,{baseOptions:{modelAssetPath:e}})},Sa.createFromModelBuffer=function(t,e){return oa(Sa,t,{baseOptions:{modelAssetBuffer:e}})},Sa.createFromOptions=function(t,e){return oa(Sa,t,e)},Sa.HAND_CONNECTIONS=xa;var Pa=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.j=new xi,t=new ei,on(this.j,0,1,t),this.s=new Ti,on(this.j,0,3,this.s),this.h=new bi,on(this.j,0,2,this.h),gn(this.h,3,1),mn(this.h,2,.5),mn(this.s,2,.5),mn(this.j,4,.5)}get baseOptions(){return nn(this.j,ei,1)}set baseOptions(t){on(this.j,0,1,t)}o(t){return"numHands"in t&&gn(this.h,3,t.numHands??1),"minHandDetectionConfidence"in t&&mn(this.h,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&mn(this.j,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&mn(this.s,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,e){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ha(this,t,e),Oa(this)}G(t,e,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ca(this,t,n,e),Oa(this)}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"hand_landmarks"),ss(t,"world_hand_landmarks"),ss(t,"handedness");const e=new Nr;vn(e,Si,this.j);const n=new Yr;qr(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),$r(n,"IMAGE:image_in"),$r(n,"NORM_RECT:norm_rect"),Kr(n,"LANDMARKS:hand_landmarks"),Kr(n,"WORLD_LANDMARKS:world_hand_landmarks"),Kr(n,"HANDEDNESS:handedness"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("hand_landmarks",((t,e)=>{for(const e of t)t=Ps(e),this.landmarks.push(to(t));_o(this,e)})),this.g.attachEmptyPacketListener("hand_landmarks",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("world_hand_landmarks",((t,e)=>{for(const e of t)t=Fs(e),this.worldLandmarks.push(eo(t));_o(this,e)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(t=>{_o(this,t)})),this.g.attachProtoVectorListener("handedness",((t,e)=>{var n=this.handedness,r=n.push;const s=[];for(const e of t){t=ds(e);const n=[];for(const e of t.g())n.push({score:dn(e,2)??0,index:fn(cn(e,1))??-1,categoryName:ln(e,3)??""??"",displayName:ln(e,4)??""??""});s.push(n)}r.call(n,...s),_o(this,e)})),this.g.attachEmptyPacketListener("handedness",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Pa.prototype.detectForVideo=Pa.prototype.G,Pa.prototype.detect=Pa.prototype.F,Pa.prototype.setOptions=Pa.prototype.o,Pa.createFromModelPath=function(t,e){return oa(Pa,t,{baseOptions:{modelAssetPath:e}})},Pa.createFromModelBuffer=function(t,e){return oa(Pa,t,{baseOptions:{modelAssetBuffer:e}})},Pa.createFromOptions=function(t,e){return oa(Pa,t,e)},Pa.HAND_CONNECTIONS=xa;var Ca=class extends la{constructor(t,e){super(new ia(t,e),"input_image","norm_rect",!0),this.j={classifications:[]},this.h=new Pi,t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){var e=Ji(t,nn(this.h,qs,2));return on(this.h,0,2,e),this.l(t)}ia(t,e){return this.j={classifications:[]},ha(this,t,e),this.j}ja(t,e,n){return this.j={classifications:[]},ca(this,t,n,e),this.j}m(){var t=new is;rs(t,"input_image"),rs(t,"norm_rect"),ss(t,"classifications");const e=new Nr;vn(e,Ci,this.h);const n=new Yr;qr(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),$r(n,"IMAGE:input_image"),$r(n,"NORM_RECT:norm_rect"),Kr(n,"CLASSIFICATIONS:classifications"),n.o(e),ns(t,n),this.g.attachProtoListener("classifications",((t,e)=>{this.j=function(t){const e={classifications:sn(t,Ds,1).map((t=>Zi(nn(t,ls,4)?.g()??[],fn(cn(t,2)),ln(t,3)??"")))};return null!=un(t)&&(e.timestampMs=fn(un(t))),e}(Ns(t)),_o(this,e)})),this.g.attachEmptyPacketListener("classifications",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ca.prototype.classifyForVideo=Ca.prototype.ja,Ca.prototype.classify=Ca.prototype.ia,Ca.prototype.setOptions=Ca.prototype.o,Ca.createFromModelPath=function(t,e){return oa(Ca,t,{baseOptions:{modelAssetPath:e}})},Ca.createFromModelBuffer=function(t,e){return oa(Ca,t,{baseOptions:{modelAssetBuffer:e}})},Ca.createFromOptions=function(t,e){return oa(Ca,t,e)};var Ra=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!0),this.h=new Ri,this.embeddings={embeddings:[]},t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){var e=this.h,n=nn(this.h,Ks,2);return n=n?n.clone():new Ks,void 0!==t.l2Normalize?pn(n,1,t.l2Normalize):"l2Normalize"in t&&Ve(n,1),void 0!==t.quantize?pn(n,2,t.quantize):"quantize"in t&&Ve(n,2),on(e,0,2,n),this.l(t)}na(t,e){return ha(this,t,e),this.embeddings}oa(t,e,n){return ca(this,t,n,e),this.embeddings}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"embeddings_out");const e=new Nr;vn(e,Ii,this.h);const n=new Yr;qr(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),$r(n,"IMAGE:image_in"),$r(n,"NORM_RECT:norm_rect"),Kr(n,"EMBEDDINGS:embeddings_out"),n.o(e),ns(t,n),this.g.attachProtoListener("embeddings_out",((t,e)=>{t=Hs(t),this.embeddings=function(t){return{embeddings:sn(t,Vs,1).map((t=>{const e={headIndex:fn(cn(t,3))??-1,headName:ln(t,4)??""??""};if(void 0!==en(t,Gs,Ze(t,1)))t=qe(t=nn(t,Gs,Ze(t,1)),1,he),e.floatEmbedding=t;else{const n=new Uint8Array(0);e.quantizedEmbedding=nn(t,js,Ze(t,2))?.fa()?.ha()??n}return e})),timestampMs:fn(un(t))}}(t),_o(this,e)})),this.g.attachEmptyPacketListener("embeddings_out",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ra.cosineSimilarity=function(t,e){if(t.floatEmbedding&&e.floatEmbedding)t=ro(t.floatEmbedding,e.floatEmbedding);else{if(!t.quantizedEmbedding||!e.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=ro(no(t.quantizedEmbedding),no(e.quantizedEmbedding))}return t},Ra.prototype.embedForVideo=Ra.prototype.oa,Ra.prototype.embed=Ra.prototype.na,Ra.prototype.setOptions=Ra.prototype.o,Ra.createFromModelPath=function(t,e){return oa(Ra,t,{baseOptions:{modelAssetPath:e}})},Ra.createFromModelBuffer=function(t,e){return oa(Ra,t,{baseOptions:{modelAssetBuffer:e}})},Ra.createFromOptions=function(t,e){return oa(Ra,t,e)};var Ia=class{constructor(t,e,n){this.confidenceMasks=t,this.categoryMask=e,this.qualityScores=n}close(){this.confidenceMasks?.forEach((t=>{t.close()})),this.categoryMask?.close()}};function Da(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function Ba(t){try{const e=new Ia(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return e;t.j(e)}finally{bo(t)}}Ia.prototype.close=Ia.prototype.close;var Ua=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Gi,this.v=new Di,on(this.h,0,3,this.v),t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return void 0!==t.displayNamesLocale?Ve(this.h,2,pe(t.displayNamesLocale)):"displayNamesLocale"in t&&Ve(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}P(){!function(t){const e=sn(t.W(),Yr,1).filter((t=>(ln(t,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator")));if(t.s=[],1<e.length)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");1===e.length&&(nn(e[0],Nr,7)?.l()?.g()??new Map).forEach(((e,n)=>{t.s[Number(n)]=ln(e,1)??""}))}(this)}X(t,e,n){const r="function"!=typeof e?e:{};return this.j="function"==typeof e?e:n,Da(this),ha(this,t,r),Ba(this)}Ca(t,e,n,r){const s="function"!=typeof n?n:{};return this.j="function"==typeof n?n:r,Da(this),ca(this,t,s,e),Ba(this)}ta(){return this.s}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect");const e=new Nr;vn(e,ji,this.h);const n=new Yr;qr(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),$r(n,"IMAGE:image_in"),$r(n,"NORM_RECT:norm_rect"),n.o(e),ns(t,n),wo(this,t),this.outputConfidenceMasks&&(ss(t,"confidence_masks"),Kr(n,"CONFIDENCE_MASKS:confidence_masks"),Ao(this,"confidence_masks"),this.g.T("confidence_masks",((t,e)=>{this.confidenceMasks=t.map((t=>ua(this,t,!this.j))),_o(this,e)})),this.g.attachEmptyPacketListener("confidence_masks",(t=>{this.confidenceMasks=[],_o(this,t)}))),this.outputCategoryMask&&(ss(t,"category_mask"),Kr(n,"CATEGORY_MASK:category_mask"),Ao(this,"category_mask"),this.g.S("category_mask",((t,e)=>{this.categoryMask=ua(this,t,!this.j),_o(this,e)})),this.g.attachEmptyPacketListener("category_mask",(t=>{this.categoryMask=void 0,_o(this,t)}))),ss(t,"quality_scores"),Kr(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((t,e)=>{this.qualityScores=t,_o(this,e)})),this.g.attachEmptyPacketListener("quality_scores",(t=>{this.categoryMask=void 0,_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ua.prototype.getLabels=Ua.prototype.ta,Ua.prototype.segmentForVideo=Ua.prototype.Ca,Ua.prototype.segment=Ua.prototype.X,Ua.prototype.setOptions=Ua.prototype.o,Ua.createFromModelPath=function(t,e){return oa(Ua,t,{baseOptions:{modelAssetPath:e}})},Ua.createFromModelBuffer=function(t,e){return oa(Ua,t,{baseOptions:{modelAssetBuffer:e}})},Ua.createFromOptions=function(t,e){return oa(Ua,t,e)};var Na=class{constructor(t,e,n){this.confidenceMasks=t,this.categoryMask=e,this.qualityScores=n}close(){this.confidenceMasks?.forEach((t=>{t.close()})),this.categoryMask?.close()}};Na.prototype.close=Na.prototype.close;var Ga=class extends _n{constructor(t){super(t)}},ja=[0,hr,hr,hr],Va=[0,er,er,er,er,lr],za=[0,er,er,er,er,lr,er,er],Wa=[0,yr,za],Xa=[0,yr,Wa,yr,ja],Ha=[0,yr,za,yr,ja],qa=[0,yr,za,hr,hr],$a=[0,yr,qa,yr,ja],Ka=[0,er,er,er,er,lr,yr,ja,yr,ja],Ya=[0,er,er,er,er,lr,br],Ja=class extends _n{constructor(t){super(t)}},Za=[0,er,er,lr],Qa=class extends _n{constructor(){super()}};Qa.B=[1];var th=class extends _n{constructor(t){super(t)}},eh=[1,2,3,4,5,6,7,8,9,10,14,15],nh=[0,_r,za,eh,_r,Ha,eh,_r,Wa,eh,_r,Xa,eh,_r,Za,eh,_r,Ya,eh,_r,Va,eh,_r,[0,gr,er,er,er,lr,hr,lr,lr,er,3,yr,ja],eh,_r,qa,eh,_r,$a,eh,er,yr,ja,gr,_r,Ka,eh,_r,[0,vr,Za],eh],rh=[0,gr,hr,hr,lr],sh=class extends _n{constructor(){super()}};sh.B=[1],sh.prototype.g=Mr([0,vr,nh,gr,yr,rh]);var ih=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new Gi,this.v=new Di,on(this.h,0,3,this.v),t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}X(t,e,n,r){const s="function"!=typeof n?n:{};this.j="function"==typeof n?n:r,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.I+1,r=new sh;const i=new th;var o=new Ga;if(gn(o,1,255),on(i,0,12,o),e.keypoint&&e.scribble)throw Error("Cannot provide both keypoint and scribble.");if(e.keypoint){var a=new Ja;pn(a,3,!0),mn(a,1,e.keypoint.x),mn(a,2,e.keypoint.y),an(i,5,eh,a)}else{if(!e.scribble)throw Error("Must provide either a keypoint or a scribble.");for(a of(o=new Qa,e.scribble))pn(e=new Ja,3,!0),mn(e,1,a.x),mn(e,2,a.y),hn(o,Ja,e);an(i,15,eh,o)}hn(r,th,i),this.g.addProtoToStream(r.g(),"drishti.RenderData","roi_in",n),ha(this,t,s);t:{try{const t=new Na(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var h=t;break t}this.j(t)}finally{bo(this)}h=void 0}return h}m(){var t=new is;rs(t,"image_in"),rs(t,"roi_in"),rs(t,"norm_rect_in");const e=new Nr;vn(e,ji,this.h);const n=new Yr;qr(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),$r(n,"IMAGE:image_in"),$r(n,"ROI:roi_in"),$r(n,"NORM_RECT:norm_rect_in"),n.o(e),ns(t,n),wo(this,t),this.outputConfidenceMasks&&(ss(t,"confidence_masks"),Kr(n,"CONFIDENCE_MASKS:confidence_masks"),Ao(this,"confidence_masks"),this.g.T("confidence_masks",((t,e)=>{this.confidenceMasks=t.map((t=>ua(this,t,!this.j))),_o(this,e)})),this.g.attachEmptyPacketListener("confidence_masks",(t=>{this.confidenceMasks=[],_o(this,t)}))),this.outputCategoryMask&&(ss(t,"category_mask"),Kr(n,"CATEGORY_MASK:category_mask"),Ao(this,"category_mask"),this.g.S("category_mask",((t,e)=>{this.categoryMask=ua(this,t,!this.j),_o(this,e)})),this.g.attachEmptyPacketListener("category_mask",(t=>{this.categoryMask=void 0,_o(this,t)}))),ss(t,"quality_scores"),Kr(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((t,e)=>{this.qualityScores=t,_o(this,e)})),this.g.attachEmptyPacketListener("quality_scores",(t=>{this.categoryMask=void 0,_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ih.prototype.segment=ih.prototype.X,ih.prototype.setOptions=ih.prototype.o,ih.createFromModelPath=function(t,e){return oa(ih,t,{baseOptions:{modelAssetPath:e}})},ih.createFromModelBuffer=function(t,e){return oa(ih,t,{baseOptions:{modelAssetBuffer:e}})},ih.createFromOptions=function(t,e){return oa(ih,t,e)};var oh=class extends la{constructor(t,e){super(new ia(t,e),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},this.h=new Vi,t=new ei,on(this.h,0,1,t)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return void 0!==t.displayNamesLocale?Ve(this.h,2,pe(t.displayNamesLocale)):"displayNamesLocale"in t&&Ve(this.h,2),void 0!==t.maxResults?gn(this.h,3,t.maxResults):"maxResults"in t&&Ve(this.h,3),void 0!==t.scoreThreshold?mn(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&Ve(this.h,4),void 0!==t.categoryAllowlist?Je(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&Ve(this.h,5),void 0!==t.categoryDenylist?Je(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&Ve(this.h,6),this.l(t)}F(t,e){return this.j={detections:[]},ha(this,t,e),this.j}G(t,e,n){return this.j={detections:[]},ca(this,t,n,e),this.j}m(){var t=new is;rs(t,"input_frame_gpu"),rs(t,"norm_rect"),ss(t,"detections");const e=new Nr;vn(e,zi,this.h);const n=new Yr;qr(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),$r(n,"IMAGE:input_frame_gpu"),$r(n,"NORM_RECT:norm_rect"),Kr(n,"DETECTIONS:detections"),n.o(e),ns(t,n),this.g.attachProtoVectorListener("detections",((t,e)=>{for(const e of t)t=Ts(e),this.j.detections.push(Qi(t));_o(this,e)})),this.g.attachEmptyPacketListener("detections",(t=>{_o(this,t)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function ah(t){t.landmarks=[],t.worldLandmarks=[],t.v=void 0}function hh(t){try{const e=new class{constructor(t,e,n){this.landmarks=t,this.worldLandmarks=e,this.g=n}close(){this.g?.forEach((t=>{t.close()}))}}(t.landmarks,t.worldLandmarks,t.v);if(!t.s)return e;t.s(e)}finally{bo(t)}}oh.prototype.detectForVideo=oh.prototype.G,oh.prototype.detect=oh.prototype.F,oh.prototype.setOptions=oh.prototype.o,oh.createFromModelPath=async function(t,e){return oa(oh,t,{baseOptions:{modelAssetPath:e}})},oh.createFromModelBuffer=function(t,e){return oa(oh,t,{baseOptions:{modelAssetBuffer:e}})},oh.createFromOptions=function(t,e){return oa(oh,t,e)};var ch=class extends la{constructor(t,e){super(new ia(t,e),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,this.h=new $i,t=new ei,on(this.h,0,1,t),this.C=new Hi,on(this.h,0,3,this.C),this.j=new Wi,on(this.h,0,2,this.j),gn(this.j,4,1),mn(this.j,2,.5),mn(this.C,2,.5),mn(this.h,4,.5)}get baseOptions(){return nn(this.h,ei,1)}set baseOptions(t){on(this.h,0,1,t)}o(t){return"numPoses"in t&&gn(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&mn(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&mn(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&mn(this.C,2,t.minPosePresenceConfidence??.5),"outputSegmentationMasks"in t&&(this.outputSegmentationMasks=t.outputSegmentationMasks??!1),this.l(t)}F(t,e,n){const r="function"!=typeof e?e:{};return this.s="function"==typeof e?e:n,ah(this),ha(this,t,r),hh(this)}G(t,e,n,r){const s="function"!=typeof n?n:{};return this.s="function"==typeof n?n:r,ah(this),ca(this,t,s,e),hh(this)}m(){var t=new is;rs(t,"image_in"),rs(t,"norm_rect"),ss(t,"normalized_landmarks"),ss(t,"world_landmarks"),ss(t,"segmentation_masks");const e=new Nr;vn(e,Yi,this.h);const n=new Yr;qr(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),$r(n,"IMAGE:image_in"),$r(n,"NORM_RECT:norm_rect"),Kr(n,"NORM_LANDMARKS:normalized_landmarks"),Kr(n,"WORLD_LANDMARKS:world_landmarks"),n.o(e),ns(t,n),wo(this,t),this.g.attachProtoVectorListener("normalized_landmarks",((t,e)=>{this.landmarks=[];for(const e of t)t=Ps(e),this.landmarks.push(to(t));_o(this,e)})),this.g.attachEmptyPacketListener("normalized_landmarks",(t=>{this.landmarks=[],_o(this,t)})),this.g.attachProtoVectorListener("world_landmarks",((t,e)=>{this.worldLandmarks=[];for(const e of t)t=Fs(e),this.worldLandmarks.push(eo(t));_o(this,e)})),this.g.attachEmptyPacketListener("world_landmarks",(t=>{this.worldLandmarks=[],_o(this,t)})),this.outputSegmentationMasks&&(Kr(n,"SEGMENTATION_MASK:segmentation_masks"),Ao(this,"segmentation_masks"),this.g.T("segmentation_masks",((t,e)=>{this.v=t.map((t=>ua(this,t,!this.s))),_o(this,e)})),this.g.attachEmptyPacketListener("segmentation_masks",(t=>{this.v=[],_o(this,t)}))),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ch.prototype.detectForVideo=ch.prototype.G,ch.prototype.detect=ch.prototype.F,ch.prototype.setOptions=ch.prototype.o,ch.createFromModelPath=function(t,e){return oa(ch,t,{baseOptions:{modelAssetPath:e}})},ch.createFromModelBuffer=function(t,e){return oa(ch,t,{baseOptions:{modelAssetBuffer:e}})},ch.createFromOptions=function(t,e){return oa(ch,t,e)},ch.POSE_CONNECTIONS=na([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);var uh="undefined"!=typeof Float32Array?Float32Array:Array;function lh(t,e){var n=new uh(3);!function(t,e){var n=e[0],r=e[1],s=e[2],i=e[4],o=e[5],a=e[6],h=e[8],c=e[9],u=e[10];t[0]=Math.hypot(n,r,s),t[1]=Math.hypot(i,o,a),t[2]=Math.hypot(h,c,u)}(n,e);var r=1/n[0],s=1/n[1],i=1/n[2],o=e[0]*r,a=e[1]*s,h=e[2]*i,c=e[4]*r,u=e[5]*s,l=e[6]*i,f=e[8]*r,d=e[9]*s,p=e[10]*i,g=o+u+p,m=0;return g>0?(m=2*Math.sqrt(g+1),t[3]=.25*m,t[0]=(l-d)/m,t[1]=(f-h)/m,t[2]=(a-c)/m):o>u&&o>p?(m=2*Math.sqrt(1+o-u-p),t[3]=(l-d)/m,t[0]=.25*m,t[1]=(a+c)/m,t[2]=(f+h)/m):u>p?(m=2*Math.sqrt(1+u-o-p),t[3]=(f-h)/m,t[0]=(a+c)/m,t[1]=.25*m,t[2]=(l+d)/m):(m=2*Math.sqrt(1+p-o-u),t[3]=(a-c)/m,t[0]=(f+h)/m,t[1]=(l+d)/m,t[2]=.25*m),t}function fh(){var t=new uh(3);return uh!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function dh(t,e,n){var r=new uh(3);return r[0]=t,r[1]=e,r[2]=n,r}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});function ph(){var t=new uh(4);return uh!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}fh(),function(){var t,e=(t=new uh(4),uh!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var gh;let mh;fh(),dh(1,0,0),dh(0,1,0),ph(),ph(),gh=new uh(9),uh!=Float32Array&&(gh[1]=0,gh[2]=0,gh[3]=0,gh[5]=0,gh[6]=0,gh[7]=0),gh[0]=1,gh[4]=1,gh[8]=1;const yh=10;let vh;function _h(t,e,n){return{x:t.x*e,y:t.y*n,z:t.z}}function wh(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}function Ah(t,e,n){if(null==(null==t?void 0:t.faceLandmarks)||null==(null==t?void 0:t.faceLandmarks[0]))return{error:"No landmarks detected!",ipd:0,faceWidth:0};const r=t.facialTransformationMatrixes[0].data,s=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(fh(),r),i=function(t,e){let n=e[0],r=e[1],s=e[2],i=e[3],o=r*r,a=s*s,h=i*i,c=n*n+o+a+h,u=n*i-r*s;return u>.499995*c?(t[0]=Math.PI/2*180/Math.PI,t[1]=2*Math.atan2(r,n)*180/Math.PI,t[2]=0/Math.PI):u<-.499995*c?(t[0]=-Math.PI/2*180/Math.PI,t[1]=2*Math.atan2(r,n)*180/Math.PI,t[2]=0/Math.PI):(t[0]=180*Math.asin(2*(n*s-i*r))/Math.PI,t[1]=180*Math.atan2(2*(n*i+r*s),1-2*(a+h))/Math.PI,t[2]=180*Math.atan2(2*(n*r+s*i),1-2*(o+a))/Math.PI),t}(fh(),lh(ph(),r)),o=t.faceLandmarks[0],a=wh(_h(o[468],e,n),_h(o[473],e,n));if(a<yh)return{error:"User is too far!",ipd:0,faceWidth:0,translation:s,rotation:i};const h=_h(o[469],e,n),c=_h(o[470],e,n),u=_h(o[471],e,n),l=_h(o[472],e,n),f=_h(o[474],e,n),d=_h(o[475],e,n),p=_h(o[476],e,n),g=_h(o[477],e,n),m=[wh(h,u),wh(c,l),wh(f,p),wh(d,g)],y=.5*(m[0]+m[2]);if(Math.abs(m[0]-m[2])>1.5)return{error:"User is not aligned, iris diff: "+(m[0]-m[2]),ipd:0,faceWidth:0,translation:s,rotation:i};const v=_h(o[34],e,n),_=wh(_h(o[264],e,n),v);let w=0;const A=_/Math.max(e,n);return A<.12?w=58*(.12-A):A>.2&&(w=58*(A-.2)),{ipd:11.7/y*a,faceWidth:11.7/y*_+w,translation:s,rotation:i}}t.initialize=function(t,n=null){return e(this,void 0,void 0,(function*(){const e=yield ho.forVisionTasks(t);mh=yield Ta.createFromOptions(e,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task",delegate:"CPU"},outputFaceBlendshapes:!1,outputFacialTransformationMatrixes:!0,runningMode:"VIDEO"}),n&&(vh=n)}))},t.predict=function(t){return e(this,void 0,void 0,(function*(){return Ah(null==mh?void 0:mh.detectForVideo(vh,t),null==vh?void 0:vh.videoWidth,null==vh?void 0:vh.videoHeight)}))},t.setVideoElement=function(t){return e(this,void 0,void 0,(function*(){vh=t}))}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shopar-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-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",
|