"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),I=require("./PictometryPanel-sN08UTVp.cjs"),g={size:100,fillColor:"rgba(0, 102, 255, 0.25)",strokeColor:"rgba(0, 102, 255, 0.6)",strokeWidth:1};function x(s){const{hFov:o,size:c=g.size,fillColor:l=g.fillColor,strokeColor:u=g.strokeColor,strokeWidth:a=g.strokeWidth}=s,d=Math.min(Math.max(o,10),170),m=30,h=120,n=1-(Math.min(Math.max(d,m),h)-m)/(h-m)*.6,r=(c-a*2)*n,b=d/2*Math.PI/180,p=r*Math.tan(b),v=Math.ceil(p*2+a*2),f=Math.ceil(r+a*2),y=document.createElement("canvas");y.width=v,y.height=f;const e=y.getContext("2d");if(!e)throw new Error("Failed to get canvas 2d context");e.clearRect(0,0,v,f);const w=v/2,k=f-a,F=a,M=w-p,H=w+p;return e.beginPath(),e.moveTo(w,k),e.lineTo(M,F),e.lineTo(H,F),e.closePath(),e.fillStyle=l,e.fill(),e.strokeStyle=u,e.lineWidth=a,e.stroke(),e.getImageData(0,0,v,f)}function C(s){return`cyclomedia-viewcone-${Math.round(s)}`}const z=t.defineComponent({__name:"CyclomediaViewcone",props:{position:{},yaw:{default:0},hFov:{default:80},iconSize:{default:.5}},setup(s){const o=s,c=t.inject("map"),l=t.inject("isLoaded"),u=t.ref(!1);let a=null;async function d(i){if(!c?.value)return;const n=C(i);if(c.value.hasImage(n)){a=n,u.value=!0;return}try{const r=x({hFov:i,size:100});c.value.addImage(n,r),a=n,u.value=!0}catch{}}t.onMounted(async()=>{!c||!c.value||l&&(l.value||await new Promise(i=>{const n=t.watch(l,r=>{r&&(n(),i())})}),await d(o.hFov))}),t.watch(()=>o.hFov,async i=>{!c?.value||!l?.value||await d(i)});const m=t.computed(()=>o.position?{type:"geojson",data:{type:"Feature",geometry:{type:"Point",coordinates:o.position},properties:{}}}:{type:"geojson",data:{type:"FeatureCollection",features:[]}}),h=t.computed(()=>({"icon-image":a||C(o.hFov),"icon-size":o.iconSize,"icon-anchor":"bottom","icon-rotate":o.yaw,"icon-rotation-alignment":"map","icon-allow-overlap":!0,"icon-ignore-placement":!0}));return(i,n)=>s.position&&u.value?(t.openBlock(),t.createBlock(I._sfc_main$5,{key:0,id:"cyclomedia-viewcone",source:m.value,layout:h.value,"before-id":"cyclomedia-camera-icon"},null,8,["source","layout"])):t.createCommentVNode("",!0)}});exports.default=z;
