@virtualdisplay.io/client 4.0.0-alpha.30 → 4.0.0-alpha.33

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,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c={HANDSHAKE:"handshake",SESSION:"session",MUTATION:"mutation",STATE:"state",LOADING_INDICATOR:"loading_indicator",CAMERA:"camera",SNAPSHOT:"snapshot",MAPPING:"mapping",AR_ACTIVATE:"ar_activate",FULLSCREEN:"fullscreen",CONFIG:"config",ANNOTATION_TOGGLE:"annotation_toggle",FOCUS:"focus",PRICING:"pricing",QR_SHOWN:"qr_shown",SYNC:"sync",SELECTABLE:"selectable",APP_RESOLVED:"app_resolved"},O="main",tt={FOCUS:"focus",UNFOCUS:"unfocus"},Bt={FOCUSED:"focused"},mt={AVAILABLE:"available",VIEW_ONLY:"view_only",HIDDEN:"hidden"},Ut=new Set(Object.values(c));function Vt(n){if(typeof n!="object"||n===null)return!1;const t=n;return typeof t.target=="string"?!1:typeof t.type=="string"&&Ut.has(t.type)}function Ht(n){const t=w(n);return t!==null&&t.type===c.HANDSHAKE}function jt(n){const t=w(n);return t!==null&&t.type===c.SESSION&&typeof t.sessionId=="string"}function qt(n){const t=w(n);return t!==null&&t.type===c.APP_RESOLVED&&typeof t.appType=="string"&&t.appType!==""&&typeof t.name=="string"}function Gt(n){const t=w(n);return t!==null&&t.type===c.MUTATION&&typeof t.instance=="string"&&t.instance!==""&&Array.isArray(t.results)}function Zt(n){const t=w(n);return t!==null&&t.type===c.SNAPSHOT&&("data"in t||"error"in t)}function Wt(n){const t=w(n);return t!==null&&t.type===c.CAMERA&&Array.isArray(t.transforms)}function Yt(n){const t=w(n);return t!==null&&t.type===c.MAPPING&&typeof t.instance=="string"&&t.instance!==""&&Array.isArray(t.attributes)}function Qt(n){const t=w(n);return t!==null&&t.type===c.LOADING_INDICATOR&&typeof t.progress=="number"}function Kt(n){const t=w(n);return t!==null&&t.type===c.SYNC&&typeof t.connected=="boolean"}function Xt(n){const t=w(n);return t!==null&&t.type===c.SELECTABLE&&typeof t.instance=="string"&&t.instance!==""&&Array.isArray(t.attributes)}function Jt(n){const t=w(n);return t!==null&&t.type===c.CONFIG&&typeof t.viewerSettings=="object"}function te(n){const t=w(n);return t!==null&&t.type===c.FOCUS&&typeof t.instance=="string"&&t.instance!==""&&typeof t.state=="string"}function ee(n){const t=w(n);return t!==null&&t.type===c.PRICING&&typeof t.instance=="string"&&t.instance!==""&&typeof t.pricing=="object"&&t.pricing!==null}function w(n){return typeof n!="object"||n===null?null:n}class et{constructor(t){this.processor=t}processor;pending=[];isReady=!1;enqueue(t){if(this.isReady){this.processor(t);return}this.pending.push(t)}markReady(){if(this.isReady||(this.isReady=!0,this.pending.length===0))return;const t=[...this.pending];this.pending.length=0;for(const e of t)this.processor(e)}get ready(){return this.isReady}get pendingCount(){return this.pending.length}hasPending(t){return this.pending.some(e=>e.type===t)}clear(){this.pending.length=0}}class ne{constructor(t,e){this.getTarget=t,this.sourceId=`vd-${Math.random().toString(36).slice(2,8)}`,this.targetOrigin="*",this.isValid=e?.isValid??Vt,this.onHandlerError=e?.onHandlerError??ie,this.publisher=new et(i=>this.post(i)),this.consumer=new et(i=>this.routeToHandler(i)),e?.bufferIncoming!==!0&&this.consumer.markReady()}getTarget;handlers=new Map;publisher;consumer;listener=null;sourceId;targetOrigin;isValid;onHandlerError;on(t,e){this.handlers.set(t,e)}setTargetOrigin(t){this.targetOrigin=t}send(t){this.publisher.enqueue(t)}receive(t){this.isValid(t)&&this.consumer.enqueue(t)}markReady(){this.publisher.markReady()}markConsumerReady(){this.consumer.markReady()}consumerHasPending(t){return this.consumer.hasPending(t)}start(){this.listener===null&&(this.listener=t=>{const{data:e}=t;if(!this.isValid(e)||e._source===this.sourceId)return;const i=this.getTarget();if(i!==null&&t.source!==null&&t.source!==i)return;const o=e;this.consumer.enqueue(o)},window.addEventListener("message",this.listener))}destroy(){this.listener!==null&&(window.removeEventListener("message",this.listener),this.listener=null),this.publisher.clear(),this.consumer.clear(),this.handlers.clear()}post(t){const e=this.getTarget();e!==null&&e.postMessage({...t,_source:this.sourceId},this.targetOrigin)}routeToHandler(t){const e=this.handlers.get(t.type);if(e===void 0)return;const i=e(t);i instanceof Promise&&i.catch(o=>{this.onHandlerError(t,o)})}}function ie(n,t){const e=t instanceof Error?t.message:String(t);console.error(`Virtualdisplay: error handling ${n.type}: ${e}`)}class ft{constructor(t,e){this.send=t,this.instance=e}send;instance;setEnabled(t){this.send({type:c.ANNOTATION_TOGGLE,instance:this.instance,enabled:t})}}class gt{constructor(t,e){this.value=t,this.attribute=e}value;attribute;isSelectedValue=!1;get isSelected(){return this.isSelectedValue}setSelected(t){this.isSelectedValue=t}}const _={NO_MAPPING:"NO_MAPPING",ATTRIBUTE_NOT_FOUND:"ATTRIBUTE_NOT_FOUND",VALUE_NOT_FOUND:"VALUE_NOT_FOUND",PARENT_NOT_FOUND:"PARENT_NOT_FOUND",INVALID_PARAMETER:"INVALID_PARAMETER",SNAPSHOT_FAILED:"SNAPSHOT_FAILED"};class b extends Error{code;constructor(t,e){super(t),this.name="VirtualdisplayError",this.code=e}static valueNotFound(t,e){return new b(`Value "${e}" not found for attribute "${t}"`,_.VALUE_NOT_FOUND)}static parentNotFound(t){return new b(`Parent element not found: ${t}`,_.PARENT_NOT_FOUND)}static invalidParameter(t){return new b(t,_.INVALID_PARAMETER)}}class bt{name;defaultValue;values;onSelect;onChangeCallback;constructor(t){this.name=t.name,this.defaultValue=t.defaultValue,this.onSelect=t.onSelect,this.values=this.createValues(t.values)}select(t){if(!this.values.has(t))throw b.valueNotFound(this.name,t);this.onSelect(this.name,t)}getValues(){return Array.from(this.values.values())}getValue(t){return this.values.get(t)}get selected(){for(const t of this.values.values())if(t.isSelected)return t.value}onChange(t){this.onChangeCallback=t}handleResult(t){let e;for(const i of this.values.values()){const o=i.value===t;i.setSelected(o),o&&(e=i)}e!==void 0&&this.onChangeCallback!==void 0&&this.onChangeCallback(e)}createValues(t){const e=new Map;for(const i of t){const o=new gt(i,this.name);i===this.defaultValue&&o.setSelected(!0),e.set(i,o)}return e}}class oe{attributes=new Map;constructor(t,e,i){for(const o of t){const s=this.buildOptions(o,e);this.attributes.set(o.name,new bt(s))}this.onMutationFailed=i}onMutationFailed;get(t){return this.attributes.get(t)}getSelection(){const t={};for(const[e,i]of this.attributes){const o=i.selected;o!==void 0&&(t[e]=o)}return t}handleResults(t){for(const e of t){if(!e.success){this.onMutationFailed?.(e.name,e.value);continue}this.get(e.name)?.handleResult(e.value)}}buildOptions(t,e){const i={name:t.name,values:t.values,onSelect:(o,s)=>{e([{name:o,value:s}],!1)}};return t.defaultValue!==void 0?{...i,defaultValue:t.defaultValue}:i}}const M=4096,F=16384,se=[1024,256,64],re=20,W=["timestamp","level","msg","service","trace_id","span_id"];function ae(n){const t=new Date(n.timestamp).toLocaleTimeString("en-GB",{hour12:!1}),e=n.level.toUpperCase().padEnd(5),i=n.trace_id?.slice(0,8)??"--------",o=n.msg,s=Object.entries(n).filter(([r])=>!W.includes(r)).map(([r,a])=>`${r}=${I(a,M).line}`).join(" ");return`${t} ${e} [${i}] ${o}${s?" "+s:""}`}function le(n){for(const o of[M,...se]){const{line:s,truncated:r}=I(n,o);if(!r){if(s.length<=F)return s;continue}const{line:a}=I({...n,log_truncated:!0},o);if(a.length<=F)return a}const t=Object.keys(n).filter(o=>!W.includes(o)),e={...ue(n,W),log_truncated:!0,log_dropped_count:t.length},i=I({...e,log_dropped_attrs:t.slice(0,re)},M);return i.line.length<=F?i.line:I(e,M).line}function I(n,t){const e=[];let i=!1;return{line:JSON.stringify(n,function(r,a){if(typeof a=="string")return a.length>t&&(i=!0),ce(a,t);if(typeof a=="bigint")return a.toString();if(typeof a!="object"||a===null)return a;for(;e.length>0&&e.at(-1)!==this;)e.pop();return e.includes(a)?"[Circular]":(e.push(a),a)}),truncated:i}}function ce(n,t){return n.length<=t?n:`${n.slice(0,t)}...[truncated ${n.length-t} chars]`}function ue(n,t){const e={};for(const i of t)n[i]!==void 0&&(e[i]=n[i]);return e}function de(n,t){const e=t?ae(n):le(n);n.level==="error"?console.error(e):n.level==="warn"?console.warn(e):console.log(e)}function vt(n,t=0){const e={name:n.name,message:n.message};n.stack!==void 0&&(e.stack=n.stack);for(const i of Object.getOwnPropertyNames(n)){if(i==="name"||i==="message"||i==="stack"||i==="cause")continue;const o=n[i];o!==void 0&&(e[i]=o)}return n.cause!==void 0&&n.cause!==null&&(e.cause=n.cause instanceof Error&&t<5?vt(n.cause,t+1):String(n.cause)),e}function he(n){const t={};for(const[e,i]of Object.entries(n))t[e]=i instanceof Error?vt(i):i;return t}function pe(){return new Date}function me(n){return n.toISOString()}function yt(){return typeof navigator>"u"?"":navigator.userAgent}function fe(){return typeof navigator>"u"?!1:navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function ge(){return/iPhone|iPad|iPod/i.test(yt())||fe()}function be(){return/Android/i.test(yt())}function ve(){return ge()||be()}class ye{constructor(t){this.config=t}config;log(t,e,i={}){const o=this.config.traceProvider?.()??{},s={timestamp:me(pe()),level:t,msg:e,service:this.config.service,...o,...he(i)};de(s,this.config.isDev)}debug(t,e){this.config.isDev&&this.log("debug",t,e)}info(t,e){this.log("info",t,e)}warn(t,e){this.log("warn",t,e)}error(t,e){this.log("error",t,e)}}function wt(n,t){const e=t?.isDev!==void 0?t.isDev:typeof process<"u"?process.env.NODE_ENV!=="production":!0;return new ye({service:n,isDev:e,traceProvider:t?.traceProvider})}function L(n){if(n!==void 0)return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!(n instanceof Error)?n:n instanceof Error?{error:n.message}:{value:n}}function St(n){return{debug:(t,e)=>n.debug(t,L(e)),info:(t,e)=>n.info(t,L(e)),warn:(t,e)=>n.warn(t,L(e)),error:(t,e)=>n.error(t,L(e))}}let Ct=!1;exports.logger=St(wt("client",{isDev:!1}));function _t(){Ct=!0,exports.logger=St(wt("client",{isDev:!0}))}function we(){return Ct}class Se{constructor(t,e,i){this.send=t,this.instance=e,this.onMutationFailed=i}send;instance;onMutationFailed;registry;pendingCallbacks=[];handleMappingReceived(t){exports.logger.debug("Initializing from server mapping",{attributeCount:t.attributes.length}),this.registry=new oe(t.attributes,(e,i)=>this.sendMutation(e,i),this.onMutationFailed),this.replayPendingCallbacks()}handleMutationResult(t){this.registry?.handleResults(t.results)}select(t,e){this.sendMutation([{name:t,value:e}],!1)}selectTransient(t,e){this.sendMutation([{name:t,value:e}],!1,!0)}getValues(t){return this.registry?.get(t)?.getValues()??[]}getValue(t,e){return this.registry?.get(t)?.getValue(e)}onChange(t,e){if(this.registry===void 0){this.pendingCallbacks.push({name:t,callback:e});return}const i=this.registry.get(t);if(i===void 0){exports.logger.warn(`onChange: attribute "${t}" not found — callback will not fire`);return}i.onChange(e)}getAttribute(t){return this.registry?.get(t)}getSelection(){return this.registry?.getSelection()??{}}sendMutation(t,e,i=!1){const o={type:c.MUTATION,instance:this.instance,mutations:t,isInitial:e,...i&&{transient:!0}};this.send(o)}replayPendingCallbacks(){for(const{name:t,callback:e}of this.pendingCallbacks){const i=this.registry?.get(t);i===void 0&&exports.logger.warn(`onChange: attribute "${t}" not found — buffered callback will not fire`),i?.onChange(e)}this.pendingCallbacks.length=0}}class Ce{snapshot;callbacks=[];handleSnapshot(t){this.snapshot=t.attributes;for(const e of this.callbacks)e(t.attributes)}onChange(t){this.callbacks.push(t),this.snapshot!==void 0&&t(this.snapshot)}selectableFor(t){return this.snapshot?.find(i=>i.name===t)?.selectable??null}get current(){return this.snapshot??[]}}let kt=class{constructor(t){this.send=t}send;commands=[];rotate(t){return this.validateFiniteNumber(t,"rotate"),this.commands.push({action:"rotate",value:t}),this}tilt(t){return this.validateFiniteNumber(t,"tilt"),this.commands.push({action:"tilt",value:t}),this}zoom(t){return this.validateFiniteNumber(t,"zoom"),this.commands.push({action:"zoom",value:t}),this}set(){if(this.commands.length===0)throw b.invalidParameter("No camera commands to execute. Call rotate(), tilt(), or zoom() before set().");const t={type:c.CAMERA,commands:this.commands};this.send(t),this.commands=[]}validateFiniteNumber(t,e){if(!Number.isFinite(t))throw b.invalidParameter(`${e}() requires a finite number, got ${String(t)}`)}reset(){const t={type:c.CAMERA,commands:[{action:"reset"}]};this.send(t)}};class At{state;limitsState;changeCallbacks=[];constructor(){this.state={rotation:0,tilt:0,zoom:100}}get rotation(){return this.state.rotation}get tilt(){return this.state.tilt}get zoom(){return this.state.zoom}onChange(t){this.changeCallbacks.push(t)}get limits(){return this.limitsState}applyLimits(t){this.limitsState=t;const e={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(const i of this.changeCallbacks)i(e)}handlePositionUpdate(t){this.update(t.transforms)}update(t){let e=!1;for(const i of t)switch(i.type){case"rotation":this.state.rotation=i.value,e=!0;break;case"tilt":this.state.tilt=i.value,e=!0;break;case"zoom":this.state.zoom=i.value,e=!0;break}if(e){const i={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(const o of this.changeCallbacks)o(i)}}}function _e(n,t){const e=n.filter(s=>ke(s,t));if(e.length===0)return;const i=Math.max(...e.map(nt)),o=e.filter(s=>nt(s)===i);return o.length===1?o[0]:void 0}function ke(n,t){return Object.entries(n.attributes).every(([e,i])=>t[e]===i)}function nt(n){return Object.keys(n.attributes).length}class Et{constructor(t,e){this.dispatchChange=t,this.dispatchSubmit=e}dispatchChange;dispatchSubmit;pricing;selection={};resolved;changeCallbacks=[];renderCallbacks=[];submitCallback;submitDefaultLabel;get current(){return this.resolved}get vatDisplay(){return this.pricing?.vatDisplay}get buttonLabel(){const t=this.pricing?.buttonLabel;if(t!=null&&t!=="")return t;if(this.submitDefaultLabel!==void 0&&this.submitDefaultLabel!=="")return this.submitDefaultLabel}get submittable(){return this.submitCallback===void 0?!1:this.pricing===void 0?!0:this.resolved?.availability==="available"}get submitEnabled(){return this.submittable&&this.buttonLabel!==void 0}onChange(t){this.changeCallbacks.push(t)}onSubmit(t,e){this.submitCallback=t,this.submitDefaultLabel=e?.defaultLabel,this.notifyRender()}onRender(t){return this.renderCallbacks.push(t),()=>{const e=this.renderCallbacks.indexOf(t);e!==-1&&this.renderCallbacks.splice(e,1)}}async submit(){if(!this.submittable)return;const t=this.resolved!==void 0?{attributes:this.resolved.attributes,reference:this.resolved.reference}:{attributes:{...this.selection},reference:""};this.dispatchSubmit(t),await this.submitCallback?.(t)}handlePricingReceived(t){this.pricing=t,this.recompute()}handleSelectionChanged(t){this.selection=t,this.recompute()}recompute(){this.resolved=this.resolve();for(const t of this.changeCallbacks)t(this.resolved);this.dispatchChange(this.resolved),this.notifyRender()}notifyRender(){for(const t of this.renderCallbacks)t()}resolve(){if(this.pricing===void 0)return;const t=_e(this.pricing.rules,this.selection);if(!(t===void 0||t.availability===mt.HIDDEN))return{attributes:{...this.selection},reference:t.reference,price:t.priceCents,currency:this.pricing.currency,availability:t.availability}}}class xt{constructor(t,e,i){this.send=t,this.dispatch=e,this.instance=i}send;dispatch;instance;focused=null;attributes=[];changeCallbacks=[];get current(){return this.focused}set(t){if(typeof t!="string"||t.length===0)throw b.invalidParameter(`set() requires a non-empty component name, got ${String(t)}`);this.send({type:c.FOCUS,instance:this.instance,action:tt.FOCUS,component:t})}clear(){this.send({type:c.FOCUS,instance:this.instance,action:tt.UNFOCUS})}onChange(t){this.changeCallbacks.push(t)}handleStateReceived(t){t.state===Bt.FOCUSED&&t.component!==void 0?(this.focused=t.component,this.attributes=t.attributes??[]):(this.focused=null,this.attributes=[]);const e=this.focused!==null?{component:this.focused,attributes:this.attributes}:null;for(const i of this.changeCallbacks)i(e);this.dispatch(e)}}class Tt{constructor(t){this.filename=t}filename;developedCallbacks=new Set;errorCallbacks=new Set;developed=!1;failed=!1;photoData=null;onDeveloped(t){return this.developed&&this.photoData!==null?(t(this.photoData),this):(this.developedCallbacks.add(t),this)}onError(t){return this.errorCallbacks.add(t),this}getFilename(){return this.filename}develop(t){this.developed||this.failed||(this.photoData=t,this.developed=!0,this.developedCallbacks.forEach(e=>{e(this.photoData)}),this.developedCallbacks.clear(),this.errorCallbacks.clear())}fail(t){this.developed||this.failed||(this.failed=!0,this.errorCallbacks.forEach(e=>{e(t)}),this.developedCallbacks.clear(),this.errorCallbacks.clear())}}const it=3e4;class Rt{constructor(t){this.send=t}send;validExtensions=[".png"];pendingPhotos=new Map;take(t){this.validateFilename(t),exports.logger.debug("Taking snapshot",{filename:t});const e=new Tt(t),i=setTimeout(()=>{this.pendingPhotos.delete(t),exports.logger.warn("Snapshot timed out",{filename:t}),e.fail(new b(`Snapshot timed out: the viewer did not respond within ${it}ms`,_.SNAPSHOT_FAILED))},it);return this.pendingPhotos.set(t,{photo:e,timeout:i}),this.send({type:c.SNAPSHOT,filename:t}),e}handleSnapshotResult(t){const e=this.pendingPhotos.get(t.filename);if(e===void 0){exports.logger.warn("No pending photo found for filename",{filename:t.filename,pendingFilenames:Array.from(this.pendingPhotos.keys())});return}clearTimeout(e.timeout),this.pendingPhotos.delete(t.filename);const{photo:i}=e;if(t.error!==void 0){i.fail(new b(t.error,_.SNAPSHOT_FAILED));return}t.data!==void 0&&i.develop({filename:t.filename,data:t.data})}clear(){if(this.pendingPhotos.size===0)return;const t=new b("Client destroyed before snapshot completed",_.SNAPSHOT_FAILED);for(const{photo:e,timeout:i}of this.pendingPhotos.values())clearTimeout(i),e.fail(t);this.pendingPhotos.clear()}validateFilename(t){if(t===""||typeof t!="string")throw new b("Filename must be a non-empty string",_.INVALID_PARAMETER);if(!this.validExtensions.some(i=>t.toLowerCase().endsWith(i)))throw new b(`Invalid filename: "${t}". Filename must end with one of: ${this.validExtensions.join(", ")}`,_.INVALID_PARAMETER);if(t.includes("..")||t.includes("/")||t.includes("\\"))throw new b('Filename cannot contain path separators or ".."',_.INVALID_PARAMETER)}}class Ae{container=null;attach(t){this.container=t}dispatch(t,e,i=!1){const o=new CustomEvent(t,{detail:e,cancelable:i});return this.container?.dispatchEvent(o),o}on(t,e){const i=o=>{const s=o,r={...s.detail,preventDefault:()=>{s.preventDefault()}};e(r)};return this.container?.addEventListener(t,i),()=>{this.container?.removeEventListener(t,i)}}}const Ee={},xe="en",It=["en","nl","de"],K=["baseLocale"],ot=[],Y=typeof window>"u";globalThis.__paraglide=globalThis.__paraglide??{};globalThis.__paraglide.ssr=globalThis.__paraglide.ssr??{};let st=!1,p=()=>{let n=K;!Y&&typeof window<"u"&&window.location?.href&&(n=Lt(window.location.href));const t=Te(n);if(t)return st||(st=!0,Ot(t,{reload:!1})),t;throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found")};function Te(n,t){let e;for(const i of n){if(i==="baseLocale")e=xe;else if(Mt(i)&&N.has(i)){const s=N.get(i);if(s){const r=s.getLocale();if(r instanceof Promise)continue;if(r!==void 0)return Oe(r)}}const o=X(e);if(o)return o}}const Re=n=>{window.location.reload()};let Ot=(n,t)=>{const e={reload:!0,...t};let i;try{i=p()}catch{}const o=[];let s=K;!Y&&typeof window<"u"&&window.location?.href&&(s=Lt(window.location.href));for(const a of s)if(a!=="baseLocale"&&Mt(a)&&N.has(a)){const u=N.get(a);if(u){let d=u.setLocale(n);d instanceof Promise&&(d=d.catch(f=>{throw new Error(`Custom strategy "${a}" setLocale failed.`,{cause:f})}),o.push(d))}}const r=()=>{!Y&&e.reload&&window.location&&n!==i&&Re()};if(o.length)return Promise.all(o).then(()=>{r()});r()},Ie=()=>typeof window<"u"?window.location.origin:"http://fallback.com";function X(n){if(typeof n!="string")return;const t=n.toLowerCase();for(const e of It)if(e.toLowerCase()===t)return e}function Oe(n){const t=X(n);if(t)return t;throw new Error(`Invalid locale: ${n}. Expected one of: ${It.join(", ")}`)}function Le(n,t){return n.exec(t.href)}function Me(n){return Ne(n)}function Ne(n){const t=typeof n=="string"?new URL(n,Ie()):new URL(n),e=t.pathname.split("/").filter(Boolean);return e.length>0&&X(e[0])&&(t.pathname="/"+e.slice(1).join("/")),t}let rt,at;function ze(n){if(ot.length===0)return;const t=typeof n=="string"?n:n.href;if(rt===t)return at;const e=new URL(t,"http://example.com"),i=Me(e),o=i.href===e.href?[e]:[e,i];let s;for(const r of o){for(const a of ot){const u=new Ee(a.match,r.href);if(Le(u,r)){s=a;break}}if(s)break}return rt=t,at=s,s}function Lt(n){const t=ze(n);return t&&t.exclude!==!0&&Array.isArray(t.strategy)?t.strategy:K}const N=new Map;function Mt(n){return typeof n=="string"&&/^custom-[A-Za-z0-9_-]+$/.test(n)}const Pe=()=>"Working…",Fe=()=>"Bezig…",De=()=>"Läuft…",$e=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Fe():e==="de"?De():Pe()}),Be=()=>"Failed",Ue=()=>"Mislukt",Ve=()=>"Fehlgeschlagen",He=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Ue():e==="de"?Ve():Be()}),je=()=>"Done",qe=()=>"Gelukt",Ge=()=>"Fertig",Ze=((n={},t={})=>{const e=t.locale??p();return e==="nl"?qe():e==="de"?Ge():je()}),We=()=>"Annotations",Ye=()=>"Annotaties",Qe=()=>"Anmerkungen",Ke=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Ye():e==="de"?Qe():We()}),Xe=()=>"Activate AR",Je=()=>"AR activeren",tn=()=>"AR aktivieren",en=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Je():e==="de"?tn():Xe()}),nn=()=>"Reset camera",on=()=>"Camera resetten",sn=()=>"Kamera zurücksetzen",rn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?on():e==="de"?sn():nn()}),an=()=>"Rotate left",ln=()=>"Naar links draaien",cn=()=>"Nach links drehen",un=((n={},t={})=>{const e=t.locale??p();return e==="nl"?ln():e==="de"?cn():an()}),dn=()=>"Rotate right",hn=()=>"Naar rechts draaien",pn=()=>"Nach rechts drehen",mn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?hn():e==="de"?pn():dn()}),fn=()=>"Tilt down",gn=()=>"Omlaag kantelen",bn=()=>"Nach unten kippen",vn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?gn():e==="de"?bn():fn()}),yn=()=>"Tilt up",wn=()=>"Omhoog kantelen",Sn=()=>"Nach oben kippen",Cn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?wn():e==="de"?Sn():yn()}),_n=()=>"Zoom in",kn=()=>"Inzoomen",An=()=>"Hineinzoomen",En=((n={},t={})=>{const e=t.locale??p();return e==="nl"?kn():e==="de"?An():_n()}),xn=()=>"Zoom out",Tn=()=>"Uitzoomen",Rn=()=>"Herauszoomen",In=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Tn():e==="de"?Rn():xn()}),On=()=>"Close",Ln=()=>"Sluiten",Mn=()=>"Schließen",Nn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Ln():e==="de"?Mn():On()}),zn=()=>"Configure",Pn=()=>"Configureren",Fn=()=>"Konfigurieren",Dn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Pn():e==="de"?Fn():zn()}),$n=()=>"Fullscreen",Bn=()=>"Volledig scherm",Un=()=>"Vollbild",Vn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Bn():e==="de"?Un():$n()}),Hn=()=>"Close",jn=()=>"Sluiten",qn=()=>"Schließen",Gn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?jn():e==="de"?qn():Hn()}),Zn=()=>"Use your smartphone camera to scan this QR code",Wn=()=>"Gebruik de camera van je smartphone om deze QR-code te scannen",Yn=()=>"Verwende die Kamera deines Smartphones, um diesen QR-Code zu scannen",Qn=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Wn():e==="de"?Yn():Zn()}),Kn=()=>"Your phone will open the 3D model in AR mode.",Xn=()=>"Je telefoon opent het 3D-model in AR-modus.",Jn=()=>"Dein Telefon öffnet das 3D-Modell im AR-Modus.",ti=((n={},t={})=>{const e=t.locale??p();return e==="nl"?Xn():e==="de"?Jn():Kn()}),ei=()=>"Scan to view in AR",ni=()=>"Scan om in AR te bekijken",ii=()=>"Scannen für AR-Ansicht",oi=((n={},t={})=>{const e=t.locale??p();return e==="nl"?ni():e==="de"?ii():ei()}),si=()=>"Screenshot",ri=()=>"Screenshot",ai=()=>"Screenshot",li=((n={},t={})=>{const e=t.locale??p();return e==="nl"?ri():e==="de"?ai():si()}),ci=()=>"Downloading",ui=()=>"Downloaden",di=()=>"Herunterladen",hi=((n={},t={})=>{const e=t.locale??p();return e==="nl"?ui():e==="de"?di():ci()});const pi={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};const Nt=([n,t,e])=>{const i=document.createElementNS("http://www.w3.org/2000/svg",n);return Object.keys(t).forEach(o=>{i.setAttribute(o,String(t[o]))}),e?.length&&e.forEach(o=>{const s=Nt(o);i.appendChild(s)}),i},zt=(n,t={})=>{const i={...pi,...t};return Nt(["svg",i,n])};const mi=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}],["path",{d:"m3.3 7 8.7 5 8.7-5"}],["path",{d:"M12 22V12"}]];const fi=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z"}],["circle",{cx:"12",cy:"13",r:"3"}]];const Pt=[["path",{d:"m6 9 6 6 6-6"}]];const gi=[["path",{d:"m15 18-6-6 6-6"}]];const bi=[["path",{d:"m9 18 6-6-6-6"}]];const vi=[["path",{d:"m18 15-6-6-6 6"}]];const yi=[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568"}],["path",{d:"m2 2 20 20"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74"}]];const wi=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}],["circle",{cx:"12",cy:"10",r:"3"}]];const Si=[["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]];const Ci=[["path",{d:"m14 10 7-7"}],["path",{d:"M20 10h-6V4"}],["path",{d:"m3 21 7-7"}],["path",{d:"M4 14h6v6"}]];const _i=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}]];const ki=[["path",{d:"M10 5H3"}],["path",{d:"M12 19H3"}],["path",{d:"M14 3v4"}],["path",{d:"M16 17v4"}],["path",{d:"M21 12h-9"}],["path",{d:"M21 19h-5"}],["path",{d:"M21 5h-7"}],["path",{d:"M8 10v4"}],["path",{d:"M8 12H3"}]];const Ai=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];const Ei=[["circle",{cx:"11",cy:"11",r:"8"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11"}]];const xi=[["circle",{cx:"11",cy:"11",r:"8"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11"}]];function v(n,{size:t=20,strokeWidth:e=1.75}={}){return zt(n,{width:t,height:t,"stroke-width":e})}const g={ar:n=>v(mi,n),annotations:n=>v(wi,n),annotationsOff:n=>v(yi,n),fullscreen:n=>v(Si,n),exitFullscreen:n=>v(Ci,n),screenshot:n=>v(fi,n),tiltUp:n=>v(vi,n),tiltDown:n=>v(Pt,n),rotateLeft:n=>v(gi,n),rotateRight:n=>v(bi,n),zoomIn:n=>v(Ei,n),zoomOut:n=>v(xi,n),reset:n=>v(_i,n),configurator:n=>v(ki,n),close:n=>v(Ai,n)};class y{element;constructor({variant:t="default",size:e="default",label:i,icon:o,onClick:s,disabled:r=!1}={}){this.element=document.createElement("button"),this.element.className=`ui-btn ui-btn--${t} ui-btn--size-${e}`,i!==void 0&&(this.element.setAttribute("aria-label",i),this.element.title=i),o!==void 0?this.element.appendChild(o):i!==void 0&&(this.element.textContent=i),s&&this.element.addEventListener("click",s),this.element.disabled=r}setIcon(t){const e=this.element.querySelector("svg");e!==null?e.replaceWith(t):this.element.appendChild(t)}}const m={semantic:{error:"#dc2626"},neutral:{500:"#737373",600:"#525252",900:"#171717"},white:"#ffffff",black:"#000000"},l={0:"0",.5:"0.125rem",1:"0.25rem",1.5:"0.375rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",9:"2.25rem"};class Ti{element;constructor(){this.element=document.createElement("div"),Object.assign(this.element.style,{background:m.white,borderRadius:l[3],padding:l[6],boxShadow:`0 ${l[2]} ${l[8]} oklch(0% 0 0 / 20%)`,maxWidth:"20rem",width:"100%"})}}class Ri{constructor(t={}){this.options=t,this.card=new Ti,this.backdrop=this.createBackdrop(),this.backdrop.appendChild(this.card.element)}options;card;backdrop;keyHandler=null;open(){document.body.appendChild(this.backdrop),this.keyHandler=t=>{t.key==="Escape"&&this.close()},document.addEventListener("keydown",this.keyHandler)}close(){this.backdrop.remove(),this.keyHandler!==null&&(document.removeEventListener("keydown",this.keyHandler),this.keyHandler=null),this.options.onClose?.()}createBackdrop(){const t=document.createElement("div");return Object.assign(t.style,{position:"fixed",inset:l[0],background:"oklch(0% 0 0 / 50%)",zIndex:"9999",display:"flex",alignItems:"center",justifyContent:"center"}),t.addEventListener("click",e=>{e.target===t&&this.close()}),t}}class Ii{element;selectCallback=null;constructor(t,e,i){this.element=document.createElement("div"),this.element.className="ui-toggle-group";for(let o=0;o<t.length;o++){const s=t[o],r=document.createElement("button");r.className="ui-toggle-group-item",r.dataset.value=s,r.textContent=i?.[o]??s,r.dataset.state=s===e?"on":"off",r.setAttribute("aria-pressed",s===e?"true":"false"),r.addEventListener("click",()=>{this.selectCallback?.(s)}),this.element.appendChild(r)}}setSelected(t){for(const e of this.element.querySelectorAll(".ui-toggle-group-item")){const i=e.dataset.value===t;e.dataset.state=i?"on":"off",e.setAttribute("aria-pressed",i?"true":"false")}}onSelect(t){this.selectCallback=t}setEnabled(t){for(const e of this.element.querySelectorAll(".ui-toggle-group-item")){const i=t===null||t.includes(e.dataset.value??"");e.disabled=!i,e.setAttribute("aria-disabled",i?"false":"true")}}}class Oi{element;select;constructor(t,e,i,o,s){this.select=document.createElement("select"),this.select.className="ui-native-select",this.select.dataset.name=t,this.select.setAttribute("aria-label",i);const r=document.createElement("option");r.value="",r.disabled=!0,r.textContent=i,this.select.appendChild(r);let a=!1;for(let d=0;d<e.length;d++){const f=e[d],h=document.createElement("option");h.value=f,h.textContent=s?.[d]??f,f===o&&(h.selected=!0,a=!0),this.select.appendChild(h)}a||(r.selected=!0);const u=zt(Pt,{width:16,height:16,"stroke-width":2});u.classList.add("ui-native-select-icon"),this.element=document.createElement("div"),this.element.className="ui-native-select-wrap",this.element.appendChild(this.select),this.element.appendChild(u)}setSelected(t){this.select.value=t}onSelect(t){this.select.addEventListener("change",()=>{t(this.select.value)})}setEnabled(t){for(const e of this.select.options)e.value!==""&&(e.disabled=t!==null&&!t.includes(e.value))}}class Li{element;input;valueText;values;options;selectCallback=null;settleCallback=null;constructor(t,e){if(t.length===0)throw new Error("Virtualdisplay: Slider needs at least one value");this.values=t,this.options=e,this.input=document.createElement("input"),this.input.type="range",this.input.className="ui-slider-input",this.input.min="0",this.input.max=String(t.length-1),this.input.step="1",this.input.setAttribute("aria-label",e.label),this.valueText=document.createElement("span"),this.valueText.className="ui-slider-value",this.valueText.setAttribute("aria-hidden","true");const i=document.createElement("div");i.className="ui-slider-track",i.appendChild(this.input),i.appendChild(this.buildEnds()),this.element=document.createElement("div"),this.element.className="ui-slider",this.element.appendChild(i),this.element.appendChild(this.valueText);const o=e.initialSelected===void 0?0:t.indexOf(e.initialSelected);this.applyIndex(o===-1?0:o),this.listen()}setSelected(t){const e=this.values.indexOf(t);e!==-1&&this.applyIndex(e)}onSelect(t){this.selectCallback=t}onSettle(t){this.settleCallback=t}listen(){this.input.addEventListener("input",()=>{const t=this.values[this.currentIndex];t!==void 0&&(this.applyIndex(this.currentIndex),this.selectCallback?.(t))}),this.input.addEventListener("change",()=>{const t=this.values[this.currentIndex];t!==void 0&&this.settleCallback?.(t)})}get currentIndex(){return Number(this.input.value)}applyIndex(t){this.input.value=String(t);const e=this.displayAt(t);this.valueText.textContent=e,this.input.setAttribute("aria-valuetext",e);const i=this.values.length===1?100:t/(this.values.length-1)*100;this.element.style.setProperty("--ui-slider-pct",`${i}%`)}buildEnds(){const t=document.createElement("div");t.className="ui-slider-ends",t.setAttribute("aria-hidden","true");for(const e of[0,this.values.length-1]){const i=document.createElement("span");i.textContent=this.labelAt(e),t.appendChild(i)}return t}labelAt(t){return this.options.labels?.[t]??this.values[t]??""}displayAt(t){const e=this.labelAt(t);return this.options.unit===void 0?e:`${e} ${this.options.unit}`}}const S={fontFamily:{sans:["Mona Sans","ui-sans-serif","system-ui","sans-serif","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"]},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem"},fontWeight:{medium:"500",semibold:"600"}},E=S.fontFamily.sans.join(", "),Mi=`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-5iZMYShA.cjs");var t={HANDSHAKE:`handshake`,SESSION:`session`,MUTATION:`mutation`,STATE:`state`,LOADING_INDICATOR:`loading_indicator`,CAMERA:`camera`,SNAPSHOT:`snapshot`,MAPPING:`mapping`,AR_ACTIVATE:`ar_activate`,FULLSCREEN:`fullscreen`,CONFIG:`config`,ANNOTATION_TOGGLE:`annotation_toggle`,FOCUS:`focus`,PRICING:`pricing`,QR_SHOWN:`qr_shown`,SYNC:`sync`,SELECTABLE:`selectable`,APP_RESOLVED:`app_resolved`},n=`main`,r={FOCUS:`focus`,UNFOCUS:`unfocus`},i={FOCUSED:`focused`,UNFOCUSED:`unfocused`},a={AVAILABLE:`available`,VIEW_ONLY:`view_only`,HIDDEN:`hidden`};function o(e){return typeof e!=`object`||!e?null:e}var s=new Set(Object.values(t));function c(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.target!=`string`&&typeof t.type==`string`&&s.has(t.type)}function l(e){let n=o(e);return n!==null&&n.type===t.HANDSHAKE}function u(e){let n=o(e);return n!==null&&n.type===t.SESSION&&typeof n.sessionId==`string`}function ee(e){let n=o(e);return n!==null&&n.type===t.APP_RESOLVED&&typeof n.appType==`string`&&n.appType!==``&&typeof n.name==`string`}function d(e){let n=o(e);return n!==null&&n.type===t.MUTATION&&typeof n.instance==`string`&&n.instance!==``&&Array.isArray(n.results)}function f(e){let n=o(e);return n!==null&&n.type===t.SNAPSHOT&&(`data`in n||`error`in n)}function p(e){let n=o(e);return n!==null&&n.type===t.CAMERA&&Array.isArray(n.transforms)}function te(e){let n=o(e);return n!==null&&n.type===t.MAPPING&&typeof n.instance==`string`&&n.instance!==``&&Array.isArray(n.attributes)}function ne(e){let n=o(e);return n!==null&&n.type===t.LOADING_INDICATOR&&typeof n.progress==`number`}function m(e){let n=o(e);return n!==null&&n.type===t.SYNC&&typeof n.connected==`boolean`}function re(e){let n=o(e);return n!==null&&n.type===t.SELECTABLE&&typeof n.instance==`string`&&n.instance!==``&&Array.isArray(n.attributes)}function ie(e){let n=o(e);return n!==null&&n.type===t.CONFIG&&typeof n.viewerSettings==`object`}function ae(e){let n=o(e);return n!==null&&n.type===t.FOCUS&&typeof n.instance==`string`&&n.instance!==``&&typeof n.state==`string`}function oe(e){let n=o(e);return n!==null&&n.type===t.PRICING&&typeof n.instance==`string`&&n.instance!==``&&typeof n.pricing==`object`&&n.pricing!==null}var se=class{processor;pending=[];isReady=!1;constructor(e){this.processor=e}enqueue(e){this.isReady?this.processor(e):this.pending.push(e)}markReady(){if(this.isReady||(this.isReady=!0,this.pending.length===0))return;let e=[...this.pending];this.pending.length=0;for(let t of e)this.processor(t)}hasPending(e){return this.pending.some(t=>t.type===e)}clear(){this.pending.length=0}},ce=class{getTarget;handlers=new Map;publisher;consumer;listener=null;sourceId;targetOrigin;isValid;onHandlerError;constructor(e,t){this.getTarget=e,this.sourceId=`vd-${Math.random().toString(36).slice(2,8)}`,this.targetOrigin=`*`,this.isValid=t?.isValid??c,this.onHandlerError=t?.onHandlerError??le,this.publisher=new se(e=>this.post(e)),this.consumer=new se(e=>this.routeToHandler(e)),t?.bufferIncoming!==!0&&this.consumer.markReady()}on(e,t){this.handlers.set(e,t)}setTargetOrigin(e){this.targetOrigin=e}send(e){this.publisher.enqueue(e)}receive(e){this.isValid(e)&&this.consumer.enqueue(e)}markReady(){this.publisher.markReady()}markConsumerReady(){this.consumer.markReady()}consumerHasPending(e){return this.consumer.hasPending(e)}start(){this.listener===null&&(this.listener=e=>{let{data:t}=e;if(!this.isValid(t)||t._source===this.sourceId)return;let n=this.getTarget();if(n!==null&&e.source!==null&&e.source!==n)return;let r=t;this.consumer.enqueue(r)},window.addEventListener(`message`,this.listener))}destroy(){this.listener!==null&&(window.removeEventListener(`message`,this.listener),this.listener=null),this.publisher.clear(),this.consumer.clear(),this.handlers.clear()}post(e){let t=this.getTarget();t!==null&&t.postMessage({...e,_source:this.sourceId},this.targetOrigin)}routeToHandler(e){let t=this.handlers.get(e.type);if(t===void 0)return;let n;try{n=t(e)}catch(t){this.onHandlerError(e,t);return}n instanceof Promise&&n.catch(t=>{this.onHandlerError(e,t)})}};function le(e,t){let n=t instanceof Error?t.message:String(t);console.error(`Virtualdisplay: error handling ${e.type}: ${n}`)}t.CAMERA,t.LOADING_INDICATOR;var ue=class{send;instance;constructor(e,t){this.send=e,this.instance=t}setEnabled(e){this.send({type:t.ANNOTATION_TOGGLE,instance:this.instance,enabled:e})}},de=class{value;attribute;label;isSelectedValue=!1;constructor(e,t,n){this.value=e,this.attribute=t,this.label=n}get isSelected(){return this.isSelectedValue}setSelected(e){this.isSelectedValue=e}},fe={},pe=[`en`,`nl`,`de`],me=`PARAGLIDE_LOCALE`,h=[`globalVariable`,`baseLocale`],he=[],g=typeof window>`u`;globalThis.__paraglide=globalThis.__paraglide??{},globalThis.__paraglide.ssr=globalThis.__paraglide.ssr??{};var _,ge=!1,v=()=>{let e=h;!g&&typeof window<`u`&&window.location?.href&&(e=Ne(window.location.href));let t=_e(e,typeof window<`u`?window.location?.href:void 0);if(t)return ge||(_=t,ge=!0,ye(t,{reload:!1})),t;throw Error(`No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found`)};function _e(e,t){let n;for(let t of e){if(t===`baseLocale`)n=`en`;else if(t===`globalVariable`&&_!==void 0)n=_;else if(Pe(t)&&x.has(t)){let e=x.get(t);if(e){let t=e.getLocale();if(t instanceof Promise)continue;if(t!==void 0)return xe(t)}}let e=y(n);if(e)return e}}var ve=e=>{e?window.location.href=e:window.location.reload()},ye=(e,t)=>{let n={reload:!0,...t},r;try{r=v()}catch{}let i=[],a=h;!g&&typeof window<`u`&&window.location?.href&&(a=Ne(window.location.href));for(let t of a)if(t===`globalVariable`)_=e;else if(t===`baseLocale`)continue;else if(Pe(t)&&x.has(t)){let n=x.get(t);if(n){let r=n.setLocale(e);r instanceof Promise&&(r=r.catch(e=>{throw Error(`Custom strategy "${t}" setLocale failed.`,{cause:e})}),i.push(r))}}let o=()=>{!g&&n.reload&&window.location&&e!==r&&ve(void 0)};if(i.length)return Promise.all(i).then(()=>{o()});o()},be=()=>typeof window<`u`?window.location.origin:`http://fallback.com`;function y(e){if(typeof e!=`string`)return;let t=e.toLowerCase();for(let e of pe)if(e.toLowerCase()===t)return e}function xe(e){let t=y(e);if(t)return t;throw Error(`Invalid locale: ${e}. Expected one of: ${pe.join(`, `)}`)}function b(e){return e}function Se(e,t){return new fe(e,t.href)}function Ce(){return 0}function we(e){return he}function Te(e,t){return e.exec(t.href)}var Ee=me.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?:^|;\\s*)${Ee}=([^;]*)`);function De(e){return Oe(e)}function Oe(e){let t=b(typeof e==`string`?new URL(e,be()):new URL(e.href)),n=t.pathname.replace(/^\/+/,``).split(`/`);return n.length>0&&y(n[0])&&(t.pathname=`/`+n.slice(1).join(`/`)),b(t)}var ke=-1,Ae,je;function Me(e){if(he.length===0)return;let t=typeof e==`string`?e:e.href,n=Ce();if(Ae===t&&ke===n)return je;let r=b(new URL(t,`http://example.com`)),i=De(r),a=i.href===r.href?[r]:[r,i],o;for(let e of a){for(let t of we(e))if(Te(Se(t.match,e),e)){o=t;break}if(o)break}return ke=n,Ae=t,je=o,o}function Ne(e){let t=Me(e);return t&&t.exclude!==!0&&Array.isArray(t.strategy)?t.strategy:h}var x=new Map;function Pe(e){return typeof e==`string`&&/^custom-[A-Za-z0-9_-]+$/.test(e)}function Fe(e,t){return Ie(t!==void 0&&Object.hasOwn(t,e)?t[e]:void 0)??S(e)}function Ie(e){if(e===void 0)return;for(let t of[v(),`nl`,`en`])if(Object.hasOwn(e,t)&&e[t]!==void 0)return e[t];let[t]=Object.values(e);return t}function S(e){let t=e.replace(/([A-Z])/g,` $1`).trim();return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}var C={NO_MAPPING:`NO_MAPPING`,ATTRIBUTE_NOT_FOUND:`ATTRIBUTE_NOT_FOUND`,VALUE_NOT_FOUND:`VALUE_NOT_FOUND`,PARENT_NOT_FOUND:`PARENT_NOT_FOUND`,INVALID_PARAMETER:`INVALID_PARAMETER`,SNAPSHOT_FAILED:`SNAPSHOT_FAILED`},w=class e extends Error{code;constructor(e,t){super(e),this.name=`VirtualdisplayError`,this.code=t}static valueNotFound(t,n){return new e(`Value "${n}" not found for attribute "${t}"`,C.VALUE_NOT_FOUND)}static parentNotFound(t){return new e(`Parent element not found: ${t}`,C.PARENT_NOT_FOUND)}static invalidParameter(t){return new e(t,C.INVALID_PARAMETER)}},Le=class{name;defaultValue;values;onSelect;onChangeCallback;constructor(e){this.name=e.name,this.defaultValue=e.defaultValue,this.onSelect=e.onSelect,this.values=this.createValues(e.values,e.labels)}select(e){if(!this.values.has(e))throw w.valueNotFound(this.name,e);this.onSelect(this.name,e)}getValues(){return Array.from(this.values.values())}getValue(e){return this.values.get(e)}get selected(){for(let e of this.values.values())if(e.isSelected)return e.value}onChange(e){this.onChangeCallback=e}handleResult(e){let t;for(let n of this.values.values()){let r=n.value===e;n.setSelected(r),r&&(t=n)}t!==void 0&&this.onChangeCallback!==void 0&&this.onChangeCallback(t)}createValues(e,t){let n=new Map;for(let r of e){let e=new de(r,this.name,Fe(r,t));r===this.defaultValue&&e.setSelected(!0),n.set(r,e)}return n}},Re=class{attributes=new Map;constructor(e,t,n){for(let n of e){let e=this.buildOptions(n,t);this.attributes.set(n.name,new Le(e))}this.onMutationFailed=n}onMutationFailed;get(e){return this.attributes.get(e)}getSelection(){let e={};for(let[t,n]of this.attributes){let r=n.selected;r!==void 0&&(e[t]=r)}return e}handleResults(e){for(let t of e)t.success?this.get(t.name)?.handleResult(t.value):this.onMutationFailed?.(t.name,t.value)}buildOptions(e,t){let n={name:e.name,values:e.values,...e.labels!==void 0&&{labels:e.labels},onSelect:(e,n)=>{t([{name:e,value:n}],!1)}};return e.defaultValue===void 0?n:{...n,defaultValue:e.defaultValue}}},T=4096,E=16384,ze=[1024,256,64],Be=20,D=[`timestamp`,`level`,`msg`,`service`,`trace_id`,`span_id`];function Ve(e){let t=new Date(e.timestamp).toLocaleTimeString(`en-GB`,{hour12:!1}),n=e.level.toUpperCase().padEnd(5),r=e.trace_id?.slice(0,8)??`--------`,i=e.msg,a=Object.entries(e).filter(([e])=>!D.includes(e)).map(([e,t])=>`${e}=${O(t,T).line}`).join(` `);return`${t} ${n} [${r}] ${i}${a?` `+a:``}`}function He(e){for(let t of[T,...ze]){let{line:n,truncated:r}=O(e,t);if(!r){if(n.length<=E)return n;continue}let{line:i}=O({...e,log_truncated:!0},t);if(i.length<=E)return i}let t=Object.keys(e).filter(e=>!D.includes(e)),n={...We(e,D),log_truncated:!0,log_dropped_count:t.length},r=O({...n,log_dropped_attrs:t.slice(0,Be)},T);return r.line.length<=E?r.line:O(n,T).line}function O(e,t){let n=[],r=!1;return{line:JSON.stringify(e,function(e,i){if(typeof i==`string`)return i.length>t&&(r=!0),Ue(i,t);if(typeof i==`bigint`)return i.toString();if(typeof i!=`object`||!i)return i;for(;n.length>0&&n.at(-1)!==this;)n.pop();return n.includes(i)?`[Circular]`:(n.push(i),i)}),truncated:r}}function Ue(e,t){return e.length<=t?e:`${e.slice(0,t)}...[truncated ${e.length-t} chars]`}function We(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Ge(e,t){let n=t?Ve(e):He(e);e.level===`error`?console.error(n):e.level===`warn`?console.warn(n):console.log(n)}function Ke(e,t=0){let n={name:e.name,message:e.message};return e.stack!==void 0&&(n.stack=e.stack),Je(e,n),e.cause!==void 0&&e.cause!==null&&(n.cause=e.cause instanceof Error&&t<5?Ke(e.cause,t+1):String(e.cause)),n}var qe=new Set([`name`,`message`,`stack`,`cause`]);function Je(e,t){for(let n of Object.getOwnPropertyNames(e)){if(qe.has(n))continue;let r=e[n];r!==void 0&&(t[n]=r)}}function Ye(e){let t={};for(let[n,r]of Object.entries(e))t[n]=r instanceof Error?Ke(r):r;return t}function Xe(){return new Date}function Ze(){return typeof navigator>`u`?``:navigator.userAgent}function Qe(){return typeof navigator>`u`?!1:navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function $e(){return/iPhone|iPad|iPod/i.test(Ze())||Qe()}function et(){return/Android/i.test(Ze())}function tt(){return $e()||et()}var nt=class{config;constructor(e){this.config=e}log(e,t,n={}){let r=this.config.traceProvider?.()??{};Ge({timestamp:Xe().toISOString(),level:e,msg:t,service:this.config.service,...r,...Ye(n)},this.config.isDev)}debug(e,t){this.config.isDev&&this.log(`debug`,e,t)}info(e,t){this.log(`info`,e,t)}warn(e,t){this.log(`warn`,e,t)}error(e,t){this.log(`error`,e,t)}};function rt(e,t){return new nt({service:e,isDev:t?.isDev===void 0?typeof process<`u`?process.env.NODE_ENV!==`production`:!0:t.isDev,traceProvider:t?.traceProvider})}function k(e){if(e!==void 0)return typeof e==`object`&&e&&!Array.isArray(e)&&!(e instanceof Error)?e:e instanceof Error?{error:e.message}:{value:e}}function it(e){return{debug:(t,n)=>e.debug(t,k(n)),info:(t,n)=>e.info(t,k(n)),warn:(t,n)=>e.warn(t,k(n)),error:(t,n)=>e.error(t,k(n))}}var at=!1,A=it(rt(`client`,{isDev:!1}));function ot(){at=!0,A=it(rt(`client`,{isDev:!0}))}function st(){return at}var ct=class{send;instance;onMutationFailed;registry;pendingCallbacks=[];constructor(e,t,n){this.send=e,this.instance=t,this.onMutationFailed=n}handleMappingReceived(e){A.debug(`Initializing from server mapping`,{attributeCount:e.attributes.length}),this.registry=new Re(e.attributes,(e,t)=>this.sendMutation(e,t),this.onMutationFailed),this.replayPendingCallbacks()}handleMutationResult(e){this.registry?.handleResults(e.results)}select(e,t){this.sendMutation([{name:e,value:t}],!1)}selectTransient(e,t){this.sendMutation([{name:e,value:t}],!1,!0)}getValues(e){return this.registry?.get(e)?.getValues()??[]}getValue(e,t){return this.registry?.get(e)?.getValue(t)}onChange(e,t){if(this.registry===void 0){this.pendingCallbacks.push({name:e,callback:t});return}let n=this.registry.get(e);n===void 0?A.warn(`onChange: attribute "${e}" not found — callback will not fire`):n.onChange(t)}getAttribute(e){return this.registry?.get(e)}getSelection(){return this.registry?.getSelection()??{}}sendMutation(e,n,r=!1){let i={type:t.MUTATION,instance:this.instance,mutations:e,isInitial:n,...r&&{transient:!0}};this.send(i)}replayPendingCallbacks(){for(let{name:e,callback:t}of this.pendingCallbacks){let n=this.registry?.get(e);n===void 0&&A.warn(`onChange: attribute "${e}" not found — buffered callback will not fire`),n?.onChange(t)}this.pendingCallbacks.length=0}},lt=class{snapshot;callbacks=[];handleSnapshot(e){this.snapshot=e.attributes;for(let t of this.callbacks)t(e.attributes)}onChange(e){this.callbacks.push(e),this.snapshot!==void 0&&e(this.snapshot)}selectableFor(e){return this.snapshot?.find(t=>t.name===e)?.selectable??null}get current(){return this.snapshot??[]}},ut=class{send;commands=[];constructor(e){this.send=e}rotate(e){return this.validateFiniteNumber(e,`rotate`),this.commands.push({action:`rotate`,value:e}),this}tilt(e){return this.validateFiniteNumber(e,`tilt`),this.commands.push({action:`tilt`,value:e}),this}zoom(e){return this.validateFiniteNumber(e,`zoom`),this.commands.push({action:`zoom`,value:e}),this}set(){if(this.commands.length===0)throw w.invalidParameter(`No camera commands to execute. Call rotate(), tilt(), or zoom() before set().`);let e={type:t.CAMERA,commands:this.commands};this.send(e),this.commands=[]}validateFiniteNumber(e,t){if(!Number.isFinite(e))throw w.invalidParameter(`${t}() requires a finite number, got ${String(e)}`)}reset(){let e={type:t.CAMERA,commands:[{action:`reset`}]};this.send(e)}},dt=class{state;limitsState;changeCallbacks=[];constructor(){this.state={rotation:0,tilt:0,zoom:100}}get rotation(){return this.state.rotation}get tilt(){return this.state.tilt}get zoom(){return this.state.zoom}onChange(e){this.changeCallbacks.push(e)}get limits(){return this.limitsState}applyLimits(e){this.limitsState=e;let t={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(let e of this.changeCallbacks)e(t)}handlePositionUpdate(e){this.update(e.transforms)}update(e){let t=!1;for(let n of e)switch(n.type){case`rotation`:this.state.rotation=n.value,t=!0;break;case`tilt`:this.state.tilt=n.value,t=!0;break;case`zoom`:this.state.zoom=n.value,t=!0}if(t){let e={rotation:this.rotation,tilt:this.tilt,zoom:this.zoom};for(let t of this.changeCallbacks)t(e)}}};function ft(e,t){let n=e.filter(e=>pt(e,t));if(n.length===0)return;let r=Math.max(...n.map(mt)),i=n.filter(e=>mt(e)===r);return i.length===1?i[0]:void 0}function pt(e,t){return Object.entries(e.attributes).every(([e,n])=>t[e]===n)}function mt(e){return Object.keys(e.attributes).length}var ht=class{dispatchChange;dispatchSubmit;pricing;selection={};resolved;changeCallbacks=[];renderCallbacks=[];submitCallback;submitDefaultLabel;constructor(e,t){this.dispatchChange=e,this.dispatchSubmit=t}get current(){return this.resolved}get vatDisplay(){return this.pricing?.vatDisplay}get buttonLabel(){let e=this.pricing?.buttonLabel;if(e!=null&&e!==``)return e;if(this.submitDefaultLabel!==void 0&&this.submitDefaultLabel!==``)return this.submitDefaultLabel}get submittable(){return this.submitCallback===void 0?!1:this.pricing===void 0||this.resolved?.availability===`available`}get submitEnabled(){return this.submittable&&this.buttonLabel!==void 0}onChange(e){this.changeCallbacks.push(e)}onSubmit(e,t){this.submitCallback=e,this.submitDefaultLabel=t?.defaultLabel,this.notifyRender()}onRender(e){return this.renderCallbacks.push(e),()=>{let t=this.renderCallbacks.indexOf(e);t!==-1&&this.renderCallbacks.splice(t,1)}}async submit(){if(!this.submittable)return;let e=this.resolved===void 0?{attributes:{...this.selection},reference:``}:{attributes:this.resolved.attributes,reference:this.resolved.reference};this.dispatchSubmit(e),await this.submitCallback?.(e)}handlePricingReceived(e){this.pricing=e,this.recompute()}handleSelectionChanged(e){this.selection=e,this.recompute()}recompute(){this.resolved=this.resolve();for(let e of this.changeCallbacks)e(this.resolved);this.dispatchChange(this.resolved),this.notifyRender()}notifyRender(){for(let e of this.renderCallbacks)e()}resolve(){if(this.pricing===void 0)return;let e=ft(this.pricing.rules,this.selection);if(e!==void 0&&e.availability!==a.HIDDEN)return{attributes:{...this.selection},reference:e.reference,price:e.priceCents,currency:this.pricing.currency,availability:e.availability}}},gt=class{send;dispatch;instance;focused=null;attributes=[];changeCallbacks=[];constructor(e,t,n){this.send=e,this.dispatch=t,this.instance=n}get current(){return this.focused}set(e){if(typeof e!=`string`||e.length===0)throw w.invalidParameter(`set() requires a non-empty component name, got ${String(e)}`);this.send({type:t.FOCUS,instance:this.instance,action:r.FOCUS,component:e})}clear(){this.send({type:t.FOCUS,instance:this.instance,action:r.UNFOCUS})}onChange(e){this.changeCallbacks.push(e)}handleStateReceived(e){e.state===i.FOCUSED&&e.component!==void 0?(this.focused=e.component,this.attributes=e.attributes??[]):(this.focused=null,this.attributes=[]);let t=this.focused===null?null:{component:this.focused,attributes:this.attributes};for(let e of this.changeCallbacks)e(t);this.dispatch(t)}},_t=class{filename;developedCallbacks=new Set;errorCallbacks=new Set;developed=!1;failed=!1;photoData=null;constructor(e){this.filename=e}onDeveloped(e){return this.developed&&this.photoData!==null?(e(this.photoData),this):(this.developedCallbacks.add(e),this)}onError(e){return this.errorCallbacks.add(e),this}getFilename(){return this.filename}develop(e){this.developed||this.failed||(this.photoData=e,this.developed=!0,this.developedCallbacks.forEach(e=>{e(this.photoData)}),this.developedCallbacks.clear(),this.errorCallbacks.clear())}fail(e){this.developed||this.failed||(this.failed=!0,this.errorCallbacks.forEach(t=>{t(e)}),this.developedCallbacks.clear(),this.errorCallbacks.clear())}},vt=3e4,yt=class{send;validExtensions=[`.png`];pendingPhotos=new Map;constructor(e){this.send=e}take(e){return this.request(e,void 0)}takeOf(e,t){return this.request(e,t)}request(e,n){this.validateFilename(e),A.debug(`Taking snapshot`,{filename:e});let r=new _t(e),i=setTimeout(()=>{this.pendingPhotos.delete(e),A.warn(`Snapshot timed out`,{filename:e}),r.fail(new w(`Snapshot timed out: the viewer did not respond within ${vt}ms`,C.SNAPSHOT_FAILED))},vt);return this.pendingPhotos.set(e,{photo:r,timeout:i}),this.send({type:t.SNAPSHOT,filename:e,...n!==void 0&&{subject:n}}),r}handleSnapshotResult(e){let t=this.pendingPhotos.get(e.filename);if(t===void 0){A.warn(`No pending photo found for filename`,{filename:e.filename,pendingFilenames:Array.from(this.pendingPhotos.keys())});return}clearTimeout(t.timeout),this.pendingPhotos.delete(e.filename);let{photo:n}=t;e.error===void 0?e.data!==void 0&&n.develop({filename:e.filename,data:e.data}):n.fail(new w(e.error,C.SNAPSHOT_FAILED))}clear(){if(this.pendingPhotos.size===0)return;let e=new w(`Client destroyed before snapshot completed`,C.SNAPSHOT_FAILED);for(let{photo:t,timeout:n}of this.pendingPhotos.values())clearTimeout(n),t.fail(e);this.pendingPhotos.clear()}validateFilename(e){if(e===``||typeof e!=`string`)throw new w(`Filename must be a non-empty string`,C.INVALID_PARAMETER);if(!this.validExtensions.some(t=>e.toLowerCase().endsWith(t)))throw new w(`Invalid filename: "${e}". Filename must end with one of: ${this.validExtensions.join(`, `)}`,C.INVALID_PARAMETER);if(e.includes(`..`)||e.includes(`/`)||e.includes(`\\`))throw new w(`Filename cannot contain path separators or ".."`,C.INVALID_PARAMETER)}},bt=class{container=null;attach(e){this.container=e}dispatch(e,t,n=!1){let r=new CustomEvent(e,{detail:t,cancelable:n});return this.container?.dispatchEvent(r),r}on(e,t){let n=e=>{let n=e;t({...n.detail,preventDefault:()=>{n.preventDefault()}})};return this.container?.addEventListener(e,n),()=>{this.container?.removeEventListener(e,n)}}},xt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Bezig…`:n===`de`?`Läuft…`:`Working…`}),St=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Mislukt`:n===`de`?`Fehlgeschlagen`:`Failed`}),Ct=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Gelukt`:n===`de`?`Fertig`:`Done`}),wt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Annotaties`:n===`de`?`Anmerkungen`:`Annotations`}),Tt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`AR activeren`:n===`de`?`AR aktivieren`:`Activate AR`}),Et=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Camera resetten`:n===`de`?`Kamera zurücksetzen`:`Reset camera`}),Dt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Naar links draaien`:n===`de`?`Nach links drehen`:`Rotate left`}),Ot=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Naar rechts draaien`:n===`de`?`Nach rechts drehen`:`Rotate right`}),kt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Omlaag kantelen`:n===`de`?`Nach unten kippen`:`Tilt down`}),At=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Omhoog kantelen`:n===`de`?`Nach oben kippen`:`Tilt up`}),jt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Inzoomen`:n===`de`?`Hineinzoomen`:`Zoom in`}),Mt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Uitzoomen`:n===`de`?`Herauszoomen`:`Zoom out`}),Nt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Sluiten`:n===`de`?`Schließen`:`Close`}),Pt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Configureren`:n===`de`?`Konfigurieren`:`Configure`}),Ft=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Volledig scherm`:n===`de`?`Vollbild`:`Fullscreen`}),It=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Sluiten`:n===`de`?`Schließen`:`Close`}),Lt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`QR-code`:n===`de`?`QR-Code`:`QR code`}),Rt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Gebruik de camera van je smartphone om deze QR-code te scannen`:n===`de`?`Verwende die Kamera deines Smartphones, um diesen QR-Code zu scannen`:`Use your smartphone camera to scan this QR code`}),zt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Je telefoon opent het 3D-model in AR-modus.`:n===`de`?`Dein Telefon öffnet das 3D-Modell im AR-Modus.`:`Your phone will open the 3D model in AR mode.`}),Bt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Scan om in AR te bekijken`:n===`de`?`Scannen für AR-Ansicht`:`Scan to view in AR`}),Vt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`We kunnen de QR-code nu niet tonen. Open deze link op je telefoon:`:n===`de`?`Wir können den QR-Code gerade nicht anzeigen. Öffne diesen Link auf deinem Handy:`:`We can't show the QR code right now. Open this link on your phone:`}),Ht=((e={},t={})=>(t.locale??v(),`Screenshot`)),Ut=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Downloaden`:n===`de`?`Herunterladen`:`Downloading`}),Wt=((e={},t={})=>{let n=t.locale??v();return n===`nl`?`Laden mislukt. Ververs de pagina om het opnieuw te proberen.`:n===`de`?`Laden fehlgeschlagen. Lade die Seite neu, um es erneut zu versuchen.`:`Load failed. Refresh the page to try again.`}),Gt={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},Kt=([e,t,n])=>{let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(t).forEach(e=>{r.setAttribute(e,String(t[e]))}),n?.length&&n.forEach(e=>{let t=Kt(e);r.appendChild(t)}),r},qt=(e,t={})=>Kt([`svg`,{...Gt,...t},e]),Jt=[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`}],[`path`,{d:`M12 22V12`}]],Yt=[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`}],[`circle`,{cx:`12`,cy:`13`,r:`3`}]],Xt=[[`path`,{d:`m6 9 6 6 6-6`}]],Zt=[[`path`,{d:`m15 18-6-6 6-6`}]],Qt=[[`path`,{d:`m9 18 6-6-6-6`}]],$t=[[`path`,{d:`m18 15-6-6-6 6`}]],en=[[`path`,{d:`M12.75 7.09a3 3 0 0 1 2.16 2.16`}],[`path`,{d:`M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568`}],[`path`,{d:`m2 2 20 20`}],[`path`,{d:`M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533`}],[`path`,{d:`M9.13 9.13a3 3 0 0 0 3.74 3.74`}]],tn=[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`}],[`circle`,{cx:`12`,cy:`10`,r:`3`}]],nn=[[`path`,{d:`M15 3h6v6`}],[`path`,{d:`m21 3-7 7`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M9 21H3v-6`}]],rn=[[`path`,{d:`m14 10 7-7`}],[`path`,{d:`M20 10h-6V4`}],[`path`,{d:`m3 21 7-7`}],[`path`,{d:`M4 14h6v6`}]],an=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{d:`M3 3v5h5`}]],on=[[`path`,{d:`M10 5H3`}],[`path`,{d:`M12 19H3`}],[`path`,{d:`M14 3v4`}],[`path`,{d:`M16 17v4`}],[`path`,{d:`M21 12h-9`}],[`path`,{d:`M21 19h-5`}],[`path`,{d:`M21 5h-7`}],[`path`,{d:`M8 10v4`}],[`path`,{d:`M8 12H3`}]],sn=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],cn=[[`circle`,{cx:`11`,cy:`11`,r:`8`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`}]],ln=[[`circle`,{cx:`11`,cy:`11`,r:`8`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`}]];function j(e,{size:t=20,strokeWidth:n=1.75}={}){return qt(e,{width:t,height:t,"stroke-width":n})}var M={ar:e=>j(Jt,e),annotations:e=>j(tn,e),annotationsOff:e=>j(en,e),fullscreen:e=>j(nn,e),exitFullscreen:e=>j(rn,e),screenshot:e=>j(Yt,e),tiltUp:e=>j($t,e),tiltDown:e=>j(Xt,e),rotateLeft:e=>j(Zt,e),rotateRight:e=>j(Qt,e),zoomIn:e=>j(ln,e),zoomOut:e=>j(cn,e),reset:e=>j(an,e),configurator:e=>j(on,e),close:e=>j(sn,e)},N=class{element;constructor({variant:e=`default`,size:t=`default`,label:n,icon:r,onClick:i,disabled:a=!1}={}){this.element=document.createElement(`button`),this.element.className=`ui-btn ui-btn--${e} ui-btn--size-${t}`,n!==void 0&&(this.element.setAttribute(`aria-label`,n),this.element.title=n),r===void 0?n!==void 0&&(this.element.textContent=n):this.element.appendChild(r),i&&this.element.addEventListener(`click`,i),this.element.disabled=a}setIcon(e){let t=this.element.querySelector(`svg`);t===null?this.element.appendChild(e):t.replaceWith(e)}},un=class{element;selectCallback=null;constructor(e,t,n){this.element=document.createElement(`div`),this.element.className=`ui-toggle-group`;for(let r=0;r<e.length;r++){let i=e[r],a=document.createElement(`button`);a.className=`ui-toggle-group-item`,a.dataset.value=i,a.textContent=n?.[r]??i,a.dataset.state=i===t?`on`:`off`,a.setAttribute(`aria-pressed`,i===t?`true`:`false`),a.addEventListener(`click`,()=>{this.selectCallback?.(i)}),this.element.appendChild(a)}}setSelected(e){for(let t of this.element.querySelectorAll(`.ui-toggle-group-item`)){let n=t.dataset.value===e;t.dataset.state=n?`on`:`off`,t.setAttribute(`aria-pressed`,n?`true`:`false`)}}onSelect(e){this.selectCallback=e}setEnabled(e){for(let t of this.element.querySelectorAll(`.ui-toggle-group-item`)){let n=e===null||e.includes(t.dataset.value??``);t.disabled=!n,t.setAttribute(`aria-disabled`,n?`false`:`true`)}}},dn=class{element;select;constructor(e,t,n,r,i){this.select=document.createElement(`select`),this.select.className=`ui-native-select`,this.select.dataset.name=e,this.select.setAttribute(`aria-label`,n);let a=document.createElement(`option`);a.value=``,a.disabled=!0,a.textContent=n,this.select.appendChild(a);let o=!1;for(let e=0;e<t.length;e++){let n=t[e],a=document.createElement(`option`);a.value=n,a.textContent=i?.[e]??n,n===r&&(a.selected=!0,o=!0),this.select.appendChild(a)}o||(a.selected=!0);let s=qt(Xt,{width:16,height:16,"stroke-width":2});s.classList.add(`ui-native-select-icon`),this.element=document.createElement(`div`),this.element.className=`ui-native-select-wrap`,this.element.appendChild(this.select),this.element.appendChild(s)}setSelected(e){this.select.value=e}onSelect(e){this.select.addEventListener(`change`,()=>{e(this.select.value)})}setEnabled(e){for(let t of this.select.options)t.value!==``&&(t.disabled=e!==null&&!e.includes(t.value))}},fn=class{element;input;valueText;values;options;selectCallback=null;settleCallback=null;constructor(e,t){if(e.length===0)throw Error(`Virtualdisplay: Slider needs at least one value`);this.values=e,this.options=t,this.input=document.createElement(`input`),this.input.type=`range`,this.input.className=`ui-slider-input`,this.input.min=`0`,this.input.max=String(e.length-1),this.input.step=`1`,this.input.setAttribute(`aria-label`,t.label),this.valueText=document.createElement(`span`),this.valueText.className=`ui-slider-value`,this.valueText.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`div`);n.className=`ui-slider-track`,n.appendChild(this.input),n.appendChild(this.buildEnds()),this.element=document.createElement(`div`),this.element.className=`ui-slider`,this.element.appendChild(n),this.element.appendChild(this.valueText);let r=t.initialSelected===void 0?0:e.indexOf(t.initialSelected);this.applyIndex(r===-1?0:r),this.listen()}setSelected(e){let t=this.values.indexOf(e);t!==-1&&this.applyIndex(t)}onSelect(e){this.selectCallback=e}onSettle(e){this.settleCallback=e}listen(){this.input.addEventListener(`input`,()=>{let e=this.values[this.currentIndex];e!==void 0&&(this.applyIndex(this.currentIndex),this.selectCallback?.(e))}),this.input.addEventListener(`change`,()=>{let e=this.values[this.currentIndex];e!==void 0&&this.settleCallback?.(e)})}get currentIndex(){return Number(this.input.value)}applyIndex(e){this.input.value=String(e);let t=this.displayAt(e);this.valueText.textContent=t,this.input.setAttribute(`aria-valuetext`,t);let n=this.values.length===1?100:e/(this.values.length-1)*100;this.element.style.setProperty(`--ui-slider-pct`,`${n}%`)}buildEnds(){let e=document.createElement(`div`);e.className=`ui-slider-ends`,e.setAttribute(`aria-hidden`,`true`);for(let t of[0,this.values.length-1]){let n=document.createElement(`span`);n.textContent=this.labelAt(t),e.appendChild(n)}return e}labelAt(e){return this.options.labels?.[e]??this.values[e]??``}displayAt(e){let t=this.labelAt(e);return this.options.unit===void 0?t:`${t} ${this.options.unit}`}},P={neutral:{50:`oklch(98.5% 0 0)`,100:`oklch(96.5% 0 0)`,200:`oklch(92% 0 0)`,300:`oklch(82% 0 0)`,400:`oklch(70% 0 0)`,500:`oklch(55.5% 0 0)`,600:`oklch(44.5% 0 0)`,700:`oklch(37% 0 0)`,800:`oklch(27% 0 0)`,900:`oklch(21% 0 0)`,950:`oklch(14.5% 0 0)`},white:`oklch(100% 0 0)`,semantic:{error:`oklch(47% 0.17 25)`}},F={px:`1px`,0:`0`,.5:`0.125rem`,1:`0.25rem`,1.5:`0.375rem`,2:`0.5rem`,2.5:`0.625rem`,3:`0.75rem`,3.5:`0.875rem`,4:`1rem`,5:`1.25rem`,6:`1.5rem`,7:`1.75rem`,8:`2rem`,9:`2.25rem`,10:`2.5rem`,12:`3rem`,14:`3.5rem`,16:`4rem`,20:`5rem`,24:`6rem`},I={fontFamily:{sans:[`Mona Sans`,`ui-sans-serif`,`system-ui`,`sans-serif`,`Apple Color Emoji`,`Segoe UI Emoji`,`Segoe UI Symbol`,`Noto Color Emoji`],mono:[`JetBrains Mono`,`ui-monospace`,`monospace`]},fontSize:{xs:`0.75rem`,sm:`0.875rem`,base:`1rem`,lg:`1.125rem`,xl:`1.25rem`,"2xl":`1.5rem`,"3xl":`1.875rem`,"4xl":`2.25rem`},fontWeight:{normal:`400`,medium:`500`,semibold:`600`,bold:`700`},lineHeight:{tight:`1.25`,normal:`1.5`,relaxed:`1.75`}},pn=class{element;constructor(){this.element=document.createElement(`div`),Object.assign(this.element.style,{background:P.white,borderRadius:`var(--radius)`,padding:F[6],boxShadow:`0 ${F[2]} ${F[8]} oklch(0% 0 0 / 20%)`,maxWidth:`20rem`,width:`100%`})}},mn=class{options;card;backdrop;keyHandler=null;constructor(e={}){this.options=e,this.card=new pn,this.backdrop=this.createBackdrop(),this.backdrop.appendChild(this.card.element)}get content(){return this.card.element}open(){document.body.appendChild(this.backdrop),this.keyHandler=e=>{e.key===`Escape`&&this.close()},document.addEventListener(`keydown`,this.keyHandler)}close(){this.backdrop.remove(),this.keyHandler!==null&&(document.removeEventListener(`keydown`,this.keyHandler),this.keyHandler=null),this.options.onClose?.()}createBackdrop(){let e=document.createElement(`div`);return Object.assign(e.style,{position:`fixed`,inset:F[0],background:`oklch(0% 0 0 / 50%)`,zIndex:`9999`,display:`flex`,alignItems:`center`,justifyContent:`center`}),e.addEventListener(`click`,t=>{t.target===e&&this.close()}),e}},L=I.fontFamily.sans.join(`, `),hn=`
2
+ :root {
2
3
  --primary: oklch(5% 0 0);
3
4
  --primary-foreground: oklch(100% 0 0);
4
5
  --secondary: oklch(92% 0 0);
@@ -11,8 +12,7 @@
11
12
  --accent: oklch(92% 0 0);
12
13
  --accent-foreground: oklch(5% 0 0);
13
14
  --muted-foreground: oklch(44% 0 0);
14
- `,Ni=`
15
- :root { ${Mi} }
15
+ }
16
16
 
17
17
  /* ── Button ──────────────────────────────────────────────── */
18
18
  .ui-btn {
@@ -22,7 +22,7 @@
22
22
  gap: 0.5rem;
23
23
  border: 1px solid transparent;
24
24
  border-radius: var(--radius);
25
- font-family: ${E};
25
+ font-family: ${L};
26
26
  font-size: 0.875rem;
27
27
  font-weight: 600;
28
28
  white-space: nowrap;
@@ -79,7 +79,7 @@
79
79
  border-radius: var(--radius);
80
80
  background: var(--background);
81
81
  color: var(--foreground);
82
- font-family: ${E};
82
+ font-family: ${L};
83
83
  font-size: 0.875rem;
84
84
  font-weight: 600;
85
85
  cursor: pointer;
@@ -120,7 +120,7 @@
120
120
  background: var(--background);
121
121
  appearance: none;
122
122
  color: var(--foreground);
123
- font-family: ${E};
123
+ font-family: ${L};
124
124
  font-size: 0.875rem;
125
125
  font-weight: 400;
126
126
  cursor: pointer;
@@ -158,7 +158,7 @@
158
158
 
159
159
  /* Tabular figures keep the readout and layout steady mid-drag. */
160
160
  .ui-slider-value {
161
- font-family: ${E};
161
+ font-family: ${L};
162
162
  font-size: 0.875rem;
163
163
  font-weight: 600;
164
164
  color: var(--foreground);
@@ -169,7 +169,7 @@
169
169
  .ui-slider-ends {
170
170
  display: flex;
171
171
  justify-content: space-between;
172
- font-family: ${E};
172
+ font-family: ${L};
173
173
  font-size: 0.75rem;
174
174
  color: var(--muted-foreground);
175
175
  font-variant-numeric: tabular-nums;
@@ -249,6 +249,52 @@
249
249
  position: relative;
250
250
  }
251
251
 
252
+ /* A pin stands on its point: the number on top, a stick down, and a ring on
253
+ the spot. Open, a card with the number and the title takes the number's
254
+ place at the top of the stick. */
255
+ .vd-annotation-anchor--pin {
256
+ display: flex;
257
+ flex-direction: column;
258
+ align-items: center;
259
+ }
260
+ .vd-annotation-head {
261
+ position: relative;
262
+ display: flex;
263
+ justify-content: center;
264
+ }
265
+ /* A light edge around the stick and the ring, as the dot has one, so a pin
266
+ stays visible on a dark surface. */
267
+ .vd-annotation-stick {
268
+ inline-size: 2px;
269
+ block-size: 2rem;
270
+ background: var(--primary);
271
+ box-shadow: 0 0 0 1px var(--background);
272
+ }
273
+ /* Half its height below the anchor's edge, so the ring's centre is the point. */
274
+ .vd-annotation-point {
275
+ box-sizing: border-box;
276
+ inline-size: 0.625rem;
277
+ block-size: 0.625rem;
278
+ margin-block-end: -0.3125rem;
279
+ border-radius: 50%;
280
+ border: 2px solid var(--primary);
281
+ background: var(--background);
282
+ box-shadow: 0 0 0 1px var(--background), 0 1px 2px oklch(5% 0 0 / 20%);
283
+ }
284
+ .vd-annotation-anchor--pin .vd-annotation-marker--open {
285
+ visibility: hidden;
286
+ }
287
+ .vd-annotation-anchor--pin .vd-annotation-popup {
288
+ inset-block-start: auto;
289
+ inset-block-end: 0;
290
+ }
291
+ /* Too close to the top edge, the card hangs down from the head over the
292
+ stick, where above it would be clipped by the frame. */
293
+ .vd-annotation-anchor--pin .vd-annotation-popup--below {
294
+ inset-block-start: 0;
295
+ inset-block-end: auto;
296
+ }
297
+
252
298
  .vd-annotation-marker {
253
299
  display: flex;
254
300
  align-items: center;
@@ -259,7 +305,7 @@
259
305
  border: 2px solid oklch(100% 0 0);
260
306
  background: var(--primary);
261
307
  color: var(--primary-foreground);
262
- font-family: ${E};
308
+ font-family: ${L};
263
309
  font-size: 0.8125rem;
264
310
  font-weight: 600;
265
311
  cursor: pointer;
@@ -348,7 +394,7 @@
348
394
  }
349
395
 
350
396
  .vd-annotation-popup-title {
351
- font-family: ${E};
397
+ font-family: ${L};
352
398
  font-size: 0.875rem;
353
399
  font-weight: 600;
354
400
  line-height: 1.25rem;
@@ -356,8 +402,47 @@
356
402
  padding-inline-end: 1.5rem;
357
403
  }
358
404
 
405
+ .vd-annotation-popup-number {
406
+ display: inline-flex;
407
+ align-items: center;
408
+ justify-content: center;
409
+ inline-size: 1.25rem;
410
+ block-size: 1.25rem;
411
+ margin-inline-end: 0.5rem;
412
+ border-radius: 50%;
413
+ background: var(--primary);
414
+ color: var(--primary-foreground);
415
+ font-size: 0.75rem;
416
+ font-weight: 600;
417
+ vertical-align: middle;
418
+ }
419
+
420
+ /* A brief card shows its title, a button that opens the description. */
421
+ .vd-annotation-popup--brief .vd-annotation-popup-description {
422
+ display: none;
423
+ }
424
+ button.vd-annotation-popup-title {
425
+ display: block;
426
+ inline-size: 100%;
427
+ margin: 0;
428
+ /* A button's own padding would set the title off the description below it;
429
+ the end keeps the room the close button needs. */
430
+ padding-block: 0;
431
+ padding-inline-start: 0;
432
+ border: none;
433
+ background: none;
434
+ color: inherit;
435
+ text-align: start;
436
+ cursor: pointer;
437
+ }
438
+ button.vd-annotation-popup-title:focus-visible {
439
+ outline: 2px solid var(--ring);
440
+ outline-offset: 2px;
441
+ border-radius: calc(var(--radius) - 4px);
442
+ }
443
+
359
444
  .vd-annotation-popup-description {
360
- font-family: ${E};
445
+ font-family: ${L};
361
446
  font-size: 0.8125rem;
362
447
  font-weight: 400;
363
448
  line-height: 1.125rem;
@@ -396,12 +481,12 @@
396
481
  0%, 100% { opacity: 1; }
397
482
  50% { opacity: 0.55; }
398
483
  }
399
- `;let lt=!1;function Ft(){if(lt||typeof document>"u")return;lt=!0;const n=document.createElement("style");n.id="vd-ui-vanilla",n.textContent=Ni,document.head.appendChild(n)}const zi=S.fontFamily.sans.join(", ");class Pi{qrLib=null;dialog=null;qrSlot=null;show(){this.hide(),Ft(),this.dialog=new Ri({onClose:()=>{this.dialog=null,this.qrSlot=null}}),Object.assign(this.dialog.card.element.style,{display:"flex",flexDirection:"column",alignItems:"center",gap:l[3],fontFamily:zi}),this.dialog.card.element.appendChild(this.createText(oi(),{fontSize:S.fontSize.base,fontWeight:S.fontWeight.semibold,color:m.neutral[900]})),this.dialog.card.element.appendChild(this.createText(Qn(),{fontSize:S.fontSize.sm,color:m.neutral[600]})),this.qrSlot=this.createQrSlot(),this.dialog.card.element.appendChild(this.qrSlot),this.dialog.card.element.appendChild(this.createText(ti(),{fontSize:S.fontSize.xs,color:m.neutral[500]}));const t=new y({variant:"outline",label:Gn(),onClick:()=>{this.hide()}});this.dialog.card.element.appendChild(t.element),this.dialog.open()}async update(t){this.qrLib??=await Promise.resolve().then(()=>require("./browser-DfB_An57.cjs")).then(i=>i.browser);const e=await this.qrLib.toDataURL(t,{width:256,margin:4,errorCorrectionLevel:"M",color:{dark:m.black,light:m.white}});return this.qrSlot===null?!1:(this.qrSlot.classList.remove("ui-qr-slot--loading"),this.qrSlot.replaceChildren(this.createQrImage(e)),!0)}hide(){this.dialog?.close(),this.dialog=null,this.qrSlot=null}createText(t,e){const i=document.createElement("p");return i.textContent=t,Object.assign(i.style,{margin:"0",textAlign:"center",...e}),i}createQrSlot(){const t=document.createElement("div");return t.className="ui-qr-slot ui-qr-slot--loading",t}createQrImage(t){const e=document.createElement("img");return e.src=t,e.alt="QR code",e}}function ct(n){const t=Math.max(0,Math.min(1,n));return t*t*(3-2*t)}function Fi(n,t,e,i,o,s){const[r,a,u]=n,d=Math.cos(t),f=Math.sin(t),h=d*r+f*u,A=-f*r+d*u,k=Math.cos(e),C=Math.sin(e),R=k*a-C*A,P=C*a+k*A,J=.55;return[i+h*s*J,o-R*s*J,P]}function Di(n,t,e){n.beginPath(),n.moveTo(t[0],t[1]),n.lineTo(e[0],e[1]),n.strokeStyle="#000",n.lineWidth=2,n.stroke()}function $i(n,t,e,i,o){const s=t(e),r=t(i),a=[s[0]+(r[0]-s[0])*o,s[1]+(r[1]-s[1])*o,s[2]];Di(n,s,a)}const D=[-1,-1,1],$=[1,-1,1],B=[1,-1,-1],U=[-1,-1,-1],V=[-1,1,1],H=[1,1,1],j=[1,1,-1],q=[-1,1,-1],ut=[[D,$],[$,B],[B,U],[U,D],[D,V],[$,H],[B,j],[U,q],[V,H],[H,j],[j,q],[q,V]],Bi=400,dt='-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif';function Ui(){const n=document.createElement("div");Object.assign(n.style,{position:"absolute",inset:"0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",background:"#fff",zIndex:"20",opacity:"0",transition:"opacity 0.3s ease-in-out"});const t=document.createElement("canvas");Object.assign(t.style,{width:"100%",height:"100%",position:"absolute",inset:"0"});const e=document.createElement("div");Object.assign(e.style,{position:"absolute",top:"56%",left:"0",right:"0",textAlign:"center",pointerEvents:"none"});const i=document.createElement("span");Object.assign(i.style,{fontSize:"13px",fontWeight:"400",color:"#000",fontVariantNumeric:"tabular-nums",fontFamily:dt});const o=document.createElement("span");return Object.assign(o.style,{fontSize:"13px",color:"#000",fontFamily:dt}),o.textContent=hi(),e.appendChild(i),e.appendChild(o),n.appendChild(t),n.appendChild(e),{overlay:n,canvas:t,pctEl:i,phaseEl:o}}class Vi{overlay;canvas;ctx;pctEl;phaseEl;animationId=null;showTimerId=null;startTime;hidden=!1;visible=!1;constructor(t,e={}){this.startTime=performance.now();const i=Ui();this.overlay=i.overlay,this.canvas=i.canvas,this.pctEl=i.pctEl,this.phaseEl=i.phaseEl,t.appendChild(this.overlay),this.ctx=this.canvas.getContext("2d"),this.ctx!==null&&(this.sizeCanvas(),this.tick());const o=e.showDelay??Bi;this.showTimerId=setTimeout(()=>{this.reveal()},o)}updateProgress(t,e){this.hidden||(this.pctEl.textContent=`${Math.round(t)}%`,this.phaseEl.textContent=e!==""?` · ${e}`:"")}showError(t){if(this.hidden=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.ctx!==null){const e=Math.min(devicePixelRatio,2),i=this.canvas.width/e,o=this.canvas.height/e;this.ctx.fillStyle="#fff",this.ctx.fillRect(0,0,i*e,o*e)}this.pctEl.textContent="",this.phaseEl.textContent=t,this.phaseEl.style.color="#b91c1c",this.reveal()}hide(){if(!this.hidden){if(this.hidden=!0,this.cancelShowTimer(),!this.visible){this.destroy();return}this.overlay.style.opacity="0",this.overlay.addEventListener("transitionend",()=>{this.destroy()},{once:!0}),setTimeout(()=>{this.destroy()},500)}}destroy(){this.cancelShowTimer(),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.overlay.remove()}reveal(){this.hidden||this.visible||(this.visible=!0,this.overlay.style.opacity="1")}cancelShowTimer(){this.showTimerId!==null&&(clearTimeout(this.showTimerId),this.showTimerId=null)}sizeCanvas(){if(this.ctx===null)return;const t=Math.min(devicePixelRatio,2),e=this.overlay.clientWidth||440,i=this.overlay.clientHeight||360;this.canvas.width=e*t,this.canvas.height=i*t,this.ctx.scale(t,t),this.ctx.lineCap="round",this.ctx.lineJoin="round"}tick=()=>{this.hidden||(this.drawFrame(),this.animationId=requestAnimationFrame(this.tick))};drawFrame(){if(this.ctx===null)return;const t=this.canvas.width/Math.min(devicePixelRatio,2),e=this.canvas.height/Math.min(devicePixelRatio,2),i=(performance.now()-this.startTime)/1e3;this.ctx.fillStyle="#fff",this.ctx.fillRect(0,0,t,e);const o=t/2,s=e*.44,r=Math.min(t,e)*.08,a=.785,u=.615,d=C=>Fi(C,a,u,o,s,r),f=6,h=i%f/f,A=ut.length;let k;h<.35?k=ct(h/.35)*A:h<.55?k=A:h<.9?k=(1-ct((h-.55)/.35))*A:k=0,this.ctx.shadowBlur=5,this.ctx.shadowColor="rgba(30,30,30,0.08)";for(let C=0;C<A&&!(C>=k);C++){const R=ut[C];if(R===void 0)continue;const P=Math.min(1,k-C);$i(this.ctx,d,R[0],R[1],P)}this.ctx.shadowBlur=0}}class Hi{constructor(t){this.options=t,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"flex",gap:"0.375rem"}),this.onFullscreenChange=()=>{this.setFullscreenIcon(document.fullscreenElement!==null)},document.addEventListener("fullscreenchange",this.onFullscreenChange)}options;element;arBtn=null;fullscreenBtn=null;annotationsBtn=null;annotationsShown=!1;onFullscreenChange;setFullscreenIcon(t){this.fullscreenBtn!==null&&this.fullscreenBtn.setIcon(t?g.exitFullscreen():g.fullscreen())}syncButton(t,e,i){if(e&&t===null){const o=i();return this.element.appendChild(o.element),o}return!e&&t!==null?(t.element.remove(),null):t}applySettings(t){this.arBtn=this.syncButton(this.arBtn,t.ar!==!1&&this.options.onAr!==void 0,()=>new y({variant:"outline",size:"icon",label:en(),icon:g.ar(),onClick:()=>{this.options.onAr?.()}})),this.fullscreenBtn=this.syncButton(this.fullscreenBtn,t.fullscreen!==!1&&this.options.onFullscreen!==void 0,()=>new y({variant:"outline",size:"icon",label:Vn(),icon:g.fullscreen(),onClick:()=>{this.options.onFullscreen?.()}}));const e=t.annotations==="toggle-shown"||t.annotations==="toggle-hidden";this.annotationsBtn=this.syncButton(this.annotationsBtn,e&&this.options.onAnnotationsToggle!==void 0,()=>{this.annotationsShown=t.annotations==="toggle-shown";const i=new y({variant:"outline",size:"icon",label:Ke(),icon:this.annotationsShown?g.annotations():g.annotationsOff(),onClick:()=>{this.flipAnnotations()}});return i.element.setAttribute("aria-pressed",String(this.annotationsShown)),i})}flipAnnotations(){this.annotationsShown=!this.annotationsShown,this.annotationsBtn?.element.setAttribute("aria-pressed",String(this.annotationsShown)),this.annotationsBtn?.setIcon(this.annotationsShown?g.annotations():g.annotationsOff()),this.options.onAnnotationsToggle?.(this.annotationsShown)}destroy(){document.removeEventListener("fullscreenchange",this.onFullscreenChange)}}const T=.5;class z{element;constructor(t,e){this.element=Object.assign(document.createElement("div"),{className:"vd-camera-controls"});const i={targetRotation:e.rotation,targetTilt:e.tilt,targetZoom:e.zoom,thetaOffset:0},o=ji(t,e,i);e.onChange(s=>{i.targetRotation=s.rotation-i.thetaOffset,i.targetTilt=s.tilt,i.targetZoom=s.zoom,qi(o,e,s)}),this.element.appendChild(z.buildZoom(o.zoomOut,o.zoomIn)),this.element.appendChild(z.buildDpad(o.tiltUp,o.rotateLeft,o.reset,o.rotateRight,o.tiltDown))}static buildZoom(t,e){const i=document.createElement("div");return i.className="vd-zoom",i.appendChild(t.element),i.appendChild(e.element),i}static buildDpad(t,e,i,o,s){const r=document.createElement("div");r.className="vd-dpad";for(const[a,u]of[[t,"up"],[e,"left"],[i,"center"],[o,"right"],[s,"down"]])a.element.classList.add(`vd-dpad-${u}`),r.appendChild(a.element);return r}}function ji(n,t,e){const i=r=>Math.max(t.limits?.minZoom??1,Math.min(t.limits?.maxZoom??1/0,r)),o=r=>{const a=t.limits?.minRotate,u=t.limits?.maxRotate;return a!==void 0||u!==void 0?Math.max(a??-1/0,Math.min(u??1/0,r)):r},s=r=>{const a=t.limits?.minTilt,u=t.limits?.maxTilt;if(a!==void 0||u!==void 0){e.targetTilt=Math.max(a??0,Math.min(u??180,e.targetTilt+r)),n.tilt(e.targetTilt).set();return}const d=e.targetTilt+r;d>180||d<0?(e.targetTilt=d>180?360-d:-d,e.thetaOffset=(e.thetaOffset+180)%360,n.tilt(e.targetTilt).rotate(e.targetRotation+e.thetaOffset).set()):(e.targetTilt=d,n.tilt(e.targetTilt).set())};return{zoomOut:new y({variant:"outline",size:"icon",label:In(),icon:g.zoomOut(),onClick:()=>{e.targetZoom=i(e.targetZoom-10),n.zoom(e.targetZoom).set()}}),zoomIn:new y({variant:"outline",size:"icon",label:En(),icon:g.zoomIn(),onClick:()=>{e.targetZoom=i(e.targetZoom+10),n.zoom(e.targetZoom).set()}}),tiltUp:new y({variant:"outline",size:"icon",label:Cn(),icon:g.tiltUp(),onClick:()=>{s(-15)}}),rotateLeft:new y({variant:"outline",size:"icon",label:un(),icon:g.rotateLeft(),onClick:()=>{e.targetRotation=o(e.targetRotation-15),n.rotate(e.targetRotation+e.thetaOffset).set()}}),reset:new y({variant:"outline",size:"icon",label:rn(),icon:g.reset(),onClick:()=>{e.thetaOffset=0,n.reset()}}),rotateRight:new y({variant:"outline",size:"icon",label:mn(),icon:g.rotateRight(),onClick:()=>{e.targetRotation=o(e.targetRotation+15),n.rotate(e.targetRotation+e.thetaOffset).set()}}),tiltDown:new y({variant:"outline",size:"icon",label:vn(),icon:g.tiltDown(),onClick:()=>{s(15)}})}}function qi(n,t,e){const i=t.limits;i!==void 0&&(n.zoomOut.element.disabled=i.minZoom!==void 0&&e.zoom<=i.minZoom+T,n.zoomIn.element.disabled=i.maxZoom!==void 0&&e.zoom>=i.maxZoom-T,n.tiltUp.element.disabled=i.minTilt!==void 0&&e.tilt<=i.minTilt+T,n.tiltDown.element.disabled=i.maxTilt!==void 0&&e.tilt>=i.maxTilt-T,n.rotateLeft.element.disabled=i.minRotate!==void 0&&e.rotation<=i.minRotate+T,n.rotateRight.element.disabled=i.maxRotate!==void 0&&e.rotation>=i.maxRotate-T)}const x={SELECT:"vd:select",SELECTED:"vd:selected",FOCUS_CHANGE:"vd:focus-change",CONFIGURATION_CHANGE:"vd:configuration-change",CONFIGURATION_SUBMIT:"vd:configuration-submit"},Dt={mm:1,cm:10,m:1e3,in:25.4},ht=3;function Gi(n){const t=n.stepMm/Dt[n.displayUnit];for(let e=0;e<=ht;e++){const i=t*10**e;if(Math.abs(i-Math.round(i))<1e-9)return e}return ht}function Zi(n,t,e){const i=Gi(t),o=n/Dt[t.displayUnit];return new Intl.NumberFormat(e,{minimumFractionDigits:i,maximumFractionDigits:i}).format(o)}function Wi(n,t,e,i,o,s,r){const a=p(),u=n.values.map(h=>Zi(Number(h),t,a)),d=n.values.find(h=>e.getValue(n.name,h)?.isSelected===!0)??n.defaultValue,f=new Li(n.values,{label:n.name,labels:u,unit:t.displayUnit,...d!==void 0&&{initialSelected:d}});return f.onSelect(h=>{o(n.name,h)}),f.onSettle(h=>{i.dispatch(x.SELECT,{attribute:n.name,value:h},!0).defaultPrevented||s(n.name,h)}),r(n.name,h=>{f.setSelected(h.value),i.dispatch(x.SELECTED,{attribute:n.name,value:h.value})}),{element:f.element,setSelectable:()=>{}}}const Yi=5;let Qi=0;function Q(n){const t=n.replace(/([A-Z])/g," $1").trim();return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function Ki(n,t,e,i,o,s){const r=document.createElement("div");r.className="vd-attribute",r.dataset.name=n.name;const a=document.createElement("span");a.className="vd-attribute-label",a.textContent=Q(n.name),a.id=`vd-attribute-label-${Qi++}`,r.appendChild(a),r.setAttribute("role","group"),r.setAttribute("aria-labelledby",a.id);const u=f=>{r.style.display=f?"none":""},d=n.dimension!==void 0?Wi(n,n.dimension,t,e,o,i,s):Xi(n,t,e,i,s);return r.appendChild(d.element),{element:r,setSelectable:d.setSelectable,setHidden:u}}function Xi(n,t,e,i,o){const s=n.values.find(u=>t.getValue(n.name,u)?.isSelected===!0),r=n.values.map(Q),a=n.values.length<=Yi?new Ii(n.values,s,r):new Oi(n.name,n.values,Q(n.name),s,r);return a.onSelect(u=>{e.dispatch(x.SELECT,{attribute:n.name,value:u},!0).defaultPrevented||i(n.name,u)}),o(n.name,u=>{a.setSelected(u.value),e.dispatch(x.SELECTED,{attribute:n.name,value:u.value})}),{element:a.element,setSelectable:u=>{a.setEnabled(u)}}}const Ji=80,to=2500;class eo{constructor(t,e=to){this.configuration=t,this.resetMs=e,this.element=document.createElement("div"),this.element.className="vd-commerce vd-hidden";const i=document.createElement("div");i.className="vd-commerce-price",this.priceEl=document.createElement("span"),this.priceEl.className="vd-price",this.vatEl=document.createElement("span"),this.vatEl.className="vd-vat",i.append(this.priceEl,this.vatEl),this.button=new y({variant:"default",onClick:()=>{this.handleSubmit()}}),this.button.element.classList.add("vd-cta","vd-hidden"),this.element.append(i,this.button.element),this.unsubscribe=this.configuration.onRender(()=>{this.update()}),this.update()}configuration;resetMs;element;priceEl;vatEl;button;unsubscribe;state="idle";resetTimer;update(){this.renderPrice(this.configuration.current),this.renderButton();const t=this.configuration.current!==void 0||this.configuration.submitEnabled;this.element.classList.toggle("vd-hidden",!t)}destroy(){this.unsubscribe(),this.resetTimer!==void 0&&clearTimeout(this.resetTimer),this.element.remove()}renderPrice(t){if(t===void 0){this.priceEl.textContent="",this.vatEl.textContent="";return}this.priceEl.textContent=no(t.price,t.currency),this.vatEl.textContent=pt(this.configuration.vatDisplay)}renderButton(){const t=this.configuration.submitEnabled;this.button.element.classList.toggle("vd-hidden",!t),t&&this.state==="idle"&&this.setButtonText(pt(this.configuration.buttonLabel))}async handleSubmit(){if(this.state!=="busy"){this.setState("busy",$e());try{await this.configuration.submit(),this.setState("success",Ze())}catch{this.setState("failed",He())}this.scheduleReset()}}scheduleReset(){this.resetTimer!==void 0&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout(()=>{this.state="idle",this.update()},this.resetMs)}setState(t,e){this.state=t,this.element.dataset.submit=t,this.button.element.disabled=t==="busy",this.setButtonText(e)}setButtonText(t){this.button.element.textContent=t,this.button.element.setAttribute("aria-label",t)}}function pt(n){return(n??"").slice(0,Ji)}function no(n,t){try{const e=new Intl.NumberFormat(p(),{style:"currency",currency:t}),i=e.resolvedOptions().maximumFractionDigits??2;return e.format(n/10**i)}catch{return`${t} ${(n/100).toFixed(2)}`}}class $t{slot=null;panel=null;attach(t,e){this.panel=e,e.style.display="none",this.slot=document.createElement("div"),this.slot.className="vd-slot-bottom-left",this.slot.appendChild(e),t.appendChild(this.slot)}setVisible(t){this.panel!==null&&(this.panel.style.display=t?"flex":"none")}destroy(){this.slot?.remove(),this.slot=null,this.panel=null}}const io=572;class oo{constructor(t){this.actionBarSlot=t}actionBarSlot;element=null;body=null;openButton=null;closeButton=null;container=null;observer=null;collapsible=!1;expanded=!0;visible=!1;attach(t,e){this.container=t,e.classList.add("vd-attributes-sidebar"),this.closeButton=new y({variant:"ghost",size:"icon-sm",label:Nn(),icon:g.close({size:18}),onClick:()=>{this.expanded=!1,this.render()}});const i=document.createElement("div");i.className="vd-sidebar-header",i.appendChild(this.closeButton.element),this.body=document.createElement("div"),this.body.className="vd-sidebar-body",this.body.appendChild(e),this.element=document.createElement("div"),this.element.className="vd-sidebar vd-hidden",this.element.append(i,this.body),t.appendChild(this.element),this.openButton=new y({variant:"outline",size:"icon",label:Dn(),icon:g.configurator({size:18}),onClick:()=>{this.expanded=!0,this.render()}}),this.openButton.element.classList.add("vd-configurator-toggle","vd-hidden"),this.actionBarSlot.appendChild(this.openButton.element),this.observe()}setVisible(t){this.visible=t,this.render()}destroy(){this.observer?.disconnect(),this.observer=null,this.openButton?.element.remove(),this.element?.remove(),this.container?.classList.remove("vd-layout-sidebar-right","vd-layout-sidebar-permanent"),this.container=null}observe(){typeof ResizeObserver>"u"||this.container===null||(this.observer=new ResizeObserver(t=>{const e=t[0]?.contentRect.width??0;this.setCollapsible(e>0&&e<io)}),this.observer.observe(this.container))}setCollapsible(t){t!==this.collapsible&&(this.collapsible=t,this.expanded=!t,this.render())}render(){if(this.element===null||this.openButton===null||this.closeButton===null||this.container===null)return;const t=this.visible&&this.expanded,e=this.visible&&!this.expanded;this.element.classList.toggle("vd-hidden",!this.visible),this.element.classList.toggle("vd-sidebar-collapsed",e),this.openButton.element.classList.toggle("vd-hidden",!e),this.closeButton.element.style.display=this.collapsible?"":"none",this.container.classList.toggle("vd-layout-sidebar-right",t),this.container.classList.toggle("vd-layout-sidebar-permanent",t&&!this.collapsible)}}class so{attach(t,e){}setVisible(t){}destroy(){}}const ro={"inframe-bottom-left":()=>new $t,"sidebar-right":n=>new oo(n),hidden:()=>new so};function ao(n,t){return(ro[n??""]??(()=>new $t))(t)}const G=S.fontFamily.sans.join(", "),Z=`
484
+ `,gn=!1;function _n(){if(gn||typeof document>`u`)return;gn=!0;let e=document.createElement(`style`);e.id=`vd-ui-vanilla`,e.textContent=hn,document.head.appendChild(e)}var vn=I.fontFamily.sans.join(`, `),yn=class{qrLib=null;dialog=null;qrSlot=null;show(){this.hide(),_n(),this.dialog=new mn({onClose:()=>{this.dialog=null,this.qrSlot=null}}),Object.assign(this.dialog.content.style,{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:F[3],fontFamily:vn}),this.dialog.content.appendChild(this.createText(Bt(),{fontSize:I.fontSize.base,fontWeight:I.fontWeight.semibold,color:P.neutral[900]})),this.dialog.content.appendChild(this.createText(Rt(),{fontSize:I.fontSize.sm,color:P.neutral[600]})),this.qrSlot=this.createQrSlot(),this.dialog.content.appendChild(this.qrSlot),this.dialog.content.appendChild(this.createText(zt(),{fontSize:I.fontSize.xs,color:P.neutral[500]}));let e=new N({variant:`outline`,label:It(),onClick:()=>{this.hide()}});this.dialog.content.appendChild(e.element),this.dialog.open()}async update(t){let n;try{this.qrLib??=await Promise.resolve().then(()=>e.n(require("./browser-7qZ1KQYo.cjs").default,1)),n=await this.qrLib.toDataURL(t,{width:256,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000`,light:`#ffffff`}})}catch(e){throw this.showLink(t),e}return this.qrSlot!==null&&(this.qrSlot.classList.remove(`ui-qr-slot--loading`),this.qrSlot.replaceChildren(this.createQrImage(n)),!0)}showLink(e){this.qrSlot!==null&&(this.qrSlot.classList.remove(`ui-qr-slot--loading`),this.qrSlot.replaceChildren(this.createText(Vt(),{fontSize:I.fontSize.sm,color:P.neutral[600]}),this.createText(e,{fontSize:I.fontSize.xs,color:P.neutral[900],overflowWrap:`anywhere`,userSelect:`all`})))}hide(){this.dialog?.close(),this.dialog=null,this.qrSlot=null}createText(e,t){let n=document.createElement(`p`);return n.textContent=e,Object.assign(n.style,{margin:`0`,textAlign:`center`,...t}),n}createQrSlot(){let e=document.createElement(`div`);return e.className=`ui-qr-slot ui-qr-slot--loading`,e}createQrImage(e){let t=document.createElement(`img`);return t.src=e,t.alt=Lt(),t}};function bn(e){let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)}function xn(e,t,n,r,i,a){let[o,s,c]=e,l=Math.cos(t),u=Math.sin(t),ee=l*o+u*c,d=-u*o+l*c,f=Math.cos(n),p=Math.sin(n),te=f*s-p*d,ne=p*s+f*d,m=.55;return[r+ee*a*m,i-te*a*m,ne]}function Sn(e,t,n){e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),e.lineWidth=2,e.stroke()}function Cn(e,t,n,r,i){let a=t(n),o=t(r);Sn(e,a,[a[0]+(o[0]-a[0])*i,a[1]+(o[1]-a[1])*i,a[2]])}var R=[-1,-1,1],z=[1,-1,1],B=[1,-1,-1],V=[-1,-1,-1],H=[-1,1,1],U=[1,1,1],W=[1,1,-1],G=[-1,1,-1],K=[[R,z],[z,B],[B,V],[V,R],[R,H],[z,U],[B,W],[V,G],[H,U],[U,W],[W,G],[G,H]];function wn(e){let t=e%6/6,n=K.length;return t<.35?bn(t/.35)*n:t<.55?n:t<.9?(1-bn((t-.55)/.35))*n:0}function Tn(e,{width:t,height:n},r,i){let a=t/2,o=n*.44,s=Math.min(t,n)*.08,c=e=>xn(e,.785,.615,a,o,s),l=wn(r);e.shadowBlur=5,e.shadowColor=`rgba(30,30,30,0.08)`,e.strokeStyle=i;for(let t=0;t<K.length&&!(t>=l);t++){let n=K[t];if(n===void 0)continue;let r=Math.min(1,l-t);Cn(e,c,n[0],n[1],r)}e.shadowBlur=0}var En=400,Dn=3e4,On=`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`;function kn(e){let t=document.createElement(`div`);Object.assign(t.style,{position:`absolute`,inset:`0`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,background:`transparent`,color:e,zIndex:`20`,opacity:`0`,transition:`opacity 0.3s ease-in-out`});let n=document.createElement(`canvas`);Object.assign(n.style,{width:`100%`,height:`100%`,position:`absolute`,inset:`0`});let r=document.createElement(`div`);Object.assign(r.style,{position:`absolute`,top:`56%`,left:`0`,right:`0`,textAlign:`center`,pointerEvents:`none`});let i=document.createElement(`span`);Object.assign(i.style,{fontSize:`13px`,fontWeight:`400`,fontVariantNumeric:`tabular-nums`,fontFamily:On});let a=document.createElement(`span`);return Object.assign(a.style,{fontSize:`13px`,fontFamily:On}),a.textContent=Ut(),r.appendChild(i),r.appendChild(a),t.appendChild(n),t.appendChild(r),{overlay:t,canvas:n,pctEl:i,phaseEl:a}}var An=class{overlay;canvas;ctx;pctEl;phaseEl;animationId=null;showTimerId=null;noSignalTimerId=null;startTime;textColor;hidden=!1;visible=!1;errored=!1;noSignalErrored=!1;constructor(e){this.startTime=performance.now();let t=getComputedStyle(e).color;this.textColor=t===``?`#000`:t;let n=kn(this.textColor);this.overlay=n.overlay,this.canvas=n.canvas,this.pctEl=n.pctEl,this.phaseEl=n.phaseEl,e.appendChild(this.overlay),this.ctx=this.canvas.getContext(`2d`),this.ctx!==null&&(this.sizeCanvas(),this.tick()),this.showTimerId=setTimeout(()=>{this.reveal()},En),this.noSignalTimerId=setTimeout(()=>{this.hidden||(this.noSignalErrored=!0,this.showError(Wt()))},Dn)}viewerAlive(){this.cancelNoSignalTimer(),this.noSignalErrored&&this.recoverFromNoSignal()}recoverFromNoSignal(){this.noSignalErrored=!1,this.errored=!1,this.pctEl.textContent=``,this.phaseEl.textContent=Ut(),this.ctx!==null&&this.animationId===null&&!this.hidden&&this.tick()}updateProgress(e,t){this.cancelNoSignalTimer(),!(this.hidden||this.errored)&&(this.pctEl.textContent=`${Math.round(e)}%`,this.phaseEl.textContent=t===``?``:` \u00B7 ${t}`)}showError(e){if(this.cancelNoSignalTimer(),this.hidden=!1,this.errored=!0,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.ctx!==null){let e=Math.min(devicePixelRatio,2),t=this.canvas.width/e,n=this.canvas.height/e;this.ctx.clearRect(0,0,t,n)}this.pctEl.textContent=``,this.phaseEl.textContent=e,this.reveal()}hide(){this.hidden||(this.hidden=!0,this.cancelShowTimer(),this.visible?(this.overlay.style.opacity=`0`,this.overlay.addEventListener(`transitionend`,()=>{this.destroy()},{once:!0}),setTimeout(()=>{this.destroy()},500)):this.destroy())}destroy(){this.cancelShowTimer(),this.cancelNoSignalTimer(),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.overlay.remove()}reveal(){this.hidden||this.visible||(this.visible=!0,this.overlay.style.opacity=`1`)}cancelShowTimer(){this.showTimerId!==null&&(clearTimeout(this.showTimerId),this.showTimerId=null)}cancelNoSignalTimer(){this.noSignalTimerId!==null&&(clearTimeout(this.noSignalTimerId),this.noSignalTimerId=null)}sizeCanvas(){if(this.ctx===null)return;let e=Math.min(devicePixelRatio,2),t=this.overlay.clientWidth||440,n=this.overlay.clientHeight||360;this.canvas.width=t*e,this.canvas.height=n*e,this.ctx.scale(e,e),this.ctx.lineCap=`round`,this.ctx.lineJoin=`round`}tick=()=>{this.hidden||(this.drawFrame(),this.animationId=requestAnimationFrame(this.tick))};drawFrame(){if(this.ctx===null)return;let e=this.canvas.width/Math.min(devicePixelRatio,2),t=this.canvas.height/Math.min(devicePixelRatio,2),n=(performance.now()-this.startTime)/1e3;this.ctx.clearRect(0,0,e,t),Tn(this.ctx,{width:e,height:t},n,this.textColor)}},jn=class{options;element;arBtn=null;fullscreenBtn=null;annotationsBtn=null;annotationsShown=!1;onFullscreenChange;constructor(e){this.options=e,this.element=document.createElement(`div`),Object.assign(this.element.style,{display:`flex`,gap:`0.375rem`}),this.onFullscreenChange=()=>{this.setFullscreenIcon(document.fullscreenElement!==null)},document.addEventListener(`fullscreenchange`,this.onFullscreenChange)}setFullscreenIcon(e){this.fullscreenBtn!==null&&this.fullscreenBtn.setIcon(e?M.exitFullscreen():M.fullscreen())}syncButton(e,t,n){if(t&&e===null){let e=n();return this.element.appendChild(e.element),e}return!t&&e!==null?(e.element.remove(),null):e}applySettings(e){this.arBtn=this.syncButton(this.arBtn,e.ar!==!1&&this.options.onAr!==void 0,()=>new N({variant:`outline`,size:`icon`,label:Tt(),icon:M.ar(),onClick:()=>{this.options.onAr?.()}})),this.fullscreenBtn=this.syncButton(this.fullscreenBtn,e.fullscreen!==!1&&this.options.onFullscreen!==void 0,()=>new N({variant:`outline`,size:`icon`,label:Ft(),icon:M.fullscreen(),onClick:()=>{this.options.onFullscreen?.()}}));let t=e.annotations===`toggle-shown`||e.annotations===`toggle-hidden`;this.annotationsBtn=this.syncButton(this.annotationsBtn,t&&this.options.onAnnotationsToggle!==void 0,()=>{this.annotationsShown=e.annotations===`toggle-shown`;let t=new N({variant:`outline`,size:`icon`,label:wt(),icon:this.annotationsShown?M.annotations():M.annotationsOff(),onClick:()=>{this.flipAnnotations()}});return t.element.setAttribute(`aria-pressed`,String(this.annotationsShown)),t})}flipAnnotations(){this.annotationsShown=!this.annotationsShown,this.annotationsBtn?.element.setAttribute(`aria-pressed`,String(this.annotationsShown)),this.annotationsBtn?.setIcon(this.annotationsShown?M.annotations():M.annotationsOff()),this.options.onAnnotationsToggle?.(this.annotationsShown)}destroy(){document.removeEventListener(`fullscreenchange`,this.onFullscreenChange)}},q=.5,Mn=class e{element;constructor(t,n){this.element=Object.assign(document.createElement(`div`),{className:`vd-camera-controls`});let r={targetRotation:n.rotation,targetTilt:n.tilt,targetZoom:n.zoom,thetaOffset:0},i=Ln(t,n,r);n.onChange(e=>{r.targetRotation=e.rotation-r.thetaOffset,r.targetTilt=e.tilt,r.targetZoom=e.zoom,Rn(i,n,e)}),this.element.appendChild(e.buildZoom(i.zoomOut,i.zoomIn)),this.element.appendChild(e.buildDpad(i.tiltUp,i.rotateLeft,i.reset,i.rotateRight,i.tiltDown))}static buildZoom(e,t){let n=document.createElement(`div`);return n.className=`vd-zoom`,n.appendChild(e.element),n.appendChild(t.element),n}static buildDpad(e,t,n,r,i){let a=document.createElement(`div`);a.className=`vd-dpad`;for(let[o,s]of[[e,`up`],[t,`left`],[n,`center`],[r,`right`],[i,`down`]])o.element.classList.add(`vd-dpad-${s}`),a.appendChild(o.element);return a}};function Nn(e,t){let n=e;for(;n<t;)n+=360;for(;n>=t+360;)n-=360;return n}function Pn(e,t,n){let r=Nn(e,t);return r<=n?r:r-n<=t+360-r?n:t}function J(e,t,n){return new N({variant:`outline`,size:`icon`,label:e,icon:t,onClick:n})}function Fn(e,t){return Math.max(e.limits?.minZoom??1,Math.min(e.limits?.maxZoom??1/0,t))}function In(e,t){let n=e.limits?.minRotate,r=e.limits?.maxRotate;return n===void 0||r===void 0||r-n>=360?t:Pn(t,n,r)}function Y(e,t,n,r){let i=t.limits?.minTilt,a=t.limits?.maxTilt;if(i!==void 0||a!==void 0){n.targetTilt=Math.max(i??0,Math.min(a??180,n.targetTilt+r)),e.tilt(n.targetTilt).set();return}let o=n.targetTilt+r;o>180||o<0?(n.targetTilt=o>180?360-o:-o,n.thetaOffset=(n.thetaOffset+180)%360,e.tilt(n.targetTilt).rotate(n.targetRotation+n.thetaOffset).set()):(n.targetTilt=o,e.tilt(n.targetTilt).set())}function Ln(e,t,n){let r=r=>{n.targetZoom=Fn(t,n.targetZoom+r),e.zoom(n.targetZoom).set()},i=r=>{n.targetRotation=In(t,n.targetRotation+r),e.rotate(n.targetRotation+n.thetaOffset).set()};return{zoomOut:J(Mt(),M.zoomOut(),()=>{r(-10)}),zoomIn:J(jt(),M.zoomIn(),()=>{r(10)}),tiltUp:J(At(),M.tiltUp(),()=>{Y(e,t,n,-15)}),rotateLeft:J(Dt(),M.rotateLeft(),()=>{i(-15)}),reset:J(Et(),M.reset(),()=>{n.thetaOffset=0,e.reset()}),rotateRight:J(Ot(),M.rotateRight(),()=>{i(15)}),tiltDown:J(kt(),M.tiltDown(),()=>{Y(e,t,n,15)})}}function Rn(e,t,n){let r=t.limits;if(r===void 0)return;e.zoomOut.element.disabled=r.minZoom!==void 0&&n.zoom<=r.minZoom+q,e.zoomIn.element.disabled=r.maxZoom!==void 0&&n.zoom>=r.maxZoom-q,e.tiltUp.element.disabled=r.minTilt!==void 0&&n.tilt<=r.minTilt+q,e.tiltDown.element.disabled=r.maxTilt!==void 0&&n.tilt>=r.maxTilt-q;let{minRotate:i,maxRotate:a}=r;if(i===void 0||a===void 0||a-i>=360){e.rotateLeft.element.disabled=!1,e.rotateRight.element.disabled=!1;return}let o=Nn(n.rotation,i);e.rotateLeft.element.disabled=o<=i+q,e.rotateRight.element.disabled=o>=a-q}var X={SELECT:`vd:select`,SELECTED:`vd:selected`,FOCUS_CHANGE:`vd:focus-change`,CONFIGURATION_CHANGE:`vd:configuration-change`,CONFIGURATION_SUBMIT:`vd:configuration-submit`},zn={mm:1,cm:10,m:1e3,in:25.4},Bn=3;function Vn(e){let t=e.stepMm/zn[e.displayUnit];for(let e=0;e<=Bn;e++){let n=t*10**e;if(Math.abs(n-Math.round(n))<1e-9)return e}return Bn}function Hn(e,t,n){let r=Vn(t),i=e/zn[t.displayUnit];return new Intl.NumberFormat(n,{minimumFractionDigits:r,maximumFractionDigits:r}).format(i)}function Un(e,t,n,r,i,a,o){let s=v(),c=e.values.map(e=>Hn(Number(e),t,s)),l=e.values.find(t=>n.getValue(e.name,t)?.isSelected===!0)??e.defaultValue,u=new fn(e.values,{label:e.name,labels:c,unit:t.displayUnit,...l!==void 0&&{initialSelected:l}});return u.onSelect(t=>{i(e.name,t)}),u.onSettle(t=>{r.dispatch(X.SELECT,{attribute:e.name,value:t},!0).defaultPrevented||a(e.name,t)}),o(e.name,t=>{u.setSelected(t.value),r.dispatch(X.SELECTED,{attribute:e.name,value:t.value})}),{element:u.element,setSelectable:()=>{}}}var Wn=5,Gn=0;function Kn(e,t,n,r,i,a){let o=document.createElement(`div`);o.className=`vd-attribute`,o.dataset.name=e.name;let s=document.createElement(`span`);s.className=`vd-attribute-label`,s.textContent=S(e.name),s.id=`vd-attribute-label-${Gn++}`,o.appendChild(s),o.setAttribute(`role`,`group`),o.setAttribute(`aria-labelledby`,s.id);let c=e=>{o.style.display=e?`none`:``},l=e.dimension===void 0?qn(e,t,n,r,a):Un(e,e.dimension,t,n,i,r,a);return o.appendChild(l.element),{element:o,setSelectable:l.setSelectable,setHidden:c}}function qn(e,t,n,r,i){let a=e.values.find(n=>t.getValue(e.name,n)?.isSelected===!0),o=e.values.map(t=>Fe(t,e.labels)),s=e.values.length<=Wn?new un(e.values,a,o):new dn(e.name,e.values,S(e.name),a,o);return s.onSelect(t=>{n.dispatch(X.SELECT,{attribute:e.name,value:t},!0).defaultPrevented||r(e.name,t)}),i(e.name,t=>{s.setSelected(t.value),n.dispatch(X.SELECTED,{attribute:e.name,value:t.value})}),{element:s.element,setSelectable:e=>{s.setEnabled(e)}}}var Jn=80,Yn=2500,Xn=class{configuration;element;priceEl;vatEl;button;unsubscribe;state=`idle`;resetTimer;constructor(e){this.configuration=e,this.element=document.createElement(`div`),this.element.className=`vd-commerce vd-hidden`;let t=document.createElement(`div`);t.className=`vd-commerce-price`,this.priceEl=document.createElement(`span`),this.priceEl.className=`vd-price`,this.vatEl=document.createElement(`span`),this.vatEl.className=`vd-vat`,t.append(this.priceEl,this.vatEl),this.button=new N({variant:`default`,onClick:()=>{this.handleSubmit()}}),this.button.element.classList.add(`vd-cta`,`vd-hidden`),this.element.append(t,this.button.element),this.unsubscribe=this.configuration.onRender(()=>{this.update()}),this.update()}update(){this.renderPrice(this.configuration.current),this.renderButton();let e=this.configuration.current!==void 0||this.configuration.submitEnabled;this.element.classList.toggle(`vd-hidden`,!e)}destroy(){this.unsubscribe(),this.resetTimer!==void 0&&clearTimeout(this.resetTimer),this.element.remove()}renderPrice(e){e===void 0?(this.priceEl.textContent=``,this.vatEl.textContent=``):(this.priceEl.textContent=Zn(e.price,e.currency),this.vatEl.textContent=Z(this.configuration.vatDisplay))}renderButton(){let e=this.configuration.submitEnabled;this.button.element.classList.toggle(`vd-hidden`,!e),e&&this.state===`idle`&&this.setButtonText(Z(this.configuration.buttonLabel))}async handleSubmit(){if(this.state!==`busy`){this.setState(`busy`,xt());try{await this.configuration.submit(),this.setState(`success`,Ct())}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){this.setState(`idle`,Z(this.configuration.buttonLabel));return}A.warn(`Commerce submit failed`,{error:e}),this.setState(`failed`,St())}this.scheduleReset()}}scheduleReset(){this.resetTimer!==void 0&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout(()=>{this.state=`idle`,this.update()},Yn)}setState(e,t){this.state=e,this.element.dataset.submit=e,this.button.element.disabled=e===`busy`,this.setButtonText(t)}setButtonText(e){this.button.element.textContent=e,this.button.element.setAttribute(`aria-label`,e)}};function Z(e){return(e??``).slice(0,Jn)}function Zn(e,t){try{let n=new Intl.NumberFormat(v(),{style:`currency`,currency:t}),r=n.resolvedOptions().maximumFractionDigits??2;return n.format(e/10**r)}catch{return`${t} ${(e/100).toFixed(2)}`}}var Qn=class{slot=null;panel=null;attach(e,t){this.panel=t,t.style.display=`none`,this.slot=document.createElement(`div`),this.slot.className=`vd-slot-bottom-left`,this.slot.appendChild(t),e.appendChild(this.slot)}setVisible(e){this.panel!==null&&(this.panel.style.display=e?`flex`:`none`)}destroy(){this.slot?.remove(),this.slot=null,this.panel=null}},$n=572,er=class{actionBarSlot;element=null;body=null;openButton=null;closeButton=null;container=null;observer=null;collapsible=!1;expanded=!0;visible=!1;constructor(e){this.actionBarSlot=e}attach(e,t){this.container=e,t.classList.add(`vd-attributes-sidebar`),this.closeButton=new N({variant:`ghost`,size:`icon-sm`,label:Nt(),icon:M.close({size:18}),onClick:()=>{this.expanded=!1,this.render()}});let n=document.createElement(`div`);n.className=`vd-sidebar-header`,n.appendChild(this.closeButton.element),this.body=document.createElement(`div`),this.body.className=`vd-sidebar-body`,this.body.appendChild(t),this.element=document.createElement(`div`),this.element.className=`vd-sidebar vd-hidden`,this.element.append(n,this.body),e.appendChild(this.element),this.openButton=new N({variant:`outline`,size:`icon`,label:Pt(),icon:M.configurator({size:18}),onClick:()=>{this.expanded=!0,this.render()}}),this.openButton.element.classList.add(`vd-configurator-toggle`,`vd-hidden`),this.actionBarSlot.appendChild(this.openButton.element),this.observe()}setVisible(e){this.visible=e,this.render()}destroy(){this.observer?.disconnect(),this.observer=null,this.openButton?.element.remove(),this.element?.remove(),this.container?.classList.remove(`vd-layout-sidebar-right`,`vd-layout-sidebar-permanent`),this.container=null}observe(){typeof ResizeObserver<`u`&&this.container!==null&&(this.observer=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;this.setCollapsible(t>0&&t<$n)}),this.observer.observe(this.container))}setCollapsible(e){e!==this.collapsible&&(this.collapsible=e,this.expanded=!e,this.render())}render(){if(this.element===null||this.openButton===null||this.closeButton===null||this.container===null)return;let e=this.visible&&this.expanded,t=this.visible&&!this.expanded;this.element.classList.toggle(`vd-hidden`,!this.visible),this.element.classList.toggle(`vd-sidebar-collapsed`,t),this.openButton.element.classList.toggle(`vd-hidden`,!t),this.closeButton.element.style.display=this.collapsible?``:`none`,this.container.classList.toggle(`vd-layout-sidebar-right`,e),this.container.classList.toggle(`vd-layout-sidebar-permanent`,e&&!this.collapsible)}},tr=class{attach(e,t){}setVisible(e){}destroy(){}},nr={"inframe-bottom-left":()=>new Qn,"sidebar-right":e=>new er(e),hidden:()=>new tr};function rr(e,t){return(nr[e??``]??(()=>new Qn))(t)}var Q=I.fontFamily.sans.join(`, `),$=`
400
485
  position: absolute;
401
486
  display: flex;
402
487
  z-index: 10;
403
488
  transition: inset-inline-end 0.18s ease;
404
- `,lo=`
489
+ `,ir=`
405
490
  /* Override browser's default black fullscreen backdrop */
406
491
  .vd-container:fullscreen {
407
492
  background: oklch(100% 0 0);
@@ -409,52 +494,52 @@
409
494
 
410
495
  /* Layout slots — four corners */
411
496
  .vd-slot-top-right {
412
- ${Z}
413
- inset-block-start: ${l[3]};
414
- inset-inline-end: ${l[3]};
497
+ ${$}
498
+ inset-block-start: ${F[3]};
499
+ inset-inline-end: ${F[3]};
415
500
  flex-direction: column;
416
501
  align-items: flex-end;
417
- gap: ${l[1.5]};
502
+ gap: ${F[1.5]};
418
503
  }
419
504
 
420
505
  .vd-slot-bottom-left {
421
- ${Z}
422
- inset-block-end: ${l[3]};
423
- inset-inline-start: ${l[3]};
506
+ ${$}
507
+ inset-block-end: ${F[3]};
508
+ inset-inline-start: ${F[3]};
424
509
  flex-direction: column;
425
510
  align-items: flex-start;
426
- gap: ${l[1.5]};
511
+ gap: ${F[1.5]};
427
512
  }
428
513
 
429
514
  .vd-slot-bottom-right {
430
- ${Z}
431
- inset-block-end: ${l[3]};
432
- inset-inline-end: ${l[3]};
515
+ ${$}
516
+ inset-block-end: ${F[3]};
517
+ inset-inline-end: ${F[3]};
433
518
  flex-direction: row;
434
- gap: ${l[1.5]};
519
+ gap: ${F[1.5]};
435
520
  }
436
521
 
437
522
  /* Component styles — no positioning */
438
523
  .vd-camera-controls {
439
524
  display: flex;
440
525
  flex-direction: column;
441
- gap: ${l[1]};
442
- background: color-mix(in oklch, ${m.white} 85%, transparent);
526
+ gap: ${F[1]};
527
+ background: color-mix(in oklch, ${P.white} 85%, transparent);
443
528
  backdrop-filter: blur(8px);
444
- border-radius: ${l[2]};
445
- padding: ${l[2]};
529
+ border-radius: ${F[2]};
530
+ padding: ${F[2]};
446
531
  }
447
532
 
448
533
  .vd-zoom {
449
534
  display: flex;
450
- gap: ${l[.5]};
535
+ gap: ${F[.5]};
451
536
  }
452
537
 
453
538
  .vd-dpad {
454
539
  display: grid;
455
- grid-template-columns: repeat(3, ${l[9]});
456
- grid-template-rows: repeat(3, ${l[9]});
457
- gap: ${l[.5]};
540
+ grid-template-columns: repeat(3, ${F[9]});
541
+ grid-template-rows: repeat(3, ${F[9]});
542
+ gap: ${F[.5]};
458
543
  }
459
544
 
460
545
  .vd-dpad-up { grid-column: 2; grid-row: 1; }
@@ -466,30 +551,30 @@
466
551
  .vd-attributes {
467
552
  display: flex;
468
553
  flex-direction: column;
469
- gap: ${l[3]};
470
- background: color-mix(in oklch, ${m.white} 85%, transparent);
554
+ gap: ${F[3]};
555
+ background: color-mix(in oklch, ${P.white} 85%, transparent);
471
556
  backdrop-filter: blur(8px);
472
- border: 1px solid color-mix(in oklch, ${m.neutral[900]} 8%, transparent);
473
- border-radius: ${l[3]};
474
- padding: ${l[3]};
475
- box-shadow: 0 ${l[1]} ${l[4]} color-mix(in oklch, ${m.neutral[900]} 6%, transparent);
476
- font-family: ${G};
557
+ border: 1px solid color-mix(in oklch, ${P.neutral[900]} 8%, transparent);
558
+ border-radius: ${F[3]};
559
+ padding: ${F[3]};
560
+ box-shadow: 0 ${F[1]} ${F[4]} color-mix(in oklch, ${P.neutral[900]} 6%, transparent);
561
+ font-family: ${Q};
477
562
  }
478
563
 
479
564
  .vd-attribute {
480
565
  display: flex;
481
566
  flex-direction: column;
482
- gap: ${l[1.5]};
567
+ gap: ${F[1.5]};
483
568
  }
484
569
 
485
570
  /* Micro-label: recedes so the controls lead. */
486
571
  .vd-attribute-label {
487
- font-size: ${S.fontSize.xs};
488
- font-weight: ${S.fontWeight.medium};
489
- color: ${m.neutral[500]};
572
+ font-size: ${I.fontSize.xs};
573
+ font-weight: ${I.fontWeight.medium};
574
+ color: ${P.neutral[500]};
490
575
  text-transform: uppercase;
491
576
  letter-spacing: 0.05em;
492
- font-family: ${G};
577
+ font-family: ${Q};
493
578
  }
494
579
 
495
580
  /* sidebar-right layout — a docked, full-height right panel */
@@ -525,10 +610,10 @@
525
610
  z-index: 11;
526
611
  display: flex;
527
612
  flex-direction: column;
528
- background: color-mix(in oklch, ${m.white} 90%, transparent);
613
+ background: color-mix(in oklch, ${P.white} 90%, transparent);
529
614
  backdrop-filter: blur(10px);
530
- border-inline-start: 1px solid color-mix(in oklch, ${m.neutral[900]} 8%, transparent);
531
- box-shadow: -${l[1]} 0 ${l[4]} color-mix(in oklch, ${m.neutral[900]} 5%, transparent);
615
+ border-inline-start: 1px solid color-mix(in oklch, ${P.neutral[900]} 8%, transparent);
616
+ box-shadow: -${F[1]} 0 ${F[4]} color-mix(in oklch, ${P.neutral[900]} 5%, transparent);
532
617
  }
533
618
 
534
619
  @media (prefers-reduced-motion: no-preference) {
@@ -540,13 +625,13 @@
540
625
  .vd-sidebar-header {
541
626
  display: flex;
542
627
  justify-content: flex-end;
543
- padding: ${l[1.5]} ${l[1.5]} 0;
628
+ padding: ${F[1.5]} ${F[1.5]} 0;
544
629
  }
545
630
 
546
631
  .vd-sidebar-body {
547
632
  flex: 1;
548
633
  overflow-y: auto;
549
- padding: ${l[4]};
634
+ padding: ${F[4]};
550
635
  }
551
636
 
552
637
  /* attributes inside the sidebar: flat and full-width — the panel provides the frosting */
@@ -557,38 +642,38 @@
557
642
  border-radius: 0;
558
643
  padding: 0;
559
644
  box-shadow: none;
560
- gap: ${l[5]};
645
+ gap: ${F[5]};
561
646
  }
562
647
 
563
648
  /* while the panel is open, keep the corner controls clear of it */
564
- .vd-layout-sidebar-right .vd-slot-top-right { inset-inline-end: calc(var(--vd-sidebar-width) + ${l[3]}); }
565
- .vd-layout-sidebar-right .vd-slot-bottom-right { inset-inline-end: calc(var(--vd-sidebar-width) + ${l[3]}); }
649
+ .vd-layout-sidebar-right .vd-slot-top-right { inset-inline-end: calc(var(--vd-sidebar-width) + ${F[3]}); }
650
+ .vd-layout-sidebar-right .vd-slot-bottom-right { inset-inline-end: calc(var(--vd-sidebar-width) + ${F[3]}); }
566
651
 
567
652
  /* Price + CTA — sit under the attribute controls, separated by a hairline */
568
653
  .vd-commerce {
569
654
  display: flex;
570
655
  flex-direction: column;
571
- gap: ${l[2]};
572
- padding-block-start: ${l[3]};
573
- border-block-start: 1px solid color-mix(in oklch, ${m.neutral[900]} 8%, transparent);
574
- font-family: ${G};
656
+ gap: ${F[2]};
657
+ padding-block-start: ${F[3]};
658
+ border-block-start: 1px solid color-mix(in oklch, ${P.neutral[900]} 8%, transparent);
659
+ font-family: ${Q};
575
660
  }
576
661
 
577
662
  .vd-commerce-price {
578
663
  display: flex;
579
664
  align-items: baseline;
580
- gap: ${l[1.5]};
665
+ gap: ${F[1.5]};
581
666
  }
582
667
 
583
668
  .vd-price {
584
- font-size: ${S.fontSize.lg};
585
- font-weight: ${S.fontWeight.semibold};
586
- color: ${m.neutral[900]};
669
+ font-size: ${I.fontSize.lg};
670
+ font-weight: ${I.fontWeight.semibold};
671
+ color: ${P.neutral[900]};
587
672
  }
588
673
 
589
674
  .vd-vat {
590
- font-size: ${S.fontSize.xs};
591
- color: ${m.neutral[500]};
675
+ font-size: ${I.fontSize.xs};
676
+ color: ${P.neutral[500]};
592
677
  }
593
678
 
594
679
  .vd-cta {
@@ -598,9 +683,9 @@
598
683
 
599
684
  /* Failed submit is the one place red belongs: a clear, recoverable error state. */
600
685
  .vd-commerce[data-submit="failed"] .vd-cta {
601
- background: ${m.semantic.error};
602
- border-color: ${m.semantic.error};
603
- color: ${m.white};
686
+ background: ${P.semantic.error};
687
+ border-color: ${P.semantic.error};
688
+ color: ${P.white};
604
689
  }
605
690
 
606
- `;function co(){if(Ft(),document.getElementById("vd-styles")!==null)return;const n=document.createElement("style");n.id="vd-styles",n.textContent=lo,document.head.appendChild(n)}function uo(n,t){const e=document.createElement("a");e.href=`data:image/png;base64,${n}`,e.download=t,e.click()}class ho{options;settings={};container=null;loading=null;slots={topRight:null,bottomRight:null};screenshotBtn=null;actionBar=null;cameraControls=null;attributes=null;groupHandles=new Map;lastSelectable=null;layout=null;commerce=null;constructor(t){this.options=t}attach(t){co(),this.container=t,this.loading=new Vi(t),this.slots.topRight=this.createSlot(t,"vd-slot-top-right"),this.slots.bottomRight=this.createSlot(t,"vd-slot-bottom-right")}onReady(){this.loading?.hide(),this.loading=null,this.mountToolbar(),this.cameraControls!==null&&(this.cameraControls.element.style.display="flex"),this.layout?.setVisible(!0)}mountToolbar(){if(this.actionBar!==null||this.slots.bottomRight===null||this.container===null)return;const t=typeof this.container.requestFullscreen=="function";this.actionBar=new Hi({onAr:this.options.onAr,onFullscreen:t?()=>{this.toggleFullscreen()}:void 0,onAnnotationsToggle:this.options.onAnnotationsToggle}),this.actionBar.applySettings(this.settings),this.slots.bottomRight.appendChild(this.actionBar.element),this.syncScreenshotButton(),this.placeScreenshotButton()}toggleFullscreen(){this.container!==null&&(document.fullscreenElement!==null?document.exitFullscreen():(this.options.onFullscreenEnter?.(),this.container.requestFullscreen()))}updateProgress(t,e){this.loading?.updateProgress(t,e)}showError(t){this.loading?.showError(t)}applyViewerSettings(t){this.settings=t,t.language!==void 0&&Ot(t.language,{reload:!1}),this.syncScreenshotButton(),this.actionBar?.applySettings(t),this.cameraControls!==null&&(this.cameraControls.element.style.display=t.cameraControls===!0?"flex":"none"),this.placeScreenshotButton()}renderAttributeControls(t,e){if(!(this.container===null||this.slots.topRight===null||this.slots.bottomRight===null)&&(this.cameraControls?.element.remove(),this.cameraControls=null,this.teardownConfigurator(),this.settings.cameraControls===!0&&(this.cameraControls=new z(this.options.cameraApi,this.options.cameraPositionApi),this.cameraControls.element.style.display="none",this.slots.topRight.appendChild(this.cameraControls.element)),this.placeScreenshotButton(),e.length!==0)){this.attributes=document.createElement("div"),this.attributes.className="vd-attributes",this.groupHandles=new Map;for(const i of e){const o=Ki(i,t,this.options.eventBus,this.options.onSelect,this.options.onSelectTransient,this.options.onSubscribe);this.groupHandles.set(i.name,o),this.attributes.appendChild(o.element)}this.commerce=new eo(this.options.configuration),this.attributes.appendChild(this.commerce.element),this.layout=ao(this.settings.configuratorLayout,this.slots.bottomRight),this.layout.attach(this.container,this.attributes),this.lastSelectable!==null&&this.applySelectable(this.lastSelectable)}}applySelectable(t){this.lastSelectable=t;for(const[e,i]of this.groupHandles){const o=t.find(s=>s.name===e);i.setSelectable(o?.selectable??null),i.setHidden(o?.hidden===!0)}}get viewerSettings(){return this.settings}teardownConfigurator(){this.commerce?.destroy(),this.commerce=null,this.attributes?.remove(),this.attributes=null,this.groupHandles=new Map,this.layout?.destroy(),this.layout=null}destroy(){this.loading?.destroy(),this.screenshotBtn?.element.remove(),this.actionBar?.destroy(),this.actionBar?.element.remove(),this.cameraControls?.element.remove(),this.teardownConfigurator();for(const t of Object.values(this.slots))t?.remove();this.container=null}createSlot(t,e){const i=document.createElement("div");return i.className=e,t.appendChild(i),i}syncScreenshotButton(){const t=this.settings.screenshot===!0;t&&this.screenshotBtn===null&&(this.screenshotBtn=new y({variant:"outline",size:"icon",label:li(),icon:g.screenshot(),onClick:()=>{this.options.snapshotApi.take("snapshot.png").onDeveloped(({data:e,filename:i})=>{uo(e,i)})}})),!t&&this.screenshotBtn!==null&&(this.screenshotBtn.element.remove(),this.screenshotBtn=null)}placeScreenshotButton(){this.screenshotBtn===null||this.slots.topRight===null||(this.cameraControls!==null?this.cameraControls.element.appendChild(this.screenshotBtn.element):this.slots.topRight.appendChild(this.screenshotBtn.element))}}const po={};class mo{defaultServer="https://server.virtualdisplay.io";options;serverHost;extraParams;constructor(t,e,i){this.options=t,this.serverHost=e,this.extraParams=i}create(){const t=this.createContainer(),e=this.createIframe();return t.appendChild(e),this.attachToParent(t),{container:t,iframe:e}}createContainer(){const t=document.createElement("div");return t.className="vd-container",Object.assign(t.style,{position:"relative",width:"100%",height:"100%",overflow:"hidden"}),t}createIframe(){const t=document.createElement("iframe");return t.src=this.buildUrl(),t.setAttribute("allow","xr-spatial-tracking; fullscreen"),t}attachToParent(t){this.getParentElement().appendChild(t)}buildUrl(){const t=this.getServerUrl(),e=new URL(t);this.setAddressParams(e),this.options.language!==void 0&&e.searchParams.set("language",this.options.language),this.options.session!==void 0&&e.searchParams.set("session",this.options.session),this.options.debug===!0&&e.searchParams.set("debug","true"),this.options.traceparent!==void 0&&e.searchParams.set("traceparent",this.options.traceparent);for(const[i,o]of Object.entries(this.extraParams??{}))e.searchParams.set(i,o);return e.toString()}setAddressParams(t){if(this.options.app===void 0){t.searchParams.set("license",this.options.license),t.searchParams.set("model",this.options.model);return}t.searchParams.set("app",this.options.app),(this.options.license!==void 0||this.options.model!==void 0)&&exports.logger.warn("Both `app` and `license`/`model` were supplied: `app` wins, the pair was ignored")}getServerUrl(){if(this.serverHost!==void 0)return this.serverHost;if(po?.VITE_VIRTUALDISPLAY_SERVER_HOST===void 0)return this.defaultServer}getParentElement(){if(typeof this.options.parent!="string")return this.options.parent;const t=document.querySelector(this.options.parent);if(t===null)throw b.parentNotFound(this.options.parent);return t}}function fo(n){const{messenger:t}=n;t.on(c.HANDSHAKE,e=>{Ht(e)&&(exports.logger.info("Server handshake received, flushing publisher queue"),t.markReady())}),t.on(c.SESSION,e=>{jt(e)&&n.onSession(e.sessionId)}),t.on(c.MUTATION,e=>{Gt(e)&&(n.attributes.handleMutationResult(e),n.configuration.handleSelectionChanged(n.attributes.getSelection()))}),t.on(c.SNAPSHOT,e=>{Zt(e)&&n.snapshot.handleSnapshotResult(e)}),t.on(c.CAMERA,e=>{Wt(e)&&n.cameraPosition.handlePositionUpdate(e)}),t.on(c.LOADING_INDICATOR,e=>{Qt(e)&&(e.error!==void 0?n.ui.showError(e.error):n.ui.updateProgress(e.progress,e.phase))}),t.on(c.CONFIG,e=>{Jt(e)&&n.applyConfig(e)}),t.on(c.MAPPING,e=>{Yt(e)&&(n.attributes.handleMappingReceived(e),n.configuration.handleSelectionChanged(n.attributes.getSelection()),n.ui.renderAttributeControls(n.attributes,e.attributes),n.readyStateTracker.handleMappingReceived())}),go(n)}function go(n){const{messenger:t}=n;t.on(c.FOCUS,e=>{te(e)&&n.focus.handleStateReceived(e)}),t.on(c.PRICING,e=>{ee(e)&&n.configuration.handlePricingReceived(e.pricing)}),t.on(c.SYNC,e=>{Kt(e)&&n.onSync(e.connected)}),t.on(c.SELECTABLE,e=>{Xt(e)&&(n.selectable.handleSnapshot(e),n.ui.applySelectable(e.attributes))}),t.on(c.APP_RESOLVED,e=>{qt(e)&&n.onAppResolved(e)})}class bo{ready=!1;onReady;constructor(t){this.onReady=t}handleMappingReceived(){this.ready||(this.ready=!0,exports.logger.info("Mapping received from server, client is now ready"),this.onReady?.())}get isReady(){return this.ready}clear(){this.ready=!1}}function vo(n){if(n===void 0)return;const{annotations:t,...e}=n;return t===void 0?e:t===!0?{...e,annotations:"show"}:t===!1?{...e,annotations:"hide"}:{...e,annotations:t}}class yo{attributes;selectableState;readyStateTracker;messenger;cameraApi;cameraPositionApi;focusApi;configurationApi;snapshotApi;annotationsApi;eventBus;ui;options;serverHost;iframeParams;arActivation;syncTracker;iframe;container;readyCallbacks=[];mutationFailedCallbacks=[];viewerSessionId;resolvedApp;appResolvedCallbacks=[];constructor(t,e){this.options=t;const i=e??{};this.serverHost=i.serverHost,this.iframeParams=i.iframeParams,this.initializeLogging(),this.messenger=new ne(()=>this.iframe?.contentWindow??null,{onHandlerError:(s,r)=>exports.logger.error(`Error handling ${s.type}`,r),...i.messengerOptions});const o=s=>{this.messenger.send(s)};this.attributes=new Se(o,O,(s,r)=>{this.notifyMutationFailed(s,r)}),this.selectableState=new Ce,this.snapshotApi=new Rt(o),this.annotationsApi=new ft(o,O),this.cameraApi=new kt(o),this.cameraPositionApi=new At,this.focusApi=new xt(o,s=>{this.dispatchFocusChange(s)},O),this.configurationApi=new Et(s=>{this.dispatchConfigurationChange(s)},s=>{this.dispatchConfigurationSubmit(s)}),this.eventBus=new Ae,this.arActivation=i.createArActivation?.(o),this.syncTracker=i.createSyncTracker?.(),this.readyStateTracker=new bo(()=>{this.notifyReady()}),this.ui=this.createStandardInterface(),this.wireIncomingMessages(),i.registerHandlers?.(this.messenger,o),this.messenger.start(),this.createAndConnectIframe()}createStandardInterface(){const t=this.arActivation;return new ho({snapshotApi:this.snapshotApi,cameraApi:this.cameraApi,cameraPositionApi:this.cameraPositionApi,eventBus:this.eventBus,configuration:this.configurationApi,onSelect:(e,i)=>this.attributes.select(e,i),onSelectTransient:(e,i)=>this.attributes.selectTransient(e,i),onSubscribe:(e,i)=>this.attributes.onChange(e,i),...t!==void 0&&{onAr:()=>{t.activate()}},onFullscreenEnter:()=>{this.trackFullscreen()},onAnnotationsToggle:e=>{this.sendControlAnnotationToggle(e)}})}sendControlAnnotationToggle(t){this.messenger.send({type:c.ANNOTATION_TOGGLE,instance:O,enabled:t,origin:"control"})}wireIncomingMessages(){fo({messenger:this.messenger,attributes:this.attributes,selectable:this.selectableState,configuration:this.configurationApi,snapshot:this.snapshotApi,cameraPosition:this.cameraPositionApi,focus:this.focusApi,ui:this.ui,readyStateTracker:this.readyStateTracker,applyConfig:t=>{this.handleConfig(t)},onSession:t=>{this.handleSession(t)},onSync:t=>{this.syncTracker?.handleSync(t)},onAppResolved:t=>{this.handleAppResolved({appType:t.appType,name:t.name,...t.slug!==void 0&&{slug:t.slug},...t.submit!==void 0&&{submit:t.submit}})}})}handleAppResolved(t){this.resolvedApp=t;for(const e of this.appResolvedCallbacks)e(t)}handleSession(t){this.viewerSessionId=t,this.arActivation?.onSession(t)}notifyMutationFailed(t,e){for(const i of this.mutationFailedCallbacks)i({attribute:t,value:e})}notifyReady(){const t=this.readyCallbacks;this.readyCallbacks=[];for(const e of t)e(this);this.ui.onReady()}dispatchFocusChange(t){this.container?.dispatchEvent(new CustomEvent(x.FOCUS_CHANGE,{detail:t,bubbles:!0}))}dispatchConfigurationChange(t){this.container?.dispatchEvent(new CustomEvent(x.CONFIGURATION_CHANGE,{detail:t??null,bubbles:!0}))}dispatchConfigurationSubmit(t){this.container?.dispatchEvent(new CustomEvent(x.CONFIGURATION_SUBMIT,{detail:t,bubbles:!0}))}handleConfig(t){const e=t.viewerSettings,i=vo(this.options.viewerSettings);if(e!==void 0||i!==void 0){const o=i!==void 0?{...e??{},...i}:e;if(i!==void 0&&e!==void 0){const s=Object.entries(i).filter(([r,a])=>e[r]!==a).map(([r,a])=>`${r} (metadata: ${e[r]??"undefined"}, override: ${a})`);s.length>0&&exports.logger.warn(`Viewer settings override active: ${s.join(", ")}`)}this.ui.applyViewerSettings(o),this.echoAnnotationsDifference(e?.annotations,o.annotations)}this.cameraPositionApi.applyLimits(t.cameraLimits)}echoAnnotationsDifference(t,e){e===void 0||e===t||this.annotationsApi.setEnabled(e==="show"||e==="toggle-shown")}trackFullscreen(){this.messenger.send({type:c.FULLSCREEN})}initializeLogging(){this.options.debug===!0&&_t(),exports.logger.info("Initializing Virtualdisplay client",{...this.options.app===void 0?{model:this.options.model}:{app:this.options.app}})}createAndConnectIframe(){const e=new mo(this.options,this.serverHost,this.iframeParams).create();this.container=e.container,this.iframe=e.iframe,this.eventBus.attach(this.container),this.ui.attach(this.container);try{const i=new URL(this.iframe.src).origin;this.messenger.setTargetOrigin(i)}catch{}}select(t,e){this.attributes.select(t,e)}getValues(t){return this.attributes.getValues(t)}getValue(t,e){return this.attributes.getValue(t,e)}onChange(t,e){this.attributes.onChange(t,e)}getAttribute(t){return this.attributes.getAttribute(t)}get isReady(){return this.readyStateTracker.isReady}onReady(t){if(this.readyStateTracker.isReady){t(this);return}this.readyCallbacks.push(t)}onMutationFailed(t){this.mutationFailedCallbacks.push(t)}onSelectableChange(t){this.selectableState.onChange(t)}onAppResolved(t){this.appResolvedCallbacks.push(t),this.resolvedApp!==void 0&&t(this.resolvedApp)}getSelectable(t){return this.selectableState.selectableFor(t)}activateAr(){this.arActivation?.activate()}on(t,e){this.eventBus.on(t,e)}get annotations(){return this.annotationsApi}get camera(){return this.cameraApi}get focus(){return this.focusApi}get configuration(){return this.configurationApi}get cameraPosition(){return this.cameraPositionApi}get snapshot(){return this.snapshotApi}get sessionId(){return this.viewerSessionId}get viewerSettings(){return this.ui.viewerSettings}destroy(){this.readyStateTracker.clear(),this.readyCallbacks=[],this.mutationFailedCallbacks.length=0,this.snapshotApi.clear(),this.messenger.destroy(),this.arActivation?.destroy(),this.ui.destroy(),this.container?.parentElement!==null&&this.container?.parentElement!==void 0&&this.container.parentElement.removeChild(this.container),this.container=void 0,this.iframe=void 0}}const wo="ar.virtualdisplay.io";function So(n){const t=new URL(`https://${wo}/go`);return n.sessionId!==void 0?t.searchParams.set("session",n.sessionId):n.app!==void 0?t.searchParams.set("app",n.app):n.license!==void 0&&n.model!==void 0&&(t.searchParams.set("license",n.license),t.searchParams.set("model",n.model)),t.toString()}const Co=1500;class _o{options;qrModal=new Pi;sessionId;waiters=[];pendingTimers=new Set;destroyed=!1;constructor(t){this.options=t}onSession(t){this.sessionId=t;const e=this.waiters;this.waiters=[];for(const i of e)i(t)}activate(){if(ve()){this.options.send({type:c.AR_ACTIVATE});return}this.showQrCode()}destroy(){this.destroyed=!0;for(const t of this.pendingTimers)clearTimeout(t);this.pendingTimers.clear(),this.waiters=[],this.qrModal.hide()}async showQrCode(){this.qrModal.show();const t=await this.waitForSessionId();if(this.destroyed)return;const e=So({sessionId:t,app:this.options.app,license:this.options.license,model:this.options.model}),i=await this.qrModal.update(e);if(this.destroyed){this.qrModal.hide();return}i&&this.options.send({type:c.QR_SHOWN})}waitForSessionId(){return this.sessionId!==void 0?Promise.resolve(this.sessionId):new Promise(t=>{const e=setTimeout(()=>{this.pendingTimers.delete(e),t(void 0)},Co);this.pendingTimers.add(e),this.waiters.push(i=>{this.pendingTimers.delete(e),clearTimeout(e),t(i)})})}}class ko{callbacks=[];lastKnown;handleSync(t){this.lastKnown=t;for(const e of this.callbacks)e(t)}onChange(t){this.callbacks.push(t),this.lastKnown!==void 0&&t(this.lastKnown)}}class Ao extends yo{syncStatusTracker;constructor(t){const e=new ko;super(t,{createArActivation:i=>new _o({app:t.app,license:t.license,model:t.model,send:i}),createSyncTracker:()=>e}),this.syncStatusTracker=e}onSyncChange(t){this.syncStatusTracker.onChange(t)}}exports.AVAILABILITY=mt;exports.Annotations=ft;exports.Attribute=bt;exports.AttributeValue=gt;exports.Camera=kt;exports.CameraPosition=At;exports.Configuration=Et;exports.ERROR_CODES=_;exports.Focus=xt;exports.Photo=Tt;exports.Snapshot=Rt;exports.VD_EVENTS=x;exports.VirtualdisplayClient=Ao;exports.VirtualdisplayError=b;exports.enableDebugMode=_t;exports.isDebugMode=we;
691
+ `;function ar(){if(_n(),document.getElementById(`vd-styles`)!==null)return;let e=document.createElement(`style`);e.id=`vd-styles`,e.textContent=ir,document.head.appendChild(e)}function or(e,t){let n=document.createElement(`a`);n.href=`data:image/png;base64,${e}`,n.download=t,n.click()}var sr=class{options;settings={};container=null;loading=null;slots={topRight:null,bottomRight:null};screenshotBtn=null;actionBar=null;cameraControls=null;attributes=null;groupHandles=new Map;lastSelectable=null;layout=null;commerce=null;constructor(e){this.options=e}attach(e){ar(),this.container=e,this.loading=new An(e),this.slots.topRight=this.createSlot(e,`vd-slot-top-right`),this.slots.bottomRight=this.createSlot(e,`vd-slot-bottom-right`)}onReady(){this.loading?.hide(),this.loading=null,this.mountToolbar(),this.cameraControls!==null&&(this.cameraControls.element.style.display=`flex`),this.layout?.setVisible(!0)}mountToolbar(){if(this.actionBar!==null||this.slots.bottomRight===null||this.container===null)return;let e=typeof this.container.requestFullscreen==`function`&&document.fullscreenEnabled!==!1;this.actionBar=new jn({onAr:this.options.onAr,onFullscreen:e?()=>{this.toggleFullscreen()}:void 0,onAnnotationsToggle:this.options.onAnnotationsToggle}),this.actionBar.applySettings(this.settings),this.slots.bottomRight.appendChild(this.actionBar.element),this.syncScreenshotButton(),this.placeScreenshotButton()}toggleFullscreen(){this.container!==null&&(document.fullscreenElement===null?(this.options.onFullscreenEnter?.(),this.container.requestFullscreen().catch(e=>{A.warn(`Fullscreen request refused`,{error:e})})):document.exitFullscreen())}updateProgress(e,t){this.loading?.updateProgress(e,t)}showError(e){this.loading?.showError(e)}viewerAlive(){this.loading?.viewerAlive()}applyViewerSettings(e){this.settings=e,e.language!==void 0&&ye(e.language,{reload:!1}),this.syncScreenshotButton(),this.actionBar?.applySettings(e),this.cameraControls!==null&&(this.cameraControls.element.style.display=e.cameraControls===!0?`flex`:`none`),this.placeScreenshotButton()}renderModelControls(e,t){if(this.container!==null&&this.slots.topRight!==null&&this.slots.bottomRight!==null&&(this.cameraControls?.element.remove(),this.cameraControls=null,this.teardownConfigurator(),this.settings.cameraControls===!0&&(this.cameraControls=new Mn(this.options.cameraApi,this.options.cameraPositionApi),this.cameraControls.element.style.display=`none`,this.slots.topRight.appendChild(this.cameraControls.element)),this.placeScreenshotButton(),t.length!==0)){this.attributes=document.createElement(`div`),this.attributes.className=`vd-attributes`,this.groupHandles=new Map;for(let n of t){let t=Kn(n,e,this.options.eventBus,this.options.onSelect,this.options.onSelectTransient,this.options.onSubscribe);this.groupHandles.set(n.name,t),this.attributes.appendChild(t.element)}this.commerce=new Xn(this.options.configuration),this.attributes.appendChild(this.commerce.element),this.layout=rr(this.settings.configuratorLayout,this.slots.bottomRight),this.layout.attach(this.container,this.attributes),this.lastSelectable!==null&&this.applySelectable(this.lastSelectable)}}applySelectable(e){this.lastSelectable=e;for(let[t,n]of this.groupHandles){let r=e.find(e=>e.name===t);n.setSelectable(r?.selectable??null),n.setHidden(r?.hidden===!0)}}get viewerSettings(){return this.settings}teardownConfigurator(){this.commerce?.destroy(),this.commerce=null,this.attributes?.remove(),this.attributes=null,this.groupHandles=new Map,this.layout?.destroy(),this.layout=null}destroy(){this.loading?.destroy(),this.screenshotBtn?.element.remove(),this.actionBar?.destroy(),this.actionBar?.element.remove(),this.cameraControls?.element.remove(),this.teardownConfigurator();for(let e of Object.values(this.slots))e?.remove();this.container=null}createSlot(e,t){let n=document.createElement(`div`);return n.className=t,e.appendChild(n),n}syncScreenshotButton(){let e=this.settings.screenshot===!0;e&&this.screenshotBtn===null&&(this.screenshotBtn=new N({variant:`outline`,size:`icon`,label:Ht(),icon:M.screenshot(),onClick:()=>{this.takeScreenshot()}})),!e&&this.screenshotBtn!==null&&(this.screenshotBtn.element.remove(),this.screenshotBtn=null)}takeScreenshot(){let e=this.screenshotBtn;e===null||e.element.disabled||(e.element.disabled=!0,this.options.snapshotApi.take(`snapshot.png`).onDeveloped(({data:t,filename:n})=>{e.element.disabled=!1,or(t,n)}).onError(t=>{e.element.disabled=!1,A.warn(`Screenshot failed`,{error:t})}))}placeScreenshotButton(){this.screenshotBtn!==null&&this.slots.topRight!==null&&(this.cameraControls===null?this.slots.topRight.appendChild(this.screenshotBtn.element):this.cameraControls.element.appendChild(this.screenshotBtn.element))}},cr=class{defaultServer=`https://server.virtualdisplay.io`;options;serverHost;extraParams;constructor(e,t,n){this.options=e,this.serverHost=t,this.extraParams=n}create(){let e=this.createContainer(),t=this.createIframe();return e.appendChild(t),this.attachToParent(e),{container:e,iframe:t}}createContainer(){let e=document.createElement(`div`);return e.className=`vd-container`,Object.assign(e.style,{position:`relative`,width:`100%`,height:`100%`,overflow:`hidden`}),e}createIframe(){let e=document.createElement(`iframe`);return e.src=this.buildUrl(),e.setAttribute(`allow`,`xr-spatial-tracking; fullscreen`),e}attachToParent(e){this.getParentElement().appendChild(e)}buildUrl(){let e=this.getServerUrl(),t=new URL(e);this.setAddressParams(t),this.options.language!==void 0&&t.searchParams.set(`language`,this.options.language),this.options.session!==void 0&&t.searchParams.set(`session`,this.options.session),this.options.debug===!0&&t.searchParams.set(`debug`,`true`),this.options.traceparent!==void 0&&t.searchParams.set(`traceparent`,this.options.traceparent);for(let[e,n]of Object.entries(this.extraParams??{}))t.searchParams.set(e,n);return t.toString()}setAddressParams(e){this.options.app===void 0?(e.searchParams.set(`license`,this.options.license),e.searchParams.set(`model`,this.options.model)):(e.searchParams.set(`app`,this.options.app),(this.options.license!==void 0||this.options.model!==void 0)&&A.warn("Both `app` and `license`/`model` were supplied: `app` wins, the pair was ignored"))}getServerUrl(){return this.serverHost===void 0?this.defaultServer:this.serverHost}getParentElement(){if(typeof this.options.parent!=`string`)return this.options.parent;let e=document.querySelector(this.options.parent);if(e===null)throw w.parentNotFound(this.options.parent);return e}};function lr(e){let{messenger:n}=e;n.on(t.HANDSHAKE,t=>{l(t)&&(A.info(`Server handshake received, flushing publisher queue`),n.markReady(),e.ui.viewerAlive())}),n.on(t.SESSION,t=>{u(t)&&e.onSession(t.sessionId)}),n.on(t.MUTATION,t=>{d(t)&&(e.attributes.handleMutationResult(t),e.configuration.handleSelectionChanged(e.attributes.getSelection()))}),n.on(t.SNAPSHOT,t=>{f(t)&&e.snapshot.handleSnapshotResult(t)}),n.on(t.CAMERA,t=>{p(t)&&e.cameraPosition.handlePositionUpdate(t)}),n.on(t.LOADING_INDICATOR,t=>{ne(t)&&(t.error===void 0?e.ui.updateProgress(t.progress,t.phase):e.ui.showError(t.error))}),n.on(t.CONFIG,t=>{ie(t)&&e.applyConfig(t)}),n.on(t.MAPPING,t=>{te(t)&&(e.attributes.handleMappingReceived(t),e.configuration.handleSelectionChanged(e.attributes.getSelection()),e.ui.renderModelControls(e.attributes,t.attributes),e.readyStateTracker.handleMappingReceived())}),ur(e)}function ur(e){let{messenger:n}=e;n.on(t.FOCUS,t=>{ae(t)&&e.focus.handleStateReceived(t)}),n.on(t.PRICING,t=>{oe(t)&&e.configuration.handlePricingReceived(t.pricing)}),n.on(t.SYNC,t=>{m(t)&&e.onSync(t.connected)}),n.on(t.SELECTABLE,t=>{re(t)&&(e.selectable.handleSnapshot(t),e.ui.applySelectable(t.attributes))}),n.on(t.APP_RESOLVED,t=>{ee(t)&&e.onAppResolved(t)})}var dr=class{ready=!1;onReady;constructor(e){this.onReady=e}handleMappingReceived(){this.ready||(this.ready=!0,A.info(`Mapping received from server, client is now ready`),this.onReady?.())}get isReady(){return this.ready}clear(){this.ready=!1}};function fr(e){if(e===void 0)return;let{annotations:t,...n}=e;return t===void 0?n:t===!0?{...n,annotations:`show`}:t===!1?{...n,annotations:`hide`}:{...n,annotations:t}}function pr(e){if(!Array.isArray(e))return{};let t=e.filter(e=>typeof e==`string`);return t.length>0?{features:t}:{}}var mr=class{attributes;selectableState;readyStateTracker;messenger;cameraApi;cameraPositionApi;focusApi;configurationApi;snapshotApi;annotationsApi;eventBus;ui;options;serverHost;iframeParams;arActivation;syncTracker;iframe;container;readyCallbacks=[];mutationFailedCallbacks=[];viewerSessionId;resolvedApp;appResolvedCallbacks=[];constructor(e,t){this.options=e;let r=t??{};this.serverHost=r.serverHost,this.iframeParams=r.iframeParams,this.initializeLogging(),this.messenger=new ce(()=>this.iframe?.contentWindow??null,{onHandlerError:(e,t)=>A.error(`Error handling ${e.type}`,t),...r.messengerOptions});let i=e=>{this.messenger.send(e)};this.attributes=new ct(i,n,(e,t)=>{this.notifyMutationFailed(e,t)}),this.selectableState=new lt,this.snapshotApi=new yt(i),this.annotationsApi=new ue(i,n),this.cameraApi=new ut(i),this.cameraPositionApi=new dt,this.focusApi=new gt(i,e=>{this.dispatchFocusChange(e)},n),this.configurationApi=new ht(e=>{this.dispatchConfigurationChange(e)},e=>{this.dispatchConfigurationSubmit(e)}),this.eventBus=new bt,this.arActivation=r.createArActivation?.(i),this.syncTracker=r.createSyncTracker?.(),this.readyStateTracker=new dr(()=>{this.notifyReady()}),this.ui=this.createStandardInterface(),this.wireIncomingMessages(),r.registerHandlers?.(this.messenger,i),this.messenger.start(),this.mountIframe()}createStandardInterface(){let e=this.arActivation;return new sr({snapshotApi:this.snapshotApi,cameraApi:this.cameraApi,cameraPositionApi:this.cameraPositionApi,eventBus:this.eventBus,configuration:this.configurationApi,onSelect:(e,t)=>this.attributes.select(e,t),onSelectTransient:(e,t)=>this.attributes.selectTransient(e,t),onSubscribe:(e,t)=>this.attributes.onChange(e,t),...e!==void 0&&{onAr:()=>{e.activate()}},onFullscreenEnter:()=>{this.trackFullscreen()},onAnnotationsToggle:e=>{this.sendControlAnnotationToggle(e)}})}sendControlAnnotationToggle(e){this.sendAnnotationToggle(e,`control`)}sendAnnotationToggle(e,n){this.messenger.send({type:t.ANNOTATION_TOGGLE,enabled:e,...n!==void 0&&{origin:n}})}wireIncomingMessages(){lr({messenger:this.messenger,attributes:this.attributes,selectable:this.selectableState,configuration:this.configurationApi,snapshot:this.snapshotApi,cameraPosition:this.cameraPositionApi,focus:this.focusApi,ui:this.ui,readyStateTracker:this.readyStateTracker,applyConfig:e=>{this.handleConfig(e)},onSession:e=>{this.handleSession(e)},onSync:e=>{this.syncTracker?.handleSync(e)},onAppResolved:e=>{this.handleAppResolved({appType:e.appType,name:e.name,...e.slug!==void 0&&{slug:e.slug},...e.submit!==void 0&&{submit:e.submit},...pr(e.features)})}})}handleAppResolved(e){this.resolvedApp=e;for(let t of this.appResolvedCallbacks)t(e)}handleSession(e){this.viewerSessionId=e,this.arActivation?.onSession(e)}notifyMutationFailed(e,t){for(let n of this.mutationFailedCallbacks)n({attribute:e,value:t})}notifyReady(){let e=this.readyCallbacks;this.readyCallbacks=[];for(let t of e)t(this);this.ui.onReady()}dispatchFocusChange(e){this.container?.dispatchEvent(new CustomEvent(X.FOCUS_CHANGE,{detail:e,bubbles:!0}))}dispatchConfigurationChange(e){this.container?.dispatchEvent(new CustomEvent(X.CONFIGURATION_CHANGE,{detail:e??null,bubbles:!0}))}dispatchConfigurationSubmit(e){this.container?.dispatchEvent(new CustomEvent(X.CONFIGURATION_SUBMIT,{detail:e,bubbles:!0}))}handleConfig(e){let t=e.viewerSettings,n=fr(this.options.viewerSettings);if(t!==void 0||n!==void 0){let e=n===void 0?t:{...t??{},...n};if(n!==void 0&&t!==void 0){let e=Object.entries(n).filter(([e,n])=>t[e]!==n).map(([e,n])=>`${e} (metadata: ${t[e]??`undefined`}, override: ${n})`);e.length>0&&A.warn(`Viewer settings override active: ${e.join(`, `)}`)}this.ui.applyViewerSettings(e),this.echoAnnotationsDifference(t?.annotations,e.annotations)}this.cameraPositionApi.applyLimits(e.cameraLimits)}echoAnnotationsDifference(e,t){t!==void 0&&t!==e&&this.sendAnnotationToggle(t===`show`||t===`toggle-shown`)}trackFullscreen(){this.messenger.send({type:t.FULLSCREEN})}initializeLogging(){this.options.debug===!0&&ot(),A.info(`Initializing Virtualdisplay client`,{...this.options.app===void 0?{model:this.options.model}:{app:this.options.app}})}mountIframe(){let e=new cr(this.options,this.serverHost,this.iframeParams).create();this.container=e.container,this.iframe=e.iframe,this.eventBus.attach(this.container),this.ui.attach(this.container);try{let e=new URL(this.iframe.src).origin;this.messenger.setTargetOrigin(e)}catch{}}select(e,t){this.attributes.select(e,t)}getValues(e){return this.attributes.getValues(e)}getValue(e,t){return this.attributes.getValue(e,t)}onChange(e,t){this.attributes.onChange(e,t)}getAttribute(e){return this.attributes.getAttribute(e)}get isReady(){return this.readyStateTracker.isReady}onReady(e){this.readyStateTracker.isReady?e(this):this.readyCallbacks.push(e)}onMutationFailed(e){this.mutationFailedCallbacks.push(e)}onSelectableChange(e){this.selectableState.onChange(e)}onAppResolved(e){this.appResolvedCallbacks.push(e),this.resolvedApp!==void 0&&e(this.resolvedApp)}getSelectable(e){return this.selectableState.selectableFor(e)}activateAr(){this.arActivation?.activate()}on(e,t){this.eventBus.on(e,t)}get annotations(){return this.annotationsApi}get camera(){return this.cameraApi}get focus(){return this.focusApi}get configuration(){return this.configurationApi}get cameraPosition(){return this.cameraPositionApi}get snapshot(){return this.snapshotApi}get sessionId(){return this.viewerSessionId}get viewerSettings(){return this.ui.viewerSettings}destroy(){this.readyStateTracker.clear(),this.readyCallbacks=[],this.mutationFailedCallbacks.length=0,this.snapshotApi.clear(),this.messenger.destroy(),this.arActivation?.destroy(),this.ui.destroy(),this.container?.parentElement!==null&&this.container?.parentElement!==void 0&&this.container.parentElement.removeChild(this.container),this.container=void 0,this.iframe=void 0}},hr=`ar.virtualdisplay.io`;function gr(e){let t=new URL(`https://${hr}/go`);return e.sessionId===void 0?e.app===void 0?e.license!==void 0&&e.model!==void 0&&(t.searchParams.set(`license`,e.license),t.searchParams.set(`model`,e.model)):t.searchParams.set(`app`,e.app):t.searchParams.set(`session`,e.sessionId),t.toString()}var _r=1500,vr=class{options;qrModal=new yn;sessionId;waiters=[];pendingTimers=new Set;destroyed=!1;constructor(e){this.options=e}onSession(e){this.sessionId=e;let t=this.waiters;this.waiters=[];for(let n of t)n(e)}activate(){tt()?this.options.send({type:t.AR_ACTIVATE}):this.showQrCode()}destroy(){this.destroyed=!0;for(let e of this.pendingTimers)clearTimeout(e);this.pendingTimers.clear(),this.waiters=[],this.qrModal.hide()}async showQrCode(){this.qrModal.show();let e=await this.waitForSessionId();if(this.destroyed)return;let n=gr({sessionId:e,app:this.options.app,license:this.options.license,model:this.options.model}),r;try{r=await this.qrModal.update(n)}catch(e){A.warn(`AR QR code could not be rendered`,{error:e});return}this.destroyed?this.qrModal.hide():r&&this.options.send({type:t.QR_SHOWN})}waitForSessionId(){return this.sessionId===void 0?new Promise(e=>{let t=setTimeout(()=>{this.pendingTimers.delete(t),e(void 0)},_r);this.pendingTimers.add(t),this.waiters.push(n=>{this.pendingTimers.delete(t),clearTimeout(t),e(n)})}):Promise.resolve(this.sessionId)}},yr=class{callbacks=[];lastKnown;handleSync(e){this.lastKnown=e;for(let t of this.callbacks)t(e)}onChange(e){this.callbacks.push(e),this.lastKnown!==void 0&&e(this.lastKnown)}},br=class extends mr{syncStatusTracker;constructor(e){let t=new yr;super(e,{createArActivation:t=>new vr({app:e.app,license:e.license,model:e.model,send:t}),createSyncTracker:()=>t}),this.syncStatusTracker=t}onSyncChange(e){this.syncStatusTracker.onChange(e)}};exports.AVAILABILITY=a,exports.Annotations=ue,exports.Attribute=Le,exports.AttributeValue=de,exports.Camera=ut,exports.CameraPosition=dt,exports.Configuration=ht,exports.ERROR_CODES=C,exports.Focus=gt,exports.Photo=_t,exports.Snapshot=yt,exports.VD_EVENTS=X,exports.VirtualdisplayClient=br,exports.VirtualdisplayError=w,exports.enableDebugMode=ot,exports.isDebugMode=st,Object.defineProperty(exports,"logger",{enumerable:!0,get:function(){return A}});