@neurodyn/core-ar 0.2.10 → 0.3.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.
@@ -1,4 +1,4 @@
1
- (()=>{"use strict";let e,t,i;function r(e,t){let i;try{i=new URL(e)}catch{throw TypeError(`${t} must be an absolute HTTP(S) URL`)}if("http:"!==i.protocol&&"https:"!==i.protocol)throw TypeError(`${t} must be an absolute HTTP(S) URL`);return i.origin}function n(){if(!e)throw Error("Core AR widget runtime is not configured");return e}function o(){return"u"<typeof navigator?"":navigator.userAgent||navigator.vendor||""}function a(){if("u"<typeof window||"u"<typeof navigator)return!1;let e="MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;return(/iPad|iPhone|iPod/.test(o())||e)&&!("MSStream"in window)}function s(){if("u"<typeof window||"u"<typeof navigator)return!1;let e=navigator.maxTouchPoints>1,t=window.matchMedia?.("(pointer: coarse)").matches??!1,i=/Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(o());return e&&t&&(i||a())}function d(){let e=o();return[[/edg/i,"Microsoft Edge"],[/trident/i,"Microsoft Internet Explorer"],[/firefox|fxios/i,"Mozilla Firefox"],[/opr\//i,"Opera"],[/ucbrowser/i,"UC Browser"],[/samsungbrowser/i,"Samsung Browser"],[/chrome|chromium|crios/i,"Google Chrome"],[/safari/i,"Apple Safari"]].find(([t])=>t.test(e))?.[1]??"Other"}function l(){let e=function(){let e=o(),t=e.match(/\bOS (\d+)/)?.[1]??e.match(/Version\/(\d+)/)?.[1];if(!t)return null;let i=Number.parseInt(t,10);return Number.isNaN(i)?null:i}();return null!==e&&e>=17}function c(e){let t;try{t=new URL(e)}catch{throw TypeError("Native AR asset URL must be absolute HTTP(S)")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw TypeError("Native AR asset URL must be absolute HTTP(S)");return t.href}function u(e,t){let i=c(e.glbUrl),r=c(e.usdzUrl),n=encodeURIComponent(i),o=`intent://arvr.google.com/scene-viewer/1.0?file=${n}&resizable=false${"wall"===t||"ceiling"===t?"&enable_vertical_placement=true":""}&mode=ar_preferred#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;end;`,s=`${r}#allowsContentScaling=0`;return a()?s:o}function g(e,t=0){let i=document.createElement("a"),r=document.createElement("img");i.rel="ar",i.href=e,i.hidden=!0,r.alt="",r.hidden=!0,i.appendChild(r),document.body.appendChild(i),window.setTimeout(()=>{i.click(),i.remove()},t)}function m(e,t,i){let r=function(e,t,i){let{brand:r}=i??n();if(a()){let i=new URL("https://appclip.apple.com/id");return i.searchParams.set("p","com.us.vizbl.Clip"),i.searchParams.set("tinuuid",e),t&&i.searchParams.set("hid",t),i.searchParams.set("region","arizo"===r?"ru":"en"),i.toString()}return`intent:/${window.location.pathname}#Intent;scheme=open;package=com.us.vizbl;end`}(e,t,i);window.self===window.top||d().toLowerCase().includes("edge")?window.location.assign(r):window.open(r,"_top")}function h(e,t,i=!1,r){let{viewerOrigin:o}=r??n(),a=new URL("/ar/index.html",o);return a.searchParams.set("tinuuid",e),t&&a.searchParams.set("hid",t),i&&a.searchParams.set("appview","true"),a.toString()}function p(){let e=new WeakMap;return function(t){let i=e.get(t);i?.cleanup?.();let r={revision:(i?.revision??0)+1};return e.set(t,r),{isCurrent:()=>e.get(t)===r,register(i){let n=!1,o=()=>{n||(n=!0,i())};return e.get(t)!==r?(o(),o):(r.cleanup=o,()=>{e.get(t)===r&&e.delete(t),o()})}}}}let f=0,b={arizo:{conjunction:"и",privacyLabel:"Политика конфиденциальности",privacyUrl:"https://arizo.ru/privacy-policy/",termsLabel:"Условия использования",termsUrl:"https://arizo.ru/terms-of-use/"},vizbl:{conjunction:"and",privacyLabel:"Privacy Policy",privacyUrl:"https://vizbl.com/legal/privacy-policy",termsLabel:"Terms of Use",termsUrl:"https://vizbl.com/legal/terms-of-use"}};function v(){return window.QRCode}function w(e,t,i){let r=document.createElement("a");return r.dataset.vizblLegalLink=e,r.href=t,r.rel="noopener noreferrer",r.target="_blank",r.textContent=i,Object.assign(r.style,{color:"inherit",textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap"}),r}async function y(e,r="vizblQrModal",o,a){let s,d=++f;i?.(),document.querySelectorAll("[data-vizbl-qr-modal]").forEach(e=>e.remove());let l=function(e){let{brand:t,viewerOrigin:i}=e??n(),r="arizo"===t,o=document.createElement("div");o.dataset.vizblQrModal="",o.setAttribute("aria-label","View object in augmented reality"),o.setAttribute("aria-modal","true"),o.setAttribute("role","dialog"),Object.assign(o.style,{alignItems:"center",backgroundColor:"rgba(0,0,0,0.25)",display:"none",height:"100%",justifyContent:"center",left:"0",position:"fixed",top:"0",width:"100%",zIndex:"9999"});let a=document.createElement("div");Object.assign(a.style,{backgroundColor:"#fff",borderRadius:"12px",boxSizing:"border-box",color:"#000",fontFamily:"Inter, sans-serif",minHeight:"372px",padding:"48px 52px 40px",position:"relative",width:"min(460px, calc(100vw - 32px))"});let s=document.createElement("button");s.type="button",s.dataset.vizblQrClose="",s.setAttribute("aria-label","Close QR code"),s.textContent="\xd7",Object.assign(s.style,{background:"none",border:"none",color:"#AEB1B7",cursor:"pointer",fontSize:"24px",position:"absolute",right:"20px",top:"20px"});let d=document.createElement("div");d.dataset.vizblQrCode="",d.style.margin="0 auto",d.style.width="fit-content";let l=document.createElement("p");l.textContent=r?"Отсканируйте этот QR-код камерой телефона, чтобы примерить объект в интерьере":"Scan this QR code with your phone camera to view the object in Augmented Reality",Object.assign(l.style,{fontSize:"16px",fontWeight:"500",lineHeight:"24px",margin:"24px 0 0",textAlign:"center"});let c=document.createElement("p");Object.assign(c.style,{color:"#93979F",fontSize:"12px",lineHeight:"16px",margin:"12px 0 0",textAlign:"center"});let u=b[t],g=w("terms",u.termsUrl,u.termsLabel),m=w("privacy",u.privacyUrl,u.privacyLabel);c.append(r?"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.":"*Requires an AR-compatible device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome.",document.createElement("br"),g,` ${u.conjunction} `,m);let h=document.createElement("p");h.textContent=`Powered by ${r?"Arizo":"Vizbl"}`,Object.assign(h.style,{color:"#93979F",fontSize:"11px",letterSpacing:"1.5px",margin:"24px 0 4px",textAlign:"center",textTransform:"uppercase"});let p=document.createElement("a");p.dataset.vizblBrandLink="",p.href=r?"https://arizo.ru":"https://vizbl.com",p.style.display="block",p.style.textAlign="center";let f=document.createElement("img");return f.alt=`${r?"Arizo":"Vizbl"} logo`,f.src=`${i}/${r?"logoArizo.svg":"logo.svg"}`,f.height=20,f.width=r?76:60,p.appendChild(f),a.append(s,d,l,c,h,p),o.appendChild(a),o}(a);l.id=r;let c=l.querySelector("[data-vizbl-qr-close]"),u=Array.from(l.querySelectorAll("button, a[href]")),g=!1,m=e=>{if("Escape"===e.key){e.preventDefault(),s();return}if("Tab"!==e.key||0===u.length)return;let t=u[0],i=u.at(-1)??t;e.shiftKey&&(document.activeElement===t||!l.contains(document.activeElement))?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),t.focus())};i=s=()=>{g||(g=!0,document.removeEventListener("keydown",m),l.remove(),i===s&&(i=void 0),o?.focus({preventScroll:!0}))},c?.addEventListener("click",s),l.addEventListener("click",e=>{e.target===l&&s()}),document.body.appendChild(l),document.addEventListener("keydown",m),function(){let e="https://fonts.googleapis.com/css2?family=Inter&display=swap";if(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(t=>t.href===e||t.getAttribute("href")===e))return;let t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}();try{let i=await function(e){let i=v();if(i)return Promise.resolve(i);if(t)return t;let{qrCodeScriptUrl:r}=e??n();return t=new Promise((e,i)=>{let n,o=document.createElement("script"),a=()=>{n();let r=v();r?e(r):(o.remove(),t=void 0,i(Error("QR code runtime did not expose QRCode")))},s=()=>{n(),o.remove(),t=void 0,i(Error("Failed to load QR code runtime"))};n=()=>{o.removeEventListener("load",a),o.removeEventListener("error",s)},o.addEventListener("load",a,{once:!0}),o.addEventListener("error",s,{once:!0}),o.src=r,o.async=!0,o.dataset.vizblQrScript="true",document.head.appendChild(o)})}(a);if(d!==f||!l.isConnected)return s(),s;let r=l.querySelector("[data-vizbl-qr-code]");return r&&new i(r,{correctLevel:i.CorrectLevel.L,height:148,text:e,width:148}),l.style.display="flex",c?.focus({preventScroll:!0}),s}catch(e){throw s(),e}}class E extends Error{code;constructor(e){super(e),this.code=e,this.name="WidgetRuntimeError"}}function A(e){return e.runtimeConfig??n()}function C(e,t,i={}){let r=new URL(t,e);for(let[e,t]of Object.entries(i))t&&r.searchParams.set(e,t);return r.toString()}async function I(e,t,i){try{return await (i.fetchImpl??i.runtimeConfig?.fetchImpl??n().fetchImpl)(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw e;throw new E("NETWORK_ERROR")}}async function x(e){try{let t=await e.json();return[t.code,t.error,t.message].flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).join(" ").toLowerCase()}catch{return""}}async function O(e,t){let i=await x(e);return new E(429===e.status?"RATE_LIMITED":e.status>=500?"API_UNAVAILABLE":404===e.status&&"object"===t?"OBJECT_NOT_FOUND":i.includes("domain")||i.includes("origin")?"DOMAIN_NOT_ALLOWED":i.includes("revoked")?"KEY_REVOKED":i.includes("expired")?"activation"===t?"KEY_EXPIRED":"SESSION_EXPIRED":i.includes("policy")||i.includes("not available for this object")?"POLICY_DENIED":401===e.status||403===e.status?"activation"===t?"INVALID_KEY":"SESSION_EXPIRED":"REQUEST_FAILED")}async function S(e){try{return await e.json()}catch{throw new E("INVALID_RESPONSE")}}function k(e){if(!e||"object"!=typeof e||"string"!=typeof e.token||!e.token.trim()||"string"!=typeof e.sid||!e.sid.trim()||"number"!=typeof e.expiresIn||!Number.isFinite(e.expiresIn)||e.expiresIn<=0)throw new E("INVALID_RESPONSE");return e}async function T(e,t={}){let{apiOrigin:i}=A(t),r=await I(C(i,"/public/widget/activate-core",{mode:t.mode}),{cache:"no-store",headers:{"x-api-key":e},method:"POST"},t);if(!r.ok)throw await O(r,"activation");let n=await S(r);if("string"!=typeof n.productType)throw new E("INVALID_RESPONSE");return{...k(n.widgetSession),productType:n.productType}}async function L(e,t,i={}){let{apiOrigin:r}=A(i),n=await I(`${r}/public/widget/token`,{body:JSON.stringify({token:t,...i.mode?{mode:i.mode}:{}}),cache:"no-store",headers:{"Content-Type":"application/json","x-api-key":e},method:"POST"},i);if(!n.ok)throw await O(n,"token");return k(await S(n))}async function z(e,t,i={}){let{apiOrigin:r}=A(i),n=await I(C(r,`/public/objects/by-tinuuid/${encodeURIComponent(e)}`,{variantId:i.variantId}),{cache:"no-store",headers:{"x-widget-session-token":t},method:"GET"},i);if(!n.ok)throw await O(n,"object");let o=await S(n);if(!o||"object"!=typeof o||Array.isArray(o))throw new E("INVALID_RESPONSE");return o}async function R(e,t,i,r={}){let{apiOrigin:n}=A(r),o=await I(`${n}/public/widget/events`,{body:JSON.stringify({event:e,...i?{objectId:i}:{},...r.variantId?{variantId:r.variantId}:{},timestamp:new Date().toISOString()}),cache:"no-store",headers:{"Content-Type":"application/json","x-widget-session-token":t},keepalive:!0,method:"POST"},r);if(!o.ok)throw await O(o,"event");let a=await S(o);if(!a||"object"!=typeof a||Array.isArray(a)||"boolean"!=typeof a.ok)throw new E("INVALID_RESPONSE")}async function N(e,t,i){let r=i??n(),{fetchImpl:o,legacyApiOrigin:a}=r,s=await I(`${a}/obj/Fetch`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"},{fetchImpl:o,runtimeConfig:r,signal:t});if(!s.ok)throw await O(s,"object");let d=await S(s);if(!d||"object"!=typeof d||Array.isArray(d))throw new E("INVALID_RESPONSE");return d}async function P(e,t){let{fetchImpl:i,legacyApiOrigin:r}=t??n();await i(`${r}/obj/IncrViews`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"})}function D(e){try{let t=e?.();t instanceof Promise&&t.catch(()=>void 0)}catch{}}let j=p();function _(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function U(e,t={}){let i,r,n=j(e),o=e.getAttribute("data-native-link"),c=e.dataset.objectTinuuid?.trim(),p=e.dataset.objectHid?.trim()||void 0;if(!c)throw Error("Object ID is required");_(t.signal);let f=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),b=t.object??await f(c,t.signal);if(_(t.signal),!n.isCurrent())return()=>void 0;let v=p?b.materials.find(e=>e.hid===p):b.materials[0];if(!v?.native?.glbUrl||!v.native.usdzUrl)throw Error("Native AR assets are unavailable");let w=u(v.native,b.type),E=s(),A=!1,C=0;e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let I=()=>t.trackView?t.trackView():P(c,t.runtimeConfig),x=i=>{i.preventDefault();let o=++C;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??h(c,p,!0,t.runtimeConfig)).then(i=>{if(o===C&&n.isCurrent())return D(()=>t.onAction?.("interacted")),y(i,`vizbl-${c}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==C||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},O=async e=>{let i;if(i=d().toLowerCase(),["firefox","edge","opera"].some(e=>i.includes(e))){if(e.preventDefault(),A)return;A=!0,D(()=>t.onAction?.("ar_launched"));try{await Promise.resolve(I()).catch(()=>void 0)}finally{A=!1,a()&&l()?m(c,p,t.runtimeConfig):g(w)}return}D(()=>t.onAction?.("ar_launched")),D(I),a()&&l()?(e.preventDefault(),m(c,p,t.runtimeConfig)):g(w)};return E?(e.dataset.nativeLink=w,e.addEventListener("click",O)):e.addEventListener("click",x),n.register(()=>{C+=1,e.removeEventListener("click",x),e.removeEventListener("click",O),r?.(),i?.remove(),null===o?e.removeAttribute("data-native-link"):e.setAttribute("data-native-link",o)})}var V=!1;if("u">typeof window){var M={get passive(){V=!0;return}};window.addEventListener("testPassive",null,M),window.removeEventListener("testPassive",null,M)}var $="u">typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),B=[],q=!1,H=-1,W=void 0,F=void 0,K=void 0,Q=function(e){return B.some(function(t){return!!(t.options.allowTouchMove&&t.options.allowTouchMove(e))})},Y=function(e){var t=e||window.event;return!!Q(t.target)||t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1)},X=function(e){if(void 0===K){var t=!!e&&!0===e.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(t&&i>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);K=document.body.style.paddingRight,document.body.style.paddingRight=r+i+"px"}}void 0===W&&(W=document.body.style.overflow,document.body.style.overflow="hidden")},J=function(){void 0!==K&&(document.body.style.paddingRight=K,K=void 0),void 0!==W&&(document.body.style.overflow=W,W=void 0)},Z=function(){if(void 0!==F){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=F.position,document.body.style.top=F.top,document.body.style.left=F.left,window.scrollTo(t,e),F=void 0}},G=function(e,t){var i=e.targetTouches[0].clientY-H;return!Q(e.target)&&(t&&0===t.scrollTop&&i>0?Y(e):t&&t.scrollHeight-t.scrollTop<=t.clientHeight&&i<0?Y(e):(e.stopPropagation(),!0))},ee=function(e,t){e?!B.some(function(t){return t.targetElement===e})&&(B=[].concat(function(e){if(!Array.isArray(e))return Array.from(e);for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}(B),[{targetElement:e,options:t||{}}]),$?window.requestAnimationFrame(function(){if(void 0===F){F={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var e=window,t=e.scrollY,i=e.scrollX,r=e.innerHeight;document.body.style.position="fixed",document.body.style.top=-t,document.body.style.left=-i,setTimeout(function(){return window.requestAnimationFrame(function(){var e=r-window.innerHeight;e&&t>=r&&(document.body.style.top=-(t+e))})},300)}}):X(t),$&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(H=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&G(t,e)},q||(document.addEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!0))):console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},et=function(e){e?(B=B.filter(function(t){return t.targetElement!==e}),$&&(e.ontouchstart=null,e.ontouchmove=null,q&&0===B.length&&(document.removeEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!1)),$?Z():J()):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};let ei=["cm","inch"],er=["x","y","z"],en=[...er],eo="vizbl_viewer",ea=p();function es(e){return e&&ei.includes(e)?e:"inch"}function ed(e){if(!e)return en;let t=Array.from(new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(e=>er.includes(e))));return t.length>0?t:en}function el(e){let t=new URL("/model-viewer",e.modelViewerOrigin??n().modelViewerOrigin),i=e.dimensionAxes??en;t.searchParams.set("tinuuid",e.tinuuid),e.hid&&t.searchParams.set("hid",e.hid),t.searchParams.set("size-type",e.sizeType),i.length<en.length&&t.searchParams.set("dimension-axes",i.join(",")),e.cameraOrbit&&t.searchParams.set("camera-orbit",e.cameraOrbit),e.minCameraOrbit&&t.searchParams.set("min-camera-orbit",e.minCameraOrbit),e.maxCameraOrbit&&t.searchParams.set("max-camera-orbit",e.maxCameraOrbit),e.lang&&t.searchParams.set("lang",e.lang);let r=new URLSearchParams;return e.apiKey&&r.set("api-key",e.apiKey),e.mode&&r.set("mode",e.mode),e.widgetSessionToken&&r.set("widget-session-token",e.widgetSessionToken),t.hash=r.toString(),t.toString()}let ec=p();function eu(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function eg(e,t={}){let i,r,n=ec(e),o=e.getAttribute("href"),a=e.getAttribute("rel"),d=e.dataset.objectTinuuid?.trim(),l=e.dataset.objectHid?.trim()||void 0;if(!d)throw Error("Object ID is required");eu(t.signal);let c=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),g=t.object??await c(d,t.signal);if(eu(t.signal),!n.isCurrent())return()=>void 0;let m=l?g.materials.find(e=>e.hid===l):g.materials[0];if(!m?.native?.glbUrl||!m.native.usdzUrl)throw Error("Native AR assets are unavailable");let p=u(m.native,g.type),f=s(),b=0;e.rel="ar",e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let v=i=>{i.preventDefault();let o=++b;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??h(d,l,!1,t.runtimeConfig)).then(i=>{if(o===b&&n.isCurrent())return D(()=>t.onAction?.("interacted")),y(i,`vizbl-${d}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==b||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},w=()=>{D(t.trackView??(()=>P(d,t.runtimeConfig))),D(()=>t.onAction?.("ar_launched"))};return f?(e.href=p,e.addEventListener("click",w)):(e.href="#",e.addEventListener("click",v)),n.register(()=>{b+=1,e.removeEventListener("click",v),e.removeEventListener("click",w),r?.(),i?.remove(),null===o?e.removeAttribute("href"):e.setAttribute("href",o),null===a?e.removeAttribute("rel"):e.setAttribute("rel",a)})}let em=["advanced-ar","ar-one-click","ar-viewer"],eh={arizo:"arizo-core",vizbl:"vizbl-core"},ep=new Set(["core-ar","core-ar-shopify"]),ef={arizo:{"advanced-ar":"Посмотреть в расширенной AR","ar-one-click":"Посмотреть в AR","ar-viewer":"Посмотреть в 3D и AR"},vizbl:{"advanced-ar":"View in advanced AR","ar-one-click":"View in AR","ar-viewer":"View in 3D & AR"}},eb={"advanced-ar":"advanced-ar-view","ar-one-click":"ar-view","ar-viewer":"ar-viewer"},ev=["api-key","camera-orbit","dev","dimension-axes","max-camera-orbit","min-camera-orbit","object-id","size-type","trigger-class","type","variant-id"],ew=new Set(["API_UNAVAILABLE","INVALID_RESPONSE","NETWORK_ERROR","REQUEST_FAILED","SESSION_EXPIRED"]),ey="core-ar-widget-styles";class eE extends Error{code;constructor(e){super(e),this.code=e,this.name="CoreArWidgetComponentError"}}function eA(e){return em.includes(e)}function eC(e,t){let i=Array.isArray(e.materials)?e.materials:[],r=t?i.find(e=>e.hid===t):i[0];if(!r)throw new eE(t?"VARIANT_NOT_FOUND":"MODEL_UNAVAILABLE");return r}function eI(e,t){if("ar-one-click"===e&&t.policy?.instantArView===!1)throw new eE("POLICY_DENIED")}let ex="u"<typeof HTMLElement?class{}:HTMLElement;class eO extends ex{static get observedAttributes(){return[...ev]}get triggerClass(){return this.getAttribute("trigger-class")??""}set triggerClass(e){let t="string"==typeof e?e.trim():"";t?this.setAttribute("trigger-class",t):this.removeAttribute("trigger-class")}get unstyled(){return this.hasAttribute("unstyled")}set unstyled(e){this.toggleAttribute("unstyled",!!e)}abortController;actionResetTimer;cleanup;customLabelNodes=null;initializationRevision=0;object;queued=!1;session;trigger;variantId;widgetMode;connectedCallback(){!function(){if(document.getElementById(ey))return;let e=document.createElement("style");e.id=ey,e.textContent=`
1
+ (()=>{"use strict";var e,t,r,i={2585(e,t,r){r.d(t,{_:()=>i});function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,o),r.exports}o.m=i,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},s=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);o.r(r);var i={};a=a||[null,s({}),s([]),s(s)];for(var n=2&t&&e;("object"==typeof n||"function"==typeof n)&&!~a.indexOf(n);n=s(n))Object.getOwnPropertyNames(n).forEach(t=>{i[t]=()=>e[t]});return i.default=()=>e,o.d(r,i),r},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>"core-ar.chunk."+({117:"c3761997",548:"7a932efa",634:"09fa4463",886:"c15d19d9",986:"f57ba10e"})[e]+".min.js",o.miniCssF=e=>""+e+".css",o.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},o.l=function(e,t,r,i){if(l[e])return void l[e].push(t);if(void 0!==r)for(var n,a,s=document.getElementsByTagName("script"),c=0;c<s.length;c++){var d=s[c];if(d.getAttribute("src")==e||d.getAttribute("data-rspack")=="@neurodyn/core-ar:"+r){n=d;break}}n||(a=!0,(n=document.createElement("script")).timeout=120,o.nc&&n.setAttribute("nonce",o.nc),n.setAttribute("data-rspack","@neurodyn/core-ar:"+r),n.src=e),l[e]=[t];var u=function(t,r){n.onerror=n.onload=null,clearTimeout(g);var i=l[e];if(delete l[e],n.parentNode&&n.parentNode.removeChild(n),i&&i.forEach(function(e){return e(r)}),t)return t(r)},g=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),a&&document.head.appendChild(n)},o.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nc=void 0,o.g.importScripts&&(c=o.g.location+"");var a,s,l,c,d=o.g.document;if(!c&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(c=d.currentScript.src),!c)){var u=d.getElementsByTagName("script");if(u.length)for(var g=u.length-1;g>-1&&(!c||!/^http(s?):/.test(c));)c=u[g--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");o.p=c=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e={964:0},o.f.j=function(t,r){var i=o.o(e,t)?e[t]:void 0;if(0!==i)if(i)r.push(i[2]);else{var n=new Promise((r,n)=>i=e[t]=[r,n]);r.push(i[2]=n);var a=o.p+o.u(t),s=Error();o.l(a,function(r){if(o.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+a+")",s.name="ChunkLoadError",s.type=n,s.request=a,i[1](s)}},"chunk-"+t,t)}},t=(t,r)=>{var i,n,[a,s,l]=r,c=0;if(a.some(t=>0!==e[t])){for(i in s)o.o(s,i)&&(o.m[i]=s[i]);l&&l(o)}for(t&&t(r);c<a.length;c++)n=a[c],o.o(e,n)&&e[n]&&e[n][0](),e[n]=0},(r=self.webpackChunk_neurodyn_core_ar=self.webpackChunk_neurodyn_core_ar||[]).forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r)),(()=>{let e,t,r,i;var n=o(2585);function a(e,t){let r;try{r=new URL(e)}catch{throw TypeError(`${t} must be an absolute HTTP(S) URL`)}if("http:"!==r.protocol&&"https:"!==r.protocol)throw TypeError(`${t} must be an absolute HTTP(S) URL`);return r.origin}function s(){if(!e)throw Error("Core AR widget runtime is not configured");return e}function l(){return"u"<typeof navigator?"":navigator.userAgent||navigator.vendor||""}function c(){if("u"<typeof window||"u"<typeof navigator)return!1;let e="MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;return(/iPad|iPhone|iPod/.test(l())||e)&&!("MSStream"in window)}function d(){var e,t;if("u"<typeof window||"u"<typeof navigator)return!1;if(c())return!0;let r=navigator.maxTouchPoints>1,i=(null==(e=(t=window).matchMedia)?void 0:e.call(t,"(pointer: coarse)").matches)??!1,n=/Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(l());return r&&i&&(n||c())}function u(){var e;let t=l();return(null==(e=[[/edg/i,"Microsoft Edge"],[/trident/i,"Microsoft Internet Explorer"],[/firefox|fxios/i,"Mozilla Firefox"],[/opr\//i,"Opera"],[/ucbrowser/i,"UC Browser"],[/samsungbrowser/i,"Samsung Browser"],[/chrome|chromium|crios/i,"Google Chrome"],[/safari/i,"Apple Safari"]].find(e=>{let[r]=e;return r.test(t)}))?void 0:e[1])??"Other"}function g(){let e=function(){var e,t;let r=l(),i=(null==(e=r.match(/\bOS (\d+)/))?void 0:e[1])??(null==(t=r.match(/Version\/(\d+)/))?void 0:t[1]);if(!i)return null;let n=Number.parseInt(i,10);return Number.isNaN(n)?null:n}();return null!==e&&e>=17}function h(e){let t;try{t=new URL(e)}catch{throw TypeError("Native AR asset URL must be absolute HTTP(S)")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw TypeError("Native AR asset URL must be absolute HTTP(S)");return t.href}function m(e,t){let r=h(e.glbUrl),i=h(e.usdzUrl),n=encodeURIComponent(r),o=`intent://arvr.google.com/scene-viewer/1.0?file=${n}&resizable=false${"wall"===t||"ceiling"===t?"&enable_vertical_placement=true":""}&mode=ar_preferred#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;end;`,a=`${i}#allowsContentScaling=0`;return c()?a:o}function v(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=document.createElement("a"),i=document.createElement("img");r.rel="ar",r.href=e,r.hidden=!0,i.alt="",i.hidden=!0,r.appendChild(i),document.body.appendChild(r),window.setTimeout(()=>{r.click(),r.remove()},t)}function p(e,t,r){let i=function(e,t,r){let{brand:i}=r??s();if(c()){let r=new URL("https://appclip.apple.com/id");return r.searchParams.set("p","com.us.vizbl.Clip"),r.searchParams.set("tinuuid",e),t&&r.searchParams.set("hid",t),r.searchParams.set("region","arizo"===i?"ru":"en"),r.toString()}return`intent:/${window.location.pathname}#Intent;scheme=open;package=com.us.vizbl;end`}(e,t,r);window.self===window.top||u().toLowerCase().includes("edge")?window.location.assign(i):window.open(i,"_top")}function f(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,{viewerOrigin:n}=i??s(),o=new URL("/ar/index.html",n);return o.searchParams.set("tinuuid",e),t&&o.searchParams.set("hid",t),r&&o.searchParams.set("appview","true"),o.toString()}function b(){let e=new WeakMap;return function(t){var r;let i=e.get(t);null==i||null==(r=i.cleanup)||r.call(i);let n={revision:((null==i?void 0:i.revision)??0)+1};return e.set(t,n),{isCurrent:()=>e.get(t)===n,register(r){let i=!1,o=()=>{i||(i=!0,r())};return e.get(t)!==n?(o(),o):(n.cleanup=o,()=>{e.get(t)===n&&e.delete(t),o()})}}}}let w=0,y={arizo:{conjunction:"и",privacyLabel:"Политика конфиденциальности",privacyUrl:"https://arizo.ru/privacy-policy/",termsLabel:"Условия использования",termsUrl:"https://arizo.ru/terms-of-use/"},vizbl:{conjunction:"and",privacyLabel:"Privacy Policy",privacyUrl:"https://vizbl.com/legal/privacy-policy",termsLabel:"Terms of Use",termsUrl:"https://vizbl.com/legal/terms-of-use"}};function A(){return window.QRCode}function E(e,t,r){let i=document.createElement("a");return i.dataset.vizblLegalLink=e,i.href=t,i.rel="noopener noreferrer",i.target="_blank",i.textContent=r,Object.assign(i.style,{color:"inherit",textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap"}),i}async function C(e){let i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"vizblQrModal",o=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,l=++w;null==r||r(),document.querySelectorAll("[data-vizbl-qr-modal]").forEach(e=>e.remove());let c=function(e){let{brand:t,viewerOrigin:r}=e??s(),i="arizo"===t,n=document.createElement("div");n.dataset.vizblQrModal="",n.setAttribute("aria-label","View object in augmented reality"),n.setAttribute("aria-modal","true"),n.setAttribute("role","dialog"),Object.assign(n.style,{alignItems:"center",backgroundColor:"rgba(0,0,0,0.25)",display:"none",height:"100%",justifyContent:"center",left:"0",position:"fixed",top:"0",width:"100%",zIndex:"9999"});let o=document.createElement("div");Object.assign(o.style,{backgroundColor:"#fff",borderRadius:"12px",boxSizing:"border-box",color:"#000",fontFamily:"Inter, sans-serif",minHeight:"372px",padding:"48px 52px 40px",position:"relative",width:"min(460px, calc(100vw - 32px))"});let a=document.createElement("button");a.type="button",a.dataset.vizblQrClose="",a.setAttribute("aria-label","Close QR code"),a.textContent="\xd7",Object.assign(a.style,{background:"none",border:"none",color:"#AEB1B7",cursor:"pointer",fontSize:"24px",position:"absolute",right:"20px",top:"20px"});let l=document.createElement("div");l.dataset.vizblQrCode="",l.style.margin="0 auto",l.style.width="fit-content";let c=document.createElement("p");c.textContent=i?"Отсканируйте этот QR-код камерой телефона, чтобы примерить объект в интерьере":"Scan this QR code with your phone camera to view the object in Augmented Reality",Object.assign(c.style,{fontSize:"16px",fontWeight:"500",lineHeight:"24px",margin:"24px 0 0",textAlign:"center"});let d=document.createElement("p");Object.assign(d.style,{color:"#93979F",fontSize:"12px",lineHeight:"16px",margin:"12px 0 0",textAlign:"center"});let u=y[t],g=E("terms",u.termsUrl,u.termsLabel),h=E("privacy",u.privacyUrl,u.privacyLabel);d.append(i?"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.":"*Requires an AR-compatible device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome.",document.createElement("br"),g,` ${u.conjunction} `,h);let m=document.createElement("p");m.textContent=`Powered by ${i?"Arizo":"Vizbl"}`,Object.assign(m.style,{color:"#93979F",fontSize:"11px",letterSpacing:"1.5px",margin:"24px 0 4px",textAlign:"center",textTransform:"uppercase"});let v=document.createElement("a");v.dataset.vizblBrandLink="",v.href=i?"https://arizo.ru":"https://vizbl.com",v.style.display="block",v.style.textAlign="center";let p=document.createElement("img");return p.alt=`${i?"Arizo":"Vizbl"} logo`,p.src=`${r}/${i?"logoArizo.svg":"logo.svg"}`,p.height=20,p.width=i?76:60,v.appendChild(p),o.append(a,l,c,d,m,v),n.appendChild(o),n}(a);c.id=n;let d=c.querySelector("[data-vizbl-qr-close]"),u=Array.from(c.querySelectorAll("button, a[href]")),g=!1,h=e=>{if("Escape"===e.key){e.preventDefault(),i();return}if("Tab"!==e.key||0===u.length)return;let t=u[0],r=u.at(-1)??t;e.shiftKey&&(document.activeElement===t||!c.contains(document.activeElement))?(e.preventDefault(),r.focus()):e.shiftKey||document.activeElement!==r||(e.preventDefault(),t.focus())};r=i=()=>{g||(g=!0,document.removeEventListener("keydown",h),c.remove(),r===i&&(r=void 0),null==o||o.focus({preventScroll:!0}))},null==d||d.addEventListener("click",i),c.addEventListener("click",e=>{e.target===c&&i()}),document.body.appendChild(c),document.addEventListener("keydown",h),function(){let e="https://fonts.googleapis.com/css2?family=Inter&display=swap";if(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(t=>t.href===e||t.getAttribute("href")===e))return;let t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}();try{let r=await function(e){let r=A();if(r)return Promise.resolve(r);if(t)return t;let{qrCodeScriptUrl:i}=e??s();return t=new Promise((e,r)=>{let n,o=document.createElement("script"),a=()=>{n();let i=A();i?e(i):(o.remove(),t=void 0,r(Error("QR code runtime did not expose QRCode")))},s=()=>{n(),o.remove(),t=void 0,r(Error("Failed to load QR code runtime"))};n=()=>{o.removeEventListener("load",a),o.removeEventListener("error",s)},o.addEventListener("load",a,{once:!0}),o.addEventListener("error",s,{once:!0}),o.src=i,o.async=!0,o.dataset.vizblQrScript="true",document.head.appendChild(o)})}(a);if(l!==w||!c.isConnected)return i(),i;let n=c.querySelector("[data-vizbl-qr-code]");return n&&new r(n,{correctLevel:r.CorrectLevel.L,height:148,text:e,width:148}),c.style.display="flex",null==d||d.focus({preventScroll:!0}),i}catch(e){throw i(),e}}class O extends Error{constructor(e){super(e),(0,n._)(this,"code",void 0),this.code=e,this.name="WidgetRuntimeError"}}function S(e){return e.runtimeConfig??s()}function I(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=new URL(t,e);for(let[e,t]of Object.entries(r))t&&i.searchParams.set(e,t);return i.toString()}async function k(e,t,r){try{var i;return await (r.fetchImpl??(null==(i=r.runtimeConfig)?void 0:i.fetchImpl)??s().fetchImpl)(e,{...t,signal:r.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw e;throw new O("NETWORK_ERROR")}}async function T(e){try{let t=await e.json();return[t.code,t.error,t.message].flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).join(" ").toLowerCase()}catch{return""}}async function x(e,t){let r=await T(e);return new O(429===e.status?"RATE_LIMITED":e.status>=500?"API_UNAVAILABLE":404===e.status&&"object"===t?"OBJECT_NOT_FOUND":r.includes("domain")||r.includes("origin")?"DOMAIN_NOT_ALLOWED":r.includes("revoked")?"KEY_REVOKED":r.includes("expired")?"activation"===t?"KEY_EXPIRED":"SESSION_EXPIRED":r.includes("policy")||r.includes("not available for this object")?"POLICY_DENIED":401===e.status||403===e.status?"activation"===t?"INVALID_KEY":"SESSION_EXPIRED":"REQUEST_FAILED")}async function z(e){try{return await e.json()}catch{throw new O("INVALID_RESPONSE")}}function L(e){if(!e||"object"!=typeof e||"string"!=typeof e.token||!e.token.trim()||"string"!=typeof e.sid||!e.sid.trim()||"number"!=typeof e.expiresIn||!Number.isFinite(e.expiresIn)||e.expiresIn<=0)throw new O("INVALID_RESPONSE");return e}async function _(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{apiOrigin:r}=S(t),i=await k(I(r,"/public/widget/activate-core",{mode:t.mode}),{cache:"no-store",headers:{"x-api-key":e},method:"POST"},t);if(!i.ok)throw await x(i,"activation");let n=await z(i);if("string"!=typeof n.productType)throw new O("INVALID_RESPONSE");return{...L(n.widgetSession),productType:n.productType}}async function R(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{apiOrigin:i}=S(r),n=await k(`${i}/public/widget/token`,{body:JSON.stringify({token:t,...r.mode?{mode:r.mode}:{}}),cache:"no-store",headers:{"Content-Type":"application/json","x-api-key":e},method:"POST"},r);if(!n.ok)throw await x(n,"token");return L(await z(n))}async function P(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{apiOrigin:i}=S(r),n=await k(I(i,`/public/objects/by-tinuuid/${encodeURIComponent(e)}`,{variantId:r.variantId}),{cache:"no-store",headers:{"x-widget-session-token":t},method:"GET"},r);if(!n.ok)throw await x(n,"object");let o=await z(n);if(!o||"object"!=typeof o||Array.isArray(o))throw new O("INVALID_RESPONSE");return o}async function j(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},{apiOrigin:n}=S(i),o=await k(`${n}/public/widget/events`,{body:JSON.stringify({event:e,...r?{objectId:r}:{},...i.variantId?{variantId:i.variantId}:{},timestamp:new Date().toISOString()}),cache:"no-store",headers:{"Content-Type":"application/json","x-widget-session-token":t},keepalive:!0,method:"POST"},i);if(!o.ok)throw await x(o,"event");let a=await z(o);if(!a||"object"!=typeof a||Array.isArray(a)||"boolean"!=typeof a.ok)throw new O("INVALID_RESPONSE")}async function N(e,t,r){let i=r??s(),{apiOrigin:n,fetchImpl:o}=i,a=await k(`${n}/catalog/object`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"},{fetchImpl:o,runtimeConfig:i,signal:t});if(!a.ok)throw await x(a,"object");let l=await z(a);if(!l||"object"!=typeof l||Array.isArray(l))throw new O("INVALID_RESPONSE");return l}async function D(e,t){let{apiOrigin:r,fetchImpl:i}=t??s();await i(`${r}/catalog/object/incr-views`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"})}function U(e){try{let t=null==e?void 0:e();t instanceof Promise&&t.catch(()=>void 0)}catch{}}let V=b();function M(e){if(null==e?void 0:e.aborted)throw new DOMException("Aborted","AbortError")}async function $(e){var t,r,i;let n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=V(e),l=e.getAttribute("data-native-link"),h=null==(t=e.dataset.objectTinuuid)?void 0:t.trim(),b=(null==(r=e.dataset.objectHid)?void 0:r.trim())||void 0;if(!h)throw Error("Object ID is required");M(a.signal);let w=a.loadObject??((e,t)=>N(e,t,a.runtimeConfig)),y=a.object??await w(h,a.signal);if(M(a.signal),!s.isCurrent())return()=>void 0;let A=b?y.materials.find(e=>e.hid===b):y.materials[0];if(!(null==A||null==(i=A.native)?void 0:i.glbUrl)||!A.native.usdzUrl)throw Error("Native AR assets are unavailable");let E=m(A.native,y.type),O=d(),S=!1,I=0;e.querySelector("img")||((n=document.createElement("img")).alt="",n.hidden=!0,e.appendChild(n));let k=()=>a.trackView?a.trackView():D(h,a.runtimeConfig),T=t=>{var r;t.preventDefault();let i=++I;null==o||o(),o=void 0,Promise.resolve((null==(r=a.getDesktopQrUrl)?void 0:r.call(a))??f(h,b,!0,a.runtimeConfig)).then(t=>{if(i===I&&s.isCurrent())return U(()=>{var e;return null==(e=a.onAction)?void 0:e.call(a,"interacted")}),C(t,`vizbl-${h}`,e,a.runtimeConfig)}).then(e=>{if(e){if(i!==I||!s.isCurrent())return void e();o=e}}).catch(()=>void 0)},x=async e=>{let t;if(t=u().toLowerCase(),["firefox","edge","opera"].some(e=>t.includes(e))){if(e.preventDefault(),S)return;S=!0,U(()=>{var e;return null==(e=a.onAction)?void 0:e.call(a,"ar_launched")});try{await Promise.resolve(k()).catch(()=>void 0)}finally{S=!1,c()&&g()?p(h,b,a.runtimeConfig):v(E)}return}U(()=>{var e;return null==(e=a.onAction)?void 0:e.call(a,"ar_launched")}),U(k),c()&&g()?(e.preventDefault(),p(h,b,a.runtimeConfig)):v(E)};return O?(e.dataset.nativeLink=E,e.addEventListener("click",x)):e.addEventListener("click",T),s.register(()=>{I+=1,e.removeEventListener("click",T),e.removeEventListener("click",x),null==o||o(),null==n||n.remove(),null===l?e.removeAttribute("data-native-link"):e.setAttribute("data-native-link",l)})}async function q(){let[{ModelViewerDialog:e},{createElement:t},{createRoot:r}]=await Promise.all([Promise.all([o.e("117"),o.e("634"),o.e("548")]).then(o.bind(o,5535)),o.e("986").then(o.t.bind(o,9081,19)),Promise.all([o.e("117"),o.e("886")]).then(o.t.bind(o,8181,19))]);return{open:i=>{let{onClose:n,...o}=i,a=document.createElement("div");a.setAttribute("data-core-ar-model-viewer",""),document.body.appendChild(a);let s=r(a),l=!1,c=r=>s.render(t(e,{...o,onOpenChange:e=>{e||d()},open:r}));function d(){l||(l=!0,c(!1),setTimeout(()=>{s.unmount(),a.remove()},300),null==n||n())}return c(!0),d}}}let W=["cm","inch"],B=["x","y","z"],H=[...B],F=b();function K(e){return e&&W.includes(e)?e:"inch"}function Q(e){if(!e)return H;let t=Array.from(new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(e=>B.includes(e))));return t.length>0?t:H}let Y=b();function J(e){if(null==e?void 0:e.aborted)throw new DOMException("Aborted","AbortError")}async function X(e){var t,r,i;let n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=Y(e),l=e.getAttribute("href"),c=e.getAttribute("rel"),u=null==(t=e.dataset.objectTinuuid)?void 0:t.trim(),g=(null==(r=e.dataset.objectHid)?void 0:r.trim())||void 0;if(!u)throw Error("Object ID is required");J(a.signal);let h=a.loadObject??((e,t)=>N(e,t,a.runtimeConfig)),v=a.object??await h(u,a.signal);if(J(a.signal),!s.isCurrent())return()=>void 0;let p=g?v.materials.find(e=>e.hid===g):v.materials[0];if(!(null==p||null==(i=p.native)?void 0:i.glbUrl)||!p.native.usdzUrl)throw Error("Native AR assets are unavailable");let b=m(p.native,v.type),w=d(),y=0;e.rel="ar",e.querySelector("img")||((n=document.createElement("img")).alt="",n.hidden=!0,e.appendChild(n));let A=t=>{var r;t.preventDefault();let i=++y;null==o||o(),o=void 0,Promise.resolve((null==(r=a.getDesktopQrUrl)?void 0:r.call(a))??f(u,g,!1,a.runtimeConfig)).then(t=>{if(i===y&&s.isCurrent())return U(()=>{var e;return null==(e=a.onAction)?void 0:e.call(a,"interacted")}),C(t,`vizbl-${u}`,e,a.runtimeConfig)}).then(e=>{if(e){if(i!==y||!s.isCurrent())return void e();o=e}}).catch(()=>void 0)},E=()=>{U(a.trackView??(()=>D(u,a.runtimeConfig))),U(()=>{var e;return null==(e=a.onAction)?void 0:e.call(a,"ar_launched")})};return w?(e.href=b,e.addEventListener("click",E)):(e.href="#",e.addEventListener("click",A)),s.register(()=>{y+=1,e.removeEventListener("click",A),e.removeEventListener("click",E),null==o||o(),null==n||n.remove(),null===l?e.removeAttribute("href"):e.setAttribute("href",l),null===c?e.removeAttribute("rel"):e.setAttribute("rel",c)})}let Z=["advanced-ar","ar-one-click","ar-viewer"],G={arizo:"arizo-core",vizbl:"vizbl-core"},ee=new Set(["core-ar","core-ar-shopify"]),et={arizo:{"advanced-ar":"Посмотреть в расширенной AR","ar-one-click":"Посмотреть в AR","ar-viewer":"Посмотреть в 3D и AR"},vizbl:{"advanced-ar":"View in advanced AR","ar-one-click":"View in AR","ar-viewer":"View in 3D & AR"}},er={"advanced-ar":"advanced-ar-view","ar-one-click":"ar-view","ar-viewer":"ar-viewer"},ei=["api-key","camera-orbit","dev","dimension-axes","max-camera-orbit","min-camera-orbit","object-id","size-type","trigger-class","type","variant-id"],en=new Set(["API_UNAVAILABLE","INVALID_RESPONSE","NETWORK_ERROR","REQUEST_FAILED","SESSION_EXPIRED"]),eo="core-ar-widget-styles";class ea extends Error{constructor(e){super(e),(0,n._)(this,"code",void 0),this.code=e,this.name="CoreArWidgetComponentError"}}function es(e){return Z.includes(e)}function el(e,t){let r=Array.isArray(e.materials)?e.materials:[],i=t?r.find(e=>e.hid===t):r[0];if(!i)throw new ea(t?"VARIANT_NOT_FOUND":"MODEL_UNAVAILABLE");return i}function ec(e,t){var r;if("ar-one-click"===e&&(null==(r=t.policy)?void 0:r.instantArView)===!1)throw new ea("POLICY_DENIED")}let ed="u"<typeof HTMLElement?class{}:HTMLElement;class eu extends ed{static get observedAttributes(){return[...ei]}get triggerClass(){return this.getAttribute("trigger-class")??""}set triggerClass(e){let t="string"==typeof e?e.trim():"";t?this.setAttribute("trigger-class",t):this.removeAttribute("trigger-class")}get unstyled(){return this.hasAttribute("unstyled")}set unstyled(e){this.toggleAttribute("unstyled",!!e)}connectedCallback(){!function(){if(document.getElementById(eo))return;let e=document.createElement("style");e.id=eo,e.textContent=`
2
2
  :where(vizbl-core, arizo-core) {
3
3
  display: inline-block;
4
4
  --core-ar-widget-background: #3556f0;
@@ -65,4 +65,29 @@
65
65
  :where(vizbl-core, arizo-core)[data-state="error"] [data-core-ar-widget-trigger] {
66
66
  cursor: not-allowed;
67
67
  }
68
- `,document.head.appendChild(e)}(),this.captureCustomLabel(),this.queueInitialization()}disconnectedCallback(){this.initializationRevision+=1,this.abortController?.abort(),this.abortController=void 0,this.cleanup?.(),this.cleanup=void 0,this.clearActionResetTimer()}attributeChangedCallback(e,t,i){if(t!==i){if("trigger-class"===e)return void this.applyTriggerClass();("api-key"===e||"dev"===e)&&(this.session=void 0),this.isConnected&&(this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.setState("loading"),this.queueInitialization())}}captureCustomLabel(){if(null!==this.customLabelNodes)return;let e=Array.from(this.childNodes),t=e.some(e=>e.nodeType!==Node.TEXT_NODE||!!e.textContent?.trim());this.customLabelNodes=t?e:[]}queueInitialization(){this.queued||(this.queued=!0,queueMicrotask(()=>{this.queued=!1,this.isConnected&&this.initialize()}))}async initialize(){let e=++this.initializationRevision;this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.object=void 0,this.variantId=void 0,this.widgetMode=void 0,this.clearActionResetTimer();let t=new AbortController;this.abortController=t;let i=this.getAttribute("type")?.trim()??"",r=eA(i)?i:"ar-viewer",n=this.getAttribute("object-id")?.trim()??"",o=this.getAttribute("variant-id")?.trim()||void 0,a=this.getAttribute("api-key")?.trim()??"",d=this.getAttribute("size-type")?.trim()||void 0,l=this.getAttribute("dimension-axes")?.trim()||void 0,c=this.getAttribute("camera-orbit")?.trim()||void 0,u=this.getAttribute("min-camera-orbit")?.trim()||void 0,g=this.getAttribute("max-camera-orbit")?.trim()||void 0;this.removeAttribute("data-error-code"),this.setState("loading"),this.renderTrigger(r);try{let r,m=this.resolveRuntimeConfig();if(!a)throw new eE("MISSING_API_KEY");if(!n)throw new eE("MISSING_OBJECT_ID");if(!eA(i))throw new eE("INVALID_TYPE");if("ar-viewer"===i&&d&&"cm"!==d&&"inch"!==d)throw new eE("INVALID_SIZE_TYPE");let h=eb[i],p=await this.ensureSession(a,m,h,t.signal);if(this.assertCurrent(e,t.signal),this.variantId=o,this.widgetMode=h,this.applyIntegrationData(n,o,d,l,c,u,g),"ar-viewer"===i)r=await N(n,t.signal,m),this.assertCurrent(e,t.signal),eC(r,o),eI(i,r),this.object=r;else{r=s()?await this.fetchObjectWithSession(n,a,p,m,t.signal,o):await N(n,t.signal,m),this.assertCurrent(e,t.signal);let d=eC(r,o);if(eI(i,r),!d.native?.glbUrl||!d.native.usdzUrl)throw new eE("MODEL_UNAVAILABLE");this.object=r}let f=await this.initializeTrigger(i,r,m,t.signal,a,p);try{this.assertCurrent(e,t.signal)}catch(e){throw f(),e}this.cleanup=f,this.setState("ready"),this.dispatchWidgetEvent("core-ar-ready",{objectId:n,type:i})}catch(o){if(e!==this.initializationRevision||t.signal.aborted||o instanceof DOMException&&"AbortError"===o.name)return;let r=o instanceof eE||o instanceof E?o.code:"INITIALIZATION_FAILED";this.setAttribute("data-error-code",r),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:r,objectId:n,type:i})}}async ensureSession(e,t,i,r,n=!1){let o=`${t.apiOrigin}|${t.viewerOrigin}|${t.modelViewerOrigin}|${i}`,a=this.session?.publicKey===e&&this.session.runtimeKey===o?this.session:void 0;if(a&&!n&&a.expiresAt-Date.now()>3e4)return a;if(a)try{let i=await L(e,a.token,{mode:a.mode,runtimeConfig:t,signal:r}),n={...a,...i,expiresAt:Date.now()+1e3*i.expiresIn};return this.session=n,n}catch(e){if(!(e instanceof E)||!ew.has(e.code))throw e;this.session=void 0}let s=await T(e,{mode:i,runtimeConfig:t,signal:r});if(!ep.has(s.productType))throw new eE("POLICY_DENIED");let d={expiresAt:Date.now()+1e3*s.expiresIn,mode:i,productType:s.productType,publicKey:e,runtimeKey:o,sid:s.sid,token:s.token};return this.session=d,d}async fetchObjectWithSession(e,t,i,r,n,o){try{return await z(e,i.token,{runtimeConfig:r,signal:n,variantId:o})}catch(a){if(!(a instanceof E)||"SESSION_EXPIRED"!==a.code)throw a;return z(e,(await this.ensureSession(t,r,i.mode,n,!0)).token,{runtimeConfig:r,signal:n,variantId:o})}}assertCurrent(e,t){if(e!==this.initializationRevision||t.aborted)throw new DOMException("Aborted","AbortError")}renderTrigger(e){let t="ar-one-click"===e?document.createElement("a"):document.createElement("button");if(t.dataset.coreArWidgetTrigger="",t.setAttribute("part","trigger"),t.addEventListener("click",e=>{"ready"!==this.dataset.state&&(e.preventDefault(),e.stopImmediatePropagation())}),t instanceof HTMLButtonElement&&(t.type="button"),t instanceof HTMLAnchorElement&&(t.href="#",t.rel="ar"),"ar-viewer"===e&&t.setAttribute("aria-haspopup","dialog"),"ar-viewer"!==e){let e=document.createElement("img");e.alt="",e.hidden=!0,t.appendChild(e)}let i=document.createElement("span");i.dataset.coreArWidgetLabel="",this.customLabelNodes?.length?i.append(...this.customLabelNodes):i.textContent=ef[this.resolveRuntimeConfig().brand][e],t.appendChild(i),this.trigger=t,this.applyTriggerClass(),this.replaceChildren(t),this.updateTriggerAccessibility(this.dataset.state)}applyTriggerClass(){if(!this.trigger)return;let e=this.triggerClass.trim();e?this.trigger.className=e:this.trigger.removeAttribute("class")}applyIntegrationData(e,t,i,r,n,o,a){this.trigger&&(this.trigger.dataset.objectTinuuid=e,t?this.trigger.dataset.objectHid=t:delete this.trigger.dataset.objectHid,i?this.trigger.dataset.sizeType=i:delete this.trigger.dataset.sizeType,r?this.trigger.dataset.dimensionAxes=r:delete this.trigger.dataset.dimensionAxes,n?this.trigger.dataset.cameraOrbit=n:delete this.trigger.dataset.cameraOrbit,o?this.trigger.dataset.minCameraOrbit=o:delete this.trigger.dataset.minCameraOrbit,a?this.trigger.dataset.maxCameraOrbit=a:delete this.trigger.dataset.maxCameraOrbit)}async initializeTrigger(e,t,i,r,n,o){if(!this.trigger)throw new eE("INITIALIZATION_FAILED");if("ar-viewer"===e)return function(e,t={}){let i,r=ea(e),n=!1,o=async()=>{if(i||n)return;let o=e.dataset.objectTinuuid?.trim();if(!o)return;n=!0;let a=t.widgetSessionToken;try{t.getWidgetSessionToken&&(a=await t.getWidgetSessionToken())}catch{n=!1;return}if(n=!1,i||!r.isCurrent())return;let s=function(e){var t,i;let r,n;if(document.getElementById(eo))return null;let o=document.createElement("div"),a=document.createElement("div"),s=document.createElement("div"),d=e.containerClassName?document.getElementsByClassName(e.containerClassName)[0]:null,l=!!d,c=l?a:o,u=!1,g=e=>{"Escape"===e.key&&r()};r=()=>{u||(u=!0,document.removeEventListener("keydown",g),et(c),(l?a:o).remove(),e.onClose?.(),e.restoreFocusTo?.focus({preventScroll:!0}))},o.id=eo,Object.assign(o.style,{inset:"0",overflow:"auto",position:"fixed",zIndex:"2147483647"}),o.style.webkitOverflowScrolling="touch",a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-label","ru"===e.lang?"Просмотр 3D-модели":"3D model viewer"),Object.assign(s.style,{animation:"vex-fadein 0.5s",background:"#fff",inset:"0",position:"fixed",zIndex:"11111"}),s.addEventListener("click",r),(e.width||e.height)&&(s.style.background="rgba(0, 0, 0, 0.8)",Object.assign(a.style,{borderRadius:"12px",height:e.height??"100%",left:"50%",overflow:"hidden",position:"absolute",top:"50%",transform:"translate(-50%, -50%)",width:e.width??"100%",zIndex:"11112"}));let m=function(e,t,i="en"){let r=document.createElement("button");return r.type="button",r.setAttribute("aria-label","ru"===i?"Закрыть просмотр 3D-модели":"Close 3D model viewer"),e&&(r.className=e),Object.assign(r.style,{alignItems:"center",background:"#fff",border:"1px solid #E3E7E7",borderRadius:"4px",boxSizing:"border-box",cursor:"pointer",display:"flex",height:"40px",inset:"24px 24px auto auto",justifyContent:"center",padding:"8px 16px",position:"absolute",width:"56px",zIndex:"11113"}),r.innerHTML='<svg aria-hidden="true" style="flex-shrink:0" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z" fill="#484D50"/></svg>',r.addEventListener("click",t),r}(e.crossClassName,r,e.lang);return a.append((t=el(e),i=e.backgroundColor,(n=document.createElement("iframe")).src=t,n.title="3D model viewer",n.allow="fullscreen; xr-spatial-tracking",Object.assign(n.style,{backgroundColor:i??"white",border:"none",height:"100%",inset:"0",position:"absolute",width:"100%",zIndex:"11112"}),n),m),d?(a.id=eo,d.appendChild(a)):(o.append(s,a),document.body.appendChild(o)),document.addEventListener("keydown",g),ee(c),m.focus({preventScroll:!0}),r}({apiKey:t.apiKey,backgroundColor:e.dataset.background,buttonBgColor:e.dataset.buttonBgColor,buttonBorderColor:e.dataset.buttonBorderColor,buttonTextColor:e.dataset.buttonTextColor,cameraOrbit:e.dataset.cameraOrbit,containerClassName:e.dataset.container,crossClassName:e.dataset.crossClassName,dimensionAxes:ed(e.dataset.dimensionAxes),height:e.dataset.height?.trim(),hid:e.dataset.objectHid,hidePreview:e.dataset.hidePreview,hideTitle:e.dataset.hideTitle,lang:t.lang,maxCameraOrbit:e.dataset.maxCameraOrbit,minCameraOrbit:e.dataset.minCameraOrbit,mode:t.mode,modelViewerOrigin:t.modelViewerOrigin,onClose:()=>{i=void 0,t.onClose?.()},restoreFocusTo:e,sizeType:es(e.dataset.sizeType),tinuuid:o,widgetSessionToken:a,width:e.dataset.width?.trim()});s&&(i=s,t.onOpen?.(),D(()=>t.onAction?.("widget_opened")))};return e.addEventListener("click",o),r.register(()=>{e.removeEventListener("click",o),i?.(),i=void 0})}(this.trigger,{apiKey:n,getWidgetSessionToken:async()=>(await this.ensureSession(n,i,o.mode)).token,lang:"arizo"===i.brand?"ru":"en",mode:o.mode,modelViewerOrigin:i.modelViewerOrigin,onAction:e=>this.handleAction(e,i),onClose:()=>{this.isConnected&&this.setState("ready")},onOpen:()=>this.setState("opening"),widgetSessionToken:o.token});if(!t)throw new eE("INITIALIZATION_FAILED");let a={getDesktopQrUrl:async()=>{let e=await this.ensureSession(n,i,o.mode);return el({apiKey:n,cameraOrbit:this.trigger?.dataset.cameraOrbit,dimensionAxes:ed(this.trigger?.dataset.dimensionAxes),hid:this.variantId,lang:"arizo"===i.brand?"ru":"en",maxCameraOrbit:this.trigger?.dataset.maxCameraOrbit,minCameraOrbit:this.trigger?.dataset.minCameraOrbit,mode:e.mode,modelViewerOrigin:i.modelViewerOrigin,sizeType:es(this.trigger?.dataset.sizeType),tinuuid:this.trigger?.dataset.objectTinuuid??"",widgetSessionToken:e.token})},object:t,onAction:e=>this.handleAction(e,i),runtimeConfig:i,signal:r,trackView:()=>this.trackEvent("ar_launched",i)};if("ar-one-click"===e){if(!(this.trigger instanceof HTMLAnchorElement))throw new eE("INITIALIZATION_FAILED");return eg(this.trigger,a)}return U(this.trigger,a)}handleAction(e,t){this.setState("opening"),("interacted"===e||"widget_opened"===e)&&"ar-viewer"!==this.getAttribute("type")&&this.trackEvent(e,t),"ar-viewer"!==this.getAttribute("type")&&(this.clearActionResetTimer(),this.actionResetTimer=window.setTimeout(()=>{this.isConnected&&this.setState("ready")},300))}async trackEvent(e,t){let i=this.getAttribute("api-key")?.trim(),r=this.widgetMode;if(i&&r&&this.isConnected)try{let n=await this.ensureSession(i,t,r);await R(e,n.token,this.object?.uuid,{runtimeConfig:t,variantId:this.variantId})}catch{}}clearActionResetTimer(){void 0!==this.actionResetTimer&&(window.clearTimeout(this.actionResetTimer),this.actionResetTimer=void 0)}setState(e){this.dataset.state=e,this.updateTriggerAccessibility(e)}updateTriggerAccessibility(e){if(!this.trigger)return;let t="ready"===e;this.trigger.setAttribute("aria-busy",String("loading"===e)),this.trigger.setAttribute("aria-disabled",String(!t)),this.trigger.tabIndex=t?0:-1,this.trigger instanceof HTMLButtonElement&&(this.trigger.disabled=!t)}dispatchWidgetEvent(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}}function eS(e){if("u"<typeof customElements)return;let t=eh[e],i=customElements.get(t);if(i)return i;class n extends eO{resolveRuntimeConfig(){return function(e,t="prod"){var i,n;let o,a,s,d,l,c,u,g,m="arizo"===e?"arizo.ru":"vizbl.com",h="dev"===t?"-dev":"";return o=r((i={apiOrigin:`https://api${h}.${m}`,modelViewerOrigin:`https://integrations${h}.${m}`,viewerOrigin:`https://viewer${h}.${m}`}).apiOrigin,"apiOrigin"),a=r(i.viewerOrigin,"viewerOrigin"),l=i.modelViewerOrigin?r(i.modelViewerOrigin,"modelViewerOrigin"):(d=(s=new URL(a)).hostname.match(/^viewer(-dev)?\.(vizbl\.com|arizo\.ru)$/))?`${s.protocol}//integrations${d[1]??""}.${d[2]}`:a,g=i.legacyApiOrigin?(c=r(n=i.legacyApiOrigin,"legacyApiOrigin"),(u=new URL(n).pathname.replace(/\/+$/,""))?`${c}${u}`:c):`${o}/v1`,{apiOrigin:o,brand:new URL(a).hostname.endsWith("arizo.ru")?"arizo":"vizbl",fetchImpl:i.fetchImpl??fetch,legacyApiOrigin:g,modelViewerOrigin:l,qrCodeScriptUrl:i.qrCodeScriptUrl??`${a}/vendor/qrcode.min.js`,viewerOrigin:a}}(e,this.hasAttribute("dev")?"dev":"prod")}}return customElements.define(t,n),n}eS("arizo"),eS("vizbl")})();
68
+
69
+ :where(vizbl-core, arizo-core):not([unstyled])[data-state="loading"] [data-core-ar-widget-trigger] {
70
+ color: transparent;
71
+ position: relative;
72
+ }
73
+
74
+ :where(vizbl-core, arizo-core):not([unstyled])[data-state="loading"] [data-core-ar-widget-trigger]::after {
75
+ animation: core-ar-widget-spin 700ms linear infinite;
76
+ border: 2px solid var(--core-ar-widget-color);
77
+ border-radius: 50%;
78
+ border-right-color: transparent;
79
+ box-sizing: border-box;
80
+ content: "";
81
+ height: 1em;
82
+ inset: 0;
83
+ margin: auto;
84
+ position: absolute;
85
+ width: 1em;
86
+ }
87
+
88
+ @keyframes core-ar-widget-spin {
89
+ to {
90
+ transform: rotate(360deg);
91
+ }
92
+ }
93
+ `,document.head.appendChild(e)}(),this.captureCustomLabel(),this.queueInitialization()}disconnectedCallback(){var e,t;this.initializationRevision+=1,null==(e=this.abortController)||e.abort(),this.abortController=void 0,null==(t=this.cleanup)||t.call(this),this.cleanup=void 0,this.clearActionResetTimer()}attributeChangedCallback(e,t,r){if(t!==r){if("trigger-class"===e)return void this.applyTriggerClass();if(("api-key"===e||"dev"===e)&&(this.session=void 0),this.isConnected){var i,n;null==(i=this.abortController)||i.abort(),null==(n=this.cleanup)||n.call(this),this.cleanup=void 0,this.setState("loading"),this.queueInitialization()}}}captureCustomLabel(){if(null!==this.customLabelNodes)return;let e=Array.from(this.childNodes),t=e.some(e=>{var t;return e.nodeType!==Node.TEXT_NODE||!!(null==(t=e.textContent)?void 0:t.trim())});this.customLabelNodes=t?e:[]}queueInitialization(){this.queued||(this.queued=!0,queueMicrotask(()=>{this.queued=!1,this.isConnected&&this.initialize()}))}async initialize(){var e,t,r,i,n,o,a,s,l,c,u,g;let h=++this.initializationRevision;null==(e=this.abortController)||e.abort(),null==(t=this.cleanup)||t.call(this),this.cleanup=void 0,this.object=void 0,this.variantId=void 0,this.widgetMode=void 0,this.clearActionResetTimer();let m=new AbortController;this.abortController=m;let v=(null==(r=this.getAttribute("type"))?void 0:r.trim())??"",p=es(v)?v:"ar-viewer",f=(null==(i=this.getAttribute("object-id"))?void 0:i.trim())??"",b=(null==(n=this.getAttribute("variant-id"))?void 0:n.trim())||void 0,w=(null==(o=this.getAttribute("api-key"))?void 0:o.trim())??"",y=(null==(a=this.getAttribute("size-type"))?void 0:a.trim())||void 0,A=(null==(s=this.getAttribute("dimension-axes"))?void 0:s.trim())||void 0,E=(null==(l=this.getAttribute("camera-orbit"))?void 0:l.trim())||void 0,C=(null==(c=this.getAttribute("min-camera-orbit"))?void 0:c.trim())||void 0,S=(null==(u=this.getAttribute("max-camera-orbit"))?void 0:u.trim())||void 0;this.removeAttribute("data-error-code"),this.setState("loading"),this.renderTrigger(p);try{let e,t=this.resolveRuntimeConfig();if(!w)throw new ea("MISSING_API_KEY");if(!f)throw new ea("MISSING_OBJECT_ID");if(!es(v))throw new ea("INVALID_TYPE");if("ar-viewer"===v&&y&&"cm"!==y&&"inch"!==y)throw new ea("INVALID_SIZE_TYPE");let r=er[v],i=await this.ensureSession(w,t,r,m.signal);if(this.assertCurrent(h,m.signal),this.variantId=b,this.widgetMode=r,this.applyIntegrationData(f,b,y,A,E,C,S),"ar-viewer"===v)e=await N(f,m.signal,t),this.assertCurrent(h,m.signal),el(e,b),ec(v,e),this.object=e;else{e=d()?await this.fetchObjectWithSession(f,w,i,t,m.signal,b):await N(f,m.signal,t),this.assertCurrent(h,m.signal);let r=el(e,b);if(ec(v,e),!(null==(g=r.native)?void 0:g.glbUrl)||!r.native.usdzUrl)throw new ea("MODEL_UNAVAILABLE");this.object=e}let n=await this.initializeTrigger(v,e,t,m.signal,w,i);try{this.assertCurrent(h,m.signal)}catch(e){throw n(),e}this.cleanup=n,this.setState("ready"),this.dispatchWidgetEvent("core-ar-ready",{objectId:f,type:v})}catch(t){if(h!==this.initializationRevision||m.signal.aborted||t instanceof DOMException&&"AbortError"===t.name)return;let e=t instanceof ea||t instanceof O?t.code:"INITIALIZATION_FAILED";this.setAttribute("data-error-code",e),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:e,objectId:f,type:v})}}failInteraction(e,t){var r;this.isConnected&&(this.setAttribute("data-error-code",e),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:e,objectId:(null==(r=this.getAttribute("object-id"))?void 0:r.trim())??"",type:t}))}async ensureSession(e,t,r,i){var n;let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=`${t.apiOrigin}|${t.viewerOrigin}|${t.modelViewerOrigin}|${r}`,s=(null==(n=this.session)?void 0:n.publicKey)===e&&this.session.runtimeKey===a?this.session:void 0;if(s&&!o&&s.expiresAt-Date.now()>3e4)return s;if(s)try{let r=await R(e,s.token,{mode:s.mode,runtimeConfig:t,signal:i}),n={...s,...r,expiresAt:Date.now()+1e3*r.expiresIn};return this.session=n,n}catch(e){if(!(e instanceof O)||!en.has(e.code))throw e;this.session=void 0}let l=await _(e,{mode:r,runtimeConfig:t,signal:i});if(!ee.has(l.productType))throw new ea("POLICY_DENIED");let c={expiresAt:Date.now()+1e3*l.expiresIn,mode:r,productType:l.productType,publicKey:e,runtimeKey:a,sid:l.sid,token:l.token};return this.session=c,c}async fetchObjectWithSession(e,t,r,i,n,o){try{return await P(e,r.token,{runtimeConfig:i,signal:n,variantId:o})}catch(a){if(!(a instanceof O)||"SESSION_EXPIRED"!==a.code)throw a;return P(e,(await this.ensureSession(t,i,r.mode,n,!0)).token,{runtimeConfig:i,signal:n,variantId:o})}}assertCurrent(e,t){if(e!==this.initializationRevision||t.aborted)throw new DOMException("Aborted","AbortError")}renderTrigger(e){var t;let r="ar-one-click"===e?document.createElement("a"):document.createElement("button");if(r.dataset.coreArWidgetTrigger="",r.setAttribute("part","trigger"),r.addEventListener("click",e=>{"ready"!==this.dataset.state&&(e.preventDefault(),e.stopImmediatePropagation())}),r instanceof HTMLButtonElement&&(r.type="button"),r instanceof HTMLAnchorElement&&(r.href="#",r.rel="ar"),"ar-viewer"===e&&r.setAttribute("aria-haspopup","dialog"),"ar-viewer"!==e){let e=document.createElement("img");e.alt="",e.hidden=!0,r.appendChild(e)}let i=document.createElement("span");i.dataset.coreArWidgetLabel="",(null==(t=this.customLabelNodes)?void 0:t.length)?i.append(...this.customLabelNodes):i.textContent=et[this.resolveRuntimeConfig().brand][e],r.appendChild(i),this.trigger=r,this.applyTriggerClass(),this.replaceChildren(r),this.updateTriggerAccessibility(this.dataset.state)}applyTriggerClass(){if(!this.trigger)return;let e=this.triggerClass.trim();e?this.trigger.className=e:this.trigger.removeAttribute("class")}applyIntegrationData(e,t,r,i,n,o,a){this.trigger&&(this.trigger.dataset.objectTinuuid=e,t?this.trigger.dataset.objectHid=t:delete this.trigger.dataset.objectHid,r?this.trigger.dataset.sizeType=r:delete this.trigger.dataset.sizeType,i?this.trigger.dataset.dimensionAxes=i:delete this.trigger.dataset.dimensionAxes,n?this.trigger.dataset.cameraOrbit=n:delete this.trigger.dataset.cameraOrbit,o?this.trigger.dataset.minCameraOrbit=o:delete this.trigger.dataset.minCameraOrbit,a?this.trigger.dataset.maxCameraOrbit=a:delete this.trigger.dataset.maxCameraOrbit)}async initializeTrigger(e,t,r,n,o,a){if(!this.trigger)throw new ea("INITIALIZATION_FAILED");if("ar-viewer"===e){var l,c;let t,n,d,u;return l=this.trigger,c={apiKey:o,getWidgetSessionToken:async()=>(await this.ensureSession(o,r,a.mode)).token,lang:"arizo"===r.brand?"ru":"en",mode:a.mode,modelViewerOrigin:r.modelViewerOrigin,onAction:e=>this.handleAction(e,r),onClose:()=>{this.isConnected&&this.setState("ready")},onError:()=>this.failInteraction("VIEWER_UNAVAILABLE",e),onLoading:()=>this.setState("loading"),onOpen:()=>this.setState("opening"),viewer:{apiBaseUrl:r.apiOrigin},widgetSessionToken:a.token},n=F(l),d=!1,u=async()=>{var e,r;if(t||d)return;let o=null==(e=l.dataset.objectTinuuid)?void 0:e.trim();if(o){d=!0,U(()=>{var e;return null==(e=c.onLoading)?void 0:e.call(c)});try{let e=c.getWidgetSessionToken?await c.getWidgetSessionToken():c.widgetSessionToken,r=await function(){if(i)return i;let e=q();return i=e,e.catch(()=>{i===e&&(i=void 0)}),e}();if(t||!n.isCurrent())return;let a=c.modelViewerOrigin??s().modelViewerOrigin,d=!1;t=r.open({apiBaseUrl:c.viewer.apiBaseUrl,apiKey:c.apiKey,cameraOrbit:l.dataset.cameraOrbit,dimensionAxes:Q(l.dataset.dimensionAxes),handoffUrl:new URL("/model-viewer",a).toString(),hid:l.dataset.objectHid,initialWidgetSessionToken:e,lang:c.lang,maxCameraOrbit:l.dataset.maxCameraOrbit,minCameraOrbit:l.dataset.minCameraOrbit,mode:c.mode,onClose:()=>{var e;d||(d=!0,t=void 0,null==(e=c.onClose)||e.call(c),l.focus({preventScroll:!0}))},sizeType:K(l.dataset.sizeType),tinuuid:o})}catch(e){n.isCurrent()&&U(()=>{var t;return null==(t=c.onError)?void 0:t.call(c,e)});return}finally{d=!1}null==(r=c.onOpen)||r.call(c),U(()=>{var e;return null==(e=c.onAction)?void 0:e.call(c,"widget_opened")})}},l.addEventListener("click",u),n.register(()=>{l.removeEventListener("click",u),null==t||t(),t=void 0})}if(!t)throw new ea("INITIALIZATION_FAILED");let d={getDesktopQrUrl:async()=>{var e,t,i,n,l,c,d;let u,g,h,m=await this.ensureSession(o,r,a.mode);return u=new URL("/model-viewer",(d={apiKey:o,cameraOrbit:null==(e=this.trigger)?void 0:e.dataset.cameraOrbit,dimensionAxes:Q(null==(t=this.trigger)?void 0:t.dataset.dimensionAxes),hid:this.variantId,lang:"arizo"===r.brand?"ru":"en",maxCameraOrbit:null==(i=this.trigger)?void 0:i.dataset.maxCameraOrbit,minCameraOrbit:null==(n=this.trigger)?void 0:n.dataset.minCameraOrbit,mode:m.mode,modelViewerOrigin:r.modelViewerOrigin,sizeType:K(null==(l=this.trigger)?void 0:l.dataset.sizeType),tinuuid:(null==(c=this.trigger)?void 0:c.dataset.objectTinuuid)??"",widgetSessionToken:m.token}).modelViewerOrigin??s().modelViewerOrigin),g=d.dimensionAxes??H,u.searchParams.set("tinuuid",d.tinuuid),d.hid&&u.searchParams.set("hid",d.hid),u.searchParams.set("size-type",d.sizeType),g.length<H.length&&u.searchParams.set("dimension-axes",g.join(",")),d.cameraOrbit&&u.searchParams.set("camera-orbit",d.cameraOrbit),d.minCameraOrbit&&u.searchParams.set("min-camera-orbit",d.minCameraOrbit),d.maxCameraOrbit&&u.searchParams.set("max-camera-orbit",d.maxCameraOrbit),d.lang&&u.searchParams.set("lang",d.lang),h=new URLSearchParams,d.apiKey&&h.set("api-key",d.apiKey),d.mode&&h.set("mode",d.mode),d.widgetSessionToken&&h.set("widget-session-token",d.widgetSessionToken),u.hash=h.toString(),u.toString()},object:t,onAction:e=>this.handleAction(e,r),runtimeConfig:r,signal:n,trackView:()=>this.trackEvent("ar_launched",r)};if("ar-one-click"===e){if(!(this.trigger instanceof HTMLAnchorElement))throw new ea("INITIALIZATION_FAILED");return X(this.trigger,d)}return $(this.trigger,d)}handleAction(e,t){this.setState("opening"),("interacted"===e||"widget_opened"===e)&&"ar-viewer"!==this.getAttribute("type")&&this.trackEvent(e,t),"ar-viewer"!==this.getAttribute("type")&&(this.clearActionResetTimer(),this.actionResetTimer=window.setTimeout(()=>{this.isConnected&&this.setState("ready")},300))}async trackEvent(e,t){var r,i;let n=null==(r=this.getAttribute("api-key"))?void 0:r.trim(),o=this.widgetMode;if(n&&o&&this.isConnected)try{let r=await this.ensureSession(n,t,o);await j(e,r.token,null==(i=this.object)?void 0:i.uuid,{runtimeConfig:t,variantId:this.variantId})}catch{}}clearActionResetTimer(){void 0!==this.actionResetTimer&&(window.clearTimeout(this.actionResetTimer),this.actionResetTimer=void 0)}setState(e){this.dataset.state=e,this.updateTriggerAccessibility(e)}updateTriggerAccessibility(e){if(!this.trigger)return;let t="ready"===e;this.trigger.setAttribute("aria-busy",String("loading"===e)),this.trigger.setAttribute("aria-disabled",String(!t)),this.trigger.tabIndex=t?0:-1,this.trigger instanceof HTMLButtonElement&&(this.trigger.disabled=!t)}dispatchWidgetEvent(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}constructor(...e){super(...e),(0,n._)(this,"abortController",void 0),(0,n._)(this,"actionResetTimer",void 0),(0,n._)(this,"cleanup",void 0),(0,n._)(this,"customLabelNodes",null),(0,n._)(this,"initializationRevision",0),(0,n._)(this,"object",void 0),(0,n._)(this,"queued",!1),(0,n._)(this,"session",void 0),(0,n._)(this,"trigger",void 0),(0,n._)(this,"variantId",void 0),(0,n._)(this,"widgetMode",void 0)}}function eg(e){if("u"<typeof customElements)return;let t=G[e],r=customElements.get(t);if(r)return r;class i extends eu{resolveRuntimeConfig(){return function(e){var t;let r,i,n,o,s,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"prod",c="arizo"===e?"arizo.ru":"vizbl.com",d="dev"===l?"-dev":"";return r=a((t={apiOrigin:`https://api${d}.${c}`,modelViewerOrigin:`https://integrations${d}.${c}`,viewerOrigin:`https://viewer${d}.${c}`}).apiOrigin,"apiOrigin"),i=a(t.viewerOrigin,"viewerOrigin"),s=t.modelViewerOrigin?a(t.modelViewerOrigin,"modelViewerOrigin"):(o=(n=new URL(i)).hostname.match(/^viewer(-dev)?\.(vizbl\.com|arizo\.ru)$/))?`${n.protocol}//integrations${o[1]??""}.${o[2]}`:i,{apiOrigin:r,brand:new URL(i).hostname.endsWith("arizo.ru")?"arizo":"vizbl",fetchImpl:t.fetchImpl??fetch,modelViewerOrigin:s,qrCodeScriptUrl:t.qrCodeScriptUrl??`${i}/vendor/qrcode.min.js`,viewerOrigin:i}}(e,this.hasAttribute("dev")?"dev":"prod")}}return customElements.define(t,i),i}eg("arizo"),eg("vizbl")})()})();
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export declare const CORE_AR_WIDGET_TYPES: readonly ["advanced-ar", "ar-one-clic
7
7
 
8
8
  declare type CoreArWidgetBrand = 'arizo' | 'vizbl';
9
9
 
10
- export declare type CoreArWidgetErrorCode = WidgetRuntimeErrorCode | 'INITIALIZATION_FAILED' | 'INVALID_SIZE_TYPE' | 'INVALID_TYPE' | 'MISSING_API_KEY' | 'MISSING_OBJECT_ID' | 'MODEL_UNAVAILABLE' | 'POLICY_DENIED' | 'VARIANT_NOT_FOUND';
10
+ export declare type CoreArWidgetErrorCode = WidgetRuntimeErrorCode | 'INITIALIZATION_FAILED' | 'INVALID_SIZE_TYPE' | 'INVALID_TYPE' | 'MISSING_API_KEY' | 'MISSING_OBJECT_ID' | 'MODEL_UNAVAILABLE' | 'POLICY_DENIED' | 'VARIANT_NOT_FOUND' | 'VIEWER_UNAVAILABLE';
11
11
 
12
12
  export declare interface CoreArWidgetEventDetail {
13
13
  code?: CoreArWidgetErrorCode;