"use strict";var _extension=require("../../core/extension");exports.__esModule=!0,exports.default=exports.ActionType=void 0;let ActionType=exports.ActionType=function(a){return a.SCENE="scene",a.PANEL="panel",a.POI="poi",a.CAMERA="camera",a.MODEL="model",a.VIEW="view",a}({});var _default=exports.default=(0,_extension.definePlugin)("ai",{setup(a,b){let c,d,e={[ActionType.SCENE]:a=>b.render(a.model_id),[ActionType.PANEL]:a=>{},[ActionType.POI]:a=>{},[ActionType.CAMERA]:a=>b.camera.move(a.direction,a.offset,a.duration||2e3),[ActionType.MODEL]:a=>{const{model_id_list:c}=a;c.length&&c.forEach(c=>{let d=b.get(c);d&&(0==a.type?d.model.selected=!1:d.model.selected=!0)})},[ActionType.VIEW]:a=>{const{type:c}=a,d=b.camera.target,e=b.camera.position,f=Math.sqrt(Math.pow(d.x-e.x,2)+Math.pow(d.y-e.y,2)+Math.pow(d.z-e.z,2));let g,h;1===c&&(g=0,h=90),2===c&&(g=0,h=45),3===c&&(g=180,h=45),b.camera.flyTo(d,{phi:g,theta:h,distance:f})}},f=(a,b)=>{let c=e[a]||(()=>{});e[a]=a=>b(a,c)},g=(a,b)=>{if(!(c&&(b=c(a,b),!b))){let c=e[a];if(c){let e=c(b);e instanceof Promise?e.then(()=>{d&&d(a,b)}):d&&d(a,b)}}};return{invoke:g,before:a=>{c=a},after:a=>{d=a},action:f,dispose:()=>{c=null,d=null,e={}},ActionType}},destroyed(){this.dispose()}});