@archilogic/floor-plan-sdk 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fpe.css +1 -1
- package/fpe.d.ts +1 -1
- package/fpe.esm.js +2 -2
- package/fpe.js +2 -2
- package/package.json +2 -2
package/fpe.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Archilogic Floor Plan Engine SDK v3.2.
|
|
2
|
+
Archilogic Floor Plan Engine SDK v3.2.1 build 240315-153550-ae9643
|
|
3
3
|
|
|
4
4
|
(c) 2023 Archilogic AG
|
|
5
5
|
|
|
6
6
|
License: According to your license agreement with Archilogic AG
|
|
7
7
|
*/
|
|
8
|
-
function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function e(e){for(var i=1;i<arguments.length;i++){var r=null!=arguments[i]?arguments[i]:{};i%2?t(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(t,e,i,r,n,o,s){try{var a=t[o](s),h=a.value}catch(t){return void i(t)}a.done?e(h):Promise.resolve(h).then(r,n)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var s=t.apply(e,r);function a(t){i(s,n,o,a,h,"next",t)}function h(t){i(s,n,o,a,h,"throw",t)}a(void 0)}))}}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var o={api:{spaceApiV2Url:"https://api.archilogic.com/v2",storageUrl:"https://storage.3d.io",staticProductCache:"/archilogic/product/json",staticProductThumb:"/archilogic/product/thumb",staticProductOutline:"/archilogic/product/outline",staticMatLib:"/archilogic/matlib",sdkVersion:"3.2.0",productDataCacheAge:864e5,productContourCacheAge:864e6},computeMergedSpace:!1,computeConnectedSpaces:!1,loadWallRelations:!1,debug:!1,editable:{},editorId:"floor-plan-engine",exposeInstance:!1,hideElements:[],maxHistorySteps:20,panZoom:!0,planRotation:0,preserveViewbox:"center-center",roomStampSize:null,selectElements:!1,selectAllowList:["interior","group","polyfloor"],showFloorPlan:!1,showSpaceDividers:!1,showCeilingLamps:!1,showFloorTextures:!1,snapWallContours:!1,snapSpaces:!0,transformElements:!0,updateFloors:!1,xrayMode:!1,destroyOnDomRemove:!1,ui:{menu:!0,measure:!0,rotatePlan:!1,zoomExtents:!0,scale:!0,coordinates:!1},shortcuts:{measureConfirm:"Enter",measureCancel:"Escape",measureUndo:"Backspace"},spaceLabelMapping:{},theme:{background:{color:"#f3f5f8",showGrid:!1},wallContours:!1,showAssetTextures:!1,elements:{roomStamp:{showArea:!0,showUsage:!0}}},units:{system:"metric",digits:0,roomDimensions:"area"}};function s(t,e,i){this.name="JsonRpcError",this.message=t||"There was a problem. Please check your internet connection and try again.",this.stack=(new Error).stack,this.code=e,this.data=i}function a(t){return h.apply(this,arguments)}function h(){return(h=r((function*(t){if(t.status>=200&&t.status<400)return t;var e=yield t.text();try{var i=yield JSON.parse(e);return"string"==typeof i.error?Promise.reject(i.error):i.error&&void 0!==i.error.code?Promise.reject(new s(i.error.message,i.error.code,i.error.data)):Promise.reject(i)}catch(t){return Promise.reject(e)}}))).apply(this,arguments)}function l(t){return t.json()}function u(t){return fetch(t).then(a,(t=>{throw t})).then(l,(t=>{throw t})).catch((t=>Promise.reject(t)))}var p={scene:{read:function(t,e){return function(t,e,i){var r=new URL(o.api.spaceApiV2Url+t);i&&Object.keys(i).forEach((t=>r.searchParams.append(t,i[t])));var n={"Content-Type":"application/json"};o.api.sdkVersion&&(n["x-sdk-version"]=o.api.sdkVersion);var{publishableToken:s,authorization:h}=e;if(h)n.Authorization=h;else{if(!s)return Promise.reject("Either authorization or publishableToken must be provided in accessToken.");r.searchParams.append("pubtoken",s)}return fetch(r,{method:"GET",headers:n,body:JSON.stringify(i)}).then(a).then(l)}("/floor/".concat(t,"/scene-structure"),e)}},product:{read:function(t){return u(o.api.storageUrl+o.api.staticProductCache+"/"+t+".json")},outline:function(t){return u(o.api.storageUrl+o.api.staticProductOutline+"/"+t+".json")}}},c=e({},p),d={version:"6.4.2.2",use_lines:!0,use_xyz:!1},f=function(t,e){var i;if(void 0===Object.getOwnPropertyNames){for(i in e.prototype)void 0!==t.prototype[i]&&t.prototype[i]!==Object.prototype[i]||(t.prototype[i]=e.prototype[i]);for(i in e)void 0===t[i]&&(t[i]=e[i]);t.$baseCtor=e}else{for(var r=Object.getOwnPropertyNames(e.prototype),n=0;n<r.length;n++)void 0===Object.getOwnPropertyDescriptor(t.prototype,r[n])&&Object.defineProperty(t.prototype,r[n],Object.getOwnPropertyDescriptor(e.prototype,r[n]));for(i in e)void 0===t[i]&&(t[i]=e[i]);t.$baseCtor=e}};d.Path=function(){return[]},d.Path.prototype.push=Array.prototype.push,d.Paths=function(){return[]},d.Paths.prototype.push=Array.prototype.push,d.PolyNode=function(){this.m_Parent=null,this.m_polygon=new d.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},d.PolyNode.prototype.IsHoleNode=function(){for(var t=!0,e=this.m_Parent;null!==e;)t=!t,e=e.m_Parent;return t},d.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},d.PolyNode.prototype.Contour=function(){return this.m_polygon},d.PolyNode.prototype.AddChild=function(t){var e=this.m_Childs.length;this.m_Childs.push(t),t.m_Parent=this,t.m_Index=e},d.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},d.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},d.PolyNode.prototype.Childs=function(){return this.m_Childs},d.PolyNode.prototype.Parent=function(){return this.m_Parent},d.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},d.PolyTree=function(){this.m_AllPolys=[],d.PolyNode.call(this)},d.PolyTree.prototype.Clear=function(){for(var t=0,e=this.m_AllPolys.length;t<e;t++)this.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},d.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},d.PolyTree.prototype.Total=function(){var t=this.m_AllPolys.length;return t>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&t--,t},f(d.PolyTree,d.PolyNode),d.Clear=function(t){t.length=0},d.PI=3.141592653589793,d.PI2=6.283185307179586,d.FPoint=function(){var t=arguments,e=t.length;if(this.X=0,this.Y=0,d.use_xyz)if(this.Z=0,3===e)this.X=t[0],this.Y=t[1],this.Z=t[2];else if(2===e)this.X=t[0],this.Y=t[1],this.Z=0;else if(1===e)if(t[0]instanceof d.FPoint){var i=t[0];this.X=i.X,this.Y=i.Y,this.Z=0}else{void 0===(r=t[0]).Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z}else this.X=0,this.Y=0,this.Z=0;else if(2===e)this.X=t[0],this.Y=t[1];else if(1===e)if(t[0]instanceof d.FPoint){i=t[0];this.X=i.X,this.Y=i.Y}else{var r=t[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},d.FPoint.op_Equality=function(t,e){return t.X===e.X&&t.Y===e.Y},d.FPoint.op_Inequality=function(t,e){return t.X!==e.X||t.Y!==e.Y},d.FPoint0=function(){this.X=0,this.Y=0,d.use_xyz&&(this.Z=0)},d.FPoint0.prototype=d.FPoint.prototype,d.FPoint1=function(t){this.X=t.X,this.Y=t.Y,d.use_xyz&&(void 0===t.Z?this.Z=0:this.Z=t.Z)},d.FPoint1.prototype=d.FPoint.prototype,d.FPoint1dp=function(t){this.X=t.X,this.Y=t.Y,d.use_xyz&&(this.Z=0)},d.FPoint1dp.prototype=d.FPoint.prototype,d.FPoint2=function(t,e,i){this.X=t,this.Y=e,d.use_xyz&&(this.Z=void 0===i?0:i)},d.FPoint2.prototype=d.FPoint.prototype,d.FRect=function(){var t=arguments,e=t.length;if(4===e)this.left=t[0],this.top=t[1],this.right=t[2],this.bottom=t[3];else if(1===e){var i=t[0];this.left=i.left,this.top=i.top,this.right=i.right,this.bottom=i.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},d.FRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},d.FRect0.prototype=d.FRect.prototype,d.FRect1=function(t){this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom},d.FRect1.prototype=d.FRect.prototype,d.FRect4=function(t,e,i,r){this.left=t,this.top=e,this.right=i,this.bottom=r},d.FRect4.prototype=d.FRect.prototype,d.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},d.PolyType={ptSubject:0,ptClip:1},d.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},d.JoinType={jtSquare:0,jtRound:1,jtMiter:2},d.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},d.EdgeSide={esLeft:0,esRight:1},d.Direction={dRightToLeft:0,dLeftToRight:1},d.TEdge=function(){this.Bot=new d.FPoint0,this.Curr=new d.FPoint0,this.Top=new d.FPoint0,this.Delta=new d.FPoint0,this.Dx=0,this.PolyTyp=d.PolyType.ptSubject,this.Side=d.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},d.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new d.FPoint0},d.MyIntersectNodeSort=function(){},d.MyIntersectNodeSort.Compare=function(t,e){var i=e.Pt.Y-t.Pt.Y;return i>0?1:i<0?-1:0},d.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},d.Scanbeam=function(){this.Y=0,this.Next=null},d.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},d.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},d.OutPt=function(){this.Idx=0,this.Pt=new d.FPoint0,this.Next=null,this.Prev=null},d.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new d.FPoint0},d.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},d.ClipperBase.horizontal=-34e37,d.ClipperBase.Skip=-2,d.ClipperBase.Unassigned=-1,d.ClipperBase.tolerance=1e-20,d.ClipperBase.maxValue=Math.sqrt(Number.MAX_VALUE),d.ClipperBase.minValue=Math.sqrt(Number.MIN_VALUE),d.ClipperBase.near_zero=function(t){return t>-d.ClipperBase.tolerance&&t<d.ClipperBase.tolerance},d.ClipperBase.IsHorizontal=function(t){return 0===t.Delta.Y},d.ClipperBase.prototype.PointIsVertex=function(t,e){var i=e;do{if(d.FPoint.op_Equality(i.Pt,t))return!0;i=i.Next}while(i!==e);return!1},d.ClipperBase.prototype.PointOnLineSegment=function(t,e,i){return t.X===e.X&&t.Y===e.Y||t.X===i.X&&t.Y===i.Y||t.X>e.X==t.X<i.X&&t.Y>e.Y==t.Y<i.Y&&(t.X-e.X)*(i.Y-e.Y)==(i.X-e.X)*(t.Y-e.Y)},d.ClipperBase.prototype.PointOnPolygon=function(t,e){for(var i=e;;){if(this.PointOnLineSegment(t,i.Pt,i.Next.Pt))return!0;if((i=i.Next)===e)break}return!1},d.ClipperBase.prototype.SlopesEqual=d.ClipperBase.SlopesEqual=function(){var t,e,i,r,n,o,s=arguments,a=s.length;return 2===a?(t=s[0],e=s[1],t.Delta.Y*e.Delta.X==t.Delta.X*e.Delta.Y):3===a?(i=s[0],r=s[1],n=s[2],(i.Y-r.Y)*(r.X-n.X)-(i.X-r.X)*(r.Y-n.Y)==0):(i=s[0],r=s[1],n=s[2],o=s[3],(i.Y-r.Y)*(n.X-o.X)-(i.X-r.X)*(n.Y-o.Y)==0)},d.ClipperBase.SlopesEqual3=function(t,e){return t.Delta.Y*e.Delta.X==t.Delta.X*e.Delta.Y},d.ClipperBase.SlopesEqual4=function(t,e,i){return(t.Y-e.Y)*(e.X-i.X)-(t.X-e.X)*(e.Y-i.Y)==0},d.ClipperBase.SlopesEqual5=function(t,e,i,r){return(t.Y-e.Y)*(i.X-r.X)-(t.X-e.X)*(i.Y-r.Y)==0},d.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var t=0,e=this.m_edges.length;t<e;++t){for(var i=0,r=this.m_edges[t].length;i<r;++i)this.m_edges[t][i]=null;d.Clear(this.m_edges[t])}d.Clear(this.m_edges),this.m_HasOpenPaths=!1},d.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(var t=this;null!==this.m_MinimaList;){var e=t.m_MinimaList.Next;t.m_MinimaList=null,t.m_MinimaList=e}this.m_CurrentLM=null},d.ClipperBase.prototype.RangeTest=function(t){(t.X>d.ClipperBase.maxValue||t.X<-d.ClipperBase.maxValue||t.Y>d.ClipperBase.maxValue||t.Y<-d.ClipperBase.maxValue||t.X>0&&t.X<d.ClipperBase.minValue||t.Y>0&&t.Y<d.ClipperBase.minValue||t.X<0&&t.X>-d.ClipperBase.minValue||t.Y<0&&t.Y>-d.ClipperBase.minValue)&&d.Error("Coordinate outside allowed range in RangeTest().")},d.ClipperBase.prototype.InitEdge=function(t,e,i,r){t.Next=e,t.Prev=i,t.Curr.X=r.X,t.Curr.Y=r.Y,d.use_xyz&&(t.Curr.Z=r.Z),t.OutIdx=-1},d.ClipperBase.prototype.InitEdge2=function(t,e){t.Curr.Y>=t.Next.Curr.Y?(t.Bot.X=t.Curr.X,t.Bot.Y=t.Curr.Y,d.use_xyz&&(t.Bot.Z=t.Curr.Z),t.Top.X=t.Next.Curr.X,t.Top.Y=t.Next.Curr.Y,d.use_xyz&&(t.Top.Z=t.Next.Curr.Z)):(t.Top.X=t.Curr.X,t.Top.Y=t.Curr.Y,d.use_xyz&&(t.Top.Z=t.Curr.Z),t.Bot.X=t.Next.Curr.X,t.Bot.Y=t.Next.Curr.Y,d.use_xyz&&(t.Bot.Z=t.Next.Curr.Z)),this.SetDx(t),t.PolyTyp=e},d.ClipperBase.prototype.FindNextLocMin=function(t){for(var e;;){for(;d.FPoint.op_Inequality(t.Bot,t.Prev.Bot)||d.FPoint.op_Equality(t.Curr,t.Top);)t=t.Next;if(t.Dx!==d.ClipperBase.horizontal&&t.Prev.Dx!==d.ClipperBase.horizontal)break;for(;t.Prev.Dx===d.ClipperBase.horizontal;)t=t.Prev;for(e=t;t.Dx===d.ClipperBase.horizontal;)t=t.Next;if(t.Top.Y!==t.Prev.Bot.Y){e.Prev.Bot.X<t.Bot.X&&(t=e);break}}return t},d.ClipperBase.prototype.ProcessBound=function(t,e){var i,r,n=t;if(n.OutIdx===d.ClipperBase.Skip){if(t=n,e){for(;t.Top.Y===t.Next.Bot.Y;)t=t.Next;for(;t!==n&&t.Dx===d.ClipperBase.horizontal;)t=t.Prev}else{for(;t.Top.Y===t.Prev.Bot.Y;)t=t.Prev;for(;t!==n&&t.Dx===d.ClipperBase.horizontal;)t=t.Next}if(t===n)n=e?t.Next:t.Prev;else{t=e?n.Next:n.Prev;var o=new d.LocalMinima;o.Next=null,o.Y=t.Bot.Y,o.LeftBound=null,o.RightBound=t,t.WindDelta=0,n=this.ProcessBound(t,e),this.InsertLocalMinima(o)}return n}if(t.Dx===d.ClipperBase.horizontal&&((i=e?t.Prev:t.Next).Dx===d.ClipperBase.horizontal?i.Bot.X!==t.Bot.X&&i.Top.X!==t.Bot.X&&this.ReverseHorizontal(t):i.Bot.X!==t.Bot.X&&this.ReverseHorizontal(t)),i=t,e){for(;n.Top.Y===n.Next.Bot.Y&&n.Next.OutIdx!==d.ClipperBase.Skip;)n=n.Next;if(n.Dx===d.ClipperBase.horizontal&&n.Next.OutIdx!==d.ClipperBase.Skip){for(r=n;r.Prev.Dx===d.ClipperBase.horizontal;)r=r.Prev;r.Prev.Top.X>n.Next.Top.X&&(n=r.Prev)}for(;t!==n;)t.NextInLML=t.Next,t.Dx===d.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Prev.Top.X&&this.ReverseHorizontal(t),t=t.Next;t.Dx===d.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Prev.Top.X&&this.ReverseHorizontal(t),n=n.Next}else{for(;n.Top.Y===n.Prev.Bot.Y&&n.Prev.OutIdx!==d.ClipperBase.Skip;)n=n.Prev;if(n.Dx===d.ClipperBase.horizontal&&n.Prev.OutIdx!==d.ClipperBase.Skip){for(r=n;r.Next.Dx===d.ClipperBase.horizontal;)r=r.Next;(r.Next.Top.X===n.Prev.Top.X||r.Next.Top.X>n.Prev.Top.X)&&(n=r.Next)}for(;t!==n;)t.NextInLML=t.Prev,t.Dx===d.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Next.Top.X&&this.ReverseHorizontal(t),t=t.Prev;t.Dx===d.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Next.Top.X&&this.ReverseHorizontal(t),n=n.Prev}return n},d.ClipperBase.prototype.AddPath=function(t,e,i){var r=this;d.use_lines?i||e!==d.PolyType.ptClip||d.Error("AddPath: Open paths must be subject."):i||d.Error("AddPath: Open paths have been disabled.");var n=t.length-1;if(i)for(;n>0&&d.FPoint.op_Equality(t[n],t[0]);)--n;for(;n>0&&d.FPoint.op_Equality(t[n],t[n-1]);)--n;if(i&&n<2||!i&&n<1)return!1;for(var o=new Array,s=0;s<=n;s++)o.push(new d.TEdge);var a=!0;o[1].Curr.X=t[1].X,o[1].Curr.Y=t[1].Y,d.use_xyz&&(o[1].Curr.Z=t[1].Z),this.RangeTest(t[0]),this.RangeTest(t[n]),this.InitEdge(o[0],o[1],o[n],t[0]),this.InitEdge(o[n],o[0],o[n-1],t[n]);for(s=n-1;s>=1;--s)r.RangeTest(t[s]),r.InitEdge(o[s],o[s+1],o[s-1],t[s]);for(var h,l=o[0],u=l,p=l;;)if(u.Curr!==u.Next.Curr||!i&&u.Next===l){if(u.Prev===u.Next)break;if(!i||!d.ClipperBase.SlopesEqual4(u.Prev.Curr,u.Curr,u.Next.Curr)||r.PreserveCollinear&&r.Pt2IsBetweenPt1AndPt3(u.Prev.Curr,u.Curr,u.Next.Curr)){if((u=u.Next)===p||!i&&u.Next===l)break}else u===l&&(l=u.Next),p=u=(u=r.RemoveEdge(u)).Prev}else{if(u===u.Next)break;u===l&&(l=u.Next),p=u=r.RemoveEdge(u)}if(!i&&u===u.Next||i&&u.Prev===u.Next)return!1;i||(this.m_HasOpenPaths=!0,l.Prev.OutIdx=d.ClipperBase.Skip),u=l;do{r.InitEdge2(u,e),u=u.Next,a&&u.Curr.Y!==l.Curr.Y&&(a=!1)}while(u!==l);if(a){if(i)return!1;for(u.Prev.OutIdx=d.ClipperBase.Skip,(f=new d.LocalMinima).Next=null,f.Y=u.Bot.Y,f.LeftBound=null,f.RightBound=u,f.RightBound.Side=d.EdgeSide.esRight,f.RightBound.WindDelta=0;u.Bot.X!==u.Prev.Top.X&&r.ReverseHorizontal(u),u.Next.OutIdx!==d.ClipperBase.Skip;)u.NextInLML=u.Next,u=u.Next;return this.InsertLocalMinima(f),this.m_edges.push(o),!0}this.m_edges.push(o);var c=null;for(d.FPoint.op_Equality(u.Prev.Bot,u.Prev.Top)&&(u=u.Next);(u=r.FindNextLocMin(u))!==c;){var f;null===c&&(c=u),(f=new d.LocalMinima).Next=null,f.Y=u.Bot.Y,u.Dx<u.Prev.Dx?(f.LeftBound=u.Prev,f.RightBound=u,h=!1):(f.LeftBound=u,f.RightBound=u.Prev,h=!0),f.LeftBound.Side=d.EdgeSide.esLeft,f.RightBound.Side=d.EdgeSide.esRight,i?f.LeftBound.Next===f.RightBound?f.LeftBound.WindDelta=-1:f.LeftBound.WindDelta=1:f.LeftBound.WindDelta=0,f.RightBound.WindDelta=-f.LeftBound.WindDelta,(u=r.ProcessBound(f.LeftBound,h)).OutIdx===d.ClipperBase.Skip&&(u=r.ProcessBound(u,h));var v=r.ProcessBound(f.RightBound,!h);v.OutIdx===d.ClipperBase.Skip&&(v=r.ProcessBound(v,!h)),f.LeftBound.OutIdx===d.ClipperBase.Skip?f.LeftBound=null:f.RightBound.OutIdx===d.ClipperBase.Skip&&(f.RightBound=null),r.InsertLocalMinima(f),h||(u=v)}return!0},d.ClipperBase.prototype.AddPaths=function(t,e,i){for(var r=!1,n=0,o=t.length;n<o;++n)this.AddPath(t[n],e,i)&&(r=!0);return r},d.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(t,e,i){return!(d.FPoint.op_Equality(t,i)||d.FPoint.op_Equality(t,e)||d.FPoint.op_Equality(i,e))&&(t.X!==i.X?e.X>t.X==e.X<i.X:e.Y>t.Y==e.Y<i.Y)},d.ClipperBase.prototype.RemoveEdge=function(t){t.Prev.Next=t.Next,t.Next.Prev=t.Prev;var e=t.Next;return t.Prev=null,e},d.ClipperBase.prototype.SetDx=function(t){t.Delta.X=t.Top.X-t.Bot.X,t.Delta.Y=t.Top.Y-t.Bot.Y,0===t.Delta.Y?t.Dx=d.ClipperBase.horizontal:t.Dx=t.Delta.X/t.Delta.Y},d.ClipperBase.prototype.InsertLocalMinima=function(t){if(null===this.m_MinimaList)this.m_MinimaList=t;else if(t.Y>=this.m_MinimaList.Y)t.Next=this.m_MinimaList,this.m_MinimaList=t;else{for(var e=this.m_MinimaList;null!==e.Next&&t.Y<e.Next.Y;)e=e.Next;t.Next=e.Next,e.Next=t}},d.ClipperBase.prototype.PopLocalMinima=function(t,e){return e.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===t&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)},d.ClipperBase.prototype.ReverseHorizontal=function(t){var e=t.Top.X;t.Top.X=t.Bot.X,t.Bot.X=e,d.use_xyz&&(e=t.Top.Z,t.Top.Z=t.Bot.Z,t.Bot.Z=e)},d.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var t=this.m_MinimaList;null!==t;){this.InsertScanbeam(t.Y);var e=t.LeftBound;null!==e&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,d.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=d.ClipperBase.Unassigned),null!==(e=t.RightBound)&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,d.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=d.ClipperBase.Unassigned),t=t.Next}this.m_ActiveEdges=null}},d.ClipperBase.prototype.InsertScanbeam=function(t){if(null===this.m_Scanbeam)this.m_Scanbeam=new d.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=t;else if(t>this.m_Scanbeam.Y){var e=new d.Scanbeam;e.Y=t,e.Next=this.m_Scanbeam,this.m_Scanbeam=e}else{for(var i=this.m_Scanbeam;null!==i.Next&&t<=i.Next.Y;)i=i.Next;if(t===i.Y)return;var r=new d.Scanbeam;r.Y=t,r.Next=i.Next,i.Next=r}},d.ClipperBase.prototype.PopScanbeam=function(t){return null===this.m_Scanbeam?(t.v=0,!1):(t.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},d.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},d.ClipperBase.prototype.CreateOutRec=function(){var t=new d.OutRec;return t.Idx=d.ClipperBase.Unassigned,t.IsHole=!1,t.IsOpen=!1,t.FirstLeft=null,t.Pts=null,t.BottomPt=null,t.PolyNode=null,this.m_PolyOuts.push(t),t.Idx=this.m_PolyOuts.length-1,t},d.ClipperBase.prototype.DisposeOutRec=function(t){var e=this.m_PolyOuts[t];e.Pts=null,e=null,this.m_PolyOuts[t]=null},d.ClipperBase.prototype.UpdateEdgeIntoAEL=function(t){null===t.NextInLML&&d.Error("UpdateEdgeIntoAEL: invalid call");var e=t.PrevInAEL,i=t.NextInAEL;return t.NextInLML.OutIdx=t.OutIdx,null!==e?e.NextInAEL=t.NextInLML:this.m_ActiveEdges=t.NextInLML,null!==i&&(i.PrevInAEL=t.NextInLML),t.NextInLML.Side=t.Side,t.NextInLML.WindDelta=t.WindDelta,t.NextInLML.WindCnt=t.WindCnt,t.NextInLML.WindCnt2=t.WindCnt2,(t=t.NextInLML).Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,t.PrevInAEL=e,t.NextInAEL=i,d.ClipperBase.IsHorizontal(t)||this.InsertScanbeam(t.Top.Y),t},d.ClipperBase.prototype.SwapPositionsInAEL=function(t,e){if(t.NextInAEL!==t.PrevInAEL&&e.NextInAEL!==e.PrevInAEL){if(t.NextInAEL===e){var i=e.NextInAEL;null!==i&&(i.PrevInAEL=t);var r=t.PrevInAEL;null!==r&&(r.NextInAEL=e),e.PrevInAEL=r,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=i}else if(e.NextInAEL===t){var n=t.NextInAEL;null!==n&&(n.PrevInAEL=e);var o=e.PrevInAEL;null!==o&&(o.NextInAEL=t),t.PrevInAEL=o,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=n}else{var s=t.NextInAEL,a=t.PrevInAEL;t.NextInAEL=e.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=e.PrevInAEL,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t),e.NextInAEL=s,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=a,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e)}null===t.PrevInAEL?this.m_ActiveEdges=t:null===e.PrevInAEL&&(this.m_ActiveEdges=e)}},d.ClipperBase.prototype.DeleteFromAEL=function(t){var e=t.PrevInAEL,i=t.NextInAEL;null===e&&null===i&&t!==this.m_ActiveEdges||(null!==e?e.NextInAEL=i:this.m_ActiveEdges=i,null!==i&&(i.PrevInAEL=e),t.NextInAEL=null,t.PrevInAEL=null)},d.Clipper=function(t){void 0===t&&(t=0),this.m_PolyOuts=null,this.m_ClipType=d.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=d.PolyFillType.pftEvenOdd,this.m_SubjFillType=d.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,d.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=d.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=0!=(1&t),this.StrictlySimple=0!=(2&t),this.PreserveCollinear=0!=(4&t),d.use_xyz&&(this.ZFillFunction=null)},d.Clipper.ioReverseSolution=1,d.Clipper.ioStrictlySimple=2,d.Clipper.ioPreserveCollinear=4,d.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),d.ClipperBase.prototype.Clear.call(this))},d.Clipper.prototype.InsertMaxima=function(t){var e=new d.Maxima;if(e.X=t,null===this.m_Maxima)this.m_Maxima=e,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(t<this.m_Maxima.X)e.Next=this.m_Maxima,e.Prev=null,this.m_Maxima=e;else{for(var i=this.m_Maxima;null!==i.Next&&t>=i.Next.X;)i=i.Next;if(t===i.X)return;e.Next=i.Next,e.Prev=i,null!==i.Next&&(i.Next.Prev=e),i.Next=e}},d.Clipper.prototype.Execute=function(){var t=arguments,e=t.length,i=t[1]instanceof d.PolyTree;if(4===e&&!i){var r=t[0],n=t[1],o=t[2],s=t[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&d.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,d.Clear(n),this.m_SubjFillType=o,this.m_ClipFillType=s,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{(h=this.ExecuteInternal())&&this.BuildResult(n)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}if(4===e&&i){r=t[0];var a=t[1];o=t[2],s=t[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=o,this.m_ClipFillType=s,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var h;(h=this.ExecuteInternal())&&this.BuildResult2(a)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}if(2===e&&!i){r=t[0],n=t[1];return this.Execute(r,n,d.PolyFillType.pftEvenOdd,d.PolyFillType.pftEvenOdd)}if(2===e&&i){r=t[0],a=t[1];return this.Execute(r,a,d.PolyFillType.pftEvenOdd,d.PolyFillType.pftEvenOdd)}},d.Clipper.prototype.FixHoleLinkage=function(t){if(null!==t.FirstLeft&&(t.IsHole===t.FirstLeft.IsHole||null===t.FirstLeft.Pts)){for(var e=t.FirstLeft;null!==e&&(e.IsHole===t.IsHole||null===e.Pts);)e=e.FirstLeft;t.FirstLeft=e}},d.Clipper.prototype.ExecuteInternal=function(){var t=this;try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,i,r,n={},o={};if(!this.PopScanbeam(n))return!1;for(this.InsertLocalMinimaIntoAEL(n.v);this.PopScanbeam(o)||this.LocalMinimaPending();){if(t.ProcessHorizontals(),t.m_GhostJoins.length=0,!t.ProcessIntersections(o.v))return!1;t.ProcessEdgesAtTopOfScanbeam(o.v),n.v=o.v,t.InsertLocalMinimaIntoAEL(n.v)}for(i=0,r=this.m_PolyOuts.length;i<r;i++)null===(e=t.m_PolyOuts[i]).Pts||e.IsOpen||(e.IsHole^t.ReverseSolution)==t.Area$1(e)>0&&t.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),i=0,r=this.m_PolyOuts.length;i<r;i++)null!==(e=t.m_PolyOuts[i]).Pts&&(e.IsOpen?t.FixupOutPolyline(e):t.FixupOutPolygon(e));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},d.Clipper.prototype.DisposeAllPolyPts=function(){for(var t=0,e=this.m_PolyOuts.length;t<e;++t)this.DisposeOutRec(t);d.Clear(this.m_PolyOuts)},d.Clipper.prototype.AddJoin=function(t,e,i){var r=new d.Join;r.OutPt1=t,r.OutPt2=e,r.OffPt.X=i.X,r.OffPt.Y=i.Y,d.use_xyz&&(r.OffPt.Z=i.Z),this.m_Joins.push(r)},d.Clipper.prototype.AddGhostJoin=function(t,e){var i=new d.Join;i.OutPt1=t,i.OffPt.X=e.X,i.OffPt.Y=e.Y,d.use_xyz&&(i.OffPt.Z=e.Z),this.m_GhostJoins.push(i)},d.Clipper.prototype.SetZ=function(t,e,i){if(null!==this.ZFillFunction){if(0!==t.Z||null===this.ZFillFunction)return;d.FPoint.op_Equality(t,e.Bot)?t.Z=e.Bot.Z:d.FPoint.op_Equality(t,e.Top)?t.Z=e.Top.Z:d.FPoint.op_Equality(t,i.Bot)?t.Z=i.Bot.Z:d.FPoint.op_Equality(t,i.Top)?t.Z=i.Top.Z:this.ZFillFunction(e.Bot,e.Top,i.Bot,i.Top,t)}},d.Clipper.prototype.InsertLocalMinimaIntoAEL=function(t){for(var e,i,r=this,n={};this.PopLocalMinima(t,n);){e=n.v.LeftBound,i=n.v.RightBound;var o=null;if(null===e?(r.InsertEdgeIntoAEL(i,null),r.SetWindingCount(i),r.IsContributing(i)&&(o=r.AddOutPt(i,i.Bot))):null===i?(r.InsertEdgeIntoAEL(e,null),r.SetWindingCount(e),r.IsContributing(e)&&(o=r.AddOutPt(e,e.Bot)),r.InsertScanbeam(e.Top.Y)):(r.InsertEdgeIntoAEL(e,null),r.InsertEdgeIntoAEL(i,e),r.SetWindingCount(e),i.WindCnt=e.WindCnt,i.WindCnt2=e.WindCnt2,r.IsContributing(e)&&(o=r.AddLocalMinPoly(e,i,e.Bot)),r.InsertScanbeam(e.Top.Y)),null!==i&&(d.ClipperBase.IsHorizontal(i)?(null!==i.NextInLML&&r.InsertScanbeam(i.NextInLML.Top.Y),r.AddEdgeToSEL(i)):r.InsertScanbeam(i.Top.Y)),null!==e&&null!==i){if(null!==o&&d.ClipperBase.IsHorizontal(i)&&r.m_GhostJoins.length>0&&0!==i.WindDelta)for(var s=0,a=this.m_GhostJoins.length;s<a;s++){var h=r.m_GhostJoins[s];r.HorzSegmentsOverlap(h.OutPt1.Pt.X,h.OffPt.X,i.Bot.X,i.Top.X)&&r.AddJoin(h.OutPt1,o,h.OffPt)}if(e.OutIdx>=0&&null!==e.PrevInAEL&&e.PrevInAEL.Curr.X===e.Bot.X&&e.PrevInAEL.OutIdx>=0&&d.ClipperBase.SlopesEqual5(e.PrevInAEL.Curr,e.PrevInAEL.Top,e.Curr,e.Top)&&0!==e.WindDelta&&0!==e.PrevInAEL.WindDelta){var l=r.AddOutPt(e.PrevInAEL,e.Bot);r.AddJoin(o,l,e.Top)}if(e.NextInAEL!==i){if(i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&d.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta){l=r.AddOutPt(i.PrevInAEL,i.Bot);r.AddJoin(o,l,i.Top)}var u=e.NextInAEL;if(null!==u)for(;u!==i;)r.IntersectEdges(i,u,e.Curr),u=u.NextInAEL}}}},d.Clipper.prototype.InsertEdgeIntoAEL=function(t,e){if(null===this.m_ActiveEdges)t.PrevInAEL=null,t.NextInAEL=null,this.m_ActiveEdges=t;else if(null===e&&this.E2InsertsBeforeE1(this.m_ActiveEdges,t))t.PrevInAEL=null,t.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=t,this.m_ActiveEdges=t;else{for(null===e&&(e=this.m_ActiveEdges);null!==e.NextInAEL&&!this.E2InsertsBeforeE1(e.NextInAEL,t);)e=e.NextInAEL;t.NextInAEL=e.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=t),t.PrevInAEL=e,e.NextInAEL=t}},d.Clipper.prototype.E2InsertsBeforeE1=function(t,e){return e.Curr.X===t.Curr.X?e.Top.Y>t.Top.Y?e.Top.X<d.Clipper.TopX(t,e.Top.Y):t.Top.X>d.Clipper.TopX(e,t.Top.Y):e.Curr.X<t.Curr.X},d.Clipper.prototype.IsEvenOddFillType=function(t){return t.PolyTyp===d.PolyType.ptSubject?this.m_SubjFillType===d.PolyFillType.pftEvenOdd:this.m_ClipFillType===d.PolyFillType.pftEvenOdd},d.Clipper.prototype.IsEvenOddAltFillType=function(t){return t.PolyTyp===d.PolyType.ptSubject?this.m_ClipFillType===d.PolyFillType.pftEvenOdd:this.m_SubjFillType===d.PolyFillType.pftEvenOdd},d.Clipper.prototype.IsContributing=function(t){var e,i;switch(t.PolyTyp===d.PolyType.ptSubject?(e=this.m_SubjFillType,i=this.m_ClipFillType):(e=this.m_ClipFillType,i=this.m_SubjFillType),e){case d.PolyFillType.pftEvenOdd:if(0===t.WindDelta&&1!==t.WindCnt)return!1;break;case d.PolyFillType.pftNonZero:if(1!==Math.abs(t.WindCnt))return!1;break;case d.PolyFillType.pftPositive:if(1!==t.WindCnt)return!1;break;default:if(-1!==t.WindCnt)return!1}switch(this.m_ClipType){case d.ClipType.ctIntersection:switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0!==t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case d.ClipType.ctUnion:switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0===t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}case d.ClipType.ctDifference:if(t.PolyTyp===d.PolyType.ptSubject)switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0===t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0!==t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case d.ClipType.ctXor:if(0!==t.WindDelta)return!0;switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0===t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}}return!0},d.Clipper.prototype.SetWindingCount=function(t){for(var e=t.PrevInAEL;null!==e&&(e.PolyTyp!==t.PolyTyp||0===e.WindDelta);)e=e.PrevInAEL;if(null===e){var i=t.PolyTyp===d.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===t.WindDelta?t.WindCnt=i===d.PolyFillType.pftNegative?-1:1:t.WindCnt=t.WindDelta,t.WindCnt2=0,e=this.m_ActiveEdges}else if(0===t.WindDelta&&this.m_ClipType!==d.ClipType.ctUnion)t.WindCnt=1,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(t)){if(0===t.WindDelta){for(var r=!0,n=e.PrevInAEL;null!==n;)n.PolyTyp===e.PolyTyp&&0!==n.WindDelta&&(r=!r),n=n.PrevInAEL;t.WindCnt=r?0:1}else t.WindCnt=t.WindDelta;t.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta:t.WindCnt=0===t.WindDelta?1:t.WindDelta:0===t.WindDelta?t.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(t))for(;e!==t;)0!==e.WindDelta&&(t.WindCnt2=0===t.WindCnt2?1:0),e=e.NextInAEL;else for(;e!==t;)t.WindCnt2+=e.WindDelta,e=e.NextInAEL},d.Clipper.prototype.AddEdgeToSEL=function(t){null===this.m_SortedEdges?(this.m_SortedEdges=t,t.PrevInSEL=null,t.NextInSEL=null):(t.NextInSEL=this.m_SortedEdges,t.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=t,this.m_SortedEdges=t)},d.Clipper.prototype.PopEdgeFromSEL=function(t){if(t.v=this.m_SortedEdges,null===t.v)return!1;var e=t.v;return this.m_SortedEdges=t.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),e.NextInSEL=null,e.PrevInSEL=null,!0},d.Clipper.prototype.CopyAELToSEL=function(){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t=t.NextInAEL},d.Clipper.prototype.SwapPositionsInSEL=function(t,e){if(!(null===t.NextInSEL&&null===t.PrevInSEL||null===e.NextInSEL&&null===e.PrevInSEL)){if(t.NextInSEL===e)null!==(i=e.NextInSEL)&&(i.PrevInSEL=t),null!==(r=t.PrevInSEL)&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i;else if(e.NextInSEL===t){null!==(i=t.NextInSEL)&&(i.PrevInSEL=e),null!==(r=e.PrevInSEL)&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else{var i=t.NextInSEL,r=t.PrevInSEL;t.NextInSEL=e.NextInSEL,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=e.PrevInSEL,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t),e.NextInSEL=i,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=r,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e)}null===t.PrevInSEL?this.m_SortedEdges=t:null===e.PrevInSEL&&(this.m_SortedEdges=e)}},d.Clipper.prototype.AddLocalMaxPoly=function(t,e,i){this.AddOutPt(t,i),0===e.WindDelta&&this.AddOutPt(e,i),t.OutIdx===e.OutIdx?(t.OutIdx=-1,e.OutIdx=-1):t.OutIdx<e.OutIdx?this.AppendPolygon(t,e):this.AppendPolygon(e,t)},d.Clipper.prototype.AddLocalMinPoly=function(t,e,i){var r,n,o;if(d.ClipperBase.IsHorizontal(e)||t.Dx>e.Dx?(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,t.Side=d.EdgeSide.esLeft,e.Side=d.EdgeSide.esRight,o=(n=t).PrevInAEL===e?e.PrevInAEL:n.PrevInAEL):(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,t.Side=d.EdgeSide.esRight,e.Side=d.EdgeSide.esLeft,o=(n=e).PrevInAEL===t?t.PrevInAEL:n.PrevInAEL),null!==o&&o.OutIdx>=0&&o.Top.Y<i.Y&&n.Top.Y<i.Y){var s=d.Clipper.TopX(o,i.Y),a=d.Clipper.TopX(n,i.Y);if(s===a&&0!==n.WindDelta&&0!==o.WindDelta&&d.ClipperBase.SlopesEqual5(new d.FPoint2(s,i.Y),o.Top,new d.FPoint2(a,i.Y),n.Top)){var h=this.AddOutPt(o,i);this.AddJoin(r,h,n.Top)}}return r},d.Clipper.prototype.AddOutPt=function(t,e){if(t.OutIdx<0){(r=this.CreateOutRec()).IsOpen=0===t.WindDelta;var i=new d.OutPt;return r.Pts=i,i.Idx=r.Idx,i.Pt.X=e.X,i.Pt.Y=e.Y,d.use_xyz&&(i.Pt.Z=e.Z),i.Next=i,i.Prev=i,r.IsOpen||this.SetHoleState(t,r),t.OutIdx=r.Idx,i}var r,n=(r=this.m_PolyOuts[t.OutIdx]).Pts,o=t.Side===d.EdgeSide.esLeft;return o&&d.FPoint.op_Equality(e,n.Pt)?n:!o&&d.FPoint.op_Equality(e,n.Prev.Pt)?n.Prev:((i=new d.OutPt).Idx=r.Idx,i.Pt.X=e.X,i.Pt.Y=e.Y,d.use_xyz&&(i.Pt.Z=e.Z),i.Next=n,i.Prev=n.Prev,i.Prev.Next=i,n.Prev=i,o&&(r.Pts=i),i)},d.Clipper.prototype.GetLastOutPt=function(t){var e=this.m_PolyOuts[t.OutIdx];return t.Side===d.EdgeSide.esLeft?e.Pts:e.Pts.Prev},d.Clipper.prototype.SwapPoints=function(t,e){var i=new d.FPoint1(t.Value);t.Value.X=e.Value.X,t.Value.Y=e.Value.Y,d.use_xyz&&(t.Value.Z=e.Value.Z),e.Value.X=i.X,e.Value.Y=i.Y,d.use_xyz&&(e.Value.Z=i.Z)},d.Clipper.prototype.HorzSegmentsOverlap=function(t,e,i,r){var n;return t>e&&(n=t,t=e,e=n),i>r&&(n=i,i=r,r=n),t<r&&i<e},d.Clipper.prototype.SetHoleState=function(t,e){for(var i=t.PrevInAEL,r=null;null!==i;)i.OutIdx>=0&&0!==i.WindDelta&&(null===r?r=i:r.OutIdx===i.OutIdx&&(r=null)),i=i.PrevInAEL;null===r?(e.FirstLeft=null,e.IsHole=!1):(e.FirstLeft=this.m_PolyOuts[r.OutIdx],e.IsHole=!e.FirstLeft.IsHole)},d.Clipper.prototype.GetDx=function(t,e){return t.Y===e.Y?d.ClipperBase.horizontal:(e.X-t.X)/(e.Y-t.Y)},d.Clipper.prototype.FirstIsBottomPt=function(t,e){for(var i=t.Prev;d.FPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Prev;var r=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;d.FPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Next;var n=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=e.Prev;d.FPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var o=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;d.FPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var s=Math.abs(this.GetDx(e.Pt,i.Pt));return Math.max(r,n)===Math.max(o,s)&&Math.min(r,n)===Math.min(o,s)?this.Area(t)>0:r>=o&&r>=s||n>=o&&n>=s},d.Clipper.prototype.GetBottomPt=function(t){for(var e=null,i=t.Next;i!==t;)i.Pt.Y>t.Pt.Y?(t=i,e=null):i.Pt.Y===t.Pt.Y&&i.Pt.X<=t.Pt.X&&(i.Pt.X<t.Pt.X?(e=null,t=i):i.Next!==t&&i.Prev!==t&&(e=i)),i=i.Next;if(null!==e)for(;e!==i;)for(this.FirstIsBottomPt(i,e)||(t=e),e=e.Next;d.FPoint.op_Inequality(e.Pt,t.Pt);)e=e.Next;return t},d.Clipper.prototype.GetLowermostRec=function(t,e){null===t.BottomPt&&(t.BottomPt=this.GetBottomPt(t.Pts)),null===e.BottomPt&&(e.BottomPt=this.GetBottomPt(e.Pts));var i=t.BottomPt,r=e.BottomPt;return i.Pt.Y>r.Pt.Y?t:i.Pt.Y<r.Pt.Y?e:i.Pt.X<r.Pt.X?t:i.Pt.X>r.Pt.X||i.Next===i?e:r.Next===r||this.FirstIsBottomPt(i,r)?t:e},d.Clipper.prototype.OutRec1RightOfOutRec2=function(t,e){do{if((t=t.FirstLeft)===e)return!0}while(null!==t);return!1},d.Clipper.prototype.GetOutRec=function(t){for(var e=this.m_PolyOuts[t];e!==this.m_PolyOuts[e.Idx];)e=this.m_PolyOuts[e.Idx];return e},d.Clipper.prototype.AppendPolygon=function(t,e){var i,r=this.m_PolyOuts[t.OutIdx],n=this.m_PolyOuts[e.OutIdx];i=this.OutRec1RightOfOutRec2(r,n)?n:this.OutRec1RightOfOutRec2(n,r)?r:this.GetLowermostRec(r,n);var o=r.Pts,s=o.Prev,a=n.Pts,h=a.Prev;t.Side===d.EdgeSide.esLeft?e.Side===d.EdgeSide.esLeft?(this.ReversePolyPtLinks(a),a.Next=o,o.Prev=a,s.Next=h,h.Prev=s,r.Pts=h):(h.Next=o,o.Prev=h,a.Prev=s,s.Next=a,r.Pts=a):e.Side===d.EdgeSide.esRight?(this.ReversePolyPtLinks(a),s.Next=h,h.Prev=s,a.Next=o,o.Prev=a):(s.Next=a,a.Prev=s,o.Prev=h,h.Next=o),r.BottomPt=null,i===n&&(n.FirstLeft!==r&&(r.FirstLeft=n.FirstLeft),r.IsHole=n.IsHole),n.Pts=null,n.BottomPt=null,n.FirstLeft=r;var l=t.OutIdx,u=e.OutIdx;t.OutIdx=-1,e.OutIdx=-1;for(var p=this.m_ActiveEdges;null!==p;){if(p.OutIdx===u){p.OutIdx=l,p.Side=t.Side;break}p=p.NextInAEL}n.Idx=r.Idx},d.Clipper.prototype.ReversePolyPtLinks=function(t){if(null!==t){var e,i;e=t;do{i=e.Next,e.Next=e.Prev,e.Prev=i,e=i}while(e!==t)}},d.Clipper.SwapSides=function(t,e){var i=t.Side;t.Side=e.Side,e.Side=i},d.Clipper.SwapPolyIndexes=function(t,e){var i=t.OutIdx;t.OutIdx=e.OutIdx,e.OutIdx=i},d.Clipper.prototype.IntersectEdges=function(t,e,i){var r=t.OutIdx>=0,n=e.OutIdx>=0;if(d.use_xyz&&this.SetZ(i,t,e),!d.use_lines||0!==t.WindDelta&&0!==e.WindDelta){if(t.PolyTyp===e.PolyTyp)if(this.IsEvenOddFillType(t)){var o=t.WindCnt;t.WindCnt=e.WindCnt,e.WindCnt=o}else t.WindCnt+e.WindDelta===0?t.WindCnt=-t.WindCnt:t.WindCnt+=e.WindDelta,e.WindCnt-t.WindDelta==0?e.WindCnt=-e.WindCnt:e.WindCnt-=t.WindDelta;else this.IsEvenOddFillType(e)?t.WindCnt2=0===t.WindCnt2?1:0:t.WindCnt2+=e.WindDelta,this.IsEvenOddFillType(t)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2-=t.WindDelta;var s,a,h,l,u,p;switch(t.PolyTyp===d.PolyType.ptSubject?(s=this.m_SubjFillType,h=this.m_ClipFillType):(s=this.m_ClipFillType,h=this.m_SubjFillType),e.PolyTyp===d.PolyType.ptSubject?(a=this.m_SubjFillType,l=this.m_ClipFillType):(a=this.m_ClipFillType,l=this.m_SubjFillType),s){case d.PolyFillType.pftPositive:u=t.WindCnt;break;case d.PolyFillType.pftNegative:u=-t.WindCnt;break;default:u=Math.abs(t.WindCnt)}switch(a){case d.PolyFillType.pftPositive:p=e.WindCnt;break;case d.PolyFillType.pftNegative:p=-e.WindCnt;break;default:p=Math.abs(e.WindCnt)}if(r&&n)0!==u&&1!==u||0!==p&&1!==p||t.PolyTyp!==e.PolyTyp&&this.m_ClipType!==d.ClipType.ctXor?this.AddLocalMaxPoly(t,e,i):(this.AddOutPt(t,i),this.AddOutPt(e,i),d.Clipper.SwapSides(t,e),d.Clipper.SwapPolyIndexes(t,e));else if(r)0!==p&&1!==p||(this.AddOutPt(t,i),d.Clipper.SwapSides(t,e),d.Clipper.SwapPolyIndexes(t,e));else if(n)0!==u&&1!==u||(this.AddOutPt(e,i),d.Clipper.SwapSides(t,e),d.Clipper.SwapPolyIndexes(t,e));else if(!(0!==u&&1!==u||0!==p&&1!==p)){var c,f;switch(h){case d.PolyFillType.pftPositive:c=t.WindCnt2;break;case d.PolyFillType.pftNegative:c=-t.WindCnt2;break;default:c=Math.abs(t.WindCnt2)}switch(l){case d.PolyFillType.pftPositive:f=e.WindCnt2;break;case d.PolyFillType.pftNegative:f=-e.WindCnt2;break;default:f=Math.abs(e.WindCnt2)}if(t.PolyTyp!==e.PolyTyp)this.AddLocalMinPoly(t,e,i);else if(1===u&&1===p)switch(this.m_ClipType){case d.ClipType.ctIntersection:c>0&&f>0&&this.AddLocalMinPoly(t,e,i);break;case d.ClipType.ctUnion:c<=0&&f<=0&&this.AddLocalMinPoly(t,e,i);break;case d.ClipType.ctDifference:(t.PolyTyp===d.PolyType.ptClip&&c>0&&f>0||t.PolyTyp===d.PolyType.ptSubject&&c<=0&&f<=0)&&this.AddLocalMinPoly(t,e,i);break;case d.ClipType.ctXor:this.AddLocalMinPoly(t,e,i)}else d.Clipper.SwapSides(t,e)}}else{if(0===t.WindDelta&&0===e.WindDelta)return;t.PolyTyp===e.PolyTyp&&t.WindDelta!==e.WindDelta&&this.m_ClipType===d.ClipType.ctUnion?0===t.WindDelta?n&&(this.AddOutPt(t,i),r&&(t.OutIdx=-1)):r&&(this.AddOutPt(e,i),n&&(e.OutIdx=-1)):t.PolyTyp!==e.PolyTyp&&(0!==t.WindDelta||1!==Math.abs(e.WindCnt)||this.m_ClipType===d.ClipType.ctUnion&&0!==e.WindCnt2?0!==e.WindDelta||1!==Math.abs(t.WindCnt)||this.m_ClipType===d.ClipType.ctUnion&&0!==t.WindCnt2||(this.AddOutPt(e,i),n&&(e.OutIdx=-1)):(this.AddOutPt(t,i),r&&(t.OutIdx=-1)))}},d.Clipper.prototype.DeleteFromSEL=function(t){var e=t.PrevInSEL,i=t.NextInSEL;null===e&&null===i&&t!==this.m_SortedEdges||(null!==e?e.NextInSEL=i:this.m_SortedEdges=i,null!==i&&(i.PrevInSEL=e),t.NextInSEL=null,t.PrevInSEL=null)},d.Clipper.prototype.ProcessHorizontals=function(){for(var t={};this.PopEdgeFromSEL(t);)this.ProcessHorizontal(t.v)},d.Clipper.prototype.GetHorzDirection=function(t,e){t.Bot.X<t.Top.X?(e.Left=t.Bot.X,e.Right=t.Top.X,e.Dir=d.Direction.dLeftToRight):(e.Left=t.Top.X,e.Right=t.Bot.X,e.Dir=d.Direction.dRightToLeft)},d.Clipper.prototype.ProcessHorizontal=function(t){var e=this,i={Dir:null,Left:null,Right:null};this.GetHorzDirection(t,i);for(var r=i.Dir,n=i.Left,o=i.Right,s=0===t.WindDelta,a=t,h=null;null!==a.NextInLML&&d.ClipperBase.IsHorizontal(a.NextInLML);)a=a.NextInLML;null===a.NextInLML&&(h=this.GetMaximaPair(a));var l=this.m_Maxima;if(null!==l)if(r===d.Direction.dLeftToRight){for(;null!==l&&l.X<=t.Bot.X;)l=l.Next;null!==l&&l.X>=a.Top.X&&(l=null)}else{for(;null!==l.Next&&l.Next.X<t.Bot.X;)l=l.Next;l.X<=a.Top.X&&(l=null)}for(var u=null;;){for(var p=t===a,c=e.GetNextInAEL(t,r);null!==c;){if(null!==l)if(r===d.Direction.dLeftToRight)for(;null!==l&&l.X<c.Curr.X;)t.OutIdx>=0&&!s&&e.AddOutPt(t,new d.FPoint2(l.X,t.Bot.Y)),l=l.Next;else for(;null!==l&&l.X>c.Curr.X;)t.OutIdx>=0&&!s&&e.AddOutPt(t,new d.FPoint2(l.X,t.Bot.Y)),l=l.Prev;if(r===d.Direction.dLeftToRight&&c.Curr.X>o||r===d.Direction.dRightToLeft&&c.Curr.X<n)break;if(c.Curr.X===t.Top.X&&null!==t.NextInLML&&c.Dx<t.NextInLML.Dx)break;if(t.OutIdx>=0&&!s){d.use_xyz&&(r===d.Direction.dLeftToRight?e.SetZ(c.Curr,t,c):e.SetZ(c.Curr,c,t)),u=e.AddOutPt(t,c.Curr);for(var f=e.m_SortedEdges;null!==f;){if(f.OutIdx>=0&&e.HorzSegmentsOverlap(t.Bot.X,t.Top.X,f.Bot.X,f.Top.X)){var v=e.GetLastOutPt(f);e.AddJoin(v,u,f.Top)}f=f.NextInSEL}e.AddGhostJoin(u,t.Bot)}if(c===h&&p)return t.OutIdx>=0&&e.AddLocalMaxPoly(t,h,t.Top),e.DeleteFromAEL(t),void e.DeleteFromAEL(h);if(r===d.Direction.dLeftToRight){var y=new d.FPoint2(c.Curr.X,t.Curr.Y);e.IntersectEdges(t,c,y)}else{y=new d.FPoint2(c.Curr.X,t.Curr.Y);e.IntersectEdges(c,t,y)}var g=e.GetNextInAEL(c,r);e.SwapPositionsInAEL(t,c),c=g}if(null===t.NextInLML||!d.ClipperBase.IsHorizontal(t.NextInLML))break;(t=e.UpdateEdgeIntoAEL(t)).OutIdx>=0&&e.AddOutPt(t,t.Bot),i={Dir:r,Left:n,Right:o},e.GetHorzDirection(t,i),r=i.Dir,n=i.Left,o=i.Right}if(t.OutIdx>=0&&null===u){u=this.GetLastOutPt(t);for(f=this.m_SortedEdges;null!==f;){if(f.OutIdx>=0&&e.HorzSegmentsOverlap(t.Bot.X,t.Top.X,f.Bot.X,f.Top.X)){v=e.GetLastOutPt(f);e.AddJoin(v,u,f.Top)}f=f.NextInSEL}this.AddGhostJoin(u,t.Top)}if(null!==t.NextInLML)if(t.OutIdx>=0){if(u=this.AddOutPt(t,t.Top),0===(t=this.UpdateEdgeIntoAEL(t)).WindDelta)return;var m=t.PrevInAEL;g=t.NextInAEL;if(null!==m&&m.Curr.X===t.Bot.X&&m.Curr.Y===t.Bot.Y&&0===m.WindDelta&&m.OutIdx>=0&&m.Curr.Y>m.Top.Y&&d.ClipperBase.SlopesEqual3(t,m)){v=this.AddOutPt(m,t.Bot);this.AddJoin(u,v,t.Top)}else if(null!==g&&g.Curr.X===t.Bot.X&&g.Curr.Y===t.Bot.Y&&0!==g.WindDelta&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&d.ClipperBase.SlopesEqual3(t,g)){v=this.AddOutPt(g,t.Bot);this.AddJoin(u,v,t.Top)}}else t=this.UpdateEdgeIntoAEL(t);else t.OutIdx>=0&&this.AddOutPt(t,t.Top),this.DeleteFromAEL(t)},d.Clipper.prototype.GetNextInAEL=function(t,e){return e===d.Direction.dLeftToRight?t.NextInAEL:t.PrevInAEL},d.Clipper.prototype.IsMinima=function(t){return null!==t&&t.Prev.NextInLML!==t&&t.Next.NextInLML!==t},d.Clipper.prototype.IsMaxima=function(t,e){return null!==t&&t.Top.Y===e&&null===t.NextInLML},d.Clipper.prototype.IsIntermediate=function(t,e){return t.Top.Y===e&&null!==t.NextInLML},d.Clipper.prototype.GetMaximaPair=function(t){return d.FPoint.op_Equality(t.Next.Top,t.Top)&&null===t.Next.NextInLML?t.Next:d.FPoint.op_Equality(t.Prev.Top,t.Top)&&null===t.Prev.NextInLML?t.Prev:null},d.Clipper.prototype.GetMaximaPairEx=function(t){var e=this.GetMaximaPair(t);return null===e||e.OutIdx===d.ClipperBase.Skip||e.NextInAEL===e.PrevInAEL&&!d.ClipperBase.IsHorizontal(e)?null:e},d.Clipper.prototype.ProcessIntersections=function(t){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(t),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(t){this.m_SortedEdges=null,this.m_IntersectList.length=0,d.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},d.Clipper.prototype.BuildIntersectList=function(t){var e=this;if(null!==this.m_ActiveEdges){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;null!==i;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=d.Clipper.TopX(i,t),i=i.NextInAEL;for(var r=!0;r&&null!==this.m_SortedEdges;){for(r=!1,i=e.m_SortedEdges;null!==i.NextInSEL;){var n=i.NextInSEL,o=new d.FPoint0;if(i.Curr.X>n.Curr.X){e.IntersectPoint(i,n,o),o.Y<t&&(o=new d.FPoint2(d.Clipper.TopX(i,t),t));var s=new d.IntersectNode;s.Edge1=i,s.Edge2=n,s.Pt.X=o.X,s.Pt.Y=o.Y,d.use_xyz&&(s.Pt.Z=o.Z),e.m_IntersectList.push(s),e.SwapPositionsInSEL(i,n),r=!0}else i=n}if(null===i.PrevInSEL)break;i.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},d.Clipper.prototype.EdgesAdjacent=function(t){return t.Edge1.NextInSEL===t.Edge2||t.Edge1.PrevInSEL===t.Edge2},d.Clipper.IntersectNodeSort=function(t,e){return e.Pt.Y-t.Pt.Y},d.Clipper.prototype.FixupIntersectionOrder=function(){var t=this;this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var e=this.m_IntersectList.length,i=0;i<e;i++){if(!t.EdgesAdjacent(t.m_IntersectList[i])){for(var r=i+1;r<e&&!this.EdgesAdjacent(this.m_IntersectList[r]);)r++;if(r===e)return!1;var n=t.m_IntersectList[i];t.m_IntersectList[i]=t.m_IntersectList[r],t.m_IntersectList[r]=n}t.SwapPositionsInSEL(t.m_IntersectList[i].Edge1,t.m_IntersectList[i].Edge2)}return!0},d.Clipper.prototype.ProcessIntersectList=function(){for(var t=this,e=0,i=this.m_IntersectList.length;e<i;e++){var r=t.m_IntersectList[e];t.IntersectEdges(r.Edge1,r.Edge2,r.Pt),t.SwapPositionsInAEL(r.Edge1,r.Edge2)}this.m_IntersectList.length=0},d.Clipper.TopX=function(t,e){return e===t.Top.Y?t.Top.X:t.Bot.X+t.Dx*(e-t.Bot.Y)},d.Clipper.prototype.IntersectPoint=function(t,e,i){var r,n;if(i.X=0,i.Y=0,t.Dx===e.Dx)return i.Y=t.Curr.Y,void(i.X=d.Clipper.TopX(t,i.Y));if(0===t.Delta.X)i.X=t.Bot.X,d.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(n=e.Bot.Y-e.Bot.X/e.Dx,i.Y=i.X/e.Dx+n);else if(0===e.Delta.X)i.X=e.Bot.X,d.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(r=t.Bot.Y-t.Bot.X/t.Dx,i.Y=i.X/t.Dx+r);else{r=t.Bot.X-t.Bot.Y*t.Dx;var o=((n=e.Bot.X-e.Bot.Y*e.Dx)-r)/(t.Dx-e.Dx);i.Y=o,Math.abs(t.Dx)<Math.abs(e.Dx)?i.X=t.Dx*o+r:i.X=e.Dx*o+n}if(i.Y<t.Top.Y||i.Y<e.Top.Y){if(t.Top.Y>e.Top.Y)return i.Y=t.Top.Y,i.X=d.Clipper.TopX(e,t.Top.Y),i.X<t.Top.X;i.Y=e.Top.Y,Math.abs(t.Dx)<Math.abs(e.Dx)?i.X=d.Clipper.TopX(t,i.Y):i.X=d.Clipper.TopX(e,i.Y)}i.Y>t.Curr.Y&&(i.Y=t.Curr.Y,Math.abs(t.Dx)>Math.abs(e.Dx)?i.X=d.Clipper.TopX(e,i.Y):i.X=d.Clipper.TopX(t,i.Y))},d.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(t){for(var e=this,i=this.m_ActiveEdges;null!==i;){var r=e.IsMaxima(i,t);if(r){var n=e.GetMaximaPairEx(i);r=null===n||!d.ClipperBase.IsHorizontal(n)}if(r){e.StrictlySimple&&e.InsertMaxima(i.Top.X);var o=i.PrevInAEL;e.DoMaxima(i),i=null===o?e.m_ActiveEdges:o.NextInAEL}else{if(e.IsIntermediate(i,t)&&d.ClipperBase.IsHorizontal(i.NextInLML)?((i=e.UpdateEdgeIntoAEL(i)).OutIdx>=0&&e.AddOutPt(i,i.Bot),e.AddEdgeToSEL(i)):(i.Curr.X=d.Clipper.TopX(i,t),i.Curr.Y=t),d.use_xyz&&(i.Top.Y===t?i.Curr.Z=i.Top.Z:i.Bot.Y===t?i.Curr.Z=i.Bot.Z:i.Curr.Z=0),e.StrictlySimple){o=i.PrevInAEL;if(i.OutIdx>=0&&0!==i.WindDelta&&null!==o&&o.OutIdx>=0&&o.Curr.X===i.Curr.X&&0!==o.WindDelta){var s=new d.FPoint1(i.Curr);d.use_xyz&&e.SetZ(s,o,i);var a=e.AddOutPt(o,s),h=e.AddOutPt(i,s);e.AddJoin(a,h,s)}}i=i.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,i=this.m_ActiveEdges;null!==i;){if(e.IsIntermediate(i,t)){a=null;i.OutIdx>=0&&(a=e.AddOutPt(i,i.Top));o=(i=e.UpdateEdgeIntoAEL(i)).PrevInAEL;var l=i.NextInAEL;if(null!==o&&o.Curr.X===i.Bot.X&&o.Curr.Y===i.Bot.Y&&null!==a&&o.OutIdx>=0&&o.Curr.Y===o.Top.Y&&d.ClipperBase.SlopesEqual5(i.Curr,i.Top,o.Curr,o.Top)&&0!==i.WindDelta&&0!==o.WindDelta){h=e.AddOutPt(ePrev2,i.Bot);e.AddJoin(a,h,i.Top)}else if(null!==l&&l.Curr.X===i.Bot.X&&l.Curr.Y===i.Bot.Y&&null!==a&&l.OutIdx>=0&&l.Curr.Y===l.Top.Y&&d.ClipperBase.SlopesEqual5(i.Curr,i.Top,l.Curr,l.Top)&&0!==i.WindDelta&&0!==l.WindDelta){h=e.AddOutPt(l,i.Bot);e.AddJoin(a,h,i.Top)}}i=i.NextInAEL}},d.Clipper.prototype.DoMaxima=function(t){var e=this.GetMaximaPairEx(t);if(null===e)return t.OutIdx>=0&&this.AddOutPt(t,t.Top),void this.DeleteFromAEL(t);for(var i=t.NextInAEL;null!==i&&i!==e;)this.IntersectEdges(t,i,t.Top),this.SwapPositionsInAEL(t,i),i=t.NextInAEL;-1===t.OutIdx&&-1===e.OutIdx?(this.DeleteFromAEL(t),this.DeleteFromAEL(e)):t.OutIdx>=0&&e.OutIdx>=0?(t.OutIdx>=0&&this.AddLocalMaxPoly(t,e,t.Top),this.DeleteFromAEL(t),this.DeleteFromAEL(e)):d.use_lines&&0===t.WindDelta?(t.OutIdx>=0&&(this.AddOutPt(t,t.Top),t.OutIdx=d.ClipperBase.Unassigned),this.DeleteFromAEL(t),e.OutIdx>=0&&(this.AddOutPt(e,t.Top),e.OutIdx=d.ClipperBase.Unassigned),this.DeleteFromAEL(e)):d.Error("DoMaxima error")},d.Clipper.ReversePaths=function(t){for(var e=0,i=t.length;e<i;e++)t[e].reverse()},d.Clipper.Orientation=function(t){return d.Clipper.Area(t)>=0},d.Clipper.prototype.PointCount=function(t){if(null===t)return 0;var e=0,i=t;do{e++,i=i.Next}while(i!==t);return e},d.Clipper.prototype.BuildResult=function(t){d.Clear(t);for(var e=0,i=this.m_PolyOuts.length;e<i;e++){var r=this.m_PolyOuts[e];if(null!==r.Pts){var n=r.Pts.Prev,o=this.PointCount(n);if(!(o<2)){for(var s=new Array(o),a=0;a<o;a++)s[a]=n.Pt,n=n.Prev;t.push(s)}}}},d.Clipper.prototype.BuildResult2=function(t){var e=this;t.Clear();for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var n=e.m_PolyOuts[i],o=e.PointCount(n.Pts);if(!(n.IsOpen&&o<2||!n.IsOpen&&o<3)){e.FixHoleLinkage(n);var s=new d.PolyNode;t.m_AllPolys.push(s),n.PolyNode=s,s.m_polygon.length=o;for(var a=n.Pts.Prev,h=0;h<o;h++)s.m_polygon[h]=a.Pt,a=a.Prev}}for(i=0,r=this.m_PolyOuts.length;i<r;i++){null!==(n=e.m_PolyOuts[i]).PolyNode&&(n.IsOpen?(n.PolyNode.IsOpen=!0,t.AddChild(n.PolyNode)):null!==n.FirstLeft&&null!==n.FirstLeft.PolyNode?n.FirstLeft.PolyNode.AddChild(n.PolyNode):t.AddChild(n.PolyNode))}},d.Clipper.prototype.FixupOutPolyline=function(t){for(var e=t.Pts,i=e.Prev;e!==i;)if(e=e.Next,d.FPoint.op_Equality(e.Pt,e.Prev.Pt)){e===i&&(i=e.Prev);var r=e.Prev;r.Next=e.Next,e.Next.Prev=r,e=r}e===e.Prev&&(t.Pts=null)},d.Clipper.prototype.FixupOutPolygon=function(t){var e=null;t.BottomPt=null;for(var i=t.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(i.Prev===i||i.Prev===i.Next)return void(t.Pts=null);if(d.FPoint.op_Equality(i.Pt,i.Next.Pt)||d.FPoint.op_Equality(i.Pt,i.Prev.Pt)||d.ClipperBase.SlopesEqual4(i.Prev.Pt,i.Pt,i.Next.Pt)&&(!r||!this.Pt2IsBetweenPt1AndPt3(i.Prev.Pt,i.Pt,i.Next.Pt)))e=null,i.Prev.Next=i.Next,i.Next.Prev=i.Prev,i=i.Prev;else{if(i===e)break;null===e&&(e=i),i=i.Next}}t.Pts=i},d.Clipper.prototype.DupOutPt=function(t,e){var i=new d.OutPt;return i.Pt.X=t.Pt.X,i.Pt.Y=t.Pt.Y,d.use_xyz&&(i.Pt.Z=t.Pt.Z),i.Idx=t.Idx,e?(i.Next=t.Next,i.Prev=t,t.Next.Prev=i,t.Next=i):(i.Prev=t.Prev,i.Next=t,t.Prev.Next=i,t.Prev=i),i},d.Clipper.prototype.GetOverlap=function(t,e,i,r,n){return t<e?i<r?(n.Left=Math.max(t,i),n.Right=Math.min(e,r)):(n.Left=Math.max(t,r),n.Right=Math.min(e,i)):i<r?(n.Left=Math.max(e,i),n.Right=Math.min(t,r)):(n.Left=Math.max(e,r),n.Right=Math.min(t,i)),n.Left<n.Right},d.Clipper.prototype.JoinHorz=function(t,e,i,r,n,o){var s=t.Pt.X>e.Pt.X?d.Direction.dRightToLeft:d.Direction.dLeftToRight,a=i.Pt.X>r.Pt.X?d.Direction.dRightToLeft:d.Direction.dLeftToRight;if(s===a)return!1;if(s===d.Direction.dLeftToRight){for(;t.Next.Pt.X<=n.X&&t.Next.Pt.X>=t.Pt.X&&t.Next.Pt.Y===n.Y;)t=t.Next;o&&t.Pt.X!==n.X&&(t=t.Next),e=this.DupOutPt(t,!o),d.FPoint.op_Inequality(e.Pt,n)&&((t=e).Pt.X=n.X,t.Pt.Y=n.Y,d.use_xyz&&(t.Pt.Z=n.Z),e=this.DupOutPt(t,!o))}else{for(;t.Next.Pt.X>=n.X&&t.Next.Pt.X<=t.Pt.X&&t.Next.Pt.Y===n.Y;)t=t.Next;o||t.Pt.X===n.X||(t=t.Next),e=this.DupOutPt(t,o),d.FPoint.op_Inequality(e.Pt,n)&&((t=e).Pt.X=n.X,t.Pt.Y=n.Y,d.use_xyz&&(t.Pt.Z=n.Z),e=this.DupOutPt(t,o))}if(a===d.Direction.dLeftToRight){for(;i.Next.Pt.X<=n.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===n.Y;)i=i.Next;o&&i.Pt.X!==n.X&&(i=i.Next),r=this.DupOutPt(i,!o),d.FPoint.op_Inequality(r.Pt,n)&&((i=r).Pt.X=n.X,i.Pt.Y=n.Y,d.use_xyz&&(i.Pt.Z=n.Z),r=this.DupOutPt(i,!o))}else{for(;i.Next.Pt.X>=n.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===n.Y;)i=i.Next;o||i.Pt.X===n.X||(i=i.Next),r=this.DupOutPt(i,o),d.FPoint.op_Inequality(r.Pt,n)&&((i=r).Pt.X=n.X,i.Pt.Y=n.Y,d.use_xyz&&(i.Pt.Z=n.Z),r=this.DupOutPt(i,o))}return s===d.Direction.dLeftToRight===o?(t.Prev=i,i.Next=t,e.Next=r,r.Prev=e):(t.Next=i,i.Prev=t,e.Prev=r,r.Next=e),!0},d.Clipper.prototype.JoinPoints=function(t,e,i){var r=t.OutPt1,n=new d.OutPt,o=t.OutPt2,s=new d.OutPt,a=t.OutPt1.Pt.Y===t.OffPt.Y;if(a&&d.FPoint.op_Equality(t.OffPt,t.OutPt1.Pt)&&d.FPoint.op_Equality(t.OffPt,t.OutPt2.Pt)){if(e!==i)return!1;for(n=t.OutPt1.Next;n!==r&&d.FPoint.op_Equality(n.Pt,t.OffPt);)n=n.Next;var h=n.Pt.Y>t.OffPt.Y;for(s=t.OutPt2.Next;s!==o&&d.FPoint.op_Equality(s.Pt,t.OffPt);)s=s.Next;return h!==s.Pt.Y>t.OffPt.Y&&(h?(n=this.DupOutPt(r,!1),s=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,n.Next=s,s.Prev=n,t.OutPt1=r,t.OutPt2=n,!0):(n=this.DupOutPt(r,!0),s=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,n.Prev=s,s.Next=n,t.OutPt1=r,t.OutPt2=n,!0))}if(a){for(n=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==n&&r.Prev!==o;)r=r.Prev;for(;n.Next.Pt.Y===n.Pt.Y&&n.Next!==r&&n.Next!==o;)n=n.Next;if(n.Next===r||n.Next===o)return!1;for(s=o;o.Prev.Pt.Y===o.Pt.Y&&o.Prev!==s&&o.Prev!==n;)o=o.Prev;for(;s.Next.Pt.Y===s.Pt.Y&&s.Next!==o&&s.Next!==r;)s=s.Next;if(s.Next===o||s.Next===r)return!1;var l={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,n.Pt.X,o.Pt.X,s.Pt.X,l))return!1;var u,p=l.Left,c=l.Right,f=new d.FPoint0;return r.Pt.X>=p&&r.Pt.X<=c?(f.X=r.Pt.X,f.Y=r.Pt.Y,d.use_xyz&&(f.Z=r.Pt.Z),u=r.Pt.X>n.Pt.X):o.Pt.X>=p&&o.Pt.X<=c?(f.X=o.Pt.X,f.Y=o.Pt.Y,d.use_xyz&&(f.Z=o.Pt.Z),u=o.Pt.X>s.Pt.X):n.Pt.X>=p&&n.Pt.X<=c?(f.X=n.Pt.X,f.Y=n.Pt.Y,d.use_xyz&&(f.Z=n.Pt.Z),u=n.Pt.X>r.Pt.X):(f.X=s.Pt.X,f.Y=s.Pt.Y,d.use_xyz&&(f.Z=s.Pt.Z),u=s.Pt.X>o.Pt.X),t.OutPt1=r,t.OutPt2=o,this.JoinHorz(r,n,o,s,f,u)}for(n=r.Next;d.FPoint.op_Equality(n.Pt,r.Pt)&&n!==r;)n=n.Next;var v=n.Pt.Y>r.Pt.Y||!d.ClipperBase.SlopesEqual4(r.Pt,n.Pt,t.OffPt);if(v){for(n=r.Prev;d.FPoint.op_Equality(n.Pt,r.Pt)&&n!==r;)n=n.Prev;if(n.Pt.Y>r.Pt.Y||!d.ClipperBase.SlopesEqual4(r.Pt,n.Pt,t.OffPt))return!1}for(s=o.Next;d.FPoint.op_Equality(s.Pt,o.Pt)&&s!==o;)s=s.Next;var y=s.Pt.Y>o.Pt.Y||!d.ClipperBase.SlopesEqual4(o.Pt,s.Pt,t.OffPt);if(y){for(s=o.Prev;d.FPoint.op_Equality(s.Pt,o.Pt)&&s!==o;)s=s.Prev;if(s.Pt.Y>o.Pt.Y||!d.ClipperBase.SlopesEqual4(o.Pt,s.Pt,t.OffPt))return!1}return n!==r&&s!==o&&n!==s&&(e!==i||v!==y)&&(v?(n=this.DupOutPt(r,!1),s=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,n.Next=s,s.Prev=n,t.OutPt1=r,t.OutPt2=n,!0):(n=this.DupOutPt(r,!0),s=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,n.Prev=s,s.Next=n,t.OutPt1=r,t.OutPt2=n,!0))},d.Clipper.GetBounds=function(t){for(var e=0,i=t.length;e<i&&0===t[e].length;)e++;if(e===i)return new d.FRect(0,0,0,0);var r=new d.FRect;for(r.left=t[e][0].X,r.right=r.left,r.top=t[e][0].Y,r.bottom=r.top;e<i;e++)for(var n=0,o=t[e].length;n<o;n++)t[e][n].X<r.left?r.left=t[e][n].X:t[e][n].X>r.right&&(r.right=t[e][n].X),t[e][n].Y<r.top?r.top=t[e][n].Y:t[e][n].Y>r.bottom&&(r.bottom=t[e][n].Y);return r},d.Clipper.prototype.GetBounds2=function(t){var e=t,i=new d.FRect;for(i.left=t.Pt.X,i.right=t.Pt.X,i.top=t.Pt.Y,i.bottom=t.Pt.Y,t=t.Next;t!==e;)t.Pt.X<i.left&&(i.left=t.Pt.X),t.Pt.X>i.right&&(i.right=t.Pt.X),t.Pt.Y<i.top&&(i.top=t.Pt.Y),t.Pt.Y>i.bottom&&(i.bottom=t.Pt.Y),t=t.Next;return i},d.Clipper.PointInPolygon=function(t,e){var i=0,r=e.length;if(r<3)return 0;for(var n=e[0],o=1;o<=r;++o){var s=o===r?e[0]:e[o];if(s.Y===t.Y&&(s.X===t.X||n.Y===t.Y&&s.X>t.X==n.X<t.X))return-1;if(n.Y<t.Y!=s.Y<t.Y)if(n.X>=t.X)if(s.X>t.X)i=1-i;else{if(0===(a=(n.X-t.X)*(s.Y-t.Y)-(s.X-t.X)*(n.Y-t.Y)))return-1;a>0==s.Y>n.Y&&(i=1-i)}else if(s.X>t.X){var a;if(0===(a=(n.X-t.X)*(s.Y-t.Y)-(s.X-t.X)*(n.Y-t.Y)))return-1;a>0==s.Y>n.Y&&(i=1-i)}n=s}return i},d.Clipper.prototype.PointInPolygon=function(t,e){var i=0,r=e,n=t.X,o=t.Y,s=e.Pt.X,a=e.Pt.Y;do{var h=(e=e.Next).Pt.X,l=e.Pt.Y;if(l===o&&(h===n||a===o&&h>n==s<n))return-1;if(a<o!=l<o)if(s>=n)if(h>n)i=1-i;else{if(0===(u=(s-n)*(l-o)-(h-n)*(a-o)))return-1;u>0==l>a&&(i=1-i)}else if(h>n){var u;if(0===(u=(s-n)*(l-o)-(h-n)*(a-o)))return-1;u>0==l>a&&(i=1-i)}s=h,a=l}while(r!==e);return i},d.Clipper.prototype.Poly2ContainsPoly1=function(t,e){var i=t;do{var r=this.PointInPolygon(i.Pt,e);if(r>=0)return r>0;i=i.Next}while(i!==t);return!0},d.Clipper.prototype.FixupFirstLefts1=function(t,e){for(var i,r,n=0,o=this.m_PolyOuts.length;n<o;n++)i=this.m_PolyOuts[n],r=d.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===t&&this.Poly2ContainsPoly1(i.Pts,e.Pts)&&(i.FirstLeft=e)},d.Clipper.prototype.FixupFirstLefts2=function(t,e){for(var i,r,n=this,o=e.FirstLeft,s=0,a=this.m_PolyOuts.length;s<a;s++)null!==(i=n.m_PolyOuts[s]).Pts&&i!==e&&i!==t&&((r=d.Clipper.ParseFirstLeft(i.FirstLeft))!==o&&r!==t&&r!==e||(n.Poly2ContainsPoly1(i.Pts,t.Pts)?i.FirstLeft=t:n.Poly2ContainsPoly1(i.Pts,e.Pts)?i.FirstLeft=e:i.FirstLeft!==t&&i.FirstLeft!==e||(i.FirstLeft=o)))},d.Clipper.prototype.FixupFirstLefts3=function(t,e){for(var i,r,n=0,o=this.m_PolyOuts.length;n<o;n++)i=this.m_PolyOuts[n],r=d.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===t&&(i.FirstLeft=e)},d.Clipper.ParseFirstLeft=function(t){for(;null!==t&&null===t.Pts;)t=t.FirstLeft;return t},d.Clipper.prototype.JoinCommonEdges=function(){for(var t=this,e=0,i=this.m_Joins.length;e<i;e++){var r,n=t.m_Joins[e],o=t.GetOutRec(n.OutPt1.Idx),s=t.GetOutRec(n.OutPt2.Idx);if(null!==o.Pts&&null!==s.Pts)if(!o.IsOpen&&!s.IsOpen)r=o===s?o:t.OutRec1RightOfOutRec2(o,s)?s:t.OutRec1RightOfOutRec2(s,o)?o:t.GetLowermostRec(o,s),t.JoinPoints(n,o,s)&&(o===s?(o.Pts=n.OutPt1,o.BottomPt=null,(s=t.CreateOutRec()).Pts=n.OutPt2,t.UpdateOutPtIdxs(s),t.Poly2ContainsPoly1(s.Pts,o.Pts)?(s.IsHole=!o.IsHole,s.FirstLeft=o,t.m_UsingPolyTree&&t.FixupFirstLefts2(s,o),(s.IsHole^t.ReverseSolution)==t.Area$1(s)>0&&t.ReversePolyPtLinks(s.Pts)):t.Poly2ContainsPoly1(o.Pts,s.Pts)?(s.IsHole=o.IsHole,o.IsHole=!s.IsHole,s.FirstLeft=o.FirstLeft,o.FirstLeft=s,t.m_UsingPolyTree&&t.FixupFirstLefts2(o,s),(o.IsHole^t.ReverseSolution)==t.Area$1(o)>0&&t.ReversePolyPtLinks(o.Pts)):(s.IsHole=o.IsHole,s.FirstLeft=o.FirstLeft,t.m_UsingPolyTree&&t.FixupFirstLefts1(o,s))):(s.Pts=null,s.BottomPt=null,s.Idx=o.Idx,o.IsHole=r.IsHole,r===s&&(o.FirstLeft=s.FirstLeft),s.FirstLeft=o,t.m_UsingPolyTree&&t.FixupFirstLefts3(s,o)))}},d.Clipper.prototype.UpdateOutPtIdxs=function(t){var e=t.Pts;do{e.Idx=t.Idx,e=e.Prev}while(e!==t.Pts)},d.Clipper.prototype.DoSimplePolygons=function(){for(var t=this,e=0;e<this.m_PolyOuts.length;){var i=t.m_PolyOuts[e++],r=i.Pts;if(null!==r&&!i.IsOpen)do{for(var n=r.Next;n!==i.Pts;){if(d.FPoint.op_Equality(r.Pt,n.Pt)&&n.Next!==r&&n.Prev!==r){var o=r.Prev,s=n.Prev;r.Prev=s,s.Next=r,n.Prev=o,o.Next=n,i.Pts=r;var a=t.CreateOutRec();a.Pts=n,t.UpdateOutPtIdxs(a),t.Poly2ContainsPoly1(a.Pts,i.Pts)?(a.IsHole=!i.IsHole,a.FirstLeft=i,t.m_UsingPolyTree&&t.FixupFirstLefts2(a,i)):t.Poly2ContainsPoly1(i.Pts,a.Pts)?(a.IsHole=i.IsHole,i.IsHole=!a.IsHole,a.FirstLeft=i.FirstLeft,i.FirstLeft=a,t.m_UsingPolyTree&&t.FixupFirstLefts2(i,a)):(a.IsHole=i.IsHole,a.FirstLeft=i.FirstLeft,t.m_UsingPolyTree&&t.FixupFirstLefts1(i,a)),n=r}n=n.Next}r=r.Next}while(r!==i.Pts)}},d.Clipper.Area=function(t){if(!Array.isArray(t))return 0;var e=t.length;if(e<3)return 0;for(var i=0,r=0,n=e-1;r<e;++r)i+=(t[n].X+t[r].X)*(t[n].Y-t[r].Y),n=r;return.5*-i},d.Clipper.prototype.Area=function(t){var e=t;if(null===t)return 0;var i=0;do{i+=(t.Prev.Pt.X+t.Pt.X)*(t.Prev.Pt.Y-t.Pt.Y),t=t.Next}while(t!==e);return.5*i},d.Clipper.prototype.Area$1=function(t){return this.Area(t.Pts)},d.Clipper.SimplifyPolygon=function(t,e){var i=new Array,r=new d.Clipper(0);return r.StrictlySimple=!0,r.AddPath(t,d.PolyType.ptSubject,!0),r.Execute(d.ClipType.ctUnion,i,e,e),i},d.Clipper.SimplifyPolygons=function(t,e){void 0===e&&(e=d.PolyFillType.pftEvenOdd);var i=new Array,r=new d.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(t,d.PolyType.ptSubject,!0),r.Execute(d.ClipType.ctUnion,i,e,e),i},d.Clipper.DistanceSqrd=function(t,e){var i=t.X-e.X,r=t.Y-e.Y;return i*i+r*r},d.Clipper.DistanceFromLineSqrd=function(t,e,i){var r=e.Y-i.Y,n=i.X-e.X,o=r*e.X+n*e.Y;return(o=r*t.X+n*t.Y-o)*o/(r*r+n*n)},d.Clipper.SlopesNearCollinear=function(t,e,i,r){return Math.abs(t.X-e.X)>Math.abs(t.Y-e.Y)?t.X>e.X==t.X<i.X?d.Clipper.DistanceFromLineSqrd(t,e,i)<r:e.X>t.X==e.X<i.X?d.Clipper.DistanceFromLineSqrd(e,t,i)<r:d.Clipper.DistanceFromLineSqrd(i,t,e)<r:t.Y>e.Y==t.Y<i.Y?d.Clipper.DistanceFromLineSqrd(t,e,i)<r:e.Y>t.Y==e.Y<i.Y?d.Clipper.DistanceFromLineSqrd(e,t,i)<r:d.Clipper.DistanceFromLineSqrd(i,t,e)<r},d.Clipper.PointsAreClose=function(t,e,i){var r=t.X-e.X,n=t.Y-e.Y;return r*r+n*n<=i},d.Clipper.ExcludeOp=function(t){var e=t.Prev;return e.Next=t.Next,t.Next.Prev=e,e.Idx=0,e},d.Clipper.CleanPolygon=function(t,e){void 0===e&&(e=1.415);var i=t.length;if(0===i)return new Array;for(var r=new Array(i),n=0;n<i;++n)r[n]=new d.OutPt;for(n=0;n<i;++n)r[n].Pt=t[n],r[n].Next=r[(n+1)%i],r[n].Next.Prev=r[n],r[n].Idx=0;for(var o=e*e,s=r[0];0===s.Idx&&s.Next!==s.Prev;)d.Clipper.PointsAreClose(s.Pt,s.Prev.Pt,o)?(s=d.Clipper.ExcludeOp(s),i--):d.Clipper.PointsAreClose(s.Prev.Pt,s.Next.Pt,o)?(d.Clipper.ExcludeOp(s.Next),s=d.Clipper.ExcludeOp(s),i-=2):d.Clipper.SlopesNearCollinear(s.Prev.Pt,s.Pt,s.Next.Pt,o)?(s=d.Clipper.ExcludeOp(s),i--):(s.Idx=1,s=s.Next);i<3&&(i=0);var a=new Array(i);for(n=0;n<i;++n)a[n]=new d.FPoint1(s.Pt),s=s.Next;return r=null,a},d.Clipper.CleanPolygons=function(t,e){for(var i=new Array(t.length),r=0,n=t.length;r<n;r++)i[r]=d.Clipper.CleanPolygon(t[r],e);return i},d.Clipper.Minkowski=function(t,e,i,r){var n=r?1:0,o=t.length,s=e.length,a=new Array;if(i)for(var h=0;h<s;h++){for(var l=new Array(o),u=0,p=t.length,c=t[u];u<p;c=t[++u])l[u]=new d.FPoint2(e[h].X+c.X,e[h].Y+c.Y);a.push(l)}else for(h=0;h<s;h++){for(l=new Array(o),u=0,p=t.length,c=t[u];u<p;c=t[++u])l[u]=new d.FPoint2(e[h].X-c.X,e[h].Y-c.Y);a.push(l)}var f=new Array;for(h=0;h<s-1+n;h++)for(u=0;u<o;u++){var v=new Array;v.push(a[h%s][u%o]),v.push(a[(h+1)%s][u%o]),v.push(a[(h+1)%s][(u+1)%o]),v.push(a[h%s][(u+1)%o]),d.Clipper.Orientation(v)||v.reverse(),f.push(v)}return f},d.Clipper.MinkowskiSum=function(t,e,i){if(e[0]instanceof Array){h=e;for(var r=new d.Paths,n=(s=new d.Clipper,0);n<h.length;++n){var o=d.Clipper.Minkowski(t,h[n],!0,i);if(s.AddPaths(o,d.PolyType.ptSubject,!0),i){a=d.Clipper.TranslatePath(h[n],t[0]);s.AddPath(a,d.PolyType.ptClip,!0)}}return s.Execute(d.ClipType.ctUnion,r,d.PolyFillType.pftNonZero,d.PolyFillType.pftNonZero),r}var s,a=e,h=d.Clipper.Minkowski(t,a,!0,i);return(s=new d.Clipper).AddPaths(h,d.PolyType.ptSubject,!0),s.Execute(d.ClipType.ctUnion,h,d.PolyFillType.pftNonZero,d.PolyFillType.pftNonZero),h},d.Clipper.TranslatePath=function(t,e){for(var i=new d.Path,r=0;r<t.length;r++)i.push(new d.FPoint2(t[r].X+e.X,t[r].Y+e.Y));return i},d.Clipper.MinkowskiDiff=function(t,e){var i=d.Clipper.Minkowski(t,e,!1,!0),r=new d.Clipper;return r.AddPaths(i,d.PolyType.ptSubject,!0),r.Execute(d.ClipType.ctUnion,i,d.PolyFillType.pftNonZero,d.PolyFillType.pftNonZero),i},d.Clipper.PolyTreeToPaths=function(t){var e=new Array;return d.Clipper.AddPolyNodeToPaths(t,d.Clipper.NodeType.ntAny,e),e},d.Clipper.AddPolyNodeToPaths=function(t,e,i){var r=!0;switch(e){case d.Clipper.NodeType.ntOpen:return;case d.Clipper.NodeType.ntClosed:r=!t.IsOpen}t.m_polygon.length>0&&r&&i.push(t.m_polygon);for(var n=0,o=t.Childs(),s=o.length,a=o[n];n<s;a=o[++n])d.Clipper.AddPolyNodeToPaths(a,e,i)},d.Clipper.OpenPathsFromPolyTree=function(t){for(var e=new d.Paths,i=0,r=t.ChildCount();i<r;i++)t.Childs()[i].IsOpen&&e.push(t.Childs()[i].m_polygon);return e},d.Clipper.ClosedPathsFromPolyTree=function(t){var e=new d.Paths;return d.Clipper.AddPolyNodeToPaths(t,d.Clipper.NodeType.ntClosed,e),e},f(d.Clipper,d.ClipperBase),d.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},d.ClipperOffset=function(t,e){void 0===t&&(t=2),void 0===e&&(e=d.ClipperOffset.def_arc_tolerance),this.m_destPolys=new d.Paths,this.m_srcPoly=new d.Path,this.m_destPoly=new d.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new d.FPoint0,this.m_polyNodes=new d.PolyNode,this.MiterLimit=t,this.ArcTolerance=e,this.m_lowest.X=-1},d.ClipperOffset.two_pi=6.28318530717959,d.ClipperOffset.def_arc_tolerance=.25,d.ClipperOffset.prototype.Clear=function(){d.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},d.ClipperOffset.prototype.AddPath=function(t,e,i){var r=t.length-1;if(!(r<0)){var n=new d.PolyNode;if(n.m_jointype=e,n.m_endtype=i,i===d.EndType.etClosedLine||i===d.EndType.etClosedPolygon)for(;r>0&&d.FPoint.op_Equality(t[0],t[r]);)r--;n.m_polygon.push(t[0]);for(var o=0,s=0,a=1;a<=r;a++)d.FPoint.op_Inequality(n.m_polygon[o],t[a])&&(o++,n.m_polygon.push(t[a]),(t[a].Y>n.m_polygon[s].Y||t[a].Y===n.m_polygon[s].Y&&t[a].X<n.m_polygon[s].X)&&(s=o));if(!(i===d.EndType.etClosedPolygon&&o<2)&&(this.m_polyNodes.AddChild(n),i===d.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new d.FPoint2(this.m_polyNodes.ChildCount()-1,s);else{var h=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(n.m_polygon[s].Y>h.Y||n.m_polygon[s].Y===h.Y&&n.m_polygon[s].X<h.X)&&(this.m_lowest=new d.FPoint2(this.m_polyNodes.ChildCount()-1,s))}}},d.ClipperOffset.prototype.AddPaths=function(t,e,i){for(var r=0,n=t.length;r<n;r++)this.AddPath(t[r],e,i)},d.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!d.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var t=0;t<this.m_polyNodes.ChildCount();t++){((e=this.m_polyNodes.Childs()[t]).m_endtype===d.EndType.etClosedPolygon||e.m_endtype===d.EndType.etClosedLine&&d.Clipper.Orientation(e.m_polygon))&&e.m_polygon.reverse()}else for(t=0;t<this.m_polyNodes.ChildCount();t++){var e;(e=this.m_polyNodes.Childs()[t]).m_endtype!==d.EndType.etClosedLine||d.Clipper.Orientation(e.m_polygon)||e.m_polygon.reverse()}},d.ClipperOffset.GetUnitNormal=function(t,e){var i=e.X-t.X,r=e.Y-t.Y;if(0===i&&0===r)return new d.FPoint2(0,0);var n=1/Math.sqrt(i*i+r*r);return i*=n,r*=n,new d.FPoint2(r,-i)},d.ClipperOffset.prototype.DoOffset=function(t){var e=this;if(this.m_destPolys=new Array,this.m_delta=t,d.ClipperBase.near_zero(t))for(var i=0;i<this.m_polyNodes.ChildCount();i++){(o=e.m_polyNodes.Childs()[i]).m_endtype===d.EndType.etClosedPolygon&&e.m_destPolys.push(o.m_polygon)}else{var r;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,r=this.ArcTolerance<=0?d.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(t)*d.ClipperOffset.def_arc_tolerance?Math.abs(t)*d.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var n=3.14159265358979/Math.acos(1-r/Math.abs(t));this.m_sin=Math.sin(d.ClipperOffset.two_pi/n),this.m_cos=Math.cos(d.ClipperOffset.two_pi/n),this.m_StepsPerRad=n/d.ClipperOffset.two_pi,t<0&&(this.m_sin=-this.m_sin);for(i=0;i<this.m_polyNodes.ChildCount();i++){var o=e.m_polyNodes.Childs()[i];e.m_srcPoly=o.m_polygon;var s=e.m_srcPoly.length;if(!(0===s||t<=0&&(s<3||o.m_endtype!==d.EndType.etClosedPolygon)))if(e.m_destPoly=new Array,1!==s){e.m_normals.length=0;for(c=0;c<s-1;c++)e.m_normals.push(d.ClipperOffset.GetUnitNormal(e.m_srcPoly[c],e.m_srcPoly[c+1]));if(o.m_endtype===d.EndType.etClosedLine||o.m_endtype===d.EndType.etClosedPolygon?e.m_normals.push(d.ClipperOffset.GetUnitNormal(e.m_srcPoly[s-1],e.m_srcPoly[0])):e.m_normals.push(new d.FPoint1(e.m_normals[s-2])),o.m_endtype===d.EndType.etClosedPolygon){var a=s-1;for(c=0;c<s;c++)a=e.OffsetPoint(c,a,o.m_jointype);e.m_destPolys.push(e.m_destPoly)}else if(o.m_endtype===d.EndType.etClosedLine){for(a=s-1,c=0;c<s;c++)a=e.OffsetPoint(c,a,o.m_jointype);e.m_destPolys.push(e.m_destPoly),e.m_destPoly=new Array;var h=e.m_normals[s-1];for(c=s-1;c>0;c--)e.m_normals[c]=new d.FPoint2(-e.m_normals[c-1].X,-e.m_normals[c-1].Y);e.m_normals[0]=new d.FPoint2(-h.X,-h.Y),a=0;for(c=s-1;c>=0;c--)a=e.OffsetPoint(c,a,o.m_jointype);e.m_destPolys.push(e.m_destPoly)}else{var l;for(a=0,c=1;c<s-1;++c)a=e.OffsetPoint(c,a,o.m_jointype);if(o.m_endtype===d.EndType.etOpenButt){c=s-1;l=new d.FPoint2(e.m_srcPoly[c].X+e.m_normals[c].X*t,e.m_srcPoly[c].Y+e.m_normals[c].Y*t),e.m_destPoly.push(l),l=new d.FPoint2(e.m_srcPoly[c].X-e.m_normals[c].X*t,e.m_srcPoly[c].Y-e.m_normals[c].Y*t),e.m_destPoly.push(l)}else{c=s-1;a=s-2,e.m_sinA=0,e.m_normals[c]=new d.FPoint2(-e.m_normals[c].X,-e.m_normals[c].Y),o.m_endtype===d.EndType.etOpenSquare?e.DoSquare(c,a):e.DoRound(c,a)}for(c=s-1;c>0;c--)e.m_normals[c]=new d.FPoint2(-e.m_normals[c-1].X,-e.m_normals[c-1].Y);e.m_normals[0]=new d.FPoint2(-e.m_normals[1].X,-e.m_normals[1].Y);for(c=(a=s-1)-1;c>0;--c)a=e.OffsetPoint(c,a,o.m_jointype);o.m_endtype===d.EndType.etOpenButt?(l=new d.FPoint2(e.m_srcPoly[0].X-e.m_normals[0].X*t,e.m_srcPoly[0].Y-e.m_normals[0].Y*t),e.m_destPoly.push(l),l=new d.FPoint2(e.m_srcPoly[0].X+e.m_normals[0].X*t,e.m_srcPoly[0].Y+e.m_normals[0].Y*t),e.m_destPoly.push(l)):(a=1,e.m_sinA=0,o.m_endtype===d.EndType.etOpenSquare?e.DoSquare(0,1):e.DoRound(0,1)),e.m_destPolys.push(e.m_destPoly)}}else{if(o.m_jointype===d.JoinType.jtRound)for(var u=1,p=0,c=1;c<=n;c++){e.m_destPoly.push(new d.FPoint2(e.m_srcPoly[0].X+u*t,e.m_srcPoly[0].Y+p*t));var f=u;u=u*e.m_cos-e.m_sin*p,p=f*e.m_sin+p*e.m_cos}else{u=-1,p=-1;for(var c=0;c<4;++c)e.m_destPoly.push(new d.FPoint2(e.m_srcPoly[0].X+u*t,e.m_srcPoly[0].Y+p*t)),u<0?u=1:p<0?p=1:u=-1}e.m_destPolys.push(e.m_destPoly)}}}},d.ClipperOffset.prototype.Execute=function(){var t=arguments,e=t[0]instanceof d.PolyTree;if(e){o=t[0],s=t[1];if(o.Clear(),this.FixOrientations(),this.DoOffset(s),(n=new d.Clipper(0)).AddPaths(this.m_destPolys,d.PolyType.ptSubject,!0),s>0)n.Execute(d.ClipType.ctUnion,o,d.PolyFillType.pftPositive,d.PolyFillType.pftPositive);else{h=d.Clipper.GetBounds(this.m_destPolys);if((a=new d.Path).push(new d.FPoint2(h.left-10,h.bottom+10)),a.push(new d.FPoint2(h.right+10,h.bottom+10)),a.push(new d.FPoint2(h.right+10,h.top-10)),a.push(new d.FPoint2(h.left-10,h.top-10)),n.AddPath(a,d.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(d.ClipType.ctUnion,o,d.PolyFillType.pftNegative,d.PolyFillType.pftNegative),1===o.ChildCount()&&o.Childs()[0].ChildCount()>0){var i=o.Childs()[0];o.Childs()[0]=i.Childs()[0],o.Childs()[0].m_Parent=o;for(var r=1;r<i.ChildCount();r++)o.AddChild(i.Childs()[r])}else o.Clear()}}else{var n,o=t[0],s=t[1];if(d.Clear(o),this.FixOrientations(),this.DoOffset(s),(n=new d.Clipper(0)).AddPaths(this.m_destPolys,d.PolyType.ptSubject,!0),s>0)n.Execute(d.ClipType.ctUnion,o,d.PolyFillType.pftPositive,d.PolyFillType.pftPositive);else{var a,h=d.Clipper.GetBounds(this.m_destPolys);(a=new d.Path).push(new d.FPoint2(h.left-10,h.bottom+10)),a.push(new d.FPoint2(h.right+10,h.bottom+10)),a.push(new d.FPoint2(h.right+10,h.top-10)),a.push(new d.FPoint2(h.left-10,h.top-10)),n.AddPath(a,d.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(d.ClipType.ctUnion,o,d.PolyFillType.pftNegative,d.PolyFillType.pftNegative),o.length>0&&o.splice(0,1)}}},d.ClipperOffset.prototype.OffsetPoint=function(t,e,i){if(this.m_sinA=this.m_normals[e].X*this.m_normals[t].Y-this.m_normals[t].X*this.m_normals[e].Y,0===this.m_sinA)return e;if(this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1),this.m_sinA*this.m_delta<0)this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_normals[e].X*this.m_delta,this.m_srcPoly[t].Y+this.m_normals[e].Y*this.m_delta)),this.m_destPoly.push(new d.FPoint1(this.m_srcPoly[t])),this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta,this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta));else switch(i){case d.JoinType.jtMiter:var r=this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y+1;r>=this.m_miterLim?this.DoMiter(t,e,r):this.DoSquare(t,e);break;case d.JoinType.jtSquare:this.DoSquare(t,e);break;case d.JoinType.jtRound:this.DoRound(t,e)}return e=t},d.ClipperOffset.prototype.DoSquare=function(t,e){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y)/4);this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[e].X-this.m_normals[e].Y*i),this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[e].Y+this.m_normals[e].X*i))),this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[t].X+this.m_normals[t].Y*i),this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[t].Y-this.m_normals[t].X*i)))},d.ClipperOffset.prototype.DoMiter=function(t,e,i){var r=this.m_delta/i;this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+(this.m_normals[e].X+this.m_normals[t].X)*r,this.m_srcPoly[t].Y+(this.m_normals[e].Y+this.m_normals[t].Y)*r))},d.ClipperOffset.prototype.DoRound=function(t,e){for(var i,r=this,n=Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y),o=Math.max(Math.round(this.m_StepsPerRad*Math.abs(n)),1),s=this.m_normals[e].X,a=this.m_normals[e].Y,h=0;h<o;++h)r.m_destPoly.push(new d.FPoint2(r.m_srcPoly[t].X+s*r.m_delta,r.m_srcPoly[t].Y+a*r.m_delta)),i=s,s=s*r.m_cos-r.m_sin*a,a=i*r.m_sin+a*r.m_cos;this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta,this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta))},d.Error=function(t){try{throw new Error(t)}catch(t){alert(t.message)}},d.JS={},d.JS.AreaOfPolygon=function(t){return d.Clipper.Area(t)},d.JS.AreaOfPolygons=function(t){for(var e=0,i=0;i<t.length;i++)e+=d.Clipper.Area(t[i]);return e},d.JS.BoundsOfPath=function(t){return d.JS.BoundsOfPaths([t])},d.JS.BoundsOfPaths=function(t){return d.Clipper.GetBounds(t)},d.JS.Clean=function(t,e){if(!(t instanceof Array))return[];var i=t[0]instanceof Array;t=d.JS.Clone(t);if("number"!=typeof e||null===e)return d.Error("Delta is not a number in Clean()."),t;if(0===t.length||1===t.length&&0===t[0].length||e<0)return t;i||(t=[t]);for(var r,n,o,s,a,h,l,u=t.length,p=[],c=0;c<u;c++)if(0!==(r=(n=t[c]).length))if(r<3)o=n,p.push(o);else{for(o=n,s=e*e,a=n[0],h=1,l=1;l<r;l++)(n[l].X-a.X)*(n[l].X-a.X)+(n[l].Y-a.Y)*(n[l].Y-a.Y)<=s||(o[h]=n[l],a=n[l],h++);a=n[h-1],(n[0].X-a.X)*(n[0].X-a.X)+(n[0].Y-a.Y)*(n[0].Y-a.Y)<=s&&h--,h<r&&o.splice(h,r-h),o.length&&p.push(o)}return!i&&p.length?p=p[0]:i||0!==p.length?i&&0===p.length&&(p=[[]]):p=[],p},d.JS.Clone=function(t){if(!(t instanceof Array))return[];if(0===t.length)return[];if(1===t.length&&0===t[0].length)return[[]];var e=t[0]instanceof Array;e||(t=[t]);var i,r,n,o,s=t.length,a=new Array(s);for(r=0;r<s;r++){for(i=t[r].length,o=new Array(i),n=0;n<i;n++)o[n]={X:t[r][n].X,Y:t[r][n].Y};a[r]=o}return e||(a=a[0]),a},d.JS.Lighten=function(t,e){if(!(t instanceof Array))return[];if("number"!=typeof e||null===e)return d.Error("Tolerance is not a number in Lighten()."),d.JS.Clone(t);if(0===t.length||1===t.length&&0===t[0].length||e<0)return d.JS.Clone(t);var i,r,n,o,s,a,h,l,u,p,c,f,v,y,g,m,_=t[0]instanceof Array;_||(t=[t]);var x=t.length,b=e*e,P=[];for(i=0;i<x;i++)if(0!==(a=(n=t[i]).length)){for(o=0;o<1e6;o++){for(s=[],n[(a=n.length)-1].X!==n[0].X||n[a-1].Y!==n[0].Y?(c=1,n.push({X:n[0].X,Y:n[0].Y}),a=n.length):c=0,p=[],r=0;r<a-2;r++)h=n[r],u=n[r+1],l=n[r+2],g=h.X,m=h.Y,f=l.X-g,v=l.Y-m,0===f&&0===v||((y=((u.X-g)*f+(u.Y-m)*v)/(f*f+v*v))>1?(g=l.X,m=l.Y):y>0&&(g+=f*y,m+=v*y)),(f=u.X-g)*f+(v=u.Y-m)*v<=b&&(p[r+1]=1,r++);for(s.push({X:n[0].X,Y:n[0].Y}),r=1;r<a-1;r++)p[r]||s.push({X:n[r].X,Y:n[r].Y});if(s.push({X:n[a-1].X,Y:n[a-1].Y}),c&&n.pop(),!p.length)break;n=s}s[(a=s.length)-1].X===s[0].X&&s[a-1].Y===s[0].Y&&s.pop(),s.length>2&&P.push(s)}return _||(P=P[0]),void 0===P&&(P=[]),P},d.JS.PerimeterOfPath=function(t,e){if(void 0===t)return 0;var i,r,n=Math.sqrt,o=0,s=0,a=0,h=0,l=0,u=t.length;if(u<2)return 0;for(e&&(t[u]=t[0],u++);--u;)s=(i=t[u]).X,a=i.Y,o+=n((s-(h=(r=t[u-1]).X))*(s-h)+(a-(l=r.Y))*(a-l));return e&&t.pop(),o},d.JS.PerimeterOfPaths=function(t,e){for(var i=0,r=0;r<t.length;r++)i+=d.JS.PerimeterOfPath(t[r],e);return i},d.ExPolygons=function(){return[]},d.ExPolygon=function(){this.outer=null,this.holes=null},d.JS.AddOuterPolyNodeToExPolygons=function(t,e){var i=new d.ExPolygon;i.outer=t.Contour();var r,n,o,s,a,h,l=t.Childs(),u=l.length;for(i.holes=new Array(u),o=0;o<u;o++)for(r=l[o],i.holes[o]=r.Contour(),s=0,h=(a=r.Childs()).length;s<h;s++)n=a[s],d.JS.AddOuterPolyNodeToExPolygons(n,e);e.push(i)},d.JS.ExPolygonsToPaths=function(t){var e,i,r,n,o=new d.Paths;for(e=0,r=t.length;e<r;e++)for(o.push(t[e].outer),i=0,n=t[e].holes.length;i<n;i++)o.push(t[e].holes[i]);return o},d.JS.PolyTreeToExPolygons=function(t){var e,i,r,n,o=new d.ExPolygons;for(i=0,n=(r=t.Childs()).length;i<n;i++)e=r[i],d.JS.AddOuterPolyNodeToExPolygons(e,o);return o};var v=d;function y(t,e){return t<e?-1:t>e?1:0}var g=Object.freeze({__proto__:null,default:class{constructor(t=[],e=y){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}}peek(){return this.data[0]}_up(t){for(var{data:e,compare:i}=this,r=e[t];t>0;){var n=t-1>>1,o=e[n];if(i(r,o)>=0)break;e[t]=o,t=n}e[t]=r}_down(t){for(var{data:e,compare:i}=this,r=this.length>>1,n=e[t];t<r;){var o=1+(t<<1),s=e[o],a=o+1;if(a<this.length&&i(e[a],s)<0&&(o=a,s=e[a]),i(s,n)>=0)break;e[t]=s,t=o}e[t]=n}}}),m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})})),e}function x(t){var e={exports:{}};return t(e,e.exports),e.exports}var b=_(g);b.default&&(b=b.default);var P=E,w=E;function E(t,e,i){var r,n,o,s;e=e||1;for(var a=0;a<t[0].length;a++){var h=t[0][a];(!a||h[0]<r)&&(r=h[0]),(!a||h[1]<n)&&(n=h[1]),(!a||h[0]>o)&&(o=h[0]),(!a||h[1]>s)&&(s=h[1])}var l=o-r,u=s-n,p=Math.min(l,u),c=p/2;if(0===p){var d=[r,n];return d.distance=0,d}for(var f=new b(void 0,T),v=r;v<o;v+=p)for(var y=n;y<s;y+=p)f.push(new C(v+c,y+c,c,t));var g=function(t){for(var e=0,i=0,r=0,n=t[0],o=0,s=n.length,a=s-1;o<s;a=o++){var h=n[o],l=n[a],u=h[0]*l[1]-l[0]*h[1];i+=(h[0]+l[0])*u,r+=(h[1]+l[1])*u,e+=3*u}return 0===e?new C(n[0][0],n[0][1],0,t):new C(i/e,r/e,0,t)}(t),m=new C(r+l/2,n+u/2,0,t);m.d>g.d&&(g=m);for(var _=f.length;f.length;){var x=f.pop();x.d>g.d&&(g=x,i&&console.log("found best %d after %d probes",Math.round(1e4*x.d)/1e4,_)),x.max-g.d<=e||(c=x.h/2,f.push(new C(x.x-c,x.y-c,c,t)),f.push(new C(x.x+c,x.y-c,c,t)),f.push(new C(x.x-c,x.y+c,c,t)),f.push(new C(x.x+c,x.y+c,c,t)),_+=4)}i&&(console.log("num probes: "+_),console.log("best distance: "+g.d));var P=[g.x,g.y];return P.distance=g.d,P}function T(t,e){return e.max-t.max}function C(t,e,i,r){this.x=t,this.y=e,this.h=i,this.d=function(t,e,i){for(var r=!1,n=1/0,o=0;o<i.length;o++)for(var s=i[o],a=0,h=s.length,l=h-1;a<h;l=a++){var u=s[a],p=s[l];u[1]>e!=p[1]>e&&t<(p[0]-u[0])*(e-u[1])/(p[1]-u[1])+u[0]&&(r=!r),n=Math.min(n,I(t,e,u,p))}return 0===n?0:(r?1:-1)*Math.sqrt(n)}(t,e,r),this.max=this.d+this.h*Math.SQRT2}function I(t,e,i,r){var n=i[0],o=i[1],s=r[0]-n,a=r[1]-o;if(0!==s||0!==a){var h=((t-n)*s+(e-o)*a)/(s*s+a*a);h>1?(n=r[0],o=r[1]):h>0&&(n+=s*h,o+=a*h)}return(s=t-n)*s+(a=e-o)*a}P.default=w;var S,O="undefined"!=typeof Float32Array?Float32Array:Array;function A(){var t=new O(6);return O!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}function M(){var t=new O(2);return O!=Float32Array&&(t[0]=0,t[1]=0),t}function L(t,e){var i=new O(2);return i[0]=t,i[1]=e,i}function N(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t}function R(t,e){return t[0]*e[0]+t[1]*e[1]}function D(t,e,i){var r=e[0],n=e[1];return t[0]=i[0]*r+i[2]*n+i[4],t[1]=i[1]*r+i[3]*n+i[5],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),M();var F=new Uint8Array(16);function k(){if(!S&&!(S="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return S(F)}var B=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function U(t){return"string"==typeof t&&B.test(t)}for(var z=[],X=0;X<256;++X)z.push((X+256).toString(16).substr(1));function j(t,e,i){var r=(t=t||{}).random||(t.rng||k)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){i=i||0;for(var n=0;n<16;++n)e[i+n]=r[n];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(z[t[e+0]]+z[t[e+1]]+z[t[e+2]]+z[t[e+3]]+"-"+z[t[e+4]]+z[t[e+5]]+"-"+z[t[e+6]]+z[t[e+7]]+"-"+z[t[e+8]]+z[t[e+9]]+"-"+z[t[e+10]]+z[t[e+11]]+z[t[e+12]]+z[t[e+13]]+z[t[e+14]]+z[t[e+15]]).toLowerCase();if(!U(i))throw TypeError("Stringified UUID is invalid");return i}(r)}function Y(){}Y.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function n(){r.off(t,n),e.apply(i,arguments)}return n._=e,this.on(t,n,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,n=i.length;r<n;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],n=[];if(r&&e)for(var o=0,s=r.length;o<s;o++)r[o].fn!==e&&r[o].fn._!==e&&n.push(r[o]);return n.length?i[t]=n:delete i[t],this}};var H=Y,G=Y;H.TinyEmitter=G;var W,V,q=x((function(t,e){var i=function(){var t={},e=Math.PI/180,i=180/Math.PI,r=6378137,n=20037508.342789244;function o(t){return Number(t)===t&&t%1!=0}function s(e){if(e=e||{},this.size=e.size||256,this.expansion=!0===e.antimeridian?2:1,!t[this.size]){var i=this.size,r=t[this.size]={};r.Bc=[],r.Cc=[],r.zc=[],r.Ac=[];for(var n=0;n<30;n++)r.Bc.push(i/360),r.Cc.push(i/(2*Math.PI)),r.zc.push(i/2),r.Ac.push(i),i*=2}this.Bc=t[this.size].Bc,this.Cc=t[this.size].Cc,this.zc=t[this.size].zc,this.Ac=t[this.size].Ac}return s.prototype.px=function(t,i){if(o(i)){var r=this.size*Math.pow(2,i),n=r/2,s=r/360,a=r/(2*Math.PI),h=r,l=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),u=n+t[0]*s,p=n+.5*Math.log((1+l)/(1-l))*-a;return u>h*this.expansion&&(u=h*this.expansion),p>h&&(p=h),[u,p]}n=this.zc[i],l=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),u=Math.round(n+t[0]*this.Bc[i]),p=Math.round(n+.5*Math.log((1+l)/(1-l))*-this.Cc[i]);return u>this.Ac[i]*this.expansion&&(u=this.Ac[i]*this.expansion),p>this.Ac[i]&&(p=this.Ac[i]),[u,p]},s.prototype.ll=function(t,e){if(o(e)){var r=this.size*Math.pow(2,e),n=r/360,s=r/(2*Math.PI),a=r/2,h=(t[1]-a)/-s;return[(t[0]-a)/n,i*(2*Math.atan(Math.exp(h))-.5*Math.PI)]}h=(t[1]-this.zc[e])/-this.Cc[e];return[(t[0]-this.zc[e])/this.Bc[e],i*(2*Math.atan(Math.exp(h))-.5*Math.PI)]},s.prototype.bbox=function(t,e,i,r,n){r&&(e=Math.pow(2,i)-1-e);var o=[t*this.size,(+e+1)*this.size],s=[(+t+1)*this.size,e*this.size],a=this.ll(o,i).concat(this.ll(s,i));return"900913"===n?this.convert(a,"900913"):a},s.prototype.xyz=function(t,e,i,r){"900913"===r&&(t=this.convert(t,"WGS84"));var n=[t[0],t[1]],o=[t[2],t[3]],s=this.px(n,e),a=this.px(o,e),h=[Math.floor(s[0]/this.size),Math.floor((a[0]-1)/this.size)],l=[Math.floor(a[1]/this.size),Math.floor((s[1]-1)/this.size)],u={minX:Math.min.apply(Math,h)<0?0:Math.min.apply(Math,h),minY:Math.min.apply(Math,l)<0?0:Math.min.apply(Math,l),maxX:Math.max.apply(Math,h),maxY:Math.max.apply(Math,l)};if(i){var p={minY:Math.pow(2,e)-1-u.maxY,maxY:Math.pow(2,e)-1-u.minY};u.minY=p.minY,u.maxY=p.maxY}return u},s.prototype.convert=function(t,e){return"900913"===e?this.forward(t.slice(0,2)).concat(this.forward(t.slice(2,4))):this.inverse(t.slice(0,2)).concat(this.inverse(t.slice(2,4)))},s.prototype.forward=function(t){var i=[r*t[0]*e,r*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return i[0]>n&&(i[0]=n),i[0]<-n&&(i[0]=-n),i[1]>n&&(i[1]=n),i[1]<-n&&(i[1]=-n),i},s.prototype.inverse=function(t){return[t[0]*i/r,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/r)))*i]},s}();t.exports=i}));function Z(t,e){var i;return i=e?st(e):{x:0,y:0,z:0},J(st(t),i)}function J(t,e){e||(e={x:0,y:0,z:0});var i=rt(e,t);return Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z)}function K(t,e){e||(e={x:0,z:0});var i=nt(e,t);return Math.sqrt(i.x*i.x+i.z*i.z)}function Q(t){var e=K(t);return{x:t.x/e,z:t.z/e}}function $(t,e){return t||(t={x:0,z:0}),ht(180*Math.atan2(-e.z+t.z,e.x-t.x)/Math.PI,2)}function tt(t,e,i,r){return{x:((r.x-i.x)*(e.x*t.z-t.x*e.z)-(e.x-t.x)*(r.x*i.z-i.x*r.z))/((r.z-i.z)*(e.x-t.x)-(e.z-t.z)*(r.x-i.x)),z:((t.z-e.z)*(r.x*i.z-i.x*r.z)-(i.z-r.z)*(e.x*t.z-t.x*e.z))/((r.z-i.z)*(e.x-t.x)-(e.z-t.z)*(r.x-i.x))}}function et(t,e,i,r=0){var n,o,s=nt(t,e),a=nt(t,i),h=nt(i,e),l=J((n=st(s),o=st(a),{x:n.y*o.z-n.z*o.y,y:n.z*o.x-n.x*o.z,z:n.x*o.y-n.y*o.x})),u=function(t,e){return t.x*e.x+t.z*e.z}(h,s);return ht(l,4)<=2*r&&u>=0&&K(s)<=K(h)}function it(t,e){return{x:t.x+e.x,y:t.y+e.y,z:t.z+e.z}}function rt(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}function nt(t,e){return{x:t.x-e.x,z:t.z-e.z}}function ot(t,e){return{x:t.x*e,z:t.z*e}}function st(t){return{x:t.x,y:(null==t?void 0:t.y)||0,z:t.z}}function at(t){return 2==t.length?{x:t[0],y:0,z:t[1]}:{x:t[0],y:t[1],z:t[2]}}function ht(t,e=0){var i=Math.pow(10,e);return Math.round(t*i)/i}function lt(t){var e=xt(t),i=v.Clipper.GetBounds(e);return{x:i.left,x2:i.right,z:i.top,z2:i.bottom,length:i.right-i.left,width:i.bottom-i.top}}function ut(t){if(!Array.isArray(t))throw new Error("Union failed, input not Array");if(!t.length||!t[0])throw new Error("Union failed, empty Array");var e=xt(t),i=[e[0]],r=e.slice(1),n=new v.Clipper;n.AddPaths(i,v.PolyType.ptSubject,!0),n.AddPaths(r,v.PolyType.ptClip,!0);var o=new v.Paths;return n.Execute(v.ClipType.ctUnion,o,v.PolyFillType.pftNonZero,v.PolyFillType.pftNonZero),bt(o)}function pt(t,e=.1,i,r){if(void 0===i&&(i=v.EndType.etClosedPolygon),!(t=r?t:mt(t)).length||!t[0].length)return[];e=e&&"number"==typeof e?e:.1;var n=xt(t),o=new v.ClipperOffset(2),s=new v.Paths;return o.AddPaths(n,v.JoinType.jtMiter,i),o.Execute(s,e),bt(s)}function ct(t,e,i,r){if(!Array.isArray(t))throw new Error("Difference failed, input not Array");if(!t.length||!t[0])throw new Error("Difference failed, empty Array");var n=xt(t),o=xt(i?pt(e,i):e),s=new v.Clipper;s.AddPaths(n,v.PolyType.ptSubject,!r),s.AddPaths(o,v.PolyType.ptClip,!0);var a=r?new v.PolyTree:new v.Paths;return s.Execute(v.ClipType.ctDifference,a,v.PolyFillType.pftNonZero,v.PolyFillType.pftNonZero),bt(r?v.Clipper.PolyTreeToPaths(a):a)}function dt(t=[],e=[],i=!1){if(!Array.isArray(t))throw new Error("Intersection failed, input not Array");if(!t.length||!t[0])throw new Error("Intersection failed, empty Array");var r=xt(t),n=e.length&&xt(e),o=n?r:[r[0]],s=n||r.slice(1),a=new v.Clipper;a.AddPaths(o,v.PolyType.ptSubject,!i),a.AddPaths(s,v.PolyType.ptClip,!0);var h=v.PolyFillType.pftNonZero,l=v.PolyFillType.pftNonZero,u=v.ClipType.ctIntersection,p=i?new v.PolyTree:new v.Paths;return a.Execute(u,p,h,l),bt(i?v.Clipper.PolyTreeToPaths(p):p)}function ft(t,e,i=[]){var r=new v.FPoint(t[0],t[1]),n=xt([e])[0],o=v.Clipper.PointInPolygon(r,n);return i.forEach((e=>{var i=ft(t,e);1===i?o=0:-1===i&&(o=-1)})),o}function vt(t,e,i=[]){var r=new v.FPoint(t[0],t[1]),n=e[0],o=v.Clipper.PointInPolygon(r,n);return i.forEach((e=>{var i=ft(t,e);1===i?o=0:-1===i&&(o=-1)})),o}function yt(t){var e=xt([t]);return v.JS.AreaOfPolygon(e[0])}function gt(t){return Math.abs(yt(t))}function mt(t,e=.01){var i=xt(t);return bt(v.Clipper.CleanPolygons(i,e))}function _t(t,e=.01){return mt([t],e)[0]}function xt(t=[]){for(var e=[],i=0;i<t.length;i++){var r=t[i]||[];e[i]=[];for(var n=0;n<r.length;n++){var o=r[n];Number.isFinite(o[0])&&Number.isFinite(o[1])?e[i][n]={X:o[0],Y:o[1]}:console.warn("invalid number",o[0],o[1])}}var s=[];for(var a of e){!a.length?console.warn("empty polygon"):s.push(a)}if(!s.length)throw new Error("empty polygon invalid input");return s}function bt(t){for(var e=[],i=0;i<t.length;i++){var r=t[i]||[];e[i]=[];for(var n=0;n<r.length;n++){var o=r[n];e[i][n]=[o.X,o.Y]}}return e}function Pt(t,e,i=1e-4){return![t[0]-e[0],t[1]-e[1]].some((t=>Math.abs(t)>i))}function wt(t,e,i){if(t.length!=e.length)return!1;var r=!0;if(t.forEach(((t,i)=>{t.length!=e[i].length&&(r=!1)})),!r)return!1;for(var n=!0,o=function(r){var o=Pt(t[r][0],e[r][0]),s=0;return o||(s=e[r].findIndex((e=>Pt(t[r][0],e)))),s<0?(n=!1,"break"):t[r].every(((t,n)=>{var o=n+s<=e[r].length-1?n+s:n+s-e[r].length;return Pt(t,e[r][o],i)}))?void 0:(n=!1,"break")},s=0;s<t.length;s++){if("break"===o(s))break}return n}function Et(t,e=!0){for(var i=0,r=e?t.length:t.length-1,n=0;n<r;n++){i+=K({x:t[n][0],z:t[n][1]},{x:t[n<t.length-1?n+1:0][0],z:t[n<t.length-1?n+1:0][1]})}return i}function Tt(t,e){var i,r,n=Ct(t[0],t[1]);if(0==n)return[];for(var o=[(t[1][0]-t[0][0])/n,(t[1][1]-t[0][1])/n],s=[-o[1],o[0]],a=[],h=0;h<e.length;h++){if(0!=Ct(i=e[h],r=e[(h+1)%e.length])){var l=[r[0]-i[0],r[1]-i[1]];if(Math.abs(At(s,i)-At(s,t[0]))<=.01&&Math.abs(At(s,r)-At(s,t[0]))<=.01)if(Mt(l,o)){var u=At(l,i)>At(l,t[0])?i:t[0],p=At(l,r)<At(l,t[1])?r:t[1];if(At(l,u)<At(l,p)){var c=u==i?0:Ct(i,u);a.push({l:Ct(u,p),pos:c,start:u,end:p,edgeIdx:h})}}else if(Mt(l,[-o[0],-o[1]])){var d=At(l,i)>At(l,t[1])?i:t[1],f=At(l,r)<At(l,t[0])?r:t[0];if(At(l,d)<At(l,f)){var v=d==i?0:Ct(i,d);a.push({l:Ct(d,f),pos:v,start:d,end:f,edgeIdx:h})}}}}return a}function Ct(t,e){var i=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(i*i+r*r)}function It(t){var{min:e,max:i}=function(t){var e=[1/0,1/0],i=[-1/0,-1/0];return t.forEach((t=>{t[0]<e[0]&&(e[0]=t[0]),t[1]<e[1]&&(e[1]=t[1]),t[0]>i[0]&&(i[0]=t[0]),t[1]>i[1]&&(i[1]=t[1])})),{min:e,max:i}}(t);return[e[0]+(i[0]-e[0])/2,e[1]+(i[1]-e[1])/2]}function St(t,e){e=e||It(t);var i=t.map((t=>[t[0]-e[0],t[1]-e[1]]));return{center:e,polygon:i}}function Ot(t=[]){var e=[...t];return Pt(e[0],e[e.length-1])||e.push(e[0]),e}function At(t,e){return t[0]*e[0]+t[1]*e[1]}function Mt(t,e,i=.01){var r=Math.atan2(t[1],t[0]),n=Math.atan2(e[1],e[0]),o=Math.abs(r-n);return o<=i||o>=2*Math.PI-i}function Lt(t,e=[]){return gt(t)<.1?It(t):P([t,...e],.1)}function Nt(t,e,i=!1){var r=0,n=e.x,o=e.z;if(e.controlLine&&e.w&&(r="front"===e.controlLine?e.w:"center"===e.controlLine?e.w/2:0),r){var s=e.ry/180*Math.PI;n-=r*Math.sin(s),o-=r*Math.cos(s)}var a,h,l=t.ry||0,u=e.ry||0,p=L(t.x,t.z),c=L(n,o),d=-u*Math.PI/180,f=A(),v=M();h=c,(a=f)[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=h[0],a[5]=h[1],function(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],h=e[5],l=Math.sin(i),u=Math.cos(i);t[0]=r*u+o*l,t[1]=n*u+s*l,t[2]=r*-l+o*u,t[3]=n*-l+s*u,t[4]=a,t[5]=h}(f,f,d),D(v,p,f);var y={x:v[0],z:v[1],y:t.y+e.y||0,ry:l+u};return i?Object.assign(t,y):Object.assign({},t,y)}function Rt(t,e,i=!1){var r=0,n=e.x,o=e.z;if(e.controlLine&&e.w&&(r="front"===e.controlLine?e.w:"center"===e.controlLine?e.w/2:0),r){var s=e.ry/180*Math.PI;n-=r*Math.sin(s),o-=r*Math.cos(s)}var a=t.ry||0,h=e.ry||0,l=L(t.x,t.z),u=L(n,o),p=h*Math.PI/180,c=A(),d=M(),f=M();!function(t,e){t[0]=-e[0],t[1]=-e[1]}(f,u),function(t,e){var i=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=i,t[2]=-i,t[3]=r,t[4]=0,t[5]=0}(c,p),function(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],h=e[5],l=i[0],u=i[1];t[0]=r,t[1]=n,t[2]=o,t[3]=s,t[4]=r*l+o*u+a,t[5]=n*l+s*u+h}(c,c,f),D(d,l,c);var v={x:d[0],z:d[1],y:t.y-e.y||0,ry:a-h};return i?Object.assign(t,v):Object.assign({},t,v)}function Dt(t){if("object"!=typeof t)throw new Error("Get el data, invalid type");var i,r,n,o,s,a,h,l,u,p,c,d,{x:f,z:v,l:y,ry:g}=e({},t),m="a:helper:spaceDivider"===t.type;if(!m&&!Number.isFinite(t.w)||!Number.isFinite(y)||!Number.isFinite(f)||!Number.isFinite(v)){var _={type:t.type,id:t.id,x:f,z:v,l:y,ry:g,w:t.w};throw new Error("Get el vectors, params missing ".concat(JSON.stringify(_)))}return i=g/180*Math.PI,r=t.barCounter?t.w+.25:t.w,m&&(r=0),s={x:r*Math.sin(i),z:r*Math.cos(i)},a=m?s:Q(s),l=Q(h={x:y*Math.cos(i),z:-y*Math.sin(i)}),n=t.barCounter?f+-.25*a.x:f,o=t.barCounter?v+-.25*a.z:v,d=0,"front"===t.controlLine?d=-t.w:"center"===t.controlLine&&(d=-t.w/2),{l1:c={x:n,z:o},l2:{x:n+h.x,z:o+h.z},p1:u={x:c.x+a.x*d,z:c.z+a.z*d},p2:p={x:u.x+h.x,z:u.z+h.z},p3:{x:u.x+s.x,z:u.z+s.z},p4:{x:p.x+s.x,z:p.z+s.z},w:s,l:h,nW:a,nL:l}}function Ft(t){var e,i;return"column"===t.type?i=function(t){if("column"===t.type){var e=[];if("square"===t.shape){var i=t.l/2;e=kt(t,e=[[-i,-i],[i,-i],[i,i],[-i,i]])}else if("circle"===t.shape)for(var r=2*Math.PI/25,n=0,o=t.l/2,s=0;s<25;s++)e.push([t.x-o*Math.cos(n),t.z+o*Math.sin(n)]),n+=r;else"polygon"===t.shape&&(e=kt(t,t.polygon));return e}}(t):(e=Dt(t),i=("a:helper:spaceDivider"===t.type?[e.l1,e.l2]:[e.p1,e.p2,e.p4,e.p3]).map((t=>[t.x,t.z]))),i}function kt(t,e){return e.map((e=>{var i=Nt({x:e[0],z:e[1]},t);return[i.x,i.z]}))}(V=W||(W={}))[V.etOpenSquare=0]="etOpenSquare",V[V.etOpenRound=1]="etOpenRound",V[V.etOpenButt=2]="etOpenButt",V[V.etClosedLine=3]="etClosedLine",V[V.etClosedPolygon=4]="etClosedPolygon";var Bt=(t,e={})=>{var i={},r=e.keepTransient;return Object.keys(t).forEach((e=>{var n="_"===e.slice(0,1);"_ryOrg"!==e?n&&!r||null!==t[e]&&void 0!==t[e]&&"children"!==e&&(i[e]=t[e]):i.ry=t[e]})),t.children?i.children=t.children.map((t=>Bt(t,e))):i.children=[],i};function Ut(t,e){var i=Rt(t,e);return t.parent.removeChild(t),e.addChild(Bt(i),{setDefaults:!1})}function zt(t){return t.children.slice().forEach((t=>{"group"===t.type&&(zt(t),Xt(t))})),t}function Xt(t){for(var e=t.parent,i=[],r=t.children.length-1;r>=0;r--){var n=t.children[r],o=Bt(Nt(n,t));t.removeChild(n);var s=e.addChild(o,{setDefaults:!1});i.push(s)}return e.removeChild(t),i}function jt(t,e){for(var i=[],r=t.map(gt),n=0;n<t.length;n++)for(var o=t[n],s=0;s<e.length;s++){if(ft(e[s][0],o))if(i[s])r[i[s]]>r[n]&&(i[s]=n);else i[s]=n}var a=[];return i.forEach(((t,i)=>{a[t]||(a[t]=[]),a[t].push(e[i])})),a}function Yt(t){return{counterClockwise:t.filter((t=>yt(t)>0)),clockwise:t.filter((t=>yt(t)<0))}}function Ht(t){var e=[...t];return yt(e)<0?e:e.reverse()}function Gt(t){var e=[...t];return yt(e)>0?e:e.reverse()}function Wt({uuid:t,scene:e,node:i}){if(!(i=i||e.nodesById[t]))return[];var r=i.getWorldPosition();if(!r.polygon||!r.polygon.length)throw new Error("Invalid space"+JSON.stringify(r,null,2));var n=Gt(r.polygon);if(!(n=_t(n))||!n.length)return console.warn("Space",i.id,"is too small and will be ignored, area:",Math.round(1e3*yt(i.polygon))/1e3),[];var o=r.polygonHoles||[];return o=(o=o.map((t=>_t(Ht(t)))).filter((t=>t.length))).filter((t=>t.length)),[kt(r,n),...o.map((t=>kt(r,t)))]}function Vt({uuid:t,polygons:e,scene:i,structureEls:r,openingsOnly:n=!1}){var o;if(0==(o=(null==e?void 0:e.length)?e:Wt({uuid:t,scene:i})).length)return console.warn("Space node not found or polygon too small"),{openings:[],walls:{polylines:[],length:0},gaps:{polylines:[],length:0},polygons:[]};var{openings:s,walls:a}=r||qt(i),h=n?{wallPolylines:[],wallLength:0,gapPolylines:[],gapLength:0}:function(t=[],e=[]){var i=.005;if(!t.length||!e.length||!e[0].length)return console.warn("no polyline or wall to match"),{wallPolylines:[],wallLength:0,gapPolylines:[],gapLength:0};var r=t.map((t=>t.contour)).filter((t=>null==t?void 0:t.length)),n=[Ot(e[0]),...e.slice(1).map(Ot)],o=r.map((t=>pt([t],i)[0])),s=dt(n,o,!0),a=ct(n,o,0,!0),h={wallPolylines:[],wallLength:0,gapPolylines:[],gapLength:0};for(var l of s){var u=Et(l,!1);!u||u<.1||(h.wallPolylines.push(l),h.wallLength+=u)}for(var p of a){var c=Et(p,!1);!c||c<.1||(h.gapPolylines.push(p),h.gapLength+=c)}return h}(a,o),l=s.filter((t=>{for(var e=0;e<o.length;e++){var i=o[e],r=Zt(t,i);if(r){for(var n of(t.line=r,t.segments=Tt(r,i),t.segments))n.edgeIdx=[e,n.edgeIdx];return!0}}return!1}));return{openings:l,walls:{polylines:h.wallPolylines,length:h.wallLength},gaps:{polylines:h.gapPolylines,length:h.gapLength},polygons:o}}function qt(t){var e=t.nodesByType.window,i=t.nodesByType.door,r=e.concat(i).filter((t=>{var e=t.parent;return"wall"!==e.type&&console.log(t.type,"not in wall",t.id),"wall"===e.type})),n=t.nodesByType.column.map((t=>t.getWorldPosition())),o=t.nodesByType.wall.map((t=>t.getWorldPosition())),s=t.nodesByType["a:helper:spaceDivider"].map((t=>t.getWorldPosition())),a=(o=o.filter((t=>((t.l<=0||t.w<=0)&&console.warn("invalid wall"),t.l>0&&t.w>0)))).map((t=>({node:t,contour:Ft(t)}))),h=n.map((t=>({node:t,contour:Ft(t)}))),l=s.map((t=>({node:t,contour:Ft(t)})));return{openings:r.map((t=>{var e=t.parent,i=t.getWorldPosition();return i.w=e.w,{node:i,contour:Ft(i)}})),walls:a,dividers:l,columns:h}}function Zt(t,e){var i,r=Gt(e),n=t.contour,o=[[n[0][0]+(n[3][0]-n[0][0])/2,n[0][1]+(n[3][1]-n[0][1])/2],[n[1][0]+(n[2][0]-n[1][0])/2,n[1][1]+(n[2][1]-n[1][1])/2]],s=[o[0][0]+(o[1][0]-o[0][0])/2,o[0][1]+(o[1][1]-o[0][1])/2],a=[o[1][0]-o[0][0],o[1][1]-o[0][1]],h=(i=a,Math.sqrt(i[0]*i[0]+i[1]*i[1])),l=[-a[1]/h,a[0]/h],u=t.node.w,p=[[s[0]-l[0]*u,s[1]-l[1]*u],[s[0]+l[0]*u,s[1]+l[1]*u],s],c=[];for(var d of r)c.push({x:d[0],z:d[1]});var f=[];for(var v of n)f.push({x:v[0],z:v[1]});var y=[];for(var g of p)y.push(vt(g,xt([r])));return y[0]===y[1]?function(t,e){for(var i of e)if(et(i,t[0],t[1],.001))return[[t[0].x,t[0].z],[t[1].x,t[1].z]];for(var r of e)if(et(r,t[2],t[3],.001))return[[t[2].x,t[2].z],[t[3].x,t[3].z]];return!1}(f,c):y[0]?y[2]?[n[2],n[3]]:[n[0],n[1]]:y[2]?[n[0],n[1]]:[n[2],n[3]]}function Jt({scene:t,spaces:e}){var i=t.nodesByType.polyfloor,{walls:r,openings:n,dividers:o,columns:s}=qt(t),a=i.map((i=>{var a=function(t,e){var i={},r=[e.polygon,...e.polygonHoles||[]],n=e.getWorldPosition();return r.forEach(((e,r)=>{e.forEach(((o,s)=>{var a=s<e.length-1?s+1:0,h=[o,e[a]],l=kt(n,h),u=r+"-"+s;i[u]={},t.forEach((t=>{var e=Tt([l[0],l[1]],t.contour);e[0]&&(i[u][t.node.id]=e[0].edgeIdx)}))}))})),i}([...r,...n,...o,...s],i),h={};return Object.entries(a).forEach((([e,i])=>{Object.entries(i).forEach((([i,r])=>{h[i]||(h[i]={node:t.nodesById[i],relation:"edge",edgeRelations:[]});var n=parseInt(e.split("-")[0]),o=parseInt(e.split("-")[1]);h[i].edgeRelations.push({edgeIndex:[n,o],nodeContourIndex:r})}))})),(null==e?void 0:e.find((t=>t.id===i.id))).interiors.forEach((e=>{h[e.id]={node:t.nodesById[e.id],relation:"contained"}})),{node:i,relationsById:h,relationsByEdgeIndex:a}}));return a}function Kt(t,e="",i=!1,r,n){var o,s,a={"a:helper:spaceDivider":["plan","level","group"],wall:["plan","level","group"],interior:["plan","level","interior","group","level"],window:["plan","level","wall"],door:["plan","level","wall"],polyfloor:["plan","level"],group:["plan","level","group"]},h=i?(o=Bt(t),JSON.parse(JSON.stringify(o))):t,l=[];if(i&&r&&(h=Nt(h,r)),n||h.type!==e){if(n&&h.id===n)return[h]}else l.push(h);var u=0;if(h.children&&(!a[e]||a[e].includes(h.type)))for(var p=0;p<h.children.length;p++){var c=h.children[p];"level"===c.type&&u++,u>1||(s=Kt(c,e,i,h,n),l=l.concat(s))}return l}function Qt(t,e){return Kt(t,e,!0)}var $t={"a:helper:spaceDivider":[],"a:reference:externalId":[],"a:relation:wall":[],"a:settings:display":[],"a:settings:generatedGroup":[],box:[],"camera-bookmark":[],closet:[],column:[],curtain:[],door:[],floor:[],floorplan:[],group:[],interior:[],kitchen:[],level:[],marker:[],object:[],plan:[],polybox:[],polyfloor:[],railing:[],roomStamp:[],stairs:[],tag:[],wall:[],window:[]},te=Object.keys($t);function ee(t,e={}){var i=ie(t,{});return ne(t,null,null,i),e.exportIdMap&&(t.idMap=i),t}function ie(t,e){return void 0!==t.id&&(e[t.id]=j()),t.children.forEach((t=>ie(t,e))),e}var re=t=>"[object Object]"===Object.prototype.toString.call(t);function ne(t,e,i,r){var n;"string"==typeof t?(void 0!==e&&void 0!==i&&r[t]&&(e[i]=r[t]),"string"==typeof i&&void 0!==e&&void 0!==i&&r[i]&&(e[r[i]]=t,delete e[i])):(re(t)||(n=t,"[object Array]"===Object.prototype.toString.call(n)))&&(re(t)&&t.type&&void 0===t.id&&(t.id=j()),Object.entries(t).forEach((([e,i])=>ne(i,t,e,r))))}var oe={colorDiffuse:{type:"array"},colorSpecular:{type:"array"},wireframeColor:{type:"array"},size:{type:"array"},specularCoef:{type:"number"},opacity:{type:"number"},wireframeOpacity:{type:"number"},wireframeThickness:{type:"number"},wireframeThresholdAngle:{type:"number"},lightEmissionCoef:{type:"number"},bsdfType:{type:"string"},wrap:{type:"string"},receiveRealTimeShadows:{type:"boolean"},hideAfterBaking:{type:"boolean"},castRealTimeShadows:{type:"boolean"},no2dOutline:{type:"boolean"},mapDiffuse:{type:"string"},mapDiffusePreview:{type:"string"},mapDiffuseSource:{type:"string"},mapDiffuseKey:{type:"string"},mapSpecular:{type:"string"},mapSpecularPreview:{type:"string"},mapSpecularSource:{type:"string"},mapSpecularKey:{type:"string"},mapNormal:{type:"string"},mapNormalPreview:{type:"string"},mapNormalSource:{type:"string"},mapNormalKey:{type:"string"},mapAlpha:{type:"string"},mapAlphaPreview:{type:"string"},mapAlphaSource:{type:"string"},mapAlphaKey:{type:"string"}},se=t=>{var e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"number"!==e||Number.isFinite(t)?e:"undefined"},ae={group:"a:settings:generatedGroup"},he={properties:{x:{type:"number"},y:{type:"number"},z:{type:"number"},ry:{type:"number"},id:{type:"string"}}};class le{constructor({node:t,parent:e,scene:i,emitter:r,options:n={}}){var o;if("object"!=typeof t)throw new Error("node has to be type object: "+t);if(!t.type)throw new Error("node invalid, type is missing: "+JSON.stringify(t));void 0===n.setDefaults&&(n.setDefaults=!1),void 0===n.regenerateIds&&(n.regenerateIds=!1),this._scene=i,this._emitter=r;var s=t.children||[];t.children=[],!t.id||n.setDefaults||n.regenerateIds?this._update(fe(t,this.schema,n)):this._update(t),this._parent=e,e&&e.children.push(this),(null==(o=this._scene)?void 0:o.registerNode)&&this._scene.registerNode(this);var a="add-child";this._emitter&&this._emitter.emit(a,{node:e,args:this,options:n,event:a}),s.filter((t=>(t.type||console.warn("Prevent import from scene structure: Invalid type",t.type+""),t.type))).forEach((t=>this.addChild(t,n)))}get parent(){return this._parent}get scene(){return this._scene}get schema(){var t;return null==(t=this._scene)?void 0:t.schema}_update(t={}){var e,i,r=null==(i=null==(e=this._scene)?void 0:e.schema)?void 0:i[this.type],{properties:n}=r||he;for(var o in t){var s=null==n?void 0:n[o];if(!r||s||"_"===o[0]){var{minimum:a,maximum:h,type:l,enum:u}=s||{};if("number"===l){if("string"==typeof t[o]&&(t[o]=Number(t[o]),console.log(this.type+"."+o,"converted from string to number")),!Number.isFinite(t[o]))throw new Error("".concat(this.type,".").concat(o," = ").concat(t[o]," is invalid"));var p=Number.isFinite(a)&&t[o]<a,c=Number.isFinite(h)&&t[o]>h;if(p||c){var d=p?"min:"+a:"max:"+h;throw new Error("".concat(this.type,".").concat(o," = ").concat(t[o]," is out of range ").concat(d))}}if("string"===l){if("string"!=typeof t[o])throw new Error("".concat(this.type,".").concat(o," = '").concat(t[o],"' is invalid"));if(u&&!u.includes(t[o]))throw new Error("".concat(this.type,".").concat(o," = '").concat(t[o],"' is invalid"))}("_isSelected"!==o||t[o])&&("_highlight"!==o||t[o])?this[o]=t[o]:delete this[o]}else delete t[o]}}set(t={},e={}){if(this.locked&&!e.force){var i=[];for(var r in t)switch(r){case"locked":case"_highlight":case"_isSelected":i.push(r)}if(!(i.length>0))return void console.log("Node ID ".concat(this.id," is locked and cannot be altered."));var n={};for(var o of i)n[o]=t[o];t=n}t.id&&delete t.id,t.src&&delete t.src,t.children&&delete t.children;var s={};for(var a in t)s[a]=this[a];try{this._update(t)}catch(t){return void console.warn(t.message)}if(this._emitter){var h=0,l=0;for(var u in t)switch(t[u]===s[u]&&(delete t[u],delete s[u]),h++,u){case"x":case"y":case"z":case"ry":l++}var p=l===h?"set-transform":"set";Object.keys(t).length&&this._emitter.emit(p,{node:this,args:t,prevState:s,options:e,event:p})}}setTransform({x:t,y:e,z:i,ry:r}={},n={}){if(!this.locked||n.force){var o={},s={};if(void 0!==t){var a=Number(t);this.x!==a&&Number.isFinite(a)&&(s.x=this.x,o.x=this.x=a)}if(void 0!==e){var h=Number(e);this.y!==h&&Number.isFinite(h)&&(s.y=this.y,o.y=this.y=h)}if(void 0!==i){var l=Number(i);this.z!==l&&Number.isFinite(l)&&(s.z=this.z,o.z=this.z=l)}if(void 0!==r){var u=Number(r);this.ry!==u&&Number.isFinite(u)&&(s.ry=this.ry,o.ry=this.ry=u)}var p="set-transform";this._emitter&&Object.keys(o).length&&this._emitter.emit(p,{node:this,args:o,prevState:s,options:n,event:p})}else console.log("Node ID ".concat(this.id," is locked and cannot be altered."))}setMaterials(t={},i={}){var r=this;if(!this.locked||i.force){var n=Object.keys(oe),o={},s=0,a={},h=function(e){var i=t[e],h=se(i),l="string"===h,u="object"===h&&Object.keys(i).every((t=>{var e,r=n.includes(t),o=r&&se(i[t])===(null==(e=oe[t])?void 0:e.type);return r&&o}));(l||u)&&(a[e]=r[e],o[e]=t[e],s++)};for(var l in t)h(l);if(s<1)console.log("no valid material definitions in",t);else{var u=e(e({},this.materials||{}),t);try{this._update({materials:u})}catch(t){return void console.warn(t.message)}var p="set-materials";this._emitter&&this._emitter.emit(p,{node:this,args:t,prevState:a,options:i,event:p})}}else console.log("Node ID ".concat(this.id," is locked and cannot set materials."))}setTransient(t={},i={}){var r={},n=0,o={};for(var s in t)"_"===s[0]&&(o[s]=this[s],r[s]=t[s],n++);if(n<1)console.log("no transient values in",t,"use underscore");else{try{this._update(e({},r))}catch(t){return void console.warn(t.message)}var a="set-transient";this._emitter&&this._emitter.emit(a,{node:this,args:t,prevState:o,options:i,event:a})}}setHighlight(t={},i={}){var r,n={_highlight:this._highlight},{fill:o,fillOpacity:s,outline:a,outlineWidth:h}=t;o&&Array.isArray(o)&&(r={fill:o,fillOpacity:s}),a&&Array.isArray(a)&&(r=e(e({},r||{}),{},{outline:a,outlineWidth:h}));var l={_highlight:r};try{this._update(l)}catch(t){return void console.warn(t.message)}var u="set-transient";this._emitter&&this._emitter.emit(u,{node:this,args:l,prevState:n,options:i,event:u})}find(t={}){return t.id||t.type&&"string"==typeof t.type&&te.includes(t.type)?(this.traverse((i=>{e||(t.id&&i.id===t.id||t.type&&i.type===t.type)&&(e=i)})),e):(console.warn("type missing or invalid"),null);var e}findAll(t={}){if(!t.type||"string"!=typeof t.type||!te.includes(t.type))return console.warn("type missing or invalid"),[];var e=[];return this.traverse((i=>i.type===t.type&&e.push(i))),e}addChild(t,e={}){var i,r;if(t.type&&"string"==typeof t.type&&te.includes(t.type))if(!this.locked||["level","plan"].includes(this.type)||e.force){if(!t.id||!(null==(r=null==(i=this.scene)?void 0:i.nodesById)?void 0:r[t.id])||e.regenerateIds)return void 0===e.setDefaults&&(e.setDefaults=!0),new le({node:t,parent:this,scene:this._scene,emitter:this._emitter,options:e});console.warn("Node with id ".concat(t.id," already exists and can not be added - use options.regenerateIds = true"))}else console.log("Node ID ".concat(this.id," is locked and cannot add children."));else console.warn("type missing or invalid")}removeChild(t,e={}){var i;if(t.id)if(!this.locked||["level","plan"].includes(this.type)||e.force){for(var r,n=0;n<this.children.length;n++)if(this.children[n].id===t.id){r=n;break}if(Number.isFinite(r)){for(var o=t.children||[],s=o.length-1;s>=0;s--)t instanceof le&&o[s]&&t.removeChild(o[s],e);(null==(i=this._scene)?void 0:i.unregisterNode)&&this._scene.unregisterNode(t),this.children.splice(r,1);var a="remove-child";this._emitter&&this._emitter.emit(a,{node:this,args:t,options:e,event:a}),((null==t?void 0:t.getReferringNodes)?t.getReferringNodes():[]).forEach((t=>t.remove(e)))}else console.warn("Node does not exist or is already removed",t)}else console.log("Node ID ".concat(this.id," is locked and cannot remove children."));else console.error("not valid")}remove(t){!this.locked||t.force?this.parent.removeChild(this,t):console.warn("Node ID ".concat(this.id," is locked and cannot be removed."))}getReferringNodes(){var t,e,i=[],r=null==(t=this._scene)?void 0:t.nodesByType["a:relation:"+this.type];r&&r.forEach((t=>{var e;(null==(e=null==t?void 0:t.nodeIds)?void 0:e.hasOwnProperty(this.id))&&i.push(t)}));var n=ae[this.type]||"a:settings:"+this.type,o=null==(e=this._scene)?void 0:e.nodesByType[n];return o&&o.forEach((t=>{(null==t?void 0:t.nodeId)==this.id&&i.push(t)})),i}getWorldPosition(){return ce(this)}getLocalPositionFromWorld(t){var e=this.getParents();return(null==e?void 0:e.length)&&e.reverse().forEach((e=>{t=Rt(t,e)})),t}getParents(){return de(this)}toJson(t={}){var e=Bt(this,t),i=JSON.parse(JSON.stringify(e));return t.regenerateIds&&ee(i,t),i}traverse(t){"function"==typeof t&&(t(this),this.children.forEach((e=>{e.traverse(t)})))}}var ue,pe,ce=(t,e)=>{var i=e?e.parent:t.parent;if(!i)return console.warn("no parent found"),t;var r=Nt(t,i);return i.parent&&(r=ce(r,i)),r},de=t=>{var e=[],i=t.parent;return i&&e.push(i),(null==i?void 0:i.parent)&&(e=e.concat(de(i))),e},fe=(t,e,{setDefaults:i,regenerateIds:r})=>{if(!e&&i)throw new Error("schema is missing");if(!t)throw new Error("node missing");var n,o=e&&e[t.type];if(o&&i){if(n=((t,e)=>{if(e&&e.properties){var i={};return Object.keys(e.properties).forEach((t=>{var r=e.properties[t],n=r.const||r.default;void 0!==n&&(i[t]=n)})),"interior"!==t||i.src||(i.src="!7dddc882-1def-4497-80e3-d1de834a1a7b"),JSON.parse(JSON.stringify(i))}console.warn("schema is missing for type ".concat(t))})(t.type,o),!n)throw new Error("no defaults found")}else n={};var s=Object.assign(n,t);if(!s)throw new Error("applying defaults failed");return t.id&&!r||(s.id=j()),s};(pe=ue||(ue={})).residential="residential",pe.office="office";var ve={work:{name:"Work",isHidden:!0,description:"space for individual head-down work",spaceUsage:{privateOffice:{name:"Private office",category:[ue.office]},openWorkspace:{name:"Open workspace",category:[ue.office]},enclosedWorkspace:{name:"Enclosed workspace",category:[ue.office]},closedWorkspace:{name:"Closed workspace",isDeprecated:!0,category:[ue.office]},executiveOffice:{name:"Executive office",isDeprecated:!0,category:[ue.office]}}},meet:{name:"Meet",isHidden:!0,spaceUsage:{meetingRoom:{name:"Meeting room",category:[ue.office]},hub:{name:"Hub",category:[ue.office]},assembly:{name:"Assembly",category:[ue.office]},boardRoom:{name:"Board Room",category:[ue.office]},trainingRoom:{name:"Training Room",category:[ue.office]},collaboration:{name:"Collaboration",isDeprecated:!0,category:[ue.office]}}},live:{name:"live",isHidden:!0,spaceUsage:{living:{name:"Living",category:[ue.residential]},dining:{name:"Dining",category:[ue.residential]},dining_living:{name:"Living & Dining",category:[ue.residential]},homeOffice:{name:"Home office",category:[ue.residential]},bedroom:{name:"Bedroom",category:[ue.residential]}}},socialize:{name:"Socialize",isHidden:!0,spaceUsage:{lobby:{name:"Lobby",category:[ue.office,ue.residential]},reception:{name:"Reception",category:[ue.office]},lounge:{name:"Lounge",category:[ue.office]},cafe:{name:"Cafe",category:[ue.office]},canteen:{name:"Canteen",category:[ue.office]},pantry:{name:"Pantry",category:[ue.office]},terrace:{name:"Terrace",isOutdoor:!0,category:[ue.office,ue.residential]},balcony:{name:"Balcony",isOutdoor:!0,category:[ue.office,ue.residential]},rooftop:{name:"Rooftop",isOutdoor:!0,category:[ue.office,ue.residential]},courtyard:{name:"Courtyard",isOutdoor:!0,category:[ue.office,ue.residential]},garden:{name:"Garden",isOutdoor:!0,category:[ue.residential]},common:{name:"Common",isDeprecated:!0,category:[ue.office]}}},support:{name:"Support",isHidden:!0,spaceUsage:{printStation:{name:"Print station",category:[ue.office]},storage:{name:"Storage",category:[ue.residential,ue.office]},mailRoom:{name:"Mail room",category:[ue.office]},operationalRoom:{name:"Operational room",category:[ue.office]},serviceRoom:{name:"Service room",category:[ue.office]},laundryRoom:{name:"Laundry room",category:[ue.residential]},operate:{name:"Operate",isDeprecated:!0,category:[ue.office]},services:{name:"Services",isDeprecated:!0,category:[ue.office,ue.residential]}}},care:{name:"Care",isHidden:!0,spaceUsage:{kitchen:{name:"Kitchen",category:[ue.residential]},wellnessRoom:{name:"Wellness room",category:[ue.office]},restroom:{name:"Restroom",category:[ue.office]},bathroom:{name:"Bathroom",category:[ue.residential]},shower:{name:"Shower",category:[ue.office,ue.residential]},toilet:{name:"Toilet",category:[ue.residential]}}},circulate:{name:"Circulate",isHidden:!0,spaceUsage:{corridor:{name:"Corridor",category:[ue.residential,ue.office]},staircase:{name:"Staircase",category:[ue.residential,ue.office]},elevator:{name:"Elevator",category:[ue.residential,ue.office]},foyer:{name:"Foyer",category:[ue.residential,ue.office]},garage:{name:"Garage",category:[ue.residential,ue.office]}}},void:{isHidden:!0,name:"Void",spaceUsage:{shaft:{name:"Shaft",category:[ue.residential,ue.office]},buildingOpening:{name:"Building opening",category:[ue.residential,ue.office]},floorOpening:{name:"Floor opening",category:[ue.residential,ue.office]}}},undefined:{isHidden:!0,spaceUsage:{undefined:{name:"",category:[ue.residential,ue.office],isHidden:!0}}}},ye={};Object.keys(ve).forEach((t=>{var i=ve[t];ye[t]={name:i.name,type:"program",category:[]},i.isHidden&&(ye[t].isHidden=i.isHidden);var r={};Object.keys(ve[t].spaceUsage).forEach((i=>{var n=ve[t].spaceUsage[i];ye[i]=e(e({},n),{},{type:"space",program:t}),n.category.forEach((t=>{r[t]=!0}))})),ye[t].category=Object.keys(r)}));var ge=(t="")=>{"officeWorking"===t?t="work":"officeMeeting"===t&&(t="meet");var e=ye[t];return e?e.name:""},me=(t="")=>{var e,i=ye[t];return i&&(e="program"===i.type?t:i.program),e};function _e({scene:t,uuid:e}){var i=t.nodesByType.polyfloor;e&&(i=i.filter((t=>t.id===e)));var r=t.nodesByType.interior.map((t=>t.getWorldPosition())),n=i.map((e=>{var i=Wt({node:e});if(i.length){var n=Math.abs(i.reduce(((t,e)=>t+yt(e)),0)),o=Lt(i[0],i.slice(1)),s=lt(i),{interiors:a}=function({uuid:t,polygons:e,scene:i,interiors:r}){var n,o=(n=e&&e.length?e:Wt({uuid:t,scene:i}))[0],s=n.slice(1);return o=pt([o],.05)[0],r||(r=i.nodesByType.interior.map((t=>t.getWorldPosition()))),{interiors:r.filter((t=>{if(t.src&&t.x&&t.z)return ft([t.x,t.z],o,s)}))}}({polygons:i,scene:t,interiors:r});return{node:e,boundingBox:s,id:e.id,usage:e.usage,usageName:ge(e.usage),program:me(e.usage),polygons:i,interiors:a,area:n,center:o,customId:e.customId,name:e.name}}}));return n.flatMap((t=>t?[t]:[]))}function xe(t){var e=.01,i=t.nodesByType.column.map((t=>t.getWorldPosition())),r=t.nodesByType.wall.map((t=>t.getWorldPosition())),n=t.nodesByType["a:helper:spaceDivider"].map((t=>t.getWorldPosition())).map(Ft);n=pt(n,e,0,!0);var o=[...r,...i].map((t=>{var i=Ft(t);if(i.length&&yt(i))return i=pt([i],e)[0]})).flatMap((t=>t?[t]:[])),s=o.length?ut([...o,...n]):[];s.length&&(s=mt(s).filter((t=>t.length)));var{clockwise:a,counterClockwise:h}=Yt(s);a.length&&(a=a.map((t=>{var i=pt([t],e);if(i.length)return(i=i.sort(((t,e)=>gt(t)>gt(e)?-1:1)))[0]})).flatMap((t=>t&&yt(t)>.1?[t]:[])).map(Gt));var l=h.sort(((t,e)=>gt(t)>gt(e)?-1:1)),u=l.length?l[0]:[];u.length&&(u=pt([u],-.01)[0]);var p=jt(a,h);return{spaces:a,holes:p=p.map((t=>t.length?t.map((t=>pt([t],-.01)[0])).filter((t=>t)).map(Ht):t)),outline:u}}class be{constructor({schema:t}={}){this.sceneId=null,this.node=null,this._apiVersion="2.2.0",this.nodesById={},this.nodesByType=JSON.parse(JSON.stringify($t)),this.nodesByName={},this._schema=t||{},this._emitter=new G}get emitter(){return this._emitter}get schema(){return this._schema}set schema(t){"object"==typeof t&&(this._schema=t)}loadSceneStructure(t,e={}){if(this._emitter.emit("scene-structure-loading",this),!t||"plan"!==t.type)throw new Error("invalid sceneStructure");this.nodesById={},this.nodesByType=JSON.parse(JSON.stringify($t)),this.node=null;var i=JSON.parse(JSON.stringify(t));return Number.isFinite(e.planRotation)&&(i._ryOrg=t.ry,i.ry=e.planRotation),this.node=new le({node:i,scene:this,emitter:this.emitter,options:e}),this.setSceneType(),this._emitter.emit("scene-structure-loaded",this),this.node}setSceneType(){var t=this.node.class;if(null==t?void 0:t.length)t.includes("residential")?this.type="residential":t.includes("commercial")&&(this.type="commercial");else{var e=this.nodesByType.polyfloor.map((t=>t.usage));e.includes("bedroom")?this.type="residential":(e.includes("work")||e.includes("meetingRoom")||e.includes("openWorkspace"))&&(this.type="commercial")}}getFloorArea(){var t=_e({scene:this}).reduce(((t,e)=>t+e.area),0);return Math.round(10*t)/10}registerNode(t){this.nodesById[t.id]&&console.error("Duplicate id",t.id),this.nodesById[t.id]=t,this.nodesByType[t.type]=this.nodesByType[t.type]||[],this.nodesByType[t.type].push(t),t.name&&(this.nodesByName[t.name]=this.nodesByName[t.name]||[],this.nodesByName[t.name].push(t))}unregisterNode(t){t.id&&delete this.nodesById[t.id];var e=(e,i)=>{if(e[t[i]]){var r=e[t[i]].findIndex((e=>e.id===t.id));Number.isFinite(r)&&e[t[i]].splice(r,1)}};e(this.nodesByType,"type"),e(this.nodesByName,"name")}on(t,e,i){t&&e?this._emitter.on(t,e,i):console.log("invalid event listener")}once(t,e,i){t&&e?this._emitter.once(t,e,i):console.log("invalid event listener")}off(t,e){t&&e?this._emitter.off(t,e):console.log("invalid request")}emit(t,e,i,r,n){this._emitter.emit(t,e,i,r,n)}get apiVersion(){return this._apiVersion}}function Pe(t,e){return{type:"line",start:t,end:e}}function we(t,e,i,r=!1){return{type:"rect",position:t,width:e,height:i,isContour:r}}function Ee(t,e){return{type:"circle",position:t,r:e}}new q({size:256});var Te=({points:t,oldRotation:i,newRotation:r,rootNode:n})=>t.map((t=>{var o={ry:0,x:t[0],z:t[1],y:0};return Rt(o,{x:n.x,y:n.y,z:n.z,ry:i},!0),[(o=Nt(o,e(e({},n),{},{ry:r}))).x,o.z]})),Ce=({gfx:t,points:e,state:i,doneDrawing:r=!1})=>{var n=[{type:"polygon",points:r?e:[...e,i.snapCursor.pos],isContour:!0,props:{fill:16777215,fillOpacity:1,isContour:!0,stroke:4605266,strokeWidth:.5,native:!0}}];t.draw({shapes:n})},Ie=(t,e)=>t.map(((i,r)=>{var n=t[r+1]||t[0];return((t,e)=>{var i=(t.x*e.x+t.y*e.y)/(Math.sqrt(t.x*t.x+t.y*t.y)*Math.sqrt(e.x*e.x+e.y*e.y));return(-.6981317007977321*i*i-.8726646259971648)*i+1.5707963267948966})({x:i[0]-e[0],y:i[1]-e[1]},{x:n[0]-e[0],y:n[1]-e[1]})})),Se={start:!0,end:!0,drag:!0},Oe={x:"number",z:"number",ry:"number"},Ae={box:Oe,closet:Se,column:Oe,curtain:Se,door:Se,floor:{x:"number",z:"number",l:"number"},floorplan:Oe,group:Oe,interior:Oe,object:Oe,kitchen:Se,polybox:e(e({},Oe),{},{polygon:!0}),polyfloor:{},railing:Se,stairs:Se,wall:Se,"a:helper:spaceDivider":Se,window:Se};function Me(t){var i,r,n,o;if(!this)throw new Error("Viewport context is missing");var s=this._dragStart||{},a=t.data.global||{},h=Math.abs(a.x-s.x),l=Math.abs(a.y-s.y);if(h<5&&l<5&&!this.isDragging){var u,p=(new Date).getTime();if(this.lastClick){var c=p-this.lastClick.time,d=this.lastClick.pos&&Math.max(Math.abs(a.x-this.lastClick.pos.x),Math.abs(a.y-this.lastClick.pos.y));u=c<400&&d<10}var f=null==t||null===(i=t.target)||void 0===i||null===(r=i._handlerType)||void 0===r?void 0:r.includes("polygon-point");this.lastClick={time:p,pos:e({},a)};var v=this._getState(),y=u?"dblclick":"click",g=null===(n=t.target)||void 0===n?void 0:n._nodeId,{x:m,y:_}=(null===(o=t.data)||void 0===o?void 0:o.global)||{},x=v.getPlanPosition([m,_]);v.cursor=[...x];var b={sourceEvent:t,nodeId:g,pos:x,isDoubleClick:!!u,polygonClick:f&&t.target._handlerType};if(null!=g&&g.length&&g.includes("marker_")){var P,w,E,T,C=g.replace("marker_",""),I=v.markerPins.find((t=>t.id===C)),S=null===(P=I.events)||void 0===P||null===(w=P.click)||void 0===w?void 0:w.callback,O=null===(E=I.events)||void 0===E||null===(T=E.click)||void 0===T?void 0:T.context;if(S)return void(O?S.bind(O)(b):S(b))}if(v._splitWallHelper)return v._splitWallHelper.split(),void v.setActive({nodeId:v.active[0].id});v.emit(y,b)}}function Le(t){var e=this._getState();"Viewport"===t.target.constructor.name&&e.setActive();var{x:i,y:r}=t.data.global;e.windowPos=[i,r],e.lastSceneClick=e.getPlanPosition(e.windowPos),e.rightClick=!0}function Ne({sourceEvent:t,nodeId:e,state:i,forceSelect:r=!1,activateGroup:n=!1,isDoubleClick:o,isMultiselect:s,polygonClick:a}={}){var h=(null==t?void 0:t.currentTarget)||i&&i._getViewport();i=i||h&&h._getState();var l=s||t&&t.data.originalEvent.shiftKey;if(i&&h&&i.settings.selectElements&&(!i.isDragging||i.altKey)&&h._getHandler&&!i.isMeasuring&&!i.isCreatingElement){if(i.rightClick)return i.emit("context-menu",{sourceEvent:t,nodeId:e}),void(i.rightClick=!1);var u=h._getHandler();if(o){var p,c,d=null===(p=i.active[0])||void 0===p?void 0:p.type;if(null!==(c=Ae[d])&&void 0!==c&&c.polygon){var{x:f,y:v}=t.data.global,y=i.getPlanPosition([f,v]);if(a)(({handler:t,index:e,state:i})=>{if(i.active[0].polygon.length<4)i.setMessage("A polygon requires at least 3 points");else if(!isNaN(e)){var r=i.active[0].polygon.slice();r.splice(e,1),i.active[0].set({polygon:r}),t._update({handler:t,state:i})}})({handler:u,index:Number(a.split("_")[1]),state:i});else(({handler:t,pos:e,state:i})=>{var r=i.active[0].getLocalPositionFromWorld({x:e[0],z:e[1]}),{x:n,z:o}=Rt(r,i.active[0]),s=Ie(i.active[0].polygon,[n,o]),a=s.indexOf(Math.max(...s)),h=i.active[0].polygon.slice();h.splice(a+1,0,[n,o]),i.active[0].set({polygon:h}),t._update({handler:t,state:i})})({handler:u,pos:y,state:i});return}n=!0}if(i.active.length&&i.active.forEach((t=>{i.scene.nodesById[t.id]&&t.setTransient({_isSelected:!1})})),e){l||(i.active=[]);var g=l&&i.active.findIndex((t=>t.id===e)),m=Number.isFinite(g)&&g>=0;m&&i.active.splice(g,1);var _=i.scene.nodesById[e],x=!!i.active.find((t=>"polyfloor"===t.type));if(i.active.length>0&&(x&&"polyfloor"!==_.type||!x&&"polyfloor"===_.type))return i.active.forEach((t=>t.setTransient({_isSelected:!0}))),void i.emit("select",{node:i.active[0]});if(!_)return;if(i.settings.selectAllowList.length&&!i.settings.selectAllowList.includes(_.type))return i.active=[],i.activeGroup=null,u.visible=!1,void i.emit("select",{});var b,P=_.getParents(),w=i.activeGroup&&P.some((t=>t.id===i.activeGroup));if(!r)for(var E of P){if("group"!==E.type||i.activeGroup===E.id)break;b=E}var T=!!b||"group"===_.type;if(i.activeGroup&&!w)return i.emit("draw-xray",{xrayMode:!1}),i.activeGroup=null,void(u.visible=!1);if(n&&T)return i.activeGroup&&i.emit("draw-xray",{xrayMode:!1}),i.activeGroup=b?b.id:e,i.emit("draw-xray",{xrayMode:!0}),u.visible=!1,i.active=[],void i.emit("select",{});if(b?i.active.push(b):m||i.active.push(_),i.active.forEach((t=>t.setTransient({_isSelected:!0}))),t&&t.data){var{x:C,y:I}=t.data.global;i.windowPos=[C,I],i.lastSceneClick=i.getPlanPosition(i.windowPos)}var S=i.active[0].getWorldPosition();u.visible=!0,u.x=S.x*i.scale,u.y=S.z*i.scale,u.rotation=Math.PI/180*-S.ry,1===i.active.length&&i.active[0].locked||i.emit("handler",{handler:u,state:i}),i.viewportNeedsUpdate=!0}else i.active=[],i.activeGroup&&i.emit("draw-xray",{xrayMode:!1}),i.activeGroup=null,u.visible=!1;i.emit("select",{node:i.active[0]})}}var Re=o.debug;function De({walls:t,data:e,options:i={updateState:!0,singleConnect:!1,preservePos:!1}}){if(t){e||(e=t.map(Dt));var r=t.every((t=>"a:helper:spaceDivider"===t.type)),n=i.actionId,o=t[0].ry<=180?t[0].ry:t[0].ry-180,s=t[1].ry<=180?t[1].ry:t[1].ry-180,a=Math.abs(parseInt(o)-parseInt(s));if(a<1)return{};if(i.preservePos&&a>170&&a<190)return{};var h,l,u,p,c,d,f,v,y,g,m,_,x,b,P=2,w=[e[0].p1,e[1].p1],E=[e[0].p2,e[1].p2],T=[e[0].p3,e[1].p3],C=[e[0].p4,e[1].p4],I=[e[0].nL,e[1].nL],S=[],O=[e[0].w,e[1].w],A=[],M=[],L=[],N=[],R=[];for(h=tt(w[0],E[0],w[1],E[1]),u=rt(l=tt(w[0],E[0],T[1],C[1]),O[1]),c=rt(p=tt(T[0],C[0],w[1],E[1]),O[0]),f=rt(d=tt(T[0],C[0],T[1],C[1]),O[0]),v=rt(d,O[1]),b=0;b<P;b++)y=Z(w[b],h),(g=Z(E[b],h))>y?(A[b]=g,N[b]={x:E[b].x,z:E[b].z},L[b]=!1,R[b]=y>20):(A[b]=y,N[b]={x:w[b].x,z:w[b].z},L[b]=!0,R[b]=g>20),S[b]={x:(N[b].x-h.x)/A[b],z:(N[b].z-h.z)/A[b]},M[b]=Z(N[b],b<1?f:v);if(R[0]&&R[1])return Re&&console.log("intersection too far away"),{};if(_=Fe(I[0],I[1]),(x=Fe(S[0],S[1]))<10)return Re&&console.log("angle too small"),{};i.singleConnect&&(P=1);var D=[];for(b=0;b<P;b++){r?m=h:Math.round(_)>=88&&Math.round(_)<=92?m=L[0]===L[1]?M[0]<A[0]?_>90?b<1?l:v:b<1?f:v:_>90&&b<1?c:h:M[0]<A[0]?b<1?l:u:b<1?c:p:_<90?x<=90||M[0]<A[0]?m=h:M[0]>A[0]&&(m=b<1?f:v):x<=90?m=b<1?l:u:M[0]<A[0]?m=b<1?c:p:M[0]>A[0]&&(m=b<1?l:u);var F=t[b].l;if(!m)return Re&&console.log("pSnap failed"),{};var k=Z(N[b],m);if(Math.abs(k-F)>.5&&Re&&console.log("delta",ht(k-F),"new",ht(k),"old",ht(F)),L[b])t[b].set({l:k},{updateState:i.updateState,actionId:n}),D[b]="end";else{"back"!==t[b].controlLine&&(m.x+=-e[b].p1.x+e[b].l1.x,m.z+=-e[b].p1.z+e[b].l1.z),t[b].set({x:m.x,z:m.z,l:k},{updateState:i.updateState,actionId:n}),D[b]="start";var B=t[b].children||[];if(B.length>0)for(var U=0;U<B.length;U++){var z=B[U].x-F+k;z=Math.max(0,z),z=Math.min(k-B[U].l,z),B[U].set({x:z},{updateState:i.updateState,actionId:n})}}}return{walls:t,connections:D}}}function Fe(t,e){return ht(180*Math.acos(t.x*e.x+t.z*e.z)/Math.PI,2)}var ke=({state:t,wall1:e,wall2:i,rel1:r,rel2:n,actionId:o})=>{if(e&&i){var s=[...Be({state:t,wall:e}),...Be({state:t,wall:i})].reduce(((t,e)=>t.find((t=>t.node.id===e.node.id))?t:t.concat(e)),[]);if(!s.some((t=>{var o=t.node.nodeIds;return o[e.id]&&o[i.id]&&o[e.id]===r&&o[i.id]===n}))){s.forEach((t=>{var s=t.node.nodeIds;"edge"!==r&&s[e.id]&&s[e.id]===r&&t.node.remove({actionId:o}),"edge"!==n&&s[i.id]&&s[i.id]===n&&t.node.remove({actionId:o})}));var a={type:"a:relation:wall",nodeIds:{[e.id]:r,[i.id]:n}};return t.getActiveLevel().addChild(a,{actionId:o})}}},Be=({state:t,wall:e})=>t.computed.relations.walls.filter((t=>Object.keys(t.node.nodeIds).includes(e.id))),Ue=(t,e,i,r=!1)=>{var n=e.find((e=>e.id===Object.keys(t.nodeIds)[0]));if(n&&n.id){var o,s,a,h,l=Object.keys(t.nodeIds),u=l.map((e=>{var r=i.scene.nodesById[e];return r&&{relation:t.nodeIds[r.id],node:r}})).filter((t=>t));if(u.length<2)return console.log("invalid wall relation"),void t.remove();if(l.forEach((i=>{"start"===t.nodeIds[i]&&(o=e.find((t=>t.id===i))),"edge"===t.nodeIds[i]&&(s=e.find((t=>t.id===i))),"end"===t.nodeIds[i]&&(a=e.find((t=>t.id===i)))})),o){var{x:p,z:c}=o;h=[p,c]}else if(a){var d=Dt(a).l2;h=[d.x,d.z]}return h?{node:t,point:h,isEdge:!!s,relatedNodes:u}:(console.log("invalid wall relation"),void t.remove())}r&&t.remove()},ze=t=>{if(!t.settings.loadWallRelations)return[];var e=t.scene.nodesByType["a:relation:wall"]||[];if(!e.length)return[];var i=t.scene.nodesByType.wall.map((t=>t.getWorldPosition())),r=t.scene.nodesByType["a:helper:spaceDivider"].map((t=>t.getWorldPosition()));return e.map((e=>Ue(e,i.concat(r),t))).filter((t=>t))},Xe=(t,e=[],i)=>{e.forEach((e=>{var r=e.isEdge;De({walls:e.relatedNodes.sort(((t,e)=>"edge"===t.relation?1:"edge"===e.relation?-1:void 0)).map((t=>t.node)),options:{updateState:!1,singleConnect:r,actionId:i}}),((t,e,i)=>{if(t.computed.relations.walls){var r=Ue(e,i,t,!0),n=t.computed.relations.walls.findIndex((t=>t.node.id===e.id));r?t.computed.relations.walls[n]=r:t.computed.relations.walls.splice(n,1)}})(t,e.node,[e.relatedNodes[0].node.getWorldPosition(),e.relatedNodes[1].node.getWorldPosition()])}))},je="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ye="object"==typeof je&&je&&je.Object===Object&&je,He="object"==typeof self&&self&&self.Object===Object&&self,Ge=Ye||He||Function("return this")(),We=Ge.Symbol,Ve=Object.prototype,qe=Ve.hasOwnProperty,Ze=Ve.toString,Je=We?We.toStringTag:void 0;var Ke=Object.prototype.toString;var Qe=We?We.toStringTag:void 0;function $e(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Qe&&Qe in Object(t)?function(t){var e=qe.call(t,Je),i=t[Je];try{t[Je]=void 0;var r=!0}catch(t){}var n=Ze.call(t);return r&&(e?t[Je]=i:delete t[Je]),n}(t):function(t){return Ke.call(t)}(t)}function ti(t){return null!=t&&"object"==typeof t}function ei(t){return"symbol"==typeof t||ti(t)&&"[object Symbol]"==$e(t)}function ii(t,e){for(var i=-1,r=null==t?0:t.length,n=Array(r);++i<r;)n[i]=e(t[i],i,t);return n}var ri=Array.isArray,ni=We?We.prototype:void 0,oi=ni?ni.toString:void 0;function si(t){if("string"==typeof t)return t;if(ri(t))return ii(t,si)+"";if(ei(t))return oi?oi.call(t):"";var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e}var ai=/\s/;var hi=/^\s+/;function li(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ai.test(t.charAt(e)););return e}(t)+1).replace(hi,""):t}function ui(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var pi=/^[-+]0x[0-9a-f]+$/i,ci=/^0b[01]+$/i,di=/^0o[0-7]+$/i,fi=parseInt;function vi(t){if("number"==typeof t)return t;if(ei(t))return NaN;if(ui(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ui(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=li(t);var i=ci.test(t);return i||di.test(t)?fi(t.slice(2),i?2:8):pi.test(t)?NaN:+t}function yi(t){return t}function gi(t){if(!ui(t))return!1;var e=$e(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var mi=Ge["__core-js_shared__"],_i=function(){var t=/[^.]+$/.exec(mi&&mi.keys&&mi.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();var xi=Function.prototype.toString;function bi(t){if(null!=t){try{return xi.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Pi=/^\[object .+?Constructor\]$/,wi=Function.prototype,Ei=Object.prototype,Ti=wi.toString,Ci=Ei.hasOwnProperty,Ii=RegExp("^"+Ti.call(Ci).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Si(t){return!(!ui(t)||(e=t,_i&&_i in e))&&(gi(t)?Ii:Pi).test(bi(t));var e}function Oi(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return Si(i)?i:void 0}var Ai=Oi(Ge,"WeakMap"),Mi=Object.create,Li=function(){function t(){}return function(e){if(!ui(e))return{};if(Mi)return Mi(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();function Ni(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}function Ri(t,e){var i=-1,r=t.length;for(e||(e=Array(r));++i<r;)e[i]=t[i];return e}var Di=Date.now;var Fi,ki,Bi,Ui=function(){try{var t=Oi(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),zi=Ui,Xi=zi?function(t,e){return zi(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:yi,ji=(Fi=Xi,ki=0,Bi=0,function(){var t=Di(),e=16-(t-Bi);if(Bi=t,e>0){if(++ki>=800)return arguments[0]}else ki=0;return Fi.apply(void 0,arguments)});var Yi=/^(?:0|[1-9]\d*)$/;function Hi(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Yi.test(t))&&t>-1&&t%1==0&&t<e}function Gi(t,e,i){"__proto__"==e&&zi?zi(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function Wi(t,e){return t===e||t!=t&&e!=e}var Vi=Object.prototype.hasOwnProperty;function qi(t,e,i){var r=t[e];Vi.call(t,e)&&Wi(r,i)&&(void 0!==i||e in t)||Gi(t,e,i)}function Zi(t,e,i,r){var n=!i;i||(i={});for(var o=-1,s=e.length;++o<s;){var a=e[o],h=r?r(i[a],t[a],a,i,t):void 0;void 0===h&&(h=t[a]),n?Gi(i,a,h):qi(i,a,h)}return i}var Ji=Math.max;function Ki(t,e){return ji(function(t,e,i){return e=Ji(void 0===e?t.length-1:e,0),function(){for(var r=arguments,n=-1,o=Ji(r.length-e,0),s=Array(o);++n<o;)s[n]=r[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=r[n];return a[e]=i(s),Ni(t,this,a)}}(t,e,yi),t+"")}function Qi(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function $i(t){return null!=t&&Qi(t.length)&&!gi(t)}function tr(t,e,i){if(!ui(i))return!1;var r=typeof e;return!!("number"==r?$i(i)&&Hi(e,i.length):"string"==r&&e in i)&&Wi(i[e],t)}var er=Object.prototype;function ir(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||er)}function rr(t){return ti(t)&&"[object Arguments]"==$e(t)}var nr=Object.prototype,or=nr.hasOwnProperty,sr=nr.propertyIsEnumerable,ar=rr(function(){return arguments}())?rr:function(t){return ti(t)&&or.call(t,"callee")&&!sr.call(t,"callee")};var hr="object"==typeof exports&&exports&&!exports.nodeType&&exports,lr=hr&&"object"==typeof module&&module&&!module.nodeType&&module,ur=lr&&lr.exports===hr?Ge.Buffer:void 0,pr=(ur?ur.isBuffer:void 0)||function(){return!1},cr={};function dr(t){return function(e){return t(e)}}cr["[object Float32Array]"]=cr["[object Float64Array]"]=cr["[object Int8Array]"]=cr["[object Int16Array]"]=cr["[object Int32Array]"]=cr["[object Uint8Array]"]=cr["[object Uint8ClampedArray]"]=cr["[object Uint16Array]"]=cr["[object Uint32Array]"]=!0,cr["[object Arguments]"]=cr["[object Array]"]=cr["[object ArrayBuffer]"]=cr["[object Boolean]"]=cr["[object DataView]"]=cr["[object Date]"]=cr["[object Error]"]=cr["[object Function]"]=cr["[object Map]"]=cr["[object Number]"]=cr["[object Object]"]=cr["[object RegExp]"]=cr["[object Set]"]=cr["[object String]"]=cr["[object WeakMap]"]=!1;var fr="object"==typeof exports&&exports&&!exports.nodeType&&exports,vr=fr&&"object"==typeof module&&module&&!module.nodeType&&module,yr=vr&&vr.exports===fr&&Ye.process,gr=function(){try{var t=vr&&vr.require&&vr.require("util").types;return t||yr&&yr.binding&&yr.binding("util")}catch(t){}}(),mr=gr,_r=mr&&mr.isTypedArray,xr=_r?dr(_r):function(t){return ti(t)&&Qi(t.length)&&!!cr[$e(t)]},br=Object.prototype.hasOwnProperty;function Pr(t,e){var i=ri(t),r=!i&&ar(t),n=!i&&!r&&pr(t),o=!i&&!r&&!n&&xr(t),s=i||r||n||o,a=s?function(t,e){for(var i=-1,r=Array(t);++i<t;)r[i]=e(i);return r}(t.length,String):[],h=a.length;for(var l in t)!e&&!br.call(t,l)||s&&("length"==l||n&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Hi(l,h))||a.push(l);return a}function wr(t,e){return function(i){return t(e(i))}}var Er=wr(Object.keys,Object),Tr=Object.prototype.hasOwnProperty;function Cr(t){return $i(t)?Pr(t):function(t){if(!ir(t))return Er(t);var e=[];for(var i in Object(t))Tr.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}var Ir=Object.prototype.hasOwnProperty;function Sr(t){if(!ui(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=ir(t),i=[];for(var r in t)("constructor"!=r||!e&&Ir.call(t,r))&&i.push(r);return i}function Or(t){return $i(t)?Pr(t,!0):Sr(t)}var Ar=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mr=/^\w*$/;function Lr(t,e){if(ri(t))return!1;var i=typeof t;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=t&&!ei(t))||(Mr.test(t)||!Ar.test(t)||null!=e&&t in Object(e))}var Nr=Oi(Object,"create");var Rr=Object.prototype.hasOwnProperty;var Dr=Object.prototype.hasOwnProperty;function Fr(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}function kr(t,e){for(var i=t.length;i--;)if(Wi(t[i][0],e))return i;return-1}Fr.prototype.clear=function(){this.__data__=Nr?Nr(null):{},this.size=0},Fr.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Fr.prototype.get=function(t){var e=this.__data__;if(Nr){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Rr.call(e,t)?e[t]:void 0},Fr.prototype.has=function(t){var e=this.__data__;return Nr?void 0!==e[t]:Dr.call(e,t)},Fr.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Nr&&void 0===e?"__lodash_hash_undefined__":e,this};var Br=Array.prototype.splice;function Ur(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}Ur.prototype.clear=function(){this.__data__=[],this.size=0},Ur.prototype.delete=function(t){var e=this.__data__,i=kr(e,t);return!(i<0)&&(i==e.length-1?e.pop():Br.call(e,i,1),--this.size,!0)},Ur.prototype.get=function(t){var e=this.__data__,i=kr(e,t);return i<0?void 0:e[i][1]},Ur.prototype.has=function(t){return kr(this.__data__,t)>-1},Ur.prototype.set=function(t,e){var i=this.__data__,r=kr(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this};var zr=Oi(Ge,"Map");function Xr(t,e){var i,r,n=t.__data__;return("string"==(r=typeof(i=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==i:null===i)?n["string"==typeof e?"string":"hash"]:n.map}function jr(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}jr.prototype.clear=function(){this.size=0,this.__data__={hash:new Fr,map:new(zr||Ur),string:new Fr}},jr.prototype.delete=function(t){var e=Xr(this,t).delete(t);return this.size-=e?1:0,e},jr.prototype.get=function(t){return Xr(this,t).get(t)},jr.prototype.has=function(t){return Xr(this,t).has(t)},jr.prototype.set=function(t,e){var i=Xr(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this};function Yr(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var i=function(){var r=arguments,n=e?e.apply(this,r):r[0],o=i.cache;if(o.has(n))return o.get(n);var s=t.apply(this,r);return i.cache=o.set(n,s)||o,s};return i.cache=new(Yr.Cache||jr),i}Yr.Cache=jr;var Hr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gr=/\\(\\)?/g,Wr=function(t){var e=Yr(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Hr,(function(t,i,r,n){e.push(r?n.replace(Gr,"$1"):i||t)})),e})),Vr=Wr;function qr(t,e){return ri(t)?t:Lr(t,e)?[t]:Vr(function(t){return null==t?"":si(t)}(t))}function Zr(t){if("string"==typeof t||ei(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e}function Jr(t,e){for(var i=0,r=(e=qr(e,t)).length;null!=t&&i<r;)t=t[Zr(e[i++])];return i&&i==r?t:void 0}function Kr(t,e){for(var i=-1,r=e.length,n=t.length;++i<r;)t[n+i]=e[i];return t}var Qr=We?We.isConcatSpreadable:void 0;function $r(t){return ri(t)||ar(t)||!!(Qr&&t&&t[Qr])}function tn(t,e,i,r,n){var o=-1,s=t.length;for(i||(i=$r),n||(n=[]);++o<s;){var a=t[o];e>0&&i(a)?e>1?tn(a,e-1,i,r,n):Kr(n,a):r||(n[n.length]=a)}return n}var en=wr(Object.getPrototypeOf,Object),rn=Function.prototype,nn=Object.prototype,on=rn.toString,sn=nn.hasOwnProperty,an=on.call(Object);function hn(t){var e=this.__data__=new Ur(t);this.size=e.size}hn.prototype.clear=function(){this.__data__=new Ur,this.size=0},hn.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},hn.prototype.get=function(t){return this.__data__.get(t)},hn.prototype.has=function(t){return this.__data__.has(t)},hn.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Ur){var r=i.__data__;if(!zr||r.length<199)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new jr(r)}return i.set(t,e),this.size=i.size,this};var ln="object"==typeof exports&&exports&&!exports.nodeType&&exports,un=ln&&"object"==typeof module&&module&&!module.nodeType&&module,pn=un&&un.exports===ln?Ge.Buffer:void 0,cn=pn?pn.allocUnsafe:void 0;function dn(t,e){if(e)return t.slice();var i=t.length,r=cn?cn(i):new t.constructor(i);return t.copy(r),r}function fn(){return[]}var vn=Object.prototype.propertyIsEnumerable,yn=Object.getOwnPropertySymbols,gn=yn?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,r=null==t?0:t.length,n=0,o=[];++i<r;){var s=t[i];e(s,i,t)&&(o[n++]=s)}return o}(yn(t),(function(e){return vn.call(t,e)})))}:fn,mn=gn;var _n=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Kr(e,mn(t)),t=en(t);return e}:fn;function xn(t,e,i){var r=e(t);return ri(t)?r:Kr(r,i(t))}function bn(t){return xn(t,Cr,mn)}function Pn(t){return xn(t,Or,_n)}var wn=Oi(Ge,"DataView"),En=Oi(Ge,"Promise"),Tn=Oi(Ge,"Set"),Cn=bi(wn),In=bi(zr),Sn=bi(En),On=bi(Tn),An=bi(Ai),Mn=$e;(wn&&"[object DataView]"!=Mn(new wn(new ArrayBuffer(1)))||zr&&"[object Map]"!=Mn(new zr)||En&&"[object Promise]"!=Mn(En.resolve())||Tn&&"[object Set]"!=Mn(new Tn)||Ai&&"[object WeakMap]"!=Mn(new Ai))&&(Mn=function(t){var e=$e(t),i="[object Object]"==e?t.constructor:void 0,r=i?bi(i):"";if(r)switch(r){case Cn:return"[object DataView]";case In:return"[object Map]";case Sn:return"[object Promise]";case On:return"[object Set]";case An:return"[object WeakMap]"}return e});var Ln=Mn,Nn=Object.prototype.hasOwnProperty;var Rn=Ge.Uint8Array;function Dn(t){var e=new t.constructor(t.byteLength);return new Rn(e).set(new Rn(t)),e}var Fn=/\w*$/;var kn=We?We.prototype:void 0,Bn=kn?kn.valueOf:void 0;function Un(t,e){var i=e?Dn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}function zn(t,e,i){var r,n,o,s=t.constructor;switch(e){case"[object ArrayBuffer]":return Dn(t);case"[object Boolean]":case"[object Date]":return new s(+t);case"[object DataView]":return function(t,e){var i=e?Dn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}(t,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Un(t,i);case"[object Map]":case"[object Set]":return new s;case"[object Number]":case"[object String]":return new s(t);case"[object RegExp]":return(o=new(n=t).constructor(n.source,Fn.exec(n))).lastIndex=n.lastIndex,o;case"[object Symbol]":return r=t,Bn?Object(Bn.call(r)):{}}}function Xn(t){return"function"!=typeof t.constructor||ir(t)?{}:Li(en(t))}var jn=mr&&mr.isMap,Yn=jn?dr(jn):function(t){return ti(t)&&"[object Map]"==Ln(t)};var Hn=mr&&mr.isSet,Gn=Hn?dr(Hn):function(t){return ti(t)&&"[object Set]"==Ln(t)},Wn={};function Vn(t,e,i,r,n,o){var s,a=1&e,h=2&e,l=4&e;if(i&&(s=n?i(t,r,n,o):i(t)),void 0!==s)return s;if(!ui(t))return t;var u=ri(t);if(u){if(s=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&Nn.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t),!a)return Ri(t,s)}else{var p=Ln(t),c="[object Function]"==p||"[object GeneratorFunction]"==p;if(pr(t))return dn(t,a);if("[object Object]"==p||"[object Arguments]"==p||c&&!n){if(s=h||c?{}:Xn(t),!a)return h?function(t,e){return Zi(t,_n(t),e)}(t,function(t,e){return t&&Zi(e,Or(e),t)}(s,t)):function(t,e){return Zi(t,mn(t),e)}(t,function(t,e){return t&&Zi(e,Cr(e),t)}(s,t))}else{if(!Wn[p])return n?t:{};s=zn(t,p,a)}}o||(o=new hn);var d=o.get(t);if(d)return d;o.set(t,s),Gn(t)?t.forEach((function(r){s.add(Vn(r,e,i,r,t,o))})):Yn(t)&&t.forEach((function(r,n){s.set(n,Vn(r,e,i,n,t,o))}));var f=u?void 0:(l?h?Pn:bn:h?Or:Cr)(t);return function(t,e){for(var i=-1,r=null==t?0:t.length;++i<r&&!1!==e(t[i],i,t););}(f||t,(function(r,n){f&&(r=t[n=r]),qi(s,n,Vn(r,e,i,n,t,o))})),s}Wn["[object Arguments]"]=Wn["[object Array]"]=Wn["[object ArrayBuffer]"]=Wn["[object DataView]"]=Wn["[object Boolean]"]=Wn["[object Date]"]=Wn["[object Float32Array]"]=Wn["[object Float64Array]"]=Wn["[object Int8Array]"]=Wn["[object Int16Array]"]=Wn["[object Int32Array]"]=Wn["[object Map]"]=Wn["[object Number]"]=Wn["[object Object]"]=Wn["[object RegExp]"]=Wn["[object Set]"]=Wn["[object String]"]=Wn["[object Symbol]"]=Wn["[object Uint8Array]"]=Wn["[object Uint8ClampedArray]"]=Wn["[object Uint16Array]"]=Wn["[object Uint32Array]"]=!0,Wn["[object Error]"]=Wn["[object Function]"]=Wn["[object WeakMap]"]=!1;function qn(t){return Vn(t,5)}function Zn(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new jr;++e<i;)this.add(t[e])}function Jn(t,e){for(var i=-1,r=null==t?0:t.length;++i<r;)if(e(t[i],i,t))return!0;return!1}Zn.prototype.add=Zn.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Zn.prototype.has=function(t){return this.__data__.has(t)};function Kn(t,e,i,r,n,o){var s=1&i,a=t.length,h=e.length;if(a!=h&&!(s&&h>a))return!1;var l=o.get(t),u=o.get(e);if(l&&u)return l==e&&u==t;var p=-1,c=!0,d=2&i?new Zn:void 0;for(o.set(t,e),o.set(e,t);++p<a;){var f=t[p],v=e[p];if(r)var y=s?r(v,f,p,e,t,o):r(f,v,p,t,e,o);if(void 0!==y){if(y)continue;c=!1;break}if(d){if(!Jn(e,(function(t,e){if(s=e,!d.has(s)&&(f===t||n(f,t,i,r,o)))return d.push(e);var s}))){c=!1;break}}else if(f!==v&&!n(f,v,i,r,o)){c=!1;break}}return o.delete(t),o.delete(e),c}function Qn(t){var e=-1,i=Array(t.size);return t.forEach((function(t,r){i[++e]=[r,t]})),i}function $n(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i}var to=We?We.prototype:void 0,eo=to?to.valueOf:void 0;var io=Object.prototype.hasOwnProperty;var ro="[object Object]",no=Object.prototype.hasOwnProperty;function oo(t,e,i,r,n,o){var s=ri(t),a=ri(e),h=s?"[object Array]":Ln(t),l=a?"[object Array]":Ln(e),u=(h="[object Arguments]"==h?ro:h)==ro,p=(l="[object Arguments]"==l?ro:l)==ro,c=h==l;if(c&&pr(t)){if(!pr(e))return!1;s=!0,u=!1}if(c&&!u)return o||(o=new hn),s||xr(t)?Kn(t,e,i,r,n,o):function(t,e,i,r,n,o,s){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Rn(t),new Rn(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Wi(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Qn;case"[object Set]":var h=1&r;if(a||(a=$n),t.size!=e.size&&!h)return!1;var l=s.get(t);if(l)return l==e;r|=2,s.set(t,e);var u=Kn(a(t),a(e),r,n,o,s);return s.delete(t),u;case"[object Symbol]":if(eo)return eo.call(t)==eo.call(e)}return!1}(t,e,h,i,r,n,o);if(!(1&i)){var d=u&&no.call(t,"__wrapped__"),f=p&&no.call(e,"__wrapped__");if(d||f){var v=d?t.value():t,y=f?e.value():e;return o||(o=new hn),n(v,y,i,r,o)}}return!!c&&(o||(o=new hn),function(t,e,i,r,n,o){var s=1&i,a=bn(t),h=a.length;if(h!=bn(e).length&&!s)return!1;for(var l=h;l--;){var u=a[l];if(!(s?u in e:io.call(e,u)))return!1}var p=o.get(t),c=o.get(e);if(p&&c)return p==e&&c==t;var d=!0;o.set(t,e),o.set(e,t);for(var f=s;++l<h;){var v=t[u=a[l]],y=e[u];if(r)var g=s?r(y,v,u,e,t,o):r(v,y,u,t,e,o);if(!(void 0===g?v===y||n(v,y,i,r,o):g)){d=!1;break}f||(f="constructor"==u)}if(d&&!f){var m=t.constructor,_=e.constructor;m==_||!("constructor"in t)||!("constructor"in e)||"function"==typeof m&&m instanceof m&&"function"==typeof _&&_ instanceof _||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,i,r,n,o))}function so(t,e,i,r,n){return t===e||(null==t||null==e||!ti(t)&&!ti(e)?t!=t&&e!=e:oo(t,e,i,r,so,n))}function ao(t){return t==t&&!ui(t)}function ho(t,e){return function(i){return null!=i&&(i[t]===e&&(void 0!==e||t in Object(i)))}}function lo(t){var e=function(t){for(var e=Cr(t),i=e.length;i--;){var r=e[i],n=t[r];e[i]=[r,n,ao(n)]}return e}(t);return 1==e.length&&e[0][2]?ho(e[0][0],e[0][1]):function(i){return i===t||function(t,e,i,r){var n=i.length,o=n,s=!r;if(null==t)return!o;for(t=Object(t);n--;){var a=i[n];if(s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++n<o;){var h=(a=i[n])[0],l=t[h],u=a[1];if(s&&a[2]){if(void 0===l&&!(h in t))return!1}else{var p=new hn;if(r)var c=r(l,u,h,t,e,p);if(!(void 0===c?so(u,l,3,r,p):c))return!1}}return!0}(i,t,e)}}function uo(t,e){return null!=t&&e in Object(t)}function po(t,e){return null!=t&&function(t,e,i){for(var r=-1,n=(e=qr(e,t)).length,o=!1;++r<n;){var s=Zr(e[r]);if(!(o=null!=t&&i(t,s)))break;t=t[s]}return o||++r!=n?o:!!(n=null==t?0:t.length)&&Qi(n)&&Hi(s,n)&&(ri(t)||ar(t))}(t,e,uo)}function co(t,e){return Lr(t)&&ao(e)?ho(Zr(t),e):function(i){var r=function(t,e,i){var r=null==t?void 0:Jr(t,e);return void 0===r?i:r}(i,t);return void 0===r&&r===e?po(i,t):so(e,r,3)}}function fo(t){return Lr(t)?(e=Zr(t),function(t){return null==t?void 0:t[e]}):function(t){return function(e){return Jr(e,t)}}(t);var e}function vo(t){return"function"==typeof t?t:null==t?yi:"object"==typeof t?ri(t)?co(t[0],t[1]):lo(t):fo(t)}var yo,go=function(t,e,i){for(var r=-1,n=Object(t),o=i(t),s=o.length;s--;){var a=o[yo?s:++r];if(!1===e(n[a],a,n))break}return t},mo=go;var _o=function(t,e){return function(i,r){if(null==i)return i;if(!$i(i))return t(i,r);for(var n=i.length,o=e?n:-1,s=Object(i);(e?o--:++o<n)&&!1!==r(s[o],o,s););return i}}((function(t,e){return t&&mo(t,e,Cr)})),xo=_o,bo=function(){return Ge.Date.now()},Po=Math.max,wo=Math.min;function Eo(t,e,i){var r,n,o,s,a,h,l=0,u=!1,p=!1,c=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function d(e){var i=r,o=n;return r=n=void 0,l=e,s=t.apply(o,i)}function f(t){return l=t,a=setTimeout(y,e),u?d(t):s}function v(t){var i=t-h;return void 0===h||i>=e||i<0||p&&t-l>=o}function y(){var t=bo();if(v(t))return g(t);a=setTimeout(y,function(t){var i=e-(t-h);return p?wo(i,o-(t-l)):i}(t))}function g(t){return a=void 0,c&&r?d(t):(r=n=void 0,s)}function m(){var t=bo(),i=v(t);if(r=arguments,n=this,h=t,i){if(void 0===a)return f(h);if(p)return clearTimeout(a),a=setTimeout(y,e),d(h)}return void 0===a&&(a=setTimeout(y,e)),s}return e=vi(e)||0,ui(i)&&(u=!!i.leading,o=(p="maxWait"in i)?Po(vi(i.maxWait)||0,e):o,c="trailing"in i?!!i.trailing:c),m.cancel=function(){void 0!==a&&clearTimeout(a),l=0,r=h=n=a=void 0},m.flush=function(){return void 0===a?s:g(bo())},m}function To(t,e,i){(void 0!==i&&!Wi(t[e],i)||void 0===i&&!(e in t))&&Gi(t,e,i)}function Co(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Io(t,e,i,r,n,o,s){var a=Co(t,i),h=Co(e,i),l=s.get(h);if(l)To(t,i,l);else{var u,p=o?o(a,h,i+"",t,e,s):void 0,c=void 0===p;if(c){var d=ri(h),f=!d&&pr(h),v=!d&&!f&&xr(h);p=h,d||f||v?ri(a)?p=a:ti(u=a)&&$i(u)?p=Ri(a):f?(c=!1,p=dn(h,!0)):v?(c=!1,p=Un(h,!0)):p=[]:function(t){if(!ti(t)||"[object Object]"!=$e(t))return!1;var e=en(t);if(null===e)return!0;var i=sn.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&on.call(i)==an}(h)||ar(h)?(p=a,ar(a)?p=function(t){return Zi(t,Or(t))}(a):ui(a)&&!gi(a)||(p=Xn(h))):c=!1}c&&(s.set(h,p),n(p,h,r,o,s),s.delete(h)),To(t,i,p)}}function So(t,e,i,r,n){t!==e&&mo(e,(function(o,s){if(n||(n=new hn),ui(o))Io(t,e,s,i,So,r,n);else{var a=r?r(Co(t,s),o,s+"",t,e,n):void 0;void 0===a&&(a=o),To(t,s,a)}}),Or)}var Oo,Ao=(Oo=function(t,e,i){So(t,e,i)},Ki((function(t,e){var i=-1,r=e.length,n=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(n=Oo.length>3&&"function"==typeof n?(r--,n):void 0,o&&tr(e[0],e[1],o)&&(n=r<3?void 0:n,r=1),t=Object(t);++i<r;){var s=e[i];s&&Oo(t,s,i,n)}return t}))),Mo=Ao;function Lo(t,e){if(t!==e){var i=void 0!==t,r=null===t,n=t==t,o=ei(t),s=void 0!==e,a=null===e,h=e==e,l=ei(e);if(!a&&!l&&!o&&t>e||o&&s&&h&&!a&&!l||r&&s&&h||!i&&h||!n)return 1;if(!r&&!o&&!l&&t<e||l&&i&&n&&!r&&!o||a&&i&&n||!s&&n||!h)return-1}return 0}function No(t,e,i){e=e.length?ii(e,(function(t){return ri(t)?function(e){return Jr(e,1===t.length?t[0]:t)}:t})):[yi];var r=-1;e=ii(e,dr(vo));var n=function(t,e){var i=-1,r=$i(t)?Array(t.length):[];return xo(t,(function(t,n,o){r[++i]=e(t,n,o)})),r}(t,(function(t,i,n){return{criteria:ii(e,(function(e){return e(t)})),index:++r,value:t}}));return function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t}(n,(function(t,e){return function(t,e,i){for(var r=-1,n=t.criteria,o=e.criteria,s=n.length,a=i.length;++r<s;){var h=Lo(n[r],o[r]);if(h)return r>=a?h:h*("desc"==i[r]?-1:1)}return t.index-e.index}(t,e,i)}))}var Ro,Do=Ki((function(t,e){if(null==t)return[];var i=e.length;return i>1&&tr(t,e[0],e[1])?e=[]:i>2&&tr(e[0],e[1],e[2])&&(e=[e[0]]),No(t,tn(e,1),[])})),Fo=Do;function ko(t={}){this.maxResolvedCache=t.maxResolvedCache||1e3,this._pendingPromises={},this._resolvedPromises={}}ko.prototype={add:function(t,e){var i=this;if(this._pendingPromises[t])return this._pendingPromises[t];if(this._resolvedPromises[t])return this._resolvedPromises[t];var r={key:t,timestamp:Date.now(),promise:e};return this._pendingPromises[t]=r,e.then((function(e){var r=i._pendingPromises[t];delete i._pendingPromises[t],r.data=e,i._resolvedPromises[t]=r}),(function(){delete i._pendingPromises[t]})),this._collectGarbage(),r},get:function(t){var e=this._pendingPromises[t]||this._resolvedPromises[t];return!!e&&(e.timestamp=Date.now(),e.promise)},purge:function(){for(var t in this._resolvedPromises)delete this._resolvedPromises[t]},_collectGarbage:function(){var t=Fo(this._resolvedPromises,(function(t){return t.timestamp})),e=t.length-this.maxResolvedCache;if(!(e<=0))for(var i=0;i<e;i++)delete this._resolvedPromises[t[i].key]}};class Bo{constructor(t="keyval-store",e="keyval"){this.storeName=e,this._dbp=new Promise(((i,r)=>{var n=indexedDB.open(t,1);n.onerror=()=>r(n.error),n.onsuccess=()=>i(n.result),n.onupgradeneeded=()=>{n.result.createObjectStore(e)}}))}_withIDBStore(t,e){return this._dbp.then((i=>new Promise(((r,n)=>{var o=i.transaction(this.storeName,t);o.oncomplete=()=>r(),o.onabort=o.onerror=()=>n(o.error),e(o.objectStore(this.storeName))}))))}}function Uo(){return Ro||(Ro=new Bo),Ro}function zo(t,e=Uo()){var i;return e._withIDBStore("readonly",(e=>{i=e.get(t)})).then((()=>i.result))}function Xo(t,e,i=Uo()){return i._withIDBStore("readwrite",(i=>{i.put(e,t)}))}var jo=new Bo("al-kvs","al-keyval"),Yo=!0;function Ho(t,e,i){return Go.apply(this,arguments)}function Go(){return(Go=r((function*(t,e,i){i=i||2592e6;try{var r={timeStamp:(new Date).getTime(),content:e,maxAge:i};if(Yo)yield Xo(t,JSON.stringify(r),jo);else{var n=window&&window.localStorage;if(!n||!t||"string"!=typeof t)return;n.setItem(t,JSON.stringify(r))}return t}catch(t){return}}))).apply(this,arguments)}function Wo(t,e){return Vo.apply(this,arguments)}function Vo(){return(Vo=r((function*(t,e){var i,r=e||2592e6,n=(new Date).getTime();try{if(Yo)i=yield zo(t,jo);else{var o=window&&window.localStorage;if(!o||!t||"string"!=typeof t)return;i=o.getItem(t)}if(n-(i=JSON.parse(i)).timeStamp>Math.min(i.maxAge,r))return;if(i.content)return i.content}catch(t){return}}))).apply(this,arguments)}function qo(t){return t&&"string"==typeof t?t.toLowerCase().replace(/[()+&!?;,:_)]/g,"").replace(/\s+/g,"-"):""}function Zo(t,e){var i,r,n=null===(i=t.src)||void 0===i?void 0:i.substring(1),o=function(t={},e){var i=e&&e.length&&e[0].split(":")[0],r=Object.keys(t);return i&&"default"!==i&&(r=r.filter((t=>t===i))),1===r.length?r[0]:r.filter((t=>!t.toLowerCase().includes("base")))[0]}(t.materials,null===(r=e.products[n])||void 0===r?void 0:r.colours);return o&&qo(t.materials[o])}function Jo(t,e){var i,r=null===(i=t.src)||void 0===i?void 0:i.substring(1),n=Zo(t,e);return r+(n=n?"_"+n:"")}jo._dbp.then((()=>{Yo=!0})).catch((t=>{Yo=!1,console.log("indexedDb initialisation failed",t)}));var Ko={kitchen:function(t){var e=[],i=/90$/g.test(t.cooktopType),r=function(t){var e=t.elementLength,i=t.highCabinetLeft*e,r=t.highCabinetRight*e;return Math.max(0,t.l-i-r)}(t),n=function(t,e,i){var r,n=t.elementLength,o=.9,s=t.highCabinetLeft*n,a=[],h=0,l=0;for(r=0;r<t.highCabinetLeft;r++){var u=t.l-h;h+=u>n?n:u,a[r]=h,l++}for(;h+n<s+e;){h+=l===t.cooktopPos-1&&"none"!==t.cooktopType&&i?o:n,l++,a.push(h)}for(r=t.highCabinetRight;r>0;r--)h=t.l-n*r+n,a.push(h);return a=a.map((t=>Math.round(10*t)/10))}(t,r,i),o=function(t,e){var i,r=[];for(i=0;i<t.highCabinetLeft;i++)r.push(i);for(i=0;i<t.highCabinetRight;i++)r.push(e.length-1-i);return r}(t,n),s=function(t,e){return"number"==typeof t.sinkPos&&t.sinkPos>t.highCabinetLeft&&t.sinkPos<=e.length-t.highCabinetRight&&"none"!==t.sinkType?t.sinkPos:null}(t,n),a=function(t,e){return"number"==typeof t.cooktopPos&&t.cooktopPos>t.highCabinetLeft&&t.cooktopPos<=e.length-t.highCabinetRight&&"none"!==t.cooktopType?t.cooktopPos:null}(t,n);for(var h of(e.push(we([0,t.barCounter?-.25:0],t.l,t.barCounter?t.w+.25:t.w,!0)),n.forEach((i=>{e.push(Pe([i,t.w],[i,t.w-.075]))})),r&&t.barCounter&&e.push(Pe([t.highCabinetLeft*t.elementLength,0],[t.l-t.highCabinetRight*t.elementLength,0])),o)){var l=n[h],u=l-.6;e.push(Pe([u||0,t.w],[u||0,0]),Pe([u||0,0],[l,t.w]),Pe([u||0,t.w],[l,0]),Pe([l,t.w],[l,0]))}if(s&&n[s-2]){var p={type:"group",position:[n[s-2],0],children:[we([.05,t.w-.5],"double"!==t.sinkType?.5:1.1,.45),we([.1,t.w-.4],"double"!==t.sinkType?.4:.35,.3),we(["double"!==t.sinkType?t.elementLength/2-.02:.48,t.w-.45],.04,.18)]};"double"===t.sinkType&&p.children.push(we([.55,t.w-.4],.35,.3),Pe([.95,t.w-.4],[.95,t.w-.1]),Pe([1,t.w-.4],[1,t.w-.1]),Pe([1.05,t.w-.4],[1.05,t.w-.1]),Pe([1.1,t.w-.4],[1.1,t.w-.1])),e.push(p)}if(a&&n[a-2]){var c={type:"group",position:[n[a-2],0],children:[we([.05,t.w-.55],i?.8:.5,.5)]};i?c.children.push(Ee([.225,t.w-.4],.08),Ee([.675,t.w-.4],.08),Ee([.45,t.w-.3],.08),Ee([.225,t.w-.2],.08),Ee([.675,t.w-.2],.08)):c.children.push(Ee([.2,t.w-.4],.08),Ee([.4,t.w-.4],.08),Ee([.2,t.w-.2],.08),Ee([.4,t.w-.2],.08)),e.push(c)}return r&&t.wallCabinet&&e.push(Pe([t.highCabinetLeft*t.elementLength,t.wallCabinetWidth],[t.l-t.highCabinetRight*t.elementLength,t.wallCabinetWidth])),e},column:function(t){var e=[];return"square"===t.shape?e.push({type:"rect",position:[-t.l/2,-t.l/2],width:t.l,height:t.l,isContour:!0}):"circle"===t.shape?e.push({type:"circle",position:[0,0],r:t.l/2,isContour:!0}):"polygon"===t.shape&&e.push({type:"polygon",points:t.polygon,isContour:!0}),e},stairs:function(t,i={}){var r,n=e({w:1.2,l:4},t),o="labelled"!==i.style,s="left"===t.circulation,a=.3,h=t.stairType||"straight",l=t.l,u=t.stepWidth;"straightLanding"===t.stairType?l=t.l-1:"lShaped"===t.stairType?l=t.l+t.w-2*u:"winder"===t.stairType?l=t.l+t.w-u:"halfLanding"===t.stairType?l=2*(t.l-u):"2QuarterLanding"===t.stairType?l=2*(t.l-u)+t.w-2*u:"doubleWinder"===t.stairType&&(l=2*t.l+t.w-2*u);var p,c,d,f=(l/t.h+1.2321)/.10357/100,v=Math.round(l/f),y=l/v,g={shape:[],runs:[]};switch(h){case"straight":case"straightLanding":g.shape=[[0,0],[t.l,0],[t.l,t.w],[0,t.w]];break;case"lShaped":case"winder":g.shape=[[0,0],[t.l,0],[t.l,t.w],[t.l-u,t.w],[t.l-u,u],[0,u]];break;case"halfLanding":case"2QuarterLanding":case"doubleWinder":g.shape=[[0,0],[t.l,0],[t.l,t.w],[0,t.w],[0,t.w-u],[t.l-u,t.w-u],[t.l-u,u],[0,u]]}if(o)switch(h){case"straight":g.runs=[{type:"straight",data:[0,0,v,y,0]}];break;case"straightLanding":c=v-(p=Math.ceil(v/2)),g.runs=[{type:"straight",data:[0,0,p,y,0]},{type:"straight",data:[p*y+1,0,c,y,0]}];break;case"lShaped":c=v-(p=Math.floor((t.l-u)/y)),g.runs=[{type:"straight",data:[0,0,p,(t.l-u)/p,0]},{type:"straight",data:[t.l,u,c,(t.w-u)/c,-90]}];break;case"winder":c=2*Math.round((u/2+a)/y),d=v-(p=Math.round((t.l-u-a)/y))-c,g.runs=[{type:"straight",data:[0,0,p,(t.l-u-a)/p,0]},{type:"winder",data:[t.l-u-a,0,c,0]}],d>0&&g.runs.push({type:"straight",data:[t.l,u+a,d,(t.w-u-a)/d,-90]});break;case"halfLanding":p=v/2,c=v/2,g.runs=[{type:"straight",data:[0,0,p,y,0]},{type:"straight",data:[p*y,t.w,c,y,180]}];break;case"2QuarterLanding":d=p=Math.round((t.l-u)/y),c=v-2*p,y=(t.l-u)/p,g.runs=[{type:"straight",data:[0,0,p,(t.l-u)/p,0]},{type:"straight",data:[t.l,u,c,(t.w-2*u)/c,-90]},{type:"straight",data:[p*y,t.w,d,(t.l-u)/p,180]}];break;case"doubleWinder":c=4*Math.round((u/2+a)/y),d=Math.round((t.w-2*(u+a))/y),p=Math.round((v-c-d)/2),g.runs=[],p>0&&g.runs.push({type:"straight",data:[0,0,p,(t.l-u-a)/p,0]}),g.runs.push({type:"winder",data:[t.l-u-a,0,c/2,0]}),d>0&&g.runs.push({type:"straight",data:[t.l,u+a,d,(t.w-2*(u+a))/d,-90]}),g.runs.push({type:"winder",data:[t.l,t.w-u-a,c/2,-90]}),p>0&&g.runs.push({type:"straight",data:[t.l-u-a,t.w,p,(t.l-u-a)/p,180]})}var m,_=[];if("labelled"!==i.style){var x=[["M",y/2-.06,u/2+.12],["L",y/2+.06,u/2],["L",y/2-.06,u/2-.12]];_.push({type:"path",segments:x})}if("spiral"!==h)m={type:"polygon",points:g.shape,isContour:!0},g.runs.forEach((t=>{"straight"===t.type?_=_.concat(function(t,e,i,r,n=0){for(var o={type:"group",position:[t,e],rotation:n=n||0,children:[]},s=0;s<i;s++)o.children.push({type:"path",segments:[["M",s*r,0],["L",s*r,u]]});return o}(...t.data)):"winder"===t.type&&(_=_.concat(function(t,e,i,r){for(var n,o,s=i/2,a=(u+.3)/s,h=.3/s,l=0,p=0,c={type:"group",rotation:r=r||0,rotationOrigin:[t,e],children:[]},d=0;d<s;d++)n=["M",t+l,e+u],o=["L",t+p,e],c.children.push({type:"path",segments:[n,o]}),l+=h,p+=a;for(t+=l,l=0,p=0,d=0;d<s;d++)n=["M",t,e+u+l],o=["L",t+u,e+p],c.children.push({type:"path",segments:[n,o]}),l+=h,p+=a;return c}(...t.data)))}));else if("spiral"===h){var b,P,w,E,T,C,I;w=(P=(b=t.w)-u)+u/2,I=(E=t.l/w)/v,E>2*Math.PI&&(E=2*Math.PI-.01),T=[Math.sin(E)*b,Math.cos(E)*b-b],C=[Math.sin(E)*P,Math.cos(E)*P-b];var S=E>Math.PI?1:0;if(m={type:"path",segments:[["M",0,0],["A",b,b,0,S,1,T[0],-T[1]],["L",C[0],-C[1]],["A",P,P,0,S,0,0,u],["Z"]],isContour:!0},o)for(var O=0,A=0;A<v&&!(O>=E);A++)T=[Math.sin(O)*b,Math.cos(O)*b-b],C=[Math.sin(O)*P,Math.cos(O)*P-b],_.push({type:"path",segments:[["M",T[0],-T[1]],["L",C[0],-C[1]]]}),O+=I}s&&(m={type:"group",position:[0,-t.w],children:[m,..._]});var M=["stairs"];(null==(r=t.class)?void 0:r.length)&&(M=M.concat(t.class));var L=[{type:"group",position:[n.x,n.z],rotation:n.ry,scale:[1,s?-1:1],children:[m]}];return s||L[0].children.push(..._),L},wall:function(t){return[{type:"rect",position:[0,"center"===t.controlLine?-t.w/2:"front"===t.controlLine?-t.w:0],width:t.l,height:t.w,isContour:!0}]}};function Qo(t={},e={},i={},r){return Ko[t.type]?Ko[t.type](t,e):$o[t.type]&&$o[t.type](t,e,i,r)}var $o={box:t=>es(t),curtain:t=>{for(var e,i,r,n=Math.min(Math.max(t.folds||10,Math.round(5*t.l)),Math.round(15*t.l)),o=.05,s=t.w,a=t.l/n,h=[],l=[],u=0,p=s/2,c=.025,d=t.id.replace(/-/gi,""),f=d.length,v=0;v<n;v++){i=c,r=p;var y=parseInt(d[v%f],16)/20;c=.025+y*o/2*(v%2==0?-1:1),p=s/2+y*s/2*(v%2==0?-1:1),e=u,u=a*(v+1),l.push([e,r]),h.push([e,i]),v===n-1&&(l.push([u,p]),h.push([u,c]))}var g=ts(l),m=ts(h.reverse());return m[0][0]="L",m.push(["Z"]),[{type:"path",isContour:!0,segments:[...g,...m]}]},railing:t=>es(t),floor:t=>es(t),door:(t,e)=>{var i=function(t,e){var i=[],r=t.doorType||"singleSwing",n=t.l,o=e.w,s=t.doorAngle;if(s<20&&(s=20),"singleSwing"===r){var a=s*Math.PI/180,h=Math.round(100*(n/2-n*Math.cos(a)))/100,l=Math.round(100*(n*Math.sin(a)+o/2))/100;i.push({type:"path",segments:[["M",-n/2,o/2],["A",n,n,0,0,0,h,l],["L",n/2,o/2]]})}else if("doubleSwing"===r){var u=s*Math.PI/180,p=n/2+n/2*-Math.cos(u),c=n/2*Math.sin(u);i.push({type:"path",segments:[["M",-n/2,o/2],["L",-p,c],["A",n/2,n/2,0,0,0,0,o/2]]}),i.push({type:"path",segments:[["M",0,o/2],["A",n/2,n/2,0,0,0,p,c],["L",n/2,o/2]]})}return i}(t,e);return[...i,...[{type:"rect",isContour:!0,position:[-t.l/2,-e.w/2],width:t.l,height:e.w}]]},window:(t,e)=>es(t,e),closet:t=>es(t),interior:(t,e,i,r)=>((r=r||t.src&&i.productContours[t.src.substring(1)])||(r=t.src&&i.productBoundingBoxes[t.src.substring(1)]),r?(r=r.sort(((t,e)=>gt(t)>gt(e)?-1:1)))&&r.length?[{type:"polygon",isContour:!0,points:r[0],holes:r.slice(1)}]:void 0:[{type:"circle",position:[0,0],r:.01}]),polyfloor:t=>[{type:"polygon",isContour:!0,points:t.polygon,holes:t.polygonHoles||[]}],polybox:t=>[{type:"polygon",isContour:!0,points:t.polygon}],"a:helper:spaceDivider":t=>[{type:"rect",isContour:!0,position:[0,-.02],height:.04,width:t.l}],floorplan:t=>[{type:"rect",position:[-t.l/2,-t.w/2],width:t.l,height:t.w}]},ts=(t=[],e=1)=>{var i=e,r=[];return t.forEach(((e,n)=>{var o=n<t.length-1?t[n+1]:[e[0],t[0][1]],s=[e[0]+(o[0]-e[0])/2,e[1]+(o[1]-e[1])/2];if(0===n)r.push(["M",ht(e[0]*i,3),ht(e[1]*i,3)]);else{var a=[ht(e[0]*i,3),ht(e[1]*i,3)],h=[ht(s[0]*i,3),ht(s[1]*i,3)];r.push(["Q",...a,...h])}})),r};function es(t={},e={}){var i=0,r=t.w;return"wall"===t.type&&(i="front"===t.controlLine?t.w:"center"===t.controlLine?t.w/2:0),"window"===t.type&&(r=e.w,i="front"===e.controlLine?e.w:"center"===e.controlLine?e.w/2:0),[{type:"polygon",isContour:!0,points:[[0,0-i],[t.l,0-i],[t.l,r-i],[0,r-i]]}]}function is(t,e){return rs.apply(this,arguments)}function rs(){return(rs=r((function*(t,e){if(e._promiseCache||(e._promiseCache=new ko),e._debugLoading||(e._debugLoading={}),t&&t.src){var i=t.src.substring(1);return e._productQueue[i]||(e._productQueue[i]={loadStage:0,nodes:[]}),e._productQueue[i].nodes.push(t),e.products[i]||(yield ls(i,e)),e.settings.hideElements.includes("interior")||ns(t,e),Promise.resolve()}}))).apply(this,arguments)}function ns(t,e){return os.apply(this,arguments)}function os(){return(os=r((function*(t,e){var i=t.src.substring(1),r=e.products[i];if(r){var n=Jo(t,e);if(hs(e,t),!e._textureQueue[n]){var s=o.api.staticProductThumb+"/"+n+".png";e._textureQueue[n]={productId:i,loadStage:0,nodes:[],textureUrl:s,applyFilter:!0},e.settings.theme.showAssetTextures&&e.emit("product-load-texture",{textureId:n,productData:r})}e._textureQueue[n].nodes.push(t),2!==e._textureQueue[n].loadStage?(e.productBoundingBoxes[i]||(e.productBoundingBoxes[i]=ss(r),e._productQueue[i].loadStage=2),2===e._productQueue[i].loadStage&&e.emit("product-load-stage",{node:t,args:{_loadStage:2}}),e.productContours[i]||as(r,e).then((()=>{var i,r;1===(null===(i=e._textureQueue[n])||void 0===i?void 0:i.loadStage)||null!==(r=e._textureQueue[n])&&void 0!==r&&r.error?e.emit("product-contour",n,e):e.settings.theme.showAssetTextures&&!e.settings.svgMode||e.emit("product-load-stage",{node:t,args:{_loadStage:3}})})),e._promiseCache._collectGarbage()):e.emit("product-load-stage",{node:t,args:{_loadStage:3,_textureId:n}})}}))).apply(this,arguments)}var ss=t=>{var e,i=t.boundingPoints;if(i)return e=[[i.min[0],i.min[2]],[i.min[0],i.max[2]],[i.max[0],i.max[2]],[i.max[0],i.min[2]]],t._loadStage=1,[e]},as=function(){var t=r((function*(t,e){var{productId:i}=t,r="fpe-pc1-"+i,n=e._promiseCache.get(r);if(n)return n;e._debugLoading[i]||(e._debugLoading[i]=0),e._debugLoading[i]++;var o=t.fileKey,s=function(t,e,i){var r,n,o=null==i||null===(r=i.settings)||void 0===r||null===(n=r.api)||void 0===n?void 0:n.productContourCacheAge,s=o||864e6;if(!t)return Promise.reject("product id missing");var a="fpe-dc2-"+t,h=i._promiseCache.get(a);if(h)return h;if("string"!=typeof e)return Promise.reject("fileKey not string");if(!e.includes("data3d.buffer")){var l=e.split("/")[e.split("/").length-1];return Promise.reject("unsupported geometry "+l)}var u=Wo(a,o).then((e=>e||c.product.outline(t).then((t=>(Ho(a,t,s),t))))).catch((t=>{console.warn(t)}));return i._promiseCache.add(a,u),u}(i,o,e).then((r=>{var n=r;e.productContours[i]=n,t._shapes=Qo({type:"interior"},null,e,n),e._productQueue[i].loadStage=3})).catch((()=>{}));return e._promiseCache.add(r,s),s}));return function(e,i){return t.apply(this,arguments)}}();function hs(t,e){if(e&&"interior"===e.type){var i=e.src&&e.src.substring(1);if(i){var r=Zo(e,t);r&&!t.products[i].materials.includes(r)&&t.products[i].materials.splice(0,0,r)}}}function ls(t,e){var i,r,n=null==e||null===(i=e.settings)||void 0===i||null===(r=i.api)||void 0===r?void 0:r.productDataCacheAge,s=n||864e5;if(!t)return Promise.reject("product id missing");var a="fpe-pr1-"+t,h=e._promiseCache.get(a);if(h)return h;var l=Wo(a,n).then((e=>e&&e.matColors?e:c.product.read(t).then((t=>(t.matColors={},t.colours&&t.colours.length&&t.colours.forEach((e=>{if(e.includes(":")){var i=e.split(":"),r=qo(i[1]);t.matColors[r]=i[2]}})),Ho(a,t,s),t))))).then((i=>(e.products[t]=function(t){if(t){var e,i,r,n=t.subCategories.includes("ceilingLight"),s=t.subCategories.includes("rug"),a=t.productResourceId,h=o.api.staticProductThumb+"/"+a+".png";return{preview:t.preview,manufacturer:t.manufacturer,productId:a,name:t.productDisplayName,fileKey:t.fileKey,tags:t.tags,categories:t.categories,subCategories:t.subCategories,boundingPoints:t.boundingPoints,boundingBox:t.boundingBox,texture:h,materials:[],matColors:t.matColors,colours:t.colours,order:(e=t,i={10:["ceilingLight","wallLight"],9:["modularMeetingRoom","phoneBooth"],8:["floorLamp","tableLamp","deskDivider","cushion","plant","officeSupply","tableware","decoration","laundry","electronics","kitchen","car"],7:["shelf","cabinet","wardrobe","storageCombination","outdoor","bicycle","people","sink"],6:["highTable","diningTable","conferenceTable","desk"],5:["sofa","armchair","loungeChair","ottoman","sideboard","pedestal"],4:["taskChair","diningChair","conferenceChair","stool","barStool","bench"],3:["shower"],2:["singleBed","doubleBed","daybed","toilet","bathtub"],1:["sideTable","coffeeTable","radiator","nightstand"],0:["rug"]},r=0,e.subCategories.forEach((t=>{Object.keys(i).forEach((e=>{i[e].includes(t)&&e>r&&(r=parseInt(e))}))})),1===r&&e.categories.includes("tables")&&e.boundingBox.height>.6&&(r=6),parseInt(r)),isCeilingLamp:n,isCarpet:s,createdAt:t.createdAt,updatedAt:t.updatedAt,link:t.link}}}(i),e._productQueue[t].loadStage=1,e.products[t]))).catch((t=>{console.warn(t.message)}));return e._promiseCache.add(a,l),l}var us=function(){var t=r((function*({node:t,event:e,args:i,state:r,options:n}){var o=null==n?void 0:n.interiorUpdate,s="add-child"===e||"remove-child"===e,a="set-materials"===e,h=r.active.reduce(((t,e)=>t.concat(e.findAll({type:"interior"}))),[]),l=[];if(o?l=r.scene.nodesByType.interior:s?l="add-child"===e?[i]:[]:a?l=[t]:r.active.length&&(l=h),l=l.filter((t=>"interior"===t.type)),(o||s||a)&&(yield Promise.all(l.map((t=>is(t,r).catch((t=>console.error(t))))))),l.forEach((t=>{var e=cs(t,r);if(e){ps(e,r);var i=r.resources.assets.findIndex((e=>e.id===t.id));i>-1?r.resources.assets[i]=e:r.resources.assets.push(e)}})),"remove-child"===e){var u=r.resources.assets.findIndex((t=>t.id===i.id));u>-1&&r.resources.assets.splice(u,1),ps({id:i.id},r)}return r.active.length&&hs(r,r.active[0]),r.emit("scene-loaded",!0),Promise.resolve(!0)}));return function(e){return t.apply(this,arguments)}}();function ps(t,e){if(null!=t&&t.id){var i=t.position&&function(t,e){for(var i,r=0;r<e.resources.spaces.length;r++){var n=e.resources.spaces[r];if(ft([t.x,t.z],n.polygons[0],n.polygons.slice(1))){i=n;break}}return i}(t.position,e);i&&!i.assets.includes(t.id)&&i.assets.push(t.id),e.resources.spaces.forEach((e=>{if(!i||e.id!==i.id){var r=e.assets.findIndex((e=>e===t.id));r>-1&&e.assets.splice(r,1)}}))}}function cs(t,e){if(t){var i=t.getWorldPosition(),r=t.src&&t.src.substring(1),n=e.products[r];if(n){var o=n.boundingPoints,s=o&&[[o.min[0],o.min[2]],[o.min[0],o.max[2]],[o.max[0],o.max[2]],[o.max[0],o.min[2]]];s=o&&kt(i,s);var a=o&<([s]);return{id:t.id,customId:t.customId,node:t,polygon:s,boundingBox:a,name:n.name,manufacturer:n.manufacturer,productId:r,tags:n.tags,categories:n.categories,subCategories:n.subCategories,dimensions:n.boundingBox,position:{x:i.x,y:i.y,z:i.z},rotation:i.ry}}console.error("no productData",r,t)}}var ds={actions:{},active:[],activeGroup:null,activeBb:{},products:{},productContours:{},productBoundingBoxes:{},resources:{spaces:[],assets:[]},computed:{connectedSpaces:[],facade:{},mergedSpace:{},relations:{walls:[],spaces:[]},snapPoints:[],wallContours:[]},listeners:{},schemaLoaded:new class{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}reset(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}},isSceneStructureLoaded:!1,sceneBBox:{},guide:null,schema:{},materials:[],isMobile:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),cursor:[0,0],snapCursor:null,windowPos:[0,0],lastSceneClick:[0,0],clickStart:[],history:[],viewportInFocus:!0,keyString:null,_productQueue:{},_textureQueue:{},_gfxNodes:{},_gfxLayers:{},viewbox:{},client:[],zoom:1,scale:100,key:"",shiftKey:!1,altKey:!1,ctrlKey:!1,isDragging:!1,isPanning:!1,isMeasuring:!1,isDrawingRectangle:!1,isDrawingPolygon:!1,editingRectangle:null,editingPolygon:null,dragElement:null,isCreatingElement:!1,editPolygon:!1,infoWindows:[],htmlMarkers:[],markerPins:[]};function fs(t,{format:e,fileName:i,quality:r}={}){if("svg"!==e){var n=new Image;n.src=t,n.onload=function(){var t=document.createElement("canvas");t.width=n.naturalWidth,t.height=n.naturalHeight;var o=t.getContext("2d");o.imageSmoothingEnabled=!1,o.drawImage(n,0,0),function(t,{format:e="png",fileName:i="floorplan",quality:r=.95}){var n=document.createElement("a");n.download=i+"."+e;var o="png"===e?[]:["image/jpeg",r];t.toBlob((function(t){n.href=URL.createObjectURL(t),n.click()}),...o)}(t,{format:e,fileName:i,quality:r})}}}function vs(t,i,r,n){if((i.length||null!=n&&n.forceUpdate)&&(null==n||!n.skipHistory)){var o=r.resources.spaces,s={};o.forEach((t=>{r._debugSpaceMatching&&t.node.setHighlight(),s[t.id]=t}));var a=0,h=0,l=0,u=0,p=r.getActiveLevel(),c=null==n?void 0:n.actionId;return t.forEach((t=>{var i,n,l,d;t.holes=t.holes.filter((t=>gt(t)>.05)),t.center=Lt(t.boundary.shape,t.holes),t.polygons=[t.boundary.shape,...t.holes];for(var f=0;f<o.length;f++){var v=o[f];if(s[v.id]){if(wt(v.polygons,t.polygons)){n=v,delete s[v.id];break}var y=t.polygons.slice(1).filter((t=>gt(t)>1));if(0!==ft(v.center,t.polygons[0],y)){l=v,delete s[v.id];break}}if(0!==ft(t.center,v.polygons[0],v.polygons.slice(1))){d=v;break}}if(n)u++;else{var g=function(t,e){var i=e.getParents().reverse();i.push(e);var r=Object.assign({},t);return i.forEach((t=>Rt(r,t,!0))),r}({x:0,y:0,z:0,ry:0},p),m=kt(g,t.boundary.shape),{polygon:_,center:x}=St(m),b={polygon:_,polygonHoles:t.holes?t.holes.map((t=>St(kt(g,t),x).polygon)):[],x:x[0],z:x[1],ry:0};if(null!==(i=l)&&void 0!==i&&i.node)a++,l.node.set(b,{updateState:!1,actionId:c}),r._debugSpaceMatching&&l.node.setHighlight({fill:[255,240,180]});else{var P;h++,null!==(P=d)&&void 0!==P&&P.node?b=e(e({},d.node.toJson({regenerateIds:!0})),b):b.type="polyfloor";var w=p.addChild(b,{updateState:!1,actionId:c});r._debugSpaceMatching&&w.setHighlight({fill:[200,255,180]})}}})),Object.values(s).forEach((t=>{l++,p.removeChild(t.node,{updateState:!1,actionId:c})})),r._debugSpaceMatching&&console.log("matched",u,"transformed",a,"created",h,"deleted",l),a+h+l}}class ys{constructor({options:t}={}){var e=qn(ds);Object.keys(e).forEach((t=>this[t]=e[t])),this.settings={},this.updateSettings(t),this.changeOptions=t=>this.emit("change-options",t),this.scene=null,this._emitter=new H}initScene(t){var e,i;this._gfxNodes={},this.isSceneStructureLoaded=!1,this.scene||(this.scene=t),gs(this),this.isSceneStructureLoaded=!0,this.emit("state-loaded",!0),this.settings.theme.wallContours&&this.updateWallContours(),this.getSpaces(),this.computed.relations.walls=ze(this),(e=this,i=e.scene.nodesByType.interior,Promise.all(i.map((t=>is(t,e).catch((t=>console.error(t)))))).then((()=>{e.resources.assets=i.map((t=>cs(t,e))).filter((t=>t))}))).then((()=>{this.emit("scene-loaded",!0)})),this.settings.computeConnectedSpaces&&this.getConnectedSpaces()}on(t,e,i){t&&e?this._emitter.on(t,e,i):console.log("invalid event listener")}off(t,e,i){t&&e?this._emitter.off(t,e,i):console.log("invalid request")}once(t,e,i){t&&e?this._emitter.once(t,e,i):console.log("invalid event listener")}emit(t,e,i,r,n){this._emitter&&this._emitter.emit(t,e,i,r,n)}getActiveLevel(){return this.scene.nodesByType.level&&this.scene.nodesByType.level[0]}getScene(){return this.scene.node}getSceneBoundingBox(t=0){if(this.settings.svgMode){var i=this.scene.nodesByType.wall.map((t=>t.getWorldPosition())).map(Ft),r=this.scene.nodesByType.floor.map((t=>t.getWorldPosition())).map(Ft),n=this.scene.nodesByType.stairs.map((t=>t.getWorldPosition())).map(Ft),o=[...i,...this.resources.spaces.map((t=>t.polygons[0])),...this.resources.assets.map((t=>t.polygon)).filter((t=>t)),...r,...n].reduce(((t,e)=>t.concat(e)),[]),s={x:1/0,z:1/0,x2:-1/0,z2:-1/0};return o.forEach((t=>{t[0]<s.x&&(s.x=t[0]),t[0]>s.x2&&(s.x2=t[0]),t[1]<s.z&&(s.z=t[1]),t[1]>s.z2&&(s.z2=t[1])})),s.x-=t,s.z-=t,s.x2+=t,s.z2+=t,e(e({},s),{},{length:s.x2-s.x,width:s.z2-s.z})}var a=this._getViewport&&this._getViewport();if(a){var h=a.children.find((t=>t._sceneLayer));if(!h)return new Promise.resolve(!1);var{x:l,y:u,width:p,height:c}=h.getLocalBounds(),d={x:l/this.scale-t,z:u/this.scale-t,length:p/this.scale+2*t,width:c/this.scale+2*t};return d.x2=d.x+d.length,d.z2=d.z+d.width,d}}getElementBoundingBox(t,e=0){var i,r;if(t&&(t instanceof le?r=t.getWorldPosition():"string"==typeof t&&(r=(i=this.scene.nodesById[t].find({id:t}))&&i.getWorldPosition()),r)){var n;if("interior"===r.type&&r.src){var o=r.src.substring(1),s=this.productBoundingBoxes[o]||this.productContours[o];n=s&&kt(r,s[0])}else n="polyfloor"===r.type?kt(r,r.polygon):"group"!==r.type?Ft(r):[[r.x-2,r.z-2],[r.x+2,r.z-2],[r.x+2,r.z+2],[r.x-2,r.z+2]];var a=lt([n]);return{x:a.x-e,z:a.z-e,x2:a.x2+e,z2:a.z2+e,length:a.length+2*e,width:a.width+2*e}}}setBb(t,e=!1){var i=this.getElementBoundingBox(t,1,e);i&&(e?this.activeGroupBb={w:i.width,h:i.height,x:i.x,y:i.y}:this.activeBb={w:i.width,h:i.height,cx:i.cx,cy:i.cy})}setActive(t={}){Ne(e(e({},t),{},{state:this}))}updateSpaceRelations(){var t=this.resources.spaces.map((t=>{var i=e({},t),r=i.assets;return delete i.assets,e(e({},i),{},{interiors:r.map((t=>this.scene.nodesById[t]))})}));this.computed.relations.spaces=Jt({scene:this.scene,spaces:t}),this.emit("space-relations")}getConnectedSpaces(t){if(!this.settings.svgMode){var{connectedSpaces:e,facade:i}=function(t){var{spaces:e,holes:i,outline:r}=xe(t),n=e.map(((t,e)=>({boundary:{shape:t},holes:i[e]||[]})));return{connectedSpaces:n,facade:{boundary:{shape:r}}}}(this.scene);if(this.settings.updateFloors&&e.length&&this.resources.spaces)vs(e,this.computed.connectedSpaces,this,t)&&this.getSpaces();this.updateSpaceRelations(),this.computed.connectedSpaces=e,this.computed.facade=i;var r=this.computed.facade.boundary.shape,{openings:n}=Vt({polygons:[r],scene:this.scene});this.computed.facade.boundary.openings=n,e.length&&(ms({state:this}),this.settings.computeMergedSpace&&this.computeMergedSpace(this.scene))}}getSpaces(t=!1){var i=_e({scene:this.scene});this.resources.spaces=i.map((t=>{var i=t.interiors;return delete t.interiors,e(e({},t),{},{assets:i.map((t=>t.id))})})),ms({state:this},t);var r=this._getViewport&&this._getViewport();r&&r._updateRoomStamps&&r._updateRoomStamps()}computeMergedSpace(t){var e=function(t){var{spaces:e,holes:i,outline:r}=xe(t),n=t.nodesByType.door.map((t=>{var e=t.getWorldPosition();return e.w=t.parent.w,e})),o=t.nodesByType.window.map((t=>{var e=t.getWorldPosition();return e.w=t.parent.w,e})).filter((t=>{var e;return null==(e=t.class)?void 0:e.includes("slidingDoor")})),s=(n=[...n,...o]).map((t=>{var e=Ft(t);return Gt(e=pt([e],.05)[0])})),a=i.reduce(((t,e)=>t.concat(e)),[]),h=jt(a,e).reduce(((t,e)=>t.concat(e)),[]),l=a.length?ct(a,[...s,...h]):[],u=ut([...e,...s]),{counterClockwise:p,clockwise:c}=Yt(u);return{boundary:{shape:(p=p.sort(((t,e)=>{var i=gt(t),r=gt(e);return i>r?-1:i<r?1:0})))[0]},holes:[...l,...c],outline:r}}(t),i=[e.boundary.shape],{openings:r}=Vt({polygons:i,scene:t});e.boundary.openings=r,e.x=0,e.z=0,this.computed.mergedSpace=e}exportImage({format:t,fileName:e,quality:i,output:n,maxWidth:o,download:s=!1}={}){var a=this;return r((function*(){var r={format:t,quality:i,output:n,maxWidth:o};s&&"svg"!==t&&(r.format="png"),s&&"svg"===t&&(r.output="text");var h=yield function(t,{format:e="png",quality:i=.95}){return new Promise((r=>{var n=document.querySelector("#"+t.settings.editorId+" canvas");r("jpg"===e?n.toDataURL("image/jpeg",i):n.toDataURL())}))}(a,r).catch((t=>t));if(!s)return h;fs(h,{format:t,fileName:e,quality:i})}))()}getResourcesFromPosition(t){var e=this.resources.spaces.filter((e=>ft(t,e.polygons[0],e.polygons.slice(1)))),i=[];return e.forEach((e=>{var r=this.resources.assets.filter((t=>e.assets.includes(t.id))).filter((e=>{var i;if((null===(i=this.products[e.productId])||void 0===i||!i.isCeilingLamp||this.settings.showCeilingLamps)&&e.polygon&&e.polygon.length)return ft(t,e.polygon)}));i.push(...r)})),{spaces:e,assets:i}}rotatePlan({rotDelta:t,newRotation:i}){var r=this.scene.node.ry;void 0===i&&(i=(this.settings.planRotation+t)%360),this.updateSettings(e(e({},this.settings),{},{planRotation:i})),this.lastSceneClick=Te({points:[this.lastSceneClick],oldRotation:r,newRotation:i,rootNode:this.scene})[0],this.infoWindows=this.infoWindows.map((t=>{var n=Te({points:[t.pos],oldRotation:r,newRotation:i,rootNode:this.scene})[0];return e(e({},t),{},{pos:n})})),this.once("scene-rendered",(()=>this.zoomExtents(1,500)))}updateWallContours(){this.computed.wallContours=((t,e=!0,i=!1)=>{var r=t.nodesByType.column.map((t=>t.getWorldPosition())),n=[...t.nodesByType.wall.map((t=>t.getWorldPosition())),...r].map((t=>{var r=Ft(t);if(e&&(r=pt([r],.001)[0]),i)return[r];var n=Qt(t,"window"),o=Qt(t,"door"),s=n.concat(o);return(null==(s=s.map((e=>(e.w=t.w,e))))?void 0:s.length)?ct([r],s.map(Ft),.002):[r]})),o=n.reduce(((t,e)=>t.concat(e)),[]),s=o.length?ut(o):[],{counterClockwise:a,clockwise:h}=Yt(s),l=jt(a,h),u=a.map(((t,e)=>[t,...l[e]||[]]));return u})(this.scene),this.emit("wall-contours-computed",this.computed.wallContours)}updateSettings(t){var e,i,r,n,s,a=Mo(qn(o),t);if(null!=t&&t.selectAllowList&&(a.selectAllowList=[...t.selectAllowList]),this.settings=a,null!==(e=this.settings)&&void 0!==e&&null!==(i=e.theme)&&void 0!==i&&null!==(r=i.elements)&&void 0!==r&&null!==(n=r.space)&&void 0!==n&&n.program){var h=this.settings.theme.elements.space.program,l={wash:"care",operate:"support",common:"socialize"};Object.keys(h).forEach((t=>{Object.keys(l).includes(t)&&(h[l[t]]=h[t],delete h[t])}))}this.scene&&this.scene.node&&(!a.theme.wallContours||null!==(s=this.computed.wallContours)&&void 0!==s&&s.length||this.updateWallContours(),this.scene.node.ry!==a.planRotation&&Number.isFinite(a.planRotation)&&(this.scene.node.set({ry:parseFloat(a.planRotation)}),this.updateState(),this.computed.wallContours&&this.updateWallContours()),a.computeConnectedSpaces&&!this.computed.connectedSpaces.length&&this.getConnectedSpaces(),this.getSpaces());return this._redrawScene&&this._redrawScene(),this.emit("update-settings",this.settings),this.settings}updateState({node:t,args:e={},options:i={},event:n}={}){var o=this;return r((function*(){var r=!t&&!n,s="add-child"===n||"remove-child"===n,a="set-materials"===n||e.materials,h=null==t?void 0:t.type,l="plan"===h||"level"===h,u=!(!1===i.updateState)&&(r||!0===i.updateState||s||a||l),p=null==e?void 0:e.type,c=["wall","column","a:helper:spaceDivider"],d=c.includes(h)||c.includes(p);if(u&&(r||o.isSceneStructureLoaded)){var f=0,v=0;for(var y in e)if(f++,"_isSelected"===y)v++;if(!f||f!==v){var g="interior"===p||"interior"===h||"group"===h||i.interiorUpdate;gs(o),g?yield us({node:t,event:n,args:e,options:i,state:o}):["floor","polyfloor"].includes(h)?o.getSpaces():d?(o.settings.computeConnectedSpaces&&o.getConnectedSpaces(i),o.computed.relations.walls=ze(o)):h&&"level"!==h&&"plan"!==h||("plan"===h&&o.scene.setSceneType(o.scene),s||!o.settings.computeConnectedSpaces||o.computed.connectedSpaces.length||o.getConnectedSpaces(i),o.getSpaces(),o.computed.relations.walls=ze(o)),o.emit("state-updated",{})}}}))()}destroy(){var t;this._emitter.off(),null===(t=this.scene)||void 0===t||t._emitter.off(),this.scene=null,this._emitter=null,this.computed=null}}var gs=function(t,e,i){var r=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return ui(i)&&(r="leading"in i?!!i.leading:r,n="trailing"in i?!!i.trailing:n),Eo(t,e,{leading:r,maxWait:e,trailing:n})}((function(t){var e=t.getSceneBoundingBox();e&&e.x&&(t.sceneBBox=e)}),200),ms=({state:t},e)=>{var i=[],r=[];if(t.settings.snapWallContours){var n=t.computed.connectedSpaces.reduce(((t,e)=>t.concat([e.boundary.shape,...e.holes])),[]);t.computed.facade.boundary&&n.push(t.computed.facade.boundary.shape),i=n.reduce(((t,e)=>t.concat(e)),[])}if(t.settings.snapSpaces){var o=!!t.active.length&&t.active[0].id;r=(e?t.resources.spaces:t.resources.spaces.filter((t=>t.id!==o))).reduce(((t,e)=>t.concat(e.polygons)),[]).reduce(((t,e)=>t.concat(e)),[])}t.computed.snapPoints=[...i,...r]},_s=t=>{var e=3.28084,i=t*e,r=Math.sign(t),n=t>0?Math.floor(t*e):Math.ceil(t*e),o=Math.round(39.3701*t%12);return 12===o&&(n+=1,o=0),{feet:i,feetInt:n,inchInt:o,inchDisplay:o*r}},xs=t=>({sqft:10.7639111056*t}),bs=t=>t/180*Math.PI;class Ps{constructor(t,e){t&&e&&(this.data={cursor:[0,0]},this._state=e,this._state.on("mousemove",this.update,this),this.mount(t),this.update())}update(){if(this.rootEl){var t=[0,0];if("imperial"===this._state.settings.units.system){var{feetInt:e,inchDisplay:i}=_s(this._state.cursor[0]),{feetInt:r,inchDisplay:n}=_s(this._state.cursor[1]);t=["".concat(e,"′ ").concat(i,"″"),"".concat(r,"′ ").concat(n,"″")]}else t=[this._state.cursor[0].toFixed(2),this._state.cursor[1].toFixed(2)];this.setData({cursor:t})}}setData(t={}){for(var e in t)this.data[e]=t[e];this.rootEl.innerHTML=this.template(this.data)}template(t={}){return'<span class="fpe-coordinates__unit">x:'.concat(t.cursor[0],'</span>\n <span class="fpe-coordinates__unit">z:').concat(t.cursor[1],"</span>")}mount(t){this.rootEl||(this.rootEl=document.createElement("div"),this.rootEl.classList.add("fpe-coordinates"),t.appendChild(this.rootEl))}destroy(){this._state.off("mousemove",this.update),delete this._state._cursorCoordinates,this.rootEl.remove(),delete this._state,delete this.data}}var ws=100,Es=80;class Ts{constructor({width:t,height:e,pos:i=[0,0],html:r="",closeButton:n=!0,floorPlan:o}={}){this._floorPlan=o,this.pos=i,this.html=r,this.closeButton=n,this._anchorPos=null;var s=t||ws;this.width=Math.max(100,s);var a=e||Es;this.height=Math.max(50,a),this._getPosition=()=>{this._anchorPos=this._floorPlan.state.getScreenPosition(this.pos),this._updateInfoWindow()},this._getPosition(),this._createInfoWindow(),this._floorPlan.on("viewbox",this._getPosition,this),this._floorPlan.on("resize-canvas",this._getPosition,this)}_createInfoWindow(){var t=document.querySelector("#".concat(this._floorPlan.state.settings.editorId,".fpe")),e=t.querySelector("canvas");this.el||(this.el=document.createElement("div"),this.el.classList.add("fpe-info-window"),t.appendChild(this.el),this.el.addEventListener("wheel",(t=>{var i=new WheelEvent(t.type,t);e.dispatchEvent(i)}))),this._setContent(),this._updateInfoWindow()}_setContent(){var t='<div class="fpe-info-window__content">'.concat(this.html,"</div>");this.closeButton&&(t+='<div class="fpe-info-window__close" @click="infoWindow.remove">'.concat('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">\n <g fill="none" stroke="#000" stroke-width="1.2" stroke-miterlimit="10">\n <path d="M11.8 11.8l16.4 16.4M11.8 28.2l16.3-16.4" />\n </g>\n</svg>',"</div>")),this.el.innerHTML=t;var e=this.el.querySelector(".fpe-info-window__close");e&&e.addEventListener("click",this.remove.bind(this))}_updateInfoWindow(){if(this.el){var t=this._floorPlan.state.isPanning?"pointer-events: none;":"",e=this._anchorPos[0]-47,i=this._anchorPos[1]-this.height-15,r=1e3+2*this.pos[1],n=this.height,o=this.width;this.el.setAttribute("style","transform: translate(".concat(e,"px, ").concat(i,"px);").concat(t," height:").concat(n,"px; width:").concat(o,"px; z-index:").concat(r))}}set({width:t,height:e,pos:i,html:r,closeButton:n}){void 0!==i&&(this.pos=i),void 0!==t&&(this.width=Math.max(100,t)),void 0!==e&&(this.height=Math.max(50,e)),void 0!==r&&(this.html=r),void 0!==n&&(this.closeButton=n),void 0===r&&void 0===n||this._setContent(),this._getPosition()}remove(){this._floorPlan.off("viewbox",this._getPosition),this._floorPlan.off("resize-canvas",this._getPosition),this.el.remove(),this._floorPlan=null}}class Cs{constructor({pos:t=[0,0],offset:e=[0,0],el:i,floorPlan:r}){if(n(this,"_updateHtmlMarker",(()=>{this.el&&(this.isHidden=!(([t,e],i,r=0)=>i.x-r<t&&i.x+i.length+r>t&&i.z-r<e&&i.z+i.width+r>e)(this.pos,this._floorPlan.state.viewbox,5),this.el.classList.toggle("fpe-marker--hidden",this.isHidden),this.isHidden||(this._anchorPos=this._floorPlan.getScreenPosition(this.pos),this._updateHtmlMarkerStyle()))})),r)if(i instanceof Element!=!1){this.el=i;var o=document.querySelector("#".concat(r.state.settings.editorId,".fpe")),s=o.querySelector("canvas");o.appendChild(this.el),this.el.classList.add("fpe-marker");var{width:a,height:h}=i.getBoundingClientRect();this.el.addEventListener("wheel",(t=>{var e=new WheelEvent(t.type,t);s.dispatchEvent(e)})),this.id=j(),this._floorPlan=r,this.pos=t,this.size=[a,h],this.offset=e,this._updateHtmlMarker(),this._floorPlan.on("viewbox",this._updateHtmlMarker),this._floorPlan.on("drag-end",this._updateHtmlMarker),this._floorPlan.on("resize-canvas",this._updateHtmlMarker)}else console.warn("no Element provided")}_updateHtmlMarkerStyle(){var t=this._floorPlan.state.isPanning?"pointer-events: none":"",e=this.offset?this.offset:[0,0],i=this._anchorPos[0]-this.size[0]/2+e[0],r=this._anchorPos[1]-this.size[1]/2+e[1];this.el.setAttribute("style","transform: translate(".concat(i,"px, ").concat(r,"px);").concat(t))}set({pos:t,offset:e}){void 0!==t&&(this.pos=t),void 0!==e&&(this.offset=e),this._updateHtmlMarker()}remove(){this._floorPlan.off("viewbox",this._updateHtmlMarker),this._floorPlan.off("resize-canvas",this._updateHtmlMarker),this._floorPlan.off("drag-end",this._updateHtmlMarker),this.el.remove(),this._floorPlan=null}}var Is,Ss,Os,As,Ms,Ls,Ns,Rs,Ds,Fs,ks,Bs,Us,zs,Xs,js,Ys,Hs,Gs,Ws=(t,e,i=[0,0],r=.15)=>{for(var n,o,s,a,h=0;h<e.length;h++)if(n=e[h],!((o=Math.abs(t[0]-i[0]-n[0]))>r)&&(s=Math.abs(t[1]-i[1]-n[1]),o<r&&s<r)){a=n;break}return a},Vs=(t,e,i=.15)=>{for(var r,n=0;n<e.length;n++){var o=e[n][0],s=e[n][1],a=[Math.min(o[0],s[0]),Math.min(o[1],s[1])],h=[Math.max(o[0],s[0]),Math.max(o[1],s[1])],l=t[0]>a[0]-i&&t[0]<h[0]+i,u=t[1]>a[1]-i&&t[1]<h[1]+i;if(l&&u){var p={x:o[0]-s[0],z:o[1]-s[1]},c={x:p.z,z:-p.x},d={x:t[0],z:t[1]},f=tt({x:o[0],z:o[1]},{x:s[0],z:s[1]},d,it(d,c));if(Z(d,f)<=i){r=[f.x,f.z];break}}}return r},qs=({point:t,walls:e,offset:i=[0,0],margin:r=.15,node:n,isWallChild:o})=>{var s,a,h,l=o,u=o;o&&n&&n.parent&&(e=e.filter((t=>t.node.id===n.parent.id)),r=20);for(var p=0;p<e.length;p++){var c=e[p].points;if(s=!l&&Ws(t,c,i,r)){h={point:s,node:e[p].node};break}var d=[[c[0],c[1]],[c[2],c[3]]];if(a=Vs(t,d,r)){h={point:a,node:e[p].node,isEdge:!0};break}}if(!h&&!u){var f=((t,e,i,r=.15)=>{for(var n,o,s,a=[],h=0;h<e.length;h++)n=e[h],o=Math.abs(t[0]-i[0]-n[0]),s=Math.abs(t[1]-i[1]-n[1]),o<r&&s<10?a.push({distance:s,point:[n[0],t[1]],refPoint:n}):o<10&&s<r&&a.push({distance:o,point:[t[0],n[1]],refPoint:n});return a.sort(((t,e)=>t.distance-e.distance))})(t,e.reduce(((t,e)=>t.concat(e.points)),[]),i,r);f.length&&(h=f[0])}return h};!function(t){t[t.WEBGL_LEGACY=0]="WEBGL_LEGACY",t[t.WEBGL=1]="WEBGL",t[t.WEBGL2=2]="WEBGL2"}(Is||(Is={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.WEBGL=1]="WEBGL",t[t.CANVAS=2]="CANVAS"}(Ss||(Ss={})),function(t){t[t.COLOR=16384]="COLOR",t[t.DEPTH=256]="DEPTH",t[t.STENCIL=1024]="STENCIL"}(Os||(Os={})),function(t){t[t.NORMAL=0]="NORMAL",t[t.ADD=1]="ADD",t[t.MULTIPLY=2]="MULTIPLY",t[t.SCREEN=3]="SCREEN",t[t.OVERLAY=4]="OVERLAY",t[t.DARKEN=5]="DARKEN",t[t.LIGHTEN=6]="LIGHTEN",t[t.COLOR_DODGE=7]="COLOR_DODGE",t[t.COLOR_BURN=8]="COLOR_BURN",t[t.HARD_LIGHT=9]="HARD_LIGHT",t[t.SOFT_LIGHT=10]="SOFT_LIGHT",t[t.DIFFERENCE=11]="DIFFERENCE",t[t.EXCLUSION=12]="EXCLUSION",t[t.HUE=13]="HUE",t[t.SATURATION=14]="SATURATION",t[t.COLOR=15]="COLOR",t[t.LUMINOSITY=16]="LUMINOSITY",t[t.NORMAL_NPM=17]="NORMAL_NPM",t[t.ADD_NPM=18]="ADD_NPM",t[t.SCREEN_NPM=19]="SCREEN_NPM",t[t.NONE=20]="NONE",t[t.SRC_OVER=0]="SRC_OVER",t[t.SRC_IN=21]="SRC_IN",t[t.SRC_OUT=22]="SRC_OUT",t[t.SRC_ATOP=23]="SRC_ATOP",t[t.DST_OVER=24]="DST_OVER",t[t.DST_IN=25]="DST_IN",t[t.DST_OUT=26]="DST_OUT",t[t.DST_ATOP=27]="DST_ATOP",t[t.ERASE=26]="ERASE",t[t.SUBTRACT=28]="SUBTRACT",t[t.XOR=29]="XOR"}(As||(As={})),function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(Ms||(Ms={})),function(t){t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL"}(Ls||(Ls={})),function(t){t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"}(Ns||(Ns={})),function(t){t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT"}(Rs||(Rs={})),function(t){t[t.FLOAT=0]="FLOAT",t[t.INT=1]="INT",t[t.UINT=2]="UINT"}(Ds||(Ds={})),function(t){t[t.NEAREST=0]="NEAREST",t[t.LINEAR=1]="LINEAR"}(Fs||(Fs={})),function(t){t[t.CLAMP=33071]="CLAMP",t[t.REPEAT=10497]="REPEAT",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(ks||(ks={})),function(t){t[t.OFF=0]="OFF",t[t.POW2=1]="POW2",t[t.ON=2]="ON",t[t.ON_MANUAL=3]="ON_MANUAL"}(Bs||(Bs={})),function(t){t[t.NPM=0]="NPM",t[t.UNPACK=1]="UNPACK",t[t.PMA=2]="PMA",t[t.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",t[t.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",t[t.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA"}(Us||(Us={})),function(t){t[t.NO=0]="NO",t[t.YES=1]="YES",t[t.AUTO=2]="AUTO",t[t.BLEND=0]="BLEND",t[t.CLEAR=1]="CLEAR",t[t.BLIT=2]="BLIT"}(zs||(zs={})),function(t){t[t.AUTO=0]="AUTO",t[t.MANUAL=1]="MANUAL"}(Xs||(Xs={})),function(t){t.LOW="lowp",t.MEDIUM="mediump",t.HIGH="highp"}(js||(js={})),function(t){t[t.NONE=0]="NONE",t[t.SCISSOR=1]="SCISSOR",t[t.STENCIL=2]="STENCIL",t[t.SPRITE=3]="SPRITE"}(Ys||(Ys={})),function(t){t[t.NONE=0]="NONE",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=8]="HIGH"}(Hs||(Hs={})),function(t){t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"}(Gs||(Gs={}));
|
|
8
|
+
function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function e(e){for(var i=1;i<arguments.length;i++){var r=null!=arguments[i]?arguments[i]:{};i%2?t(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(t,e,i,r,n,o,s){try{var a=t[o](s),h=a.value}catch(t){return void i(t)}a.done?e(h):Promise.resolve(h).then(r,n)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var s=t.apply(e,r);function a(t){i(s,n,o,a,h,"next",t)}function h(t){i(s,n,o,a,h,"throw",t)}a(void 0)}))}}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var o={api:{spaceApiV2Url:"https://api.archilogic.com/v2",storageUrl:"https://storage.archilogic.com",staticProductCache:"/archilogic/product/json",staticProductThumb:"/archilogic/product/thumb",staticProductOutline:"/archilogic/product/outline",staticMatLib:"/archilogic/matlib",sdkVersion:"3.2.1",productDataCacheAge:864e5,productContourCacheAge:864e6},computeMergedSpace:!1,computeConnectedSpaces:!1,loadWallRelations:!1,debug:!1,editable:{},editorId:"floor-plan-engine",exposeInstance:!1,hideElements:[],maxHistorySteps:20,panZoom:!0,planRotation:0,preserveViewbox:"center-center",roomStampSize:null,selectElements:!1,selectAllowList:["interior","group","polyfloor"],showFloorPlan:!1,showSpaceDividers:!1,showCeilingLamps:!1,showFloorTextures:!1,snapWallContours:!1,snapSpaces:!0,transformElements:!0,updateFloors:!1,xrayMode:!1,destroyOnDomRemove:!1,ui:{menu:!0,measure:!0,rotatePlan:!1,zoomExtents:!0,scale:!0,coordinates:!1},shortcuts:{measureConfirm:"Enter",measureCancel:"Escape",measureUndo:"Backspace"},spaceLabelMapping:{},theme:{background:{color:"#f3f5f8",showGrid:!1},wallContours:!1,showAssetTextures:!1,elements:{roomStamp:{showArea:!0,showUsage:!0}}},units:{system:"metric",digits:0,roomDimensions:"area"}};function s(t,e,i){this.name="JsonRpcError",this.message=t||"There was a problem. Please check your internet connection and try again.",this.stack=(new Error).stack,this.code=e,this.data=i}function a(t){return h.apply(this,arguments)}function h(){return(h=r((function*(t){if(t.status>=200&&t.status<400)return t;var e=yield t.text();try{var i=yield JSON.parse(e);return"string"==typeof i.error?Promise.reject(i.error):i.error&&void 0!==i.error.code?Promise.reject(new s(i.error.message,i.error.code,i.error.data)):Promise.reject(i)}catch(t){return Promise.reject(e)}}))).apply(this,arguments)}function l(t){return t.json()}function u(t){return fetch(t).then(a,(t=>{throw t})).then(l,(t=>{throw t})).catch((t=>Promise.reject(t)))}var p={scene:{read:function(t,e){return function(t,e,i){var r=new URL(o.api.spaceApiV2Url+t);i&&Object.keys(i).forEach((t=>r.searchParams.append(t,i[t])));var n={"Content-Type":"application/json"};o.api.sdkVersion&&(n["x-sdk-version"]=o.api.sdkVersion);var{publishableToken:s,authorization:h}=e;if(h)n.Authorization=h;else{if(!s)return Promise.reject("Either authorization or publishableToken must be provided in accessToken.");r.searchParams.append("pubtoken",s)}return fetch(r,{method:"GET",headers:n,body:JSON.stringify(i)}).then(a).then(l)}("/floor/".concat(t,"/scene-structure"),e)}},product:{read:function(t){return u(o.api.storageUrl+o.api.staticProductCache+"/"+t+".json")},outline:function(t){return u(o.api.storageUrl+o.api.staticProductOutline+"/"+t+".json")}}},c=e({},p),d={version:"6.4.2.2",use_lines:!0,use_xyz:!1},f=function(t,e){var i;if(void 0===Object.getOwnPropertyNames){for(i in e.prototype)void 0!==t.prototype[i]&&t.prototype[i]!==Object.prototype[i]||(t.prototype[i]=e.prototype[i]);for(i in e)void 0===t[i]&&(t[i]=e[i]);t.$baseCtor=e}else{for(var r=Object.getOwnPropertyNames(e.prototype),n=0;n<r.length;n++)void 0===Object.getOwnPropertyDescriptor(t.prototype,r[n])&&Object.defineProperty(t.prototype,r[n],Object.getOwnPropertyDescriptor(e.prototype,r[n]));for(i in e)void 0===t[i]&&(t[i]=e[i]);t.$baseCtor=e}};d.Path=function(){return[]},d.Path.prototype.push=Array.prototype.push,d.Paths=function(){return[]},d.Paths.prototype.push=Array.prototype.push,d.PolyNode=function(){this.m_Parent=null,this.m_polygon=new d.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},d.PolyNode.prototype.IsHoleNode=function(){for(var t=!0,e=this.m_Parent;null!==e;)t=!t,e=e.m_Parent;return t},d.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},d.PolyNode.prototype.Contour=function(){return this.m_polygon},d.PolyNode.prototype.AddChild=function(t){var e=this.m_Childs.length;this.m_Childs.push(t),t.m_Parent=this,t.m_Index=e},d.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},d.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},d.PolyNode.prototype.Childs=function(){return this.m_Childs},d.PolyNode.prototype.Parent=function(){return this.m_Parent},d.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},d.PolyTree=function(){this.m_AllPolys=[],d.PolyNode.call(this)},d.PolyTree.prototype.Clear=function(){for(var t=0,e=this.m_AllPolys.length;t<e;t++)this.m_AllPolys[t]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},d.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},d.PolyTree.prototype.Total=function(){var t=this.m_AllPolys.length;return t>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&t--,t},f(d.PolyTree,d.PolyNode),d.Clear=function(t){t.length=0},d.PI=3.141592653589793,d.PI2=6.283185307179586,d.FPoint=function(){var t=arguments,e=t.length;if(this.X=0,this.Y=0,d.use_xyz)if(this.Z=0,3===e)this.X=t[0],this.Y=t[1],this.Z=t[2];else if(2===e)this.X=t[0],this.Y=t[1],this.Z=0;else if(1===e)if(t[0]instanceof d.FPoint){var i=t[0];this.X=i.X,this.Y=i.Y,this.Z=0}else{void 0===(r=t[0]).Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z}else this.X=0,this.Y=0,this.Z=0;else if(2===e)this.X=t[0],this.Y=t[1];else if(1===e)if(t[0]instanceof d.FPoint){i=t[0];this.X=i.X,this.Y=i.Y}else{var r=t[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},d.FPoint.op_Equality=function(t,e){return t.X===e.X&&t.Y===e.Y},d.FPoint.op_Inequality=function(t,e){return t.X!==e.X||t.Y!==e.Y},d.FPoint0=function(){this.X=0,this.Y=0,d.use_xyz&&(this.Z=0)},d.FPoint0.prototype=d.FPoint.prototype,d.FPoint1=function(t){this.X=t.X,this.Y=t.Y,d.use_xyz&&(void 0===t.Z?this.Z=0:this.Z=t.Z)},d.FPoint1.prototype=d.FPoint.prototype,d.FPoint1dp=function(t){this.X=t.X,this.Y=t.Y,d.use_xyz&&(this.Z=0)},d.FPoint1dp.prototype=d.FPoint.prototype,d.FPoint2=function(t,e,i){this.X=t,this.Y=e,d.use_xyz&&(this.Z=void 0===i?0:i)},d.FPoint2.prototype=d.FPoint.prototype,d.FRect=function(){var t=arguments,e=t.length;if(4===e)this.left=t[0],this.top=t[1],this.right=t[2],this.bottom=t[3];else if(1===e){var i=t[0];this.left=i.left,this.top=i.top,this.right=i.right,this.bottom=i.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},d.FRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},d.FRect0.prototype=d.FRect.prototype,d.FRect1=function(t){this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom},d.FRect1.prototype=d.FRect.prototype,d.FRect4=function(t,e,i,r){this.left=t,this.top=e,this.right=i,this.bottom=r},d.FRect4.prototype=d.FRect.prototype,d.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},d.PolyType={ptSubject:0,ptClip:1},d.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},d.JoinType={jtSquare:0,jtRound:1,jtMiter:2},d.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},d.EdgeSide={esLeft:0,esRight:1},d.Direction={dRightToLeft:0,dLeftToRight:1},d.TEdge=function(){this.Bot=new d.FPoint0,this.Curr=new d.FPoint0,this.Top=new d.FPoint0,this.Delta=new d.FPoint0,this.Dx=0,this.PolyTyp=d.PolyType.ptSubject,this.Side=d.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},d.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new d.FPoint0},d.MyIntersectNodeSort=function(){},d.MyIntersectNodeSort.Compare=function(t,e){var i=e.Pt.Y-t.Pt.Y;return i>0?1:i<0?-1:0},d.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},d.Scanbeam=function(){this.Y=0,this.Next=null},d.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},d.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},d.OutPt=function(){this.Idx=0,this.Pt=new d.FPoint0,this.Next=null,this.Prev=null},d.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new d.FPoint0},d.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},d.ClipperBase.horizontal=-34e37,d.ClipperBase.Skip=-2,d.ClipperBase.Unassigned=-1,d.ClipperBase.tolerance=1e-20,d.ClipperBase.maxValue=Math.sqrt(Number.MAX_VALUE),d.ClipperBase.minValue=Math.sqrt(Number.MIN_VALUE),d.ClipperBase.near_zero=function(t){return t>-d.ClipperBase.tolerance&&t<d.ClipperBase.tolerance},d.ClipperBase.IsHorizontal=function(t){return 0===t.Delta.Y},d.ClipperBase.prototype.PointIsVertex=function(t,e){var i=e;do{if(d.FPoint.op_Equality(i.Pt,t))return!0;i=i.Next}while(i!==e);return!1},d.ClipperBase.prototype.PointOnLineSegment=function(t,e,i){return t.X===e.X&&t.Y===e.Y||t.X===i.X&&t.Y===i.Y||t.X>e.X==t.X<i.X&&t.Y>e.Y==t.Y<i.Y&&(t.X-e.X)*(i.Y-e.Y)==(i.X-e.X)*(t.Y-e.Y)},d.ClipperBase.prototype.PointOnPolygon=function(t,e){for(var i=e;;){if(this.PointOnLineSegment(t,i.Pt,i.Next.Pt))return!0;if((i=i.Next)===e)break}return!1},d.ClipperBase.prototype.SlopesEqual=d.ClipperBase.SlopesEqual=function(){var t,e,i,r,n,o,s=arguments,a=s.length;return 2===a?(t=s[0],e=s[1],t.Delta.Y*e.Delta.X==t.Delta.X*e.Delta.Y):3===a?(i=s[0],r=s[1],n=s[2],(i.Y-r.Y)*(r.X-n.X)-(i.X-r.X)*(r.Y-n.Y)==0):(i=s[0],r=s[1],n=s[2],o=s[3],(i.Y-r.Y)*(n.X-o.X)-(i.X-r.X)*(n.Y-o.Y)==0)},d.ClipperBase.SlopesEqual3=function(t,e){return t.Delta.Y*e.Delta.X==t.Delta.X*e.Delta.Y},d.ClipperBase.SlopesEqual4=function(t,e,i){return(t.Y-e.Y)*(e.X-i.X)-(t.X-e.X)*(e.Y-i.Y)==0},d.ClipperBase.SlopesEqual5=function(t,e,i,r){return(t.Y-e.Y)*(i.X-r.X)-(t.X-e.X)*(i.Y-r.Y)==0},d.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var t=0,e=this.m_edges.length;t<e;++t){for(var i=0,r=this.m_edges[t].length;i<r;++i)this.m_edges[t][i]=null;d.Clear(this.m_edges[t])}d.Clear(this.m_edges),this.m_HasOpenPaths=!1},d.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(var t=this;null!==this.m_MinimaList;){var e=t.m_MinimaList.Next;t.m_MinimaList=null,t.m_MinimaList=e}this.m_CurrentLM=null},d.ClipperBase.prototype.RangeTest=function(t){(t.X>d.ClipperBase.maxValue||t.X<-d.ClipperBase.maxValue||t.Y>d.ClipperBase.maxValue||t.Y<-d.ClipperBase.maxValue||t.X>0&&t.X<d.ClipperBase.minValue||t.Y>0&&t.Y<d.ClipperBase.minValue||t.X<0&&t.X>-d.ClipperBase.minValue||t.Y<0&&t.Y>-d.ClipperBase.minValue)&&d.Error("Coordinate outside allowed range in RangeTest().")},d.ClipperBase.prototype.InitEdge=function(t,e,i,r){t.Next=e,t.Prev=i,t.Curr.X=r.X,t.Curr.Y=r.Y,d.use_xyz&&(t.Curr.Z=r.Z),t.OutIdx=-1},d.ClipperBase.prototype.InitEdge2=function(t,e){t.Curr.Y>=t.Next.Curr.Y?(t.Bot.X=t.Curr.X,t.Bot.Y=t.Curr.Y,d.use_xyz&&(t.Bot.Z=t.Curr.Z),t.Top.X=t.Next.Curr.X,t.Top.Y=t.Next.Curr.Y,d.use_xyz&&(t.Top.Z=t.Next.Curr.Z)):(t.Top.X=t.Curr.X,t.Top.Y=t.Curr.Y,d.use_xyz&&(t.Top.Z=t.Curr.Z),t.Bot.X=t.Next.Curr.X,t.Bot.Y=t.Next.Curr.Y,d.use_xyz&&(t.Bot.Z=t.Next.Curr.Z)),this.SetDx(t),t.PolyTyp=e},d.ClipperBase.prototype.FindNextLocMin=function(t){for(var e;;){for(;d.FPoint.op_Inequality(t.Bot,t.Prev.Bot)||d.FPoint.op_Equality(t.Curr,t.Top);)t=t.Next;if(t.Dx!==d.ClipperBase.horizontal&&t.Prev.Dx!==d.ClipperBase.horizontal)break;for(;t.Prev.Dx===d.ClipperBase.horizontal;)t=t.Prev;for(e=t;t.Dx===d.ClipperBase.horizontal;)t=t.Next;if(t.Top.Y!==t.Prev.Bot.Y){e.Prev.Bot.X<t.Bot.X&&(t=e);break}}return t},d.ClipperBase.prototype.ProcessBound=function(t,e){var i,r,n=t;if(n.OutIdx===d.ClipperBase.Skip){if(t=n,e){for(;t.Top.Y===t.Next.Bot.Y;)t=t.Next;for(;t!==n&&t.Dx===d.ClipperBase.horizontal;)t=t.Prev}else{for(;t.Top.Y===t.Prev.Bot.Y;)t=t.Prev;for(;t!==n&&t.Dx===d.ClipperBase.horizontal;)t=t.Next}if(t===n)n=e?t.Next:t.Prev;else{t=e?n.Next:n.Prev;var o=new d.LocalMinima;o.Next=null,o.Y=t.Bot.Y,o.LeftBound=null,o.RightBound=t,t.WindDelta=0,n=this.ProcessBound(t,e),this.InsertLocalMinima(o)}return n}if(t.Dx===d.ClipperBase.horizontal&&((i=e?t.Prev:t.Next).Dx===d.ClipperBase.horizontal?i.Bot.X!==t.Bot.X&&i.Top.X!==t.Bot.X&&this.ReverseHorizontal(t):i.Bot.X!==t.Bot.X&&this.ReverseHorizontal(t)),i=t,e){for(;n.Top.Y===n.Next.Bot.Y&&n.Next.OutIdx!==d.ClipperBase.Skip;)n=n.Next;if(n.Dx===d.ClipperBase.horizontal&&n.Next.OutIdx!==d.ClipperBase.Skip){for(r=n;r.Prev.Dx===d.ClipperBase.horizontal;)r=r.Prev;r.Prev.Top.X>n.Next.Top.X&&(n=r.Prev)}for(;t!==n;)t.NextInLML=t.Next,t.Dx===d.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Prev.Top.X&&this.ReverseHorizontal(t),t=t.Next;t.Dx===d.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Prev.Top.X&&this.ReverseHorizontal(t),n=n.Next}else{for(;n.Top.Y===n.Prev.Bot.Y&&n.Prev.OutIdx!==d.ClipperBase.Skip;)n=n.Prev;if(n.Dx===d.ClipperBase.horizontal&&n.Prev.OutIdx!==d.ClipperBase.Skip){for(r=n;r.Next.Dx===d.ClipperBase.horizontal;)r=r.Next;(r.Next.Top.X===n.Prev.Top.X||r.Next.Top.X>n.Prev.Top.X)&&(n=r.Next)}for(;t!==n;)t.NextInLML=t.Prev,t.Dx===d.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Next.Top.X&&this.ReverseHorizontal(t),t=t.Prev;t.Dx===d.ClipperBase.horizontal&&t!==i&&t.Bot.X!==t.Next.Top.X&&this.ReverseHorizontal(t),n=n.Prev}return n},d.ClipperBase.prototype.AddPath=function(t,e,i){var r=this;d.use_lines?i||e!==d.PolyType.ptClip||d.Error("AddPath: Open paths must be subject."):i||d.Error("AddPath: Open paths have been disabled.");var n=t.length-1;if(i)for(;n>0&&d.FPoint.op_Equality(t[n],t[0]);)--n;for(;n>0&&d.FPoint.op_Equality(t[n],t[n-1]);)--n;if(i&&n<2||!i&&n<1)return!1;for(var o=new Array,s=0;s<=n;s++)o.push(new d.TEdge);var a=!0;o[1].Curr.X=t[1].X,o[1].Curr.Y=t[1].Y,d.use_xyz&&(o[1].Curr.Z=t[1].Z),this.RangeTest(t[0]),this.RangeTest(t[n]),this.InitEdge(o[0],o[1],o[n],t[0]),this.InitEdge(o[n],o[0],o[n-1],t[n]);for(s=n-1;s>=1;--s)r.RangeTest(t[s]),r.InitEdge(o[s],o[s+1],o[s-1],t[s]);for(var h,l=o[0],u=l,p=l;;)if(u.Curr!==u.Next.Curr||!i&&u.Next===l){if(u.Prev===u.Next)break;if(!i||!d.ClipperBase.SlopesEqual4(u.Prev.Curr,u.Curr,u.Next.Curr)||r.PreserveCollinear&&r.Pt2IsBetweenPt1AndPt3(u.Prev.Curr,u.Curr,u.Next.Curr)){if((u=u.Next)===p||!i&&u.Next===l)break}else u===l&&(l=u.Next),p=u=(u=r.RemoveEdge(u)).Prev}else{if(u===u.Next)break;u===l&&(l=u.Next),p=u=r.RemoveEdge(u)}if(!i&&u===u.Next||i&&u.Prev===u.Next)return!1;i||(this.m_HasOpenPaths=!0,l.Prev.OutIdx=d.ClipperBase.Skip),u=l;do{r.InitEdge2(u,e),u=u.Next,a&&u.Curr.Y!==l.Curr.Y&&(a=!1)}while(u!==l);if(a){if(i)return!1;for(u.Prev.OutIdx=d.ClipperBase.Skip,(f=new d.LocalMinima).Next=null,f.Y=u.Bot.Y,f.LeftBound=null,f.RightBound=u,f.RightBound.Side=d.EdgeSide.esRight,f.RightBound.WindDelta=0;u.Bot.X!==u.Prev.Top.X&&r.ReverseHorizontal(u),u.Next.OutIdx!==d.ClipperBase.Skip;)u.NextInLML=u.Next,u=u.Next;return this.InsertLocalMinima(f),this.m_edges.push(o),!0}this.m_edges.push(o);var c=null;for(d.FPoint.op_Equality(u.Prev.Bot,u.Prev.Top)&&(u=u.Next);(u=r.FindNextLocMin(u))!==c;){var f;null===c&&(c=u),(f=new d.LocalMinima).Next=null,f.Y=u.Bot.Y,u.Dx<u.Prev.Dx?(f.LeftBound=u.Prev,f.RightBound=u,h=!1):(f.LeftBound=u,f.RightBound=u.Prev,h=!0),f.LeftBound.Side=d.EdgeSide.esLeft,f.RightBound.Side=d.EdgeSide.esRight,i?f.LeftBound.Next===f.RightBound?f.LeftBound.WindDelta=-1:f.LeftBound.WindDelta=1:f.LeftBound.WindDelta=0,f.RightBound.WindDelta=-f.LeftBound.WindDelta,(u=r.ProcessBound(f.LeftBound,h)).OutIdx===d.ClipperBase.Skip&&(u=r.ProcessBound(u,h));var v=r.ProcessBound(f.RightBound,!h);v.OutIdx===d.ClipperBase.Skip&&(v=r.ProcessBound(v,!h)),f.LeftBound.OutIdx===d.ClipperBase.Skip?f.LeftBound=null:f.RightBound.OutIdx===d.ClipperBase.Skip&&(f.RightBound=null),r.InsertLocalMinima(f),h||(u=v)}return!0},d.ClipperBase.prototype.AddPaths=function(t,e,i){for(var r=!1,n=0,o=t.length;n<o;++n)this.AddPath(t[n],e,i)&&(r=!0);return r},d.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(t,e,i){return!(d.FPoint.op_Equality(t,i)||d.FPoint.op_Equality(t,e)||d.FPoint.op_Equality(i,e))&&(t.X!==i.X?e.X>t.X==e.X<i.X:e.Y>t.Y==e.Y<i.Y)},d.ClipperBase.prototype.RemoveEdge=function(t){t.Prev.Next=t.Next,t.Next.Prev=t.Prev;var e=t.Next;return t.Prev=null,e},d.ClipperBase.prototype.SetDx=function(t){t.Delta.X=t.Top.X-t.Bot.X,t.Delta.Y=t.Top.Y-t.Bot.Y,0===t.Delta.Y?t.Dx=d.ClipperBase.horizontal:t.Dx=t.Delta.X/t.Delta.Y},d.ClipperBase.prototype.InsertLocalMinima=function(t){if(null===this.m_MinimaList)this.m_MinimaList=t;else if(t.Y>=this.m_MinimaList.Y)t.Next=this.m_MinimaList,this.m_MinimaList=t;else{for(var e=this.m_MinimaList;null!==e.Next&&t.Y<e.Next.Y;)e=e.Next;t.Next=e.Next,e.Next=t}},d.ClipperBase.prototype.PopLocalMinima=function(t,e){return e.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===t&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)},d.ClipperBase.prototype.ReverseHorizontal=function(t){var e=t.Top.X;t.Top.X=t.Bot.X,t.Bot.X=e,d.use_xyz&&(e=t.Top.Z,t.Top.Z=t.Bot.Z,t.Bot.Z=e)},d.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var t=this.m_MinimaList;null!==t;){this.InsertScanbeam(t.Y);var e=t.LeftBound;null!==e&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,d.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=d.ClipperBase.Unassigned),null!==(e=t.RightBound)&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,d.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=d.ClipperBase.Unassigned),t=t.Next}this.m_ActiveEdges=null}},d.ClipperBase.prototype.InsertScanbeam=function(t){if(null===this.m_Scanbeam)this.m_Scanbeam=new d.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=t;else if(t>this.m_Scanbeam.Y){var e=new d.Scanbeam;e.Y=t,e.Next=this.m_Scanbeam,this.m_Scanbeam=e}else{for(var i=this.m_Scanbeam;null!==i.Next&&t<=i.Next.Y;)i=i.Next;if(t===i.Y)return;var r=new d.Scanbeam;r.Y=t,r.Next=i.Next,i.Next=r}},d.ClipperBase.prototype.PopScanbeam=function(t){return null===this.m_Scanbeam?(t.v=0,!1):(t.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},d.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},d.ClipperBase.prototype.CreateOutRec=function(){var t=new d.OutRec;return t.Idx=d.ClipperBase.Unassigned,t.IsHole=!1,t.IsOpen=!1,t.FirstLeft=null,t.Pts=null,t.BottomPt=null,t.PolyNode=null,this.m_PolyOuts.push(t),t.Idx=this.m_PolyOuts.length-1,t},d.ClipperBase.prototype.DisposeOutRec=function(t){var e=this.m_PolyOuts[t];e.Pts=null,e=null,this.m_PolyOuts[t]=null},d.ClipperBase.prototype.UpdateEdgeIntoAEL=function(t){null===t.NextInLML&&d.Error("UpdateEdgeIntoAEL: invalid call");var e=t.PrevInAEL,i=t.NextInAEL;return t.NextInLML.OutIdx=t.OutIdx,null!==e?e.NextInAEL=t.NextInLML:this.m_ActiveEdges=t.NextInLML,null!==i&&(i.PrevInAEL=t.NextInLML),t.NextInLML.Side=t.Side,t.NextInLML.WindDelta=t.WindDelta,t.NextInLML.WindCnt=t.WindCnt,t.NextInLML.WindCnt2=t.WindCnt2,(t=t.NextInLML).Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,t.PrevInAEL=e,t.NextInAEL=i,d.ClipperBase.IsHorizontal(t)||this.InsertScanbeam(t.Top.Y),t},d.ClipperBase.prototype.SwapPositionsInAEL=function(t,e){if(t.NextInAEL!==t.PrevInAEL&&e.NextInAEL!==e.PrevInAEL){if(t.NextInAEL===e){var i=e.NextInAEL;null!==i&&(i.PrevInAEL=t);var r=t.PrevInAEL;null!==r&&(r.NextInAEL=e),e.PrevInAEL=r,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=i}else if(e.NextInAEL===t){var n=t.NextInAEL;null!==n&&(n.PrevInAEL=e);var o=e.PrevInAEL;null!==o&&(o.NextInAEL=t),t.PrevInAEL=o,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=n}else{var s=t.NextInAEL,a=t.PrevInAEL;t.NextInAEL=e.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=e.PrevInAEL,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t),e.NextInAEL=s,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=a,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e)}null===t.PrevInAEL?this.m_ActiveEdges=t:null===e.PrevInAEL&&(this.m_ActiveEdges=e)}},d.ClipperBase.prototype.DeleteFromAEL=function(t){var e=t.PrevInAEL,i=t.NextInAEL;null===e&&null===i&&t!==this.m_ActiveEdges||(null!==e?e.NextInAEL=i:this.m_ActiveEdges=i,null!==i&&(i.PrevInAEL=e),t.NextInAEL=null,t.PrevInAEL=null)},d.Clipper=function(t){void 0===t&&(t=0),this.m_PolyOuts=null,this.m_ClipType=d.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=d.PolyFillType.pftEvenOdd,this.m_SubjFillType=d.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,d.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=d.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=0!=(1&t),this.StrictlySimple=0!=(2&t),this.PreserveCollinear=0!=(4&t),d.use_xyz&&(this.ZFillFunction=null)},d.Clipper.ioReverseSolution=1,d.Clipper.ioStrictlySimple=2,d.Clipper.ioPreserveCollinear=4,d.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),d.ClipperBase.prototype.Clear.call(this))},d.Clipper.prototype.InsertMaxima=function(t){var e=new d.Maxima;if(e.X=t,null===this.m_Maxima)this.m_Maxima=e,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(t<this.m_Maxima.X)e.Next=this.m_Maxima,e.Prev=null,this.m_Maxima=e;else{for(var i=this.m_Maxima;null!==i.Next&&t>=i.Next.X;)i=i.Next;if(t===i.X)return;e.Next=i.Next,e.Prev=i,null!==i.Next&&(i.Next.Prev=e),i.Next=e}},d.Clipper.prototype.Execute=function(){var t=arguments,e=t.length,i=t[1]instanceof d.PolyTree;if(4===e&&!i){var r=t[0],n=t[1],o=t[2],s=t[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&d.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,d.Clear(n),this.m_SubjFillType=o,this.m_ClipFillType=s,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{(h=this.ExecuteInternal())&&this.BuildResult(n)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}if(4===e&&i){r=t[0];var a=t[1];o=t[2],s=t[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=o,this.m_ClipFillType=s,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var h;(h=this.ExecuteInternal())&&this.BuildResult2(a)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}if(2===e&&!i){r=t[0],n=t[1];return this.Execute(r,n,d.PolyFillType.pftEvenOdd,d.PolyFillType.pftEvenOdd)}if(2===e&&i){r=t[0],a=t[1];return this.Execute(r,a,d.PolyFillType.pftEvenOdd,d.PolyFillType.pftEvenOdd)}},d.Clipper.prototype.FixHoleLinkage=function(t){if(null!==t.FirstLeft&&(t.IsHole===t.FirstLeft.IsHole||null===t.FirstLeft.Pts)){for(var e=t.FirstLeft;null!==e&&(e.IsHole===t.IsHole||null===e.Pts);)e=e.FirstLeft;t.FirstLeft=e}},d.Clipper.prototype.ExecuteInternal=function(){var t=this;try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,i,r,n={},o={};if(!this.PopScanbeam(n))return!1;for(this.InsertLocalMinimaIntoAEL(n.v);this.PopScanbeam(o)||this.LocalMinimaPending();){if(t.ProcessHorizontals(),t.m_GhostJoins.length=0,!t.ProcessIntersections(o.v))return!1;t.ProcessEdgesAtTopOfScanbeam(o.v),n.v=o.v,t.InsertLocalMinimaIntoAEL(n.v)}for(i=0,r=this.m_PolyOuts.length;i<r;i++)null===(e=t.m_PolyOuts[i]).Pts||e.IsOpen||(e.IsHole^t.ReverseSolution)==t.Area$1(e)>0&&t.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),i=0,r=this.m_PolyOuts.length;i<r;i++)null!==(e=t.m_PolyOuts[i]).Pts&&(e.IsOpen?t.FixupOutPolyline(e):t.FixupOutPolygon(e));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},d.Clipper.prototype.DisposeAllPolyPts=function(){for(var t=0,e=this.m_PolyOuts.length;t<e;++t)this.DisposeOutRec(t);d.Clear(this.m_PolyOuts)},d.Clipper.prototype.AddJoin=function(t,e,i){var r=new d.Join;r.OutPt1=t,r.OutPt2=e,r.OffPt.X=i.X,r.OffPt.Y=i.Y,d.use_xyz&&(r.OffPt.Z=i.Z),this.m_Joins.push(r)},d.Clipper.prototype.AddGhostJoin=function(t,e){var i=new d.Join;i.OutPt1=t,i.OffPt.X=e.X,i.OffPt.Y=e.Y,d.use_xyz&&(i.OffPt.Z=e.Z),this.m_GhostJoins.push(i)},d.Clipper.prototype.SetZ=function(t,e,i){if(null!==this.ZFillFunction){if(0!==t.Z||null===this.ZFillFunction)return;d.FPoint.op_Equality(t,e.Bot)?t.Z=e.Bot.Z:d.FPoint.op_Equality(t,e.Top)?t.Z=e.Top.Z:d.FPoint.op_Equality(t,i.Bot)?t.Z=i.Bot.Z:d.FPoint.op_Equality(t,i.Top)?t.Z=i.Top.Z:this.ZFillFunction(e.Bot,e.Top,i.Bot,i.Top,t)}},d.Clipper.prototype.InsertLocalMinimaIntoAEL=function(t){for(var e,i,r=this,n={};this.PopLocalMinima(t,n);){e=n.v.LeftBound,i=n.v.RightBound;var o=null;if(null===e?(r.InsertEdgeIntoAEL(i,null),r.SetWindingCount(i),r.IsContributing(i)&&(o=r.AddOutPt(i,i.Bot))):null===i?(r.InsertEdgeIntoAEL(e,null),r.SetWindingCount(e),r.IsContributing(e)&&(o=r.AddOutPt(e,e.Bot)),r.InsertScanbeam(e.Top.Y)):(r.InsertEdgeIntoAEL(e,null),r.InsertEdgeIntoAEL(i,e),r.SetWindingCount(e),i.WindCnt=e.WindCnt,i.WindCnt2=e.WindCnt2,r.IsContributing(e)&&(o=r.AddLocalMinPoly(e,i,e.Bot)),r.InsertScanbeam(e.Top.Y)),null!==i&&(d.ClipperBase.IsHorizontal(i)?(null!==i.NextInLML&&r.InsertScanbeam(i.NextInLML.Top.Y),r.AddEdgeToSEL(i)):r.InsertScanbeam(i.Top.Y)),null!==e&&null!==i){if(null!==o&&d.ClipperBase.IsHorizontal(i)&&r.m_GhostJoins.length>0&&0!==i.WindDelta)for(var s=0,a=this.m_GhostJoins.length;s<a;s++){var h=r.m_GhostJoins[s];r.HorzSegmentsOverlap(h.OutPt1.Pt.X,h.OffPt.X,i.Bot.X,i.Top.X)&&r.AddJoin(h.OutPt1,o,h.OffPt)}if(e.OutIdx>=0&&null!==e.PrevInAEL&&e.PrevInAEL.Curr.X===e.Bot.X&&e.PrevInAEL.OutIdx>=0&&d.ClipperBase.SlopesEqual5(e.PrevInAEL.Curr,e.PrevInAEL.Top,e.Curr,e.Top)&&0!==e.WindDelta&&0!==e.PrevInAEL.WindDelta){var l=r.AddOutPt(e.PrevInAEL,e.Bot);r.AddJoin(o,l,e.Top)}if(e.NextInAEL!==i){if(i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&d.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta){l=r.AddOutPt(i.PrevInAEL,i.Bot);r.AddJoin(o,l,i.Top)}var u=e.NextInAEL;if(null!==u)for(;u!==i;)r.IntersectEdges(i,u,e.Curr),u=u.NextInAEL}}}},d.Clipper.prototype.InsertEdgeIntoAEL=function(t,e){if(null===this.m_ActiveEdges)t.PrevInAEL=null,t.NextInAEL=null,this.m_ActiveEdges=t;else if(null===e&&this.E2InsertsBeforeE1(this.m_ActiveEdges,t))t.PrevInAEL=null,t.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=t,this.m_ActiveEdges=t;else{for(null===e&&(e=this.m_ActiveEdges);null!==e.NextInAEL&&!this.E2InsertsBeforeE1(e.NextInAEL,t);)e=e.NextInAEL;t.NextInAEL=e.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=t),t.PrevInAEL=e,e.NextInAEL=t}},d.Clipper.prototype.E2InsertsBeforeE1=function(t,e){return e.Curr.X===t.Curr.X?e.Top.Y>t.Top.Y?e.Top.X<d.Clipper.TopX(t,e.Top.Y):t.Top.X>d.Clipper.TopX(e,t.Top.Y):e.Curr.X<t.Curr.X},d.Clipper.prototype.IsEvenOddFillType=function(t){return t.PolyTyp===d.PolyType.ptSubject?this.m_SubjFillType===d.PolyFillType.pftEvenOdd:this.m_ClipFillType===d.PolyFillType.pftEvenOdd},d.Clipper.prototype.IsEvenOddAltFillType=function(t){return t.PolyTyp===d.PolyType.ptSubject?this.m_ClipFillType===d.PolyFillType.pftEvenOdd:this.m_SubjFillType===d.PolyFillType.pftEvenOdd},d.Clipper.prototype.IsContributing=function(t){var e,i;switch(t.PolyTyp===d.PolyType.ptSubject?(e=this.m_SubjFillType,i=this.m_ClipFillType):(e=this.m_ClipFillType,i=this.m_SubjFillType),e){case d.PolyFillType.pftEvenOdd:if(0===t.WindDelta&&1!==t.WindCnt)return!1;break;case d.PolyFillType.pftNonZero:if(1!==Math.abs(t.WindCnt))return!1;break;case d.PolyFillType.pftPositive:if(1!==t.WindCnt)return!1;break;default:if(-1!==t.WindCnt)return!1}switch(this.m_ClipType){case d.ClipType.ctIntersection:switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0!==t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case d.ClipType.ctUnion:switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0===t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}case d.ClipType.ctDifference:if(t.PolyTyp===d.PolyType.ptSubject)switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0===t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}else switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0!==t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2>0;default:return t.WindCnt2<0}case d.ClipType.ctXor:if(0!==t.WindDelta)return!0;switch(i){case d.PolyFillType.pftEvenOdd:case d.PolyFillType.pftNonZero:return 0===t.WindCnt2;case d.PolyFillType.pftPositive:return t.WindCnt2<=0;default:return t.WindCnt2>=0}}return!0},d.Clipper.prototype.SetWindingCount=function(t){for(var e=t.PrevInAEL;null!==e&&(e.PolyTyp!==t.PolyTyp||0===e.WindDelta);)e=e.PrevInAEL;if(null===e){var i=t.PolyTyp===d.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===t.WindDelta?t.WindCnt=i===d.PolyFillType.pftNegative?-1:1:t.WindCnt=t.WindDelta,t.WindCnt2=0,e=this.m_ActiveEdges}else if(0===t.WindDelta&&this.m_ClipType!==d.ClipType.ctUnion)t.WindCnt=1,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(t)){if(0===t.WindDelta){for(var r=!0,n=e.PrevInAEL;null!==n;)n.PolyTyp===e.PolyTyp&&0!==n.WindDelta&&(r=!r),n=n.PrevInAEL;t.WindCnt=r?0:1}else t.WindCnt=t.WindDelta;t.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta:t.WindCnt=0===t.WindDelta?1:t.WindDelta:0===t.WindDelta?t.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*t.WindDelta<0?t.WindCnt=e.WindCnt:t.WindCnt=e.WindCnt+t.WindDelta,t.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(t))for(;e!==t;)0!==e.WindDelta&&(t.WindCnt2=0===t.WindCnt2?1:0),e=e.NextInAEL;else for(;e!==t;)t.WindCnt2+=e.WindDelta,e=e.NextInAEL},d.Clipper.prototype.AddEdgeToSEL=function(t){null===this.m_SortedEdges?(this.m_SortedEdges=t,t.PrevInSEL=null,t.NextInSEL=null):(t.NextInSEL=this.m_SortedEdges,t.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=t,this.m_SortedEdges=t)},d.Clipper.prototype.PopEdgeFromSEL=function(t){if(t.v=this.m_SortedEdges,null===t.v)return!1;var e=t.v;return this.m_SortedEdges=t.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),e.NextInSEL=null,e.PrevInSEL=null,!0},d.Clipper.prototype.CopyAELToSEL=function(){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t=t.NextInAEL},d.Clipper.prototype.SwapPositionsInSEL=function(t,e){if(!(null===t.NextInSEL&&null===t.PrevInSEL||null===e.NextInSEL&&null===e.PrevInSEL)){if(t.NextInSEL===e)null!==(i=e.NextInSEL)&&(i.PrevInSEL=t),null!==(r=t.PrevInSEL)&&(r.NextInSEL=e),e.PrevInSEL=r,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i;else if(e.NextInSEL===t){null!==(i=t.NextInSEL)&&(i.PrevInSEL=e),null!==(r=e.PrevInSEL)&&(r.NextInSEL=t),t.PrevInSEL=r,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i}else{var i=t.NextInSEL,r=t.PrevInSEL;t.NextInSEL=e.NextInSEL,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=e.PrevInSEL,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t),e.NextInSEL=i,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=r,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e)}null===t.PrevInSEL?this.m_SortedEdges=t:null===e.PrevInSEL&&(this.m_SortedEdges=e)}},d.Clipper.prototype.AddLocalMaxPoly=function(t,e,i){this.AddOutPt(t,i),0===e.WindDelta&&this.AddOutPt(e,i),t.OutIdx===e.OutIdx?(t.OutIdx=-1,e.OutIdx=-1):t.OutIdx<e.OutIdx?this.AppendPolygon(t,e):this.AppendPolygon(e,t)},d.Clipper.prototype.AddLocalMinPoly=function(t,e,i){var r,n,o;if(d.ClipperBase.IsHorizontal(e)||t.Dx>e.Dx?(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,t.Side=d.EdgeSide.esLeft,e.Side=d.EdgeSide.esRight,o=(n=t).PrevInAEL===e?e.PrevInAEL:n.PrevInAEL):(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,t.Side=d.EdgeSide.esRight,e.Side=d.EdgeSide.esLeft,o=(n=e).PrevInAEL===t?t.PrevInAEL:n.PrevInAEL),null!==o&&o.OutIdx>=0&&o.Top.Y<i.Y&&n.Top.Y<i.Y){var s=d.Clipper.TopX(o,i.Y),a=d.Clipper.TopX(n,i.Y);if(s===a&&0!==n.WindDelta&&0!==o.WindDelta&&d.ClipperBase.SlopesEqual5(new d.FPoint2(s,i.Y),o.Top,new d.FPoint2(a,i.Y),n.Top)){var h=this.AddOutPt(o,i);this.AddJoin(r,h,n.Top)}}return r},d.Clipper.prototype.AddOutPt=function(t,e){if(t.OutIdx<0){(r=this.CreateOutRec()).IsOpen=0===t.WindDelta;var i=new d.OutPt;return r.Pts=i,i.Idx=r.Idx,i.Pt.X=e.X,i.Pt.Y=e.Y,d.use_xyz&&(i.Pt.Z=e.Z),i.Next=i,i.Prev=i,r.IsOpen||this.SetHoleState(t,r),t.OutIdx=r.Idx,i}var r,n=(r=this.m_PolyOuts[t.OutIdx]).Pts,o=t.Side===d.EdgeSide.esLeft;return o&&d.FPoint.op_Equality(e,n.Pt)?n:!o&&d.FPoint.op_Equality(e,n.Prev.Pt)?n.Prev:((i=new d.OutPt).Idx=r.Idx,i.Pt.X=e.X,i.Pt.Y=e.Y,d.use_xyz&&(i.Pt.Z=e.Z),i.Next=n,i.Prev=n.Prev,i.Prev.Next=i,n.Prev=i,o&&(r.Pts=i),i)},d.Clipper.prototype.GetLastOutPt=function(t){var e=this.m_PolyOuts[t.OutIdx];return t.Side===d.EdgeSide.esLeft?e.Pts:e.Pts.Prev},d.Clipper.prototype.SwapPoints=function(t,e){var i=new d.FPoint1(t.Value);t.Value.X=e.Value.X,t.Value.Y=e.Value.Y,d.use_xyz&&(t.Value.Z=e.Value.Z),e.Value.X=i.X,e.Value.Y=i.Y,d.use_xyz&&(e.Value.Z=i.Z)},d.Clipper.prototype.HorzSegmentsOverlap=function(t,e,i,r){var n;return t>e&&(n=t,t=e,e=n),i>r&&(n=i,i=r,r=n),t<r&&i<e},d.Clipper.prototype.SetHoleState=function(t,e){for(var i=t.PrevInAEL,r=null;null!==i;)i.OutIdx>=0&&0!==i.WindDelta&&(null===r?r=i:r.OutIdx===i.OutIdx&&(r=null)),i=i.PrevInAEL;null===r?(e.FirstLeft=null,e.IsHole=!1):(e.FirstLeft=this.m_PolyOuts[r.OutIdx],e.IsHole=!e.FirstLeft.IsHole)},d.Clipper.prototype.GetDx=function(t,e){return t.Y===e.Y?d.ClipperBase.horizontal:(e.X-t.X)/(e.Y-t.Y)},d.Clipper.prototype.FirstIsBottomPt=function(t,e){for(var i=t.Prev;d.FPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Prev;var r=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;d.FPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Next;var n=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=e.Prev;d.FPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var o=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;d.FPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var s=Math.abs(this.GetDx(e.Pt,i.Pt));return Math.max(r,n)===Math.max(o,s)&&Math.min(r,n)===Math.min(o,s)?this.Area(t)>0:r>=o&&r>=s||n>=o&&n>=s},d.Clipper.prototype.GetBottomPt=function(t){for(var e=null,i=t.Next;i!==t;)i.Pt.Y>t.Pt.Y?(t=i,e=null):i.Pt.Y===t.Pt.Y&&i.Pt.X<=t.Pt.X&&(i.Pt.X<t.Pt.X?(e=null,t=i):i.Next!==t&&i.Prev!==t&&(e=i)),i=i.Next;if(null!==e)for(;e!==i;)for(this.FirstIsBottomPt(i,e)||(t=e),e=e.Next;d.FPoint.op_Inequality(e.Pt,t.Pt);)e=e.Next;return t},d.Clipper.prototype.GetLowermostRec=function(t,e){null===t.BottomPt&&(t.BottomPt=this.GetBottomPt(t.Pts)),null===e.BottomPt&&(e.BottomPt=this.GetBottomPt(e.Pts));var i=t.BottomPt,r=e.BottomPt;return i.Pt.Y>r.Pt.Y?t:i.Pt.Y<r.Pt.Y?e:i.Pt.X<r.Pt.X?t:i.Pt.X>r.Pt.X||i.Next===i?e:r.Next===r||this.FirstIsBottomPt(i,r)?t:e},d.Clipper.prototype.OutRec1RightOfOutRec2=function(t,e){do{if((t=t.FirstLeft)===e)return!0}while(null!==t);return!1},d.Clipper.prototype.GetOutRec=function(t){for(var e=this.m_PolyOuts[t];e!==this.m_PolyOuts[e.Idx];)e=this.m_PolyOuts[e.Idx];return e},d.Clipper.prototype.AppendPolygon=function(t,e){var i,r=this.m_PolyOuts[t.OutIdx],n=this.m_PolyOuts[e.OutIdx];i=this.OutRec1RightOfOutRec2(r,n)?n:this.OutRec1RightOfOutRec2(n,r)?r:this.GetLowermostRec(r,n);var o=r.Pts,s=o.Prev,a=n.Pts,h=a.Prev;t.Side===d.EdgeSide.esLeft?e.Side===d.EdgeSide.esLeft?(this.ReversePolyPtLinks(a),a.Next=o,o.Prev=a,s.Next=h,h.Prev=s,r.Pts=h):(h.Next=o,o.Prev=h,a.Prev=s,s.Next=a,r.Pts=a):e.Side===d.EdgeSide.esRight?(this.ReversePolyPtLinks(a),s.Next=h,h.Prev=s,a.Next=o,o.Prev=a):(s.Next=a,a.Prev=s,o.Prev=h,h.Next=o),r.BottomPt=null,i===n&&(n.FirstLeft!==r&&(r.FirstLeft=n.FirstLeft),r.IsHole=n.IsHole),n.Pts=null,n.BottomPt=null,n.FirstLeft=r;var l=t.OutIdx,u=e.OutIdx;t.OutIdx=-1,e.OutIdx=-1;for(var p=this.m_ActiveEdges;null!==p;){if(p.OutIdx===u){p.OutIdx=l,p.Side=t.Side;break}p=p.NextInAEL}n.Idx=r.Idx},d.Clipper.prototype.ReversePolyPtLinks=function(t){if(null!==t){var e,i;e=t;do{i=e.Next,e.Next=e.Prev,e.Prev=i,e=i}while(e!==t)}},d.Clipper.SwapSides=function(t,e){var i=t.Side;t.Side=e.Side,e.Side=i},d.Clipper.SwapPolyIndexes=function(t,e){var i=t.OutIdx;t.OutIdx=e.OutIdx,e.OutIdx=i},d.Clipper.prototype.IntersectEdges=function(t,e,i){var r=t.OutIdx>=0,n=e.OutIdx>=0;if(d.use_xyz&&this.SetZ(i,t,e),!d.use_lines||0!==t.WindDelta&&0!==e.WindDelta){if(t.PolyTyp===e.PolyTyp)if(this.IsEvenOddFillType(t)){var o=t.WindCnt;t.WindCnt=e.WindCnt,e.WindCnt=o}else t.WindCnt+e.WindDelta===0?t.WindCnt=-t.WindCnt:t.WindCnt+=e.WindDelta,e.WindCnt-t.WindDelta==0?e.WindCnt=-e.WindCnt:e.WindCnt-=t.WindDelta;else this.IsEvenOddFillType(e)?t.WindCnt2=0===t.WindCnt2?1:0:t.WindCnt2+=e.WindDelta,this.IsEvenOddFillType(t)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2-=t.WindDelta;var s,a,h,l,u,p;switch(t.PolyTyp===d.PolyType.ptSubject?(s=this.m_SubjFillType,h=this.m_ClipFillType):(s=this.m_ClipFillType,h=this.m_SubjFillType),e.PolyTyp===d.PolyType.ptSubject?(a=this.m_SubjFillType,l=this.m_ClipFillType):(a=this.m_ClipFillType,l=this.m_SubjFillType),s){case d.PolyFillType.pftPositive:u=t.WindCnt;break;case d.PolyFillType.pftNegative:u=-t.WindCnt;break;default:u=Math.abs(t.WindCnt)}switch(a){case d.PolyFillType.pftPositive:p=e.WindCnt;break;case d.PolyFillType.pftNegative:p=-e.WindCnt;break;default:p=Math.abs(e.WindCnt)}if(r&&n)0!==u&&1!==u||0!==p&&1!==p||t.PolyTyp!==e.PolyTyp&&this.m_ClipType!==d.ClipType.ctXor?this.AddLocalMaxPoly(t,e,i):(this.AddOutPt(t,i),this.AddOutPt(e,i),d.Clipper.SwapSides(t,e),d.Clipper.SwapPolyIndexes(t,e));else if(r)0!==p&&1!==p||(this.AddOutPt(t,i),d.Clipper.SwapSides(t,e),d.Clipper.SwapPolyIndexes(t,e));else if(n)0!==u&&1!==u||(this.AddOutPt(e,i),d.Clipper.SwapSides(t,e),d.Clipper.SwapPolyIndexes(t,e));else if(!(0!==u&&1!==u||0!==p&&1!==p)){var c,f;switch(h){case d.PolyFillType.pftPositive:c=t.WindCnt2;break;case d.PolyFillType.pftNegative:c=-t.WindCnt2;break;default:c=Math.abs(t.WindCnt2)}switch(l){case d.PolyFillType.pftPositive:f=e.WindCnt2;break;case d.PolyFillType.pftNegative:f=-e.WindCnt2;break;default:f=Math.abs(e.WindCnt2)}if(t.PolyTyp!==e.PolyTyp)this.AddLocalMinPoly(t,e,i);else if(1===u&&1===p)switch(this.m_ClipType){case d.ClipType.ctIntersection:c>0&&f>0&&this.AddLocalMinPoly(t,e,i);break;case d.ClipType.ctUnion:c<=0&&f<=0&&this.AddLocalMinPoly(t,e,i);break;case d.ClipType.ctDifference:(t.PolyTyp===d.PolyType.ptClip&&c>0&&f>0||t.PolyTyp===d.PolyType.ptSubject&&c<=0&&f<=0)&&this.AddLocalMinPoly(t,e,i);break;case d.ClipType.ctXor:this.AddLocalMinPoly(t,e,i)}else d.Clipper.SwapSides(t,e)}}else{if(0===t.WindDelta&&0===e.WindDelta)return;t.PolyTyp===e.PolyTyp&&t.WindDelta!==e.WindDelta&&this.m_ClipType===d.ClipType.ctUnion?0===t.WindDelta?n&&(this.AddOutPt(t,i),r&&(t.OutIdx=-1)):r&&(this.AddOutPt(e,i),n&&(e.OutIdx=-1)):t.PolyTyp!==e.PolyTyp&&(0!==t.WindDelta||1!==Math.abs(e.WindCnt)||this.m_ClipType===d.ClipType.ctUnion&&0!==e.WindCnt2?0!==e.WindDelta||1!==Math.abs(t.WindCnt)||this.m_ClipType===d.ClipType.ctUnion&&0!==t.WindCnt2||(this.AddOutPt(e,i),n&&(e.OutIdx=-1)):(this.AddOutPt(t,i),r&&(t.OutIdx=-1)))}},d.Clipper.prototype.DeleteFromSEL=function(t){var e=t.PrevInSEL,i=t.NextInSEL;null===e&&null===i&&t!==this.m_SortedEdges||(null!==e?e.NextInSEL=i:this.m_SortedEdges=i,null!==i&&(i.PrevInSEL=e),t.NextInSEL=null,t.PrevInSEL=null)},d.Clipper.prototype.ProcessHorizontals=function(){for(var t={};this.PopEdgeFromSEL(t);)this.ProcessHorizontal(t.v)},d.Clipper.prototype.GetHorzDirection=function(t,e){t.Bot.X<t.Top.X?(e.Left=t.Bot.X,e.Right=t.Top.X,e.Dir=d.Direction.dLeftToRight):(e.Left=t.Top.X,e.Right=t.Bot.X,e.Dir=d.Direction.dRightToLeft)},d.Clipper.prototype.ProcessHorizontal=function(t){var e=this,i={Dir:null,Left:null,Right:null};this.GetHorzDirection(t,i);for(var r=i.Dir,n=i.Left,o=i.Right,s=0===t.WindDelta,a=t,h=null;null!==a.NextInLML&&d.ClipperBase.IsHorizontal(a.NextInLML);)a=a.NextInLML;null===a.NextInLML&&(h=this.GetMaximaPair(a));var l=this.m_Maxima;if(null!==l)if(r===d.Direction.dLeftToRight){for(;null!==l&&l.X<=t.Bot.X;)l=l.Next;null!==l&&l.X>=a.Top.X&&(l=null)}else{for(;null!==l.Next&&l.Next.X<t.Bot.X;)l=l.Next;l.X<=a.Top.X&&(l=null)}for(var u=null;;){for(var p=t===a,c=e.GetNextInAEL(t,r);null!==c;){if(null!==l)if(r===d.Direction.dLeftToRight)for(;null!==l&&l.X<c.Curr.X;)t.OutIdx>=0&&!s&&e.AddOutPt(t,new d.FPoint2(l.X,t.Bot.Y)),l=l.Next;else for(;null!==l&&l.X>c.Curr.X;)t.OutIdx>=0&&!s&&e.AddOutPt(t,new d.FPoint2(l.X,t.Bot.Y)),l=l.Prev;if(r===d.Direction.dLeftToRight&&c.Curr.X>o||r===d.Direction.dRightToLeft&&c.Curr.X<n)break;if(c.Curr.X===t.Top.X&&null!==t.NextInLML&&c.Dx<t.NextInLML.Dx)break;if(t.OutIdx>=0&&!s){d.use_xyz&&(r===d.Direction.dLeftToRight?e.SetZ(c.Curr,t,c):e.SetZ(c.Curr,c,t)),u=e.AddOutPt(t,c.Curr);for(var f=e.m_SortedEdges;null!==f;){if(f.OutIdx>=0&&e.HorzSegmentsOverlap(t.Bot.X,t.Top.X,f.Bot.X,f.Top.X)){var v=e.GetLastOutPt(f);e.AddJoin(v,u,f.Top)}f=f.NextInSEL}e.AddGhostJoin(u,t.Bot)}if(c===h&&p)return t.OutIdx>=0&&e.AddLocalMaxPoly(t,h,t.Top),e.DeleteFromAEL(t),void e.DeleteFromAEL(h);if(r===d.Direction.dLeftToRight){var y=new d.FPoint2(c.Curr.X,t.Curr.Y);e.IntersectEdges(t,c,y)}else{y=new d.FPoint2(c.Curr.X,t.Curr.Y);e.IntersectEdges(c,t,y)}var g=e.GetNextInAEL(c,r);e.SwapPositionsInAEL(t,c),c=g}if(null===t.NextInLML||!d.ClipperBase.IsHorizontal(t.NextInLML))break;(t=e.UpdateEdgeIntoAEL(t)).OutIdx>=0&&e.AddOutPt(t,t.Bot),i={Dir:r,Left:n,Right:o},e.GetHorzDirection(t,i),r=i.Dir,n=i.Left,o=i.Right}if(t.OutIdx>=0&&null===u){u=this.GetLastOutPt(t);for(f=this.m_SortedEdges;null!==f;){if(f.OutIdx>=0&&e.HorzSegmentsOverlap(t.Bot.X,t.Top.X,f.Bot.X,f.Top.X)){v=e.GetLastOutPt(f);e.AddJoin(v,u,f.Top)}f=f.NextInSEL}this.AddGhostJoin(u,t.Top)}if(null!==t.NextInLML)if(t.OutIdx>=0){if(u=this.AddOutPt(t,t.Top),0===(t=this.UpdateEdgeIntoAEL(t)).WindDelta)return;var m=t.PrevInAEL;g=t.NextInAEL;if(null!==m&&m.Curr.X===t.Bot.X&&m.Curr.Y===t.Bot.Y&&0===m.WindDelta&&m.OutIdx>=0&&m.Curr.Y>m.Top.Y&&d.ClipperBase.SlopesEqual3(t,m)){v=this.AddOutPt(m,t.Bot);this.AddJoin(u,v,t.Top)}else if(null!==g&&g.Curr.X===t.Bot.X&&g.Curr.Y===t.Bot.Y&&0!==g.WindDelta&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&d.ClipperBase.SlopesEqual3(t,g)){v=this.AddOutPt(g,t.Bot);this.AddJoin(u,v,t.Top)}}else t=this.UpdateEdgeIntoAEL(t);else t.OutIdx>=0&&this.AddOutPt(t,t.Top),this.DeleteFromAEL(t)},d.Clipper.prototype.GetNextInAEL=function(t,e){return e===d.Direction.dLeftToRight?t.NextInAEL:t.PrevInAEL},d.Clipper.prototype.IsMinima=function(t){return null!==t&&t.Prev.NextInLML!==t&&t.Next.NextInLML!==t},d.Clipper.prototype.IsMaxima=function(t,e){return null!==t&&t.Top.Y===e&&null===t.NextInLML},d.Clipper.prototype.IsIntermediate=function(t,e){return t.Top.Y===e&&null!==t.NextInLML},d.Clipper.prototype.GetMaximaPair=function(t){return d.FPoint.op_Equality(t.Next.Top,t.Top)&&null===t.Next.NextInLML?t.Next:d.FPoint.op_Equality(t.Prev.Top,t.Top)&&null===t.Prev.NextInLML?t.Prev:null},d.Clipper.prototype.GetMaximaPairEx=function(t){var e=this.GetMaximaPair(t);return null===e||e.OutIdx===d.ClipperBase.Skip||e.NextInAEL===e.PrevInAEL&&!d.ClipperBase.IsHorizontal(e)?null:e},d.Clipper.prototype.ProcessIntersections=function(t){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(t),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(t){this.m_SortedEdges=null,this.m_IntersectList.length=0,d.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},d.Clipper.prototype.BuildIntersectList=function(t){var e=this;if(null!==this.m_ActiveEdges){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;null!==i;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=d.Clipper.TopX(i,t),i=i.NextInAEL;for(var r=!0;r&&null!==this.m_SortedEdges;){for(r=!1,i=e.m_SortedEdges;null!==i.NextInSEL;){var n=i.NextInSEL,o=new d.FPoint0;if(i.Curr.X>n.Curr.X){e.IntersectPoint(i,n,o),o.Y<t&&(o=new d.FPoint2(d.Clipper.TopX(i,t),t));var s=new d.IntersectNode;s.Edge1=i,s.Edge2=n,s.Pt.X=o.X,s.Pt.Y=o.Y,d.use_xyz&&(s.Pt.Z=o.Z),e.m_IntersectList.push(s),e.SwapPositionsInSEL(i,n),r=!0}else i=n}if(null===i.PrevInSEL)break;i.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},d.Clipper.prototype.EdgesAdjacent=function(t){return t.Edge1.NextInSEL===t.Edge2||t.Edge1.PrevInSEL===t.Edge2},d.Clipper.IntersectNodeSort=function(t,e){return e.Pt.Y-t.Pt.Y},d.Clipper.prototype.FixupIntersectionOrder=function(){var t=this;this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var e=this.m_IntersectList.length,i=0;i<e;i++){if(!t.EdgesAdjacent(t.m_IntersectList[i])){for(var r=i+1;r<e&&!this.EdgesAdjacent(this.m_IntersectList[r]);)r++;if(r===e)return!1;var n=t.m_IntersectList[i];t.m_IntersectList[i]=t.m_IntersectList[r],t.m_IntersectList[r]=n}t.SwapPositionsInSEL(t.m_IntersectList[i].Edge1,t.m_IntersectList[i].Edge2)}return!0},d.Clipper.prototype.ProcessIntersectList=function(){for(var t=this,e=0,i=this.m_IntersectList.length;e<i;e++){var r=t.m_IntersectList[e];t.IntersectEdges(r.Edge1,r.Edge2,r.Pt),t.SwapPositionsInAEL(r.Edge1,r.Edge2)}this.m_IntersectList.length=0},d.Clipper.TopX=function(t,e){return e===t.Top.Y?t.Top.X:t.Bot.X+t.Dx*(e-t.Bot.Y)},d.Clipper.prototype.IntersectPoint=function(t,e,i){var r,n;if(i.X=0,i.Y=0,t.Dx===e.Dx)return i.Y=t.Curr.Y,void(i.X=d.Clipper.TopX(t,i.Y));if(0===t.Delta.X)i.X=t.Bot.X,d.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(n=e.Bot.Y-e.Bot.X/e.Dx,i.Y=i.X/e.Dx+n);else if(0===e.Delta.X)i.X=e.Bot.X,d.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(r=t.Bot.Y-t.Bot.X/t.Dx,i.Y=i.X/t.Dx+r);else{r=t.Bot.X-t.Bot.Y*t.Dx;var o=((n=e.Bot.X-e.Bot.Y*e.Dx)-r)/(t.Dx-e.Dx);i.Y=o,Math.abs(t.Dx)<Math.abs(e.Dx)?i.X=t.Dx*o+r:i.X=e.Dx*o+n}if(i.Y<t.Top.Y||i.Y<e.Top.Y){if(t.Top.Y>e.Top.Y)return i.Y=t.Top.Y,i.X=d.Clipper.TopX(e,t.Top.Y),i.X<t.Top.X;i.Y=e.Top.Y,Math.abs(t.Dx)<Math.abs(e.Dx)?i.X=d.Clipper.TopX(t,i.Y):i.X=d.Clipper.TopX(e,i.Y)}i.Y>t.Curr.Y&&(i.Y=t.Curr.Y,Math.abs(t.Dx)>Math.abs(e.Dx)?i.X=d.Clipper.TopX(e,i.Y):i.X=d.Clipper.TopX(t,i.Y))},d.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(t){for(var e=this,i=this.m_ActiveEdges;null!==i;){var r=e.IsMaxima(i,t);if(r){var n=e.GetMaximaPairEx(i);r=null===n||!d.ClipperBase.IsHorizontal(n)}if(r){e.StrictlySimple&&e.InsertMaxima(i.Top.X);var o=i.PrevInAEL;e.DoMaxima(i),i=null===o?e.m_ActiveEdges:o.NextInAEL}else{if(e.IsIntermediate(i,t)&&d.ClipperBase.IsHorizontal(i.NextInLML)?((i=e.UpdateEdgeIntoAEL(i)).OutIdx>=0&&e.AddOutPt(i,i.Bot),e.AddEdgeToSEL(i)):(i.Curr.X=d.Clipper.TopX(i,t),i.Curr.Y=t),d.use_xyz&&(i.Top.Y===t?i.Curr.Z=i.Top.Z:i.Bot.Y===t?i.Curr.Z=i.Bot.Z:i.Curr.Z=0),e.StrictlySimple){o=i.PrevInAEL;if(i.OutIdx>=0&&0!==i.WindDelta&&null!==o&&o.OutIdx>=0&&o.Curr.X===i.Curr.X&&0!==o.WindDelta){var s=new d.FPoint1(i.Curr);d.use_xyz&&e.SetZ(s,o,i);var a=e.AddOutPt(o,s),h=e.AddOutPt(i,s);e.AddJoin(a,h,s)}}i=i.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,i=this.m_ActiveEdges;null!==i;){if(e.IsIntermediate(i,t)){a=null;i.OutIdx>=0&&(a=e.AddOutPt(i,i.Top));o=(i=e.UpdateEdgeIntoAEL(i)).PrevInAEL;var l=i.NextInAEL;if(null!==o&&o.Curr.X===i.Bot.X&&o.Curr.Y===i.Bot.Y&&null!==a&&o.OutIdx>=0&&o.Curr.Y===o.Top.Y&&d.ClipperBase.SlopesEqual5(i.Curr,i.Top,o.Curr,o.Top)&&0!==i.WindDelta&&0!==o.WindDelta){h=e.AddOutPt(ePrev2,i.Bot);e.AddJoin(a,h,i.Top)}else if(null!==l&&l.Curr.X===i.Bot.X&&l.Curr.Y===i.Bot.Y&&null!==a&&l.OutIdx>=0&&l.Curr.Y===l.Top.Y&&d.ClipperBase.SlopesEqual5(i.Curr,i.Top,l.Curr,l.Top)&&0!==i.WindDelta&&0!==l.WindDelta){h=e.AddOutPt(l,i.Bot);e.AddJoin(a,h,i.Top)}}i=i.NextInAEL}},d.Clipper.prototype.DoMaxima=function(t){var e=this.GetMaximaPairEx(t);if(null===e)return t.OutIdx>=0&&this.AddOutPt(t,t.Top),void this.DeleteFromAEL(t);for(var i=t.NextInAEL;null!==i&&i!==e;)this.IntersectEdges(t,i,t.Top),this.SwapPositionsInAEL(t,i),i=t.NextInAEL;-1===t.OutIdx&&-1===e.OutIdx?(this.DeleteFromAEL(t),this.DeleteFromAEL(e)):t.OutIdx>=0&&e.OutIdx>=0?(t.OutIdx>=0&&this.AddLocalMaxPoly(t,e,t.Top),this.DeleteFromAEL(t),this.DeleteFromAEL(e)):d.use_lines&&0===t.WindDelta?(t.OutIdx>=0&&(this.AddOutPt(t,t.Top),t.OutIdx=d.ClipperBase.Unassigned),this.DeleteFromAEL(t),e.OutIdx>=0&&(this.AddOutPt(e,t.Top),e.OutIdx=d.ClipperBase.Unassigned),this.DeleteFromAEL(e)):d.Error("DoMaxima error")},d.Clipper.ReversePaths=function(t){for(var e=0,i=t.length;e<i;e++)t[e].reverse()},d.Clipper.Orientation=function(t){return d.Clipper.Area(t)>=0},d.Clipper.prototype.PointCount=function(t){if(null===t)return 0;var e=0,i=t;do{e++,i=i.Next}while(i!==t);return e},d.Clipper.prototype.BuildResult=function(t){d.Clear(t);for(var e=0,i=this.m_PolyOuts.length;e<i;e++){var r=this.m_PolyOuts[e];if(null!==r.Pts){var n=r.Pts.Prev,o=this.PointCount(n);if(!(o<2)){for(var s=new Array(o),a=0;a<o;a++)s[a]=n.Pt,n=n.Prev;t.push(s)}}}},d.Clipper.prototype.BuildResult2=function(t){var e=this;t.Clear();for(var i=0,r=this.m_PolyOuts.length;i<r;i++){var n=e.m_PolyOuts[i],o=e.PointCount(n.Pts);if(!(n.IsOpen&&o<2||!n.IsOpen&&o<3)){e.FixHoleLinkage(n);var s=new d.PolyNode;t.m_AllPolys.push(s),n.PolyNode=s,s.m_polygon.length=o;for(var a=n.Pts.Prev,h=0;h<o;h++)s.m_polygon[h]=a.Pt,a=a.Prev}}for(i=0,r=this.m_PolyOuts.length;i<r;i++){null!==(n=e.m_PolyOuts[i]).PolyNode&&(n.IsOpen?(n.PolyNode.IsOpen=!0,t.AddChild(n.PolyNode)):null!==n.FirstLeft&&null!==n.FirstLeft.PolyNode?n.FirstLeft.PolyNode.AddChild(n.PolyNode):t.AddChild(n.PolyNode))}},d.Clipper.prototype.FixupOutPolyline=function(t){for(var e=t.Pts,i=e.Prev;e!==i;)if(e=e.Next,d.FPoint.op_Equality(e.Pt,e.Prev.Pt)){e===i&&(i=e.Prev);var r=e.Prev;r.Next=e.Next,e.Next.Prev=r,e=r}e===e.Prev&&(t.Pts=null)},d.Clipper.prototype.FixupOutPolygon=function(t){var e=null;t.BottomPt=null;for(var i=t.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(i.Prev===i||i.Prev===i.Next)return void(t.Pts=null);if(d.FPoint.op_Equality(i.Pt,i.Next.Pt)||d.FPoint.op_Equality(i.Pt,i.Prev.Pt)||d.ClipperBase.SlopesEqual4(i.Prev.Pt,i.Pt,i.Next.Pt)&&(!r||!this.Pt2IsBetweenPt1AndPt3(i.Prev.Pt,i.Pt,i.Next.Pt)))e=null,i.Prev.Next=i.Next,i.Next.Prev=i.Prev,i=i.Prev;else{if(i===e)break;null===e&&(e=i),i=i.Next}}t.Pts=i},d.Clipper.prototype.DupOutPt=function(t,e){var i=new d.OutPt;return i.Pt.X=t.Pt.X,i.Pt.Y=t.Pt.Y,d.use_xyz&&(i.Pt.Z=t.Pt.Z),i.Idx=t.Idx,e?(i.Next=t.Next,i.Prev=t,t.Next.Prev=i,t.Next=i):(i.Prev=t.Prev,i.Next=t,t.Prev.Next=i,t.Prev=i),i},d.Clipper.prototype.GetOverlap=function(t,e,i,r,n){return t<e?i<r?(n.Left=Math.max(t,i),n.Right=Math.min(e,r)):(n.Left=Math.max(t,r),n.Right=Math.min(e,i)):i<r?(n.Left=Math.max(e,i),n.Right=Math.min(t,r)):(n.Left=Math.max(e,r),n.Right=Math.min(t,i)),n.Left<n.Right},d.Clipper.prototype.JoinHorz=function(t,e,i,r,n,o){var s=t.Pt.X>e.Pt.X?d.Direction.dRightToLeft:d.Direction.dLeftToRight,a=i.Pt.X>r.Pt.X?d.Direction.dRightToLeft:d.Direction.dLeftToRight;if(s===a)return!1;if(s===d.Direction.dLeftToRight){for(;t.Next.Pt.X<=n.X&&t.Next.Pt.X>=t.Pt.X&&t.Next.Pt.Y===n.Y;)t=t.Next;o&&t.Pt.X!==n.X&&(t=t.Next),e=this.DupOutPt(t,!o),d.FPoint.op_Inequality(e.Pt,n)&&((t=e).Pt.X=n.X,t.Pt.Y=n.Y,d.use_xyz&&(t.Pt.Z=n.Z),e=this.DupOutPt(t,!o))}else{for(;t.Next.Pt.X>=n.X&&t.Next.Pt.X<=t.Pt.X&&t.Next.Pt.Y===n.Y;)t=t.Next;o||t.Pt.X===n.X||(t=t.Next),e=this.DupOutPt(t,o),d.FPoint.op_Inequality(e.Pt,n)&&((t=e).Pt.X=n.X,t.Pt.Y=n.Y,d.use_xyz&&(t.Pt.Z=n.Z),e=this.DupOutPt(t,o))}if(a===d.Direction.dLeftToRight){for(;i.Next.Pt.X<=n.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===n.Y;)i=i.Next;o&&i.Pt.X!==n.X&&(i=i.Next),r=this.DupOutPt(i,!o),d.FPoint.op_Inequality(r.Pt,n)&&((i=r).Pt.X=n.X,i.Pt.Y=n.Y,d.use_xyz&&(i.Pt.Z=n.Z),r=this.DupOutPt(i,!o))}else{for(;i.Next.Pt.X>=n.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===n.Y;)i=i.Next;o||i.Pt.X===n.X||(i=i.Next),r=this.DupOutPt(i,o),d.FPoint.op_Inequality(r.Pt,n)&&((i=r).Pt.X=n.X,i.Pt.Y=n.Y,d.use_xyz&&(i.Pt.Z=n.Z),r=this.DupOutPt(i,o))}return s===d.Direction.dLeftToRight===o?(t.Prev=i,i.Next=t,e.Next=r,r.Prev=e):(t.Next=i,i.Prev=t,e.Prev=r,r.Next=e),!0},d.Clipper.prototype.JoinPoints=function(t,e,i){var r=t.OutPt1,n=new d.OutPt,o=t.OutPt2,s=new d.OutPt,a=t.OutPt1.Pt.Y===t.OffPt.Y;if(a&&d.FPoint.op_Equality(t.OffPt,t.OutPt1.Pt)&&d.FPoint.op_Equality(t.OffPt,t.OutPt2.Pt)){if(e!==i)return!1;for(n=t.OutPt1.Next;n!==r&&d.FPoint.op_Equality(n.Pt,t.OffPt);)n=n.Next;var h=n.Pt.Y>t.OffPt.Y;for(s=t.OutPt2.Next;s!==o&&d.FPoint.op_Equality(s.Pt,t.OffPt);)s=s.Next;return h!==s.Pt.Y>t.OffPt.Y&&(h?(n=this.DupOutPt(r,!1),s=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,n.Next=s,s.Prev=n,t.OutPt1=r,t.OutPt2=n,!0):(n=this.DupOutPt(r,!0),s=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,n.Prev=s,s.Next=n,t.OutPt1=r,t.OutPt2=n,!0))}if(a){for(n=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==n&&r.Prev!==o;)r=r.Prev;for(;n.Next.Pt.Y===n.Pt.Y&&n.Next!==r&&n.Next!==o;)n=n.Next;if(n.Next===r||n.Next===o)return!1;for(s=o;o.Prev.Pt.Y===o.Pt.Y&&o.Prev!==s&&o.Prev!==n;)o=o.Prev;for(;s.Next.Pt.Y===s.Pt.Y&&s.Next!==o&&s.Next!==r;)s=s.Next;if(s.Next===o||s.Next===r)return!1;var l={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,n.Pt.X,o.Pt.X,s.Pt.X,l))return!1;var u,p=l.Left,c=l.Right,f=new d.FPoint0;return r.Pt.X>=p&&r.Pt.X<=c?(f.X=r.Pt.X,f.Y=r.Pt.Y,d.use_xyz&&(f.Z=r.Pt.Z),u=r.Pt.X>n.Pt.X):o.Pt.X>=p&&o.Pt.X<=c?(f.X=o.Pt.X,f.Y=o.Pt.Y,d.use_xyz&&(f.Z=o.Pt.Z),u=o.Pt.X>s.Pt.X):n.Pt.X>=p&&n.Pt.X<=c?(f.X=n.Pt.X,f.Y=n.Pt.Y,d.use_xyz&&(f.Z=n.Pt.Z),u=n.Pt.X>r.Pt.X):(f.X=s.Pt.X,f.Y=s.Pt.Y,d.use_xyz&&(f.Z=s.Pt.Z),u=s.Pt.X>o.Pt.X),t.OutPt1=r,t.OutPt2=o,this.JoinHorz(r,n,o,s,f,u)}for(n=r.Next;d.FPoint.op_Equality(n.Pt,r.Pt)&&n!==r;)n=n.Next;var v=n.Pt.Y>r.Pt.Y||!d.ClipperBase.SlopesEqual4(r.Pt,n.Pt,t.OffPt);if(v){for(n=r.Prev;d.FPoint.op_Equality(n.Pt,r.Pt)&&n!==r;)n=n.Prev;if(n.Pt.Y>r.Pt.Y||!d.ClipperBase.SlopesEqual4(r.Pt,n.Pt,t.OffPt))return!1}for(s=o.Next;d.FPoint.op_Equality(s.Pt,o.Pt)&&s!==o;)s=s.Next;var y=s.Pt.Y>o.Pt.Y||!d.ClipperBase.SlopesEqual4(o.Pt,s.Pt,t.OffPt);if(y){for(s=o.Prev;d.FPoint.op_Equality(s.Pt,o.Pt)&&s!==o;)s=s.Prev;if(s.Pt.Y>o.Pt.Y||!d.ClipperBase.SlopesEqual4(o.Pt,s.Pt,t.OffPt))return!1}return n!==r&&s!==o&&n!==s&&(e!==i||v!==y)&&(v?(n=this.DupOutPt(r,!1),s=this.DupOutPt(o,!0),r.Prev=o,o.Next=r,n.Next=s,s.Prev=n,t.OutPt1=r,t.OutPt2=n,!0):(n=this.DupOutPt(r,!0),s=this.DupOutPt(o,!1),r.Next=o,o.Prev=r,n.Prev=s,s.Next=n,t.OutPt1=r,t.OutPt2=n,!0))},d.Clipper.GetBounds=function(t){for(var e=0,i=t.length;e<i&&0===t[e].length;)e++;if(e===i)return new d.FRect(0,0,0,0);var r=new d.FRect;for(r.left=t[e][0].X,r.right=r.left,r.top=t[e][0].Y,r.bottom=r.top;e<i;e++)for(var n=0,o=t[e].length;n<o;n++)t[e][n].X<r.left?r.left=t[e][n].X:t[e][n].X>r.right&&(r.right=t[e][n].X),t[e][n].Y<r.top?r.top=t[e][n].Y:t[e][n].Y>r.bottom&&(r.bottom=t[e][n].Y);return r},d.Clipper.prototype.GetBounds2=function(t){var e=t,i=new d.FRect;for(i.left=t.Pt.X,i.right=t.Pt.X,i.top=t.Pt.Y,i.bottom=t.Pt.Y,t=t.Next;t!==e;)t.Pt.X<i.left&&(i.left=t.Pt.X),t.Pt.X>i.right&&(i.right=t.Pt.X),t.Pt.Y<i.top&&(i.top=t.Pt.Y),t.Pt.Y>i.bottom&&(i.bottom=t.Pt.Y),t=t.Next;return i},d.Clipper.PointInPolygon=function(t,e){var i=0,r=e.length;if(r<3)return 0;for(var n=e[0],o=1;o<=r;++o){var s=o===r?e[0]:e[o];if(s.Y===t.Y&&(s.X===t.X||n.Y===t.Y&&s.X>t.X==n.X<t.X))return-1;if(n.Y<t.Y!=s.Y<t.Y)if(n.X>=t.X)if(s.X>t.X)i=1-i;else{if(0===(a=(n.X-t.X)*(s.Y-t.Y)-(s.X-t.X)*(n.Y-t.Y)))return-1;a>0==s.Y>n.Y&&(i=1-i)}else if(s.X>t.X){var a;if(0===(a=(n.X-t.X)*(s.Y-t.Y)-(s.X-t.X)*(n.Y-t.Y)))return-1;a>0==s.Y>n.Y&&(i=1-i)}n=s}return i},d.Clipper.prototype.PointInPolygon=function(t,e){var i=0,r=e,n=t.X,o=t.Y,s=e.Pt.X,a=e.Pt.Y;do{var h=(e=e.Next).Pt.X,l=e.Pt.Y;if(l===o&&(h===n||a===o&&h>n==s<n))return-1;if(a<o!=l<o)if(s>=n)if(h>n)i=1-i;else{if(0===(u=(s-n)*(l-o)-(h-n)*(a-o)))return-1;u>0==l>a&&(i=1-i)}else if(h>n){var u;if(0===(u=(s-n)*(l-o)-(h-n)*(a-o)))return-1;u>0==l>a&&(i=1-i)}s=h,a=l}while(r!==e);return i},d.Clipper.prototype.Poly2ContainsPoly1=function(t,e){var i=t;do{var r=this.PointInPolygon(i.Pt,e);if(r>=0)return r>0;i=i.Next}while(i!==t);return!0},d.Clipper.prototype.FixupFirstLefts1=function(t,e){for(var i,r,n=0,o=this.m_PolyOuts.length;n<o;n++)i=this.m_PolyOuts[n],r=d.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===t&&this.Poly2ContainsPoly1(i.Pts,e.Pts)&&(i.FirstLeft=e)},d.Clipper.prototype.FixupFirstLefts2=function(t,e){for(var i,r,n=this,o=e.FirstLeft,s=0,a=this.m_PolyOuts.length;s<a;s++)null!==(i=n.m_PolyOuts[s]).Pts&&i!==e&&i!==t&&((r=d.Clipper.ParseFirstLeft(i.FirstLeft))!==o&&r!==t&&r!==e||(n.Poly2ContainsPoly1(i.Pts,t.Pts)?i.FirstLeft=t:n.Poly2ContainsPoly1(i.Pts,e.Pts)?i.FirstLeft=e:i.FirstLeft!==t&&i.FirstLeft!==e||(i.FirstLeft=o)))},d.Clipper.prototype.FixupFirstLefts3=function(t,e){for(var i,r,n=0,o=this.m_PolyOuts.length;n<o;n++)i=this.m_PolyOuts[n],r=d.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===t&&(i.FirstLeft=e)},d.Clipper.ParseFirstLeft=function(t){for(;null!==t&&null===t.Pts;)t=t.FirstLeft;return t},d.Clipper.prototype.JoinCommonEdges=function(){for(var t=this,e=0,i=this.m_Joins.length;e<i;e++){var r,n=t.m_Joins[e],o=t.GetOutRec(n.OutPt1.Idx),s=t.GetOutRec(n.OutPt2.Idx);if(null!==o.Pts&&null!==s.Pts)if(!o.IsOpen&&!s.IsOpen)r=o===s?o:t.OutRec1RightOfOutRec2(o,s)?s:t.OutRec1RightOfOutRec2(s,o)?o:t.GetLowermostRec(o,s),t.JoinPoints(n,o,s)&&(o===s?(o.Pts=n.OutPt1,o.BottomPt=null,(s=t.CreateOutRec()).Pts=n.OutPt2,t.UpdateOutPtIdxs(s),t.Poly2ContainsPoly1(s.Pts,o.Pts)?(s.IsHole=!o.IsHole,s.FirstLeft=o,t.m_UsingPolyTree&&t.FixupFirstLefts2(s,o),(s.IsHole^t.ReverseSolution)==t.Area$1(s)>0&&t.ReversePolyPtLinks(s.Pts)):t.Poly2ContainsPoly1(o.Pts,s.Pts)?(s.IsHole=o.IsHole,o.IsHole=!s.IsHole,s.FirstLeft=o.FirstLeft,o.FirstLeft=s,t.m_UsingPolyTree&&t.FixupFirstLefts2(o,s),(o.IsHole^t.ReverseSolution)==t.Area$1(o)>0&&t.ReversePolyPtLinks(o.Pts)):(s.IsHole=o.IsHole,s.FirstLeft=o.FirstLeft,t.m_UsingPolyTree&&t.FixupFirstLefts1(o,s))):(s.Pts=null,s.BottomPt=null,s.Idx=o.Idx,o.IsHole=r.IsHole,r===s&&(o.FirstLeft=s.FirstLeft),s.FirstLeft=o,t.m_UsingPolyTree&&t.FixupFirstLefts3(s,o)))}},d.Clipper.prototype.UpdateOutPtIdxs=function(t){var e=t.Pts;do{e.Idx=t.Idx,e=e.Prev}while(e!==t.Pts)},d.Clipper.prototype.DoSimplePolygons=function(){for(var t=this,e=0;e<this.m_PolyOuts.length;){var i=t.m_PolyOuts[e++],r=i.Pts;if(null!==r&&!i.IsOpen)do{for(var n=r.Next;n!==i.Pts;){if(d.FPoint.op_Equality(r.Pt,n.Pt)&&n.Next!==r&&n.Prev!==r){var o=r.Prev,s=n.Prev;r.Prev=s,s.Next=r,n.Prev=o,o.Next=n,i.Pts=r;var a=t.CreateOutRec();a.Pts=n,t.UpdateOutPtIdxs(a),t.Poly2ContainsPoly1(a.Pts,i.Pts)?(a.IsHole=!i.IsHole,a.FirstLeft=i,t.m_UsingPolyTree&&t.FixupFirstLefts2(a,i)):t.Poly2ContainsPoly1(i.Pts,a.Pts)?(a.IsHole=i.IsHole,i.IsHole=!a.IsHole,a.FirstLeft=i.FirstLeft,i.FirstLeft=a,t.m_UsingPolyTree&&t.FixupFirstLefts2(i,a)):(a.IsHole=i.IsHole,a.FirstLeft=i.FirstLeft,t.m_UsingPolyTree&&t.FixupFirstLefts1(i,a)),n=r}n=n.Next}r=r.Next}while(r!==i.Pts)}},d.Clipper.Area=function(t){if(!Array.isArray(t))return 0;var e=t.length;if(e<3)return 0;for(var i=0,r=0,n=e-1;r<e;++r)i+=(t[n].X+t[r].X)*(t[n].Y-t[r].Y),n=r;return.5*-i},d.Clipper.prototype.Area=function(t){var e=t;if(null===t)return 0;var i=0;do{i+=(t.Prev.Pt.X+t.Pt.X)*(t.Prev.Pt.Y-t.Pt.Y),t=t.Next}while(t!==e);return.5*i},d.Clipper.prototype.Area$1=function(t){return this.Area(t.Pts)},d.Clipper.SimplifyPolygon=function(t,e){var i=new Array,r=new d.Clipper(0);return r.StrictlySimple=!0,r.AddPath(t,d.PolyType.ptSubject,!0),r.Execute(d.ClipType.ctUnion,i,e,e),i},d.Clipper.SimplifyPolygons=function(t,e){void 0===e&&(e=d.PolyFillType.pftEvenOdd);var i=new Array,r=new d.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(t,d.PolyType.ptSubject,!0),r.Execute(d.ClipType.ctUnion,i,e,e),i},d.Clipper.DistanceSqrd=function(t,e){var i=t.X-e.X,r=t.Y-e.Y;return i*i+r*r},d.Clipper.DistanceFromLineSqrd=function(t,e,i){var r=e.Y-i.Y,n=i.X-e.X,o=r*e.X+n*e.Y;return(o=r*t.X+n*t.Y-o)*o/(r*r+n*n)},d.Clipper.SlopesNearCollinear=function(t,e,i,r){return Math.abs(t.X-e.X)>Math.abs(t.Y-e.Y)?t.X>e.X==t.X<i.X?d.Clipper.DistanceFromLineSqrd(t,e,i)<r:e.X>t.X==e.X<i.X?d.Clipper.DistanceFromLineSqrd(e,t,i)<r:d.Clipper.DistanceFromLineSqrd(i,t,e)<r:t.Y>e.Y==t.Y<i.Y?d.Clipper.DistanceFromLineSqrd(t,e,i)<r:e.Y>t.Y==e.Y<i.Y?d.Clipper.DistanceFromLineSqrd(e,t,i)<r:d.Clipper.DistanceFromLineSqrd(i,t,e)<r},d.Clipper.PointsAreClose=function(t,e,i){var r=t.X-e.X,n=t.Y-e.Y;return r*r+n*n<=i},d.Clipper.ExcludeOp=function(t){var e=t.Prev;return e.Next=t.Next,t.Next.Prev=e,e.Idx=0,e},d.Clipper.CleanPolygon=function(t,e){void 0===e&&(e=1.415);var i=t.length;if(0===i)return new Array;for(var r=new Array(i),n=0;n<i;++n)r[n]=new d.OutPt;for(n=0;n<i;++n)r[n].Pt=t[n],r[n].Next=r[(n+1)%i],r[n].Next.Prev=r[n],r[n].Idx=0;for(var o=e*e,s=r[0];0===s.Idx&&s.Next!==s.Prev;)d.Clipper.PointsAreClose(s.Pt,s.Prev.Pt,o)?(s=d.Clipper.ExcludeOp(s),i--):d.Clipper.PointsAreClose(s.Prev.Pt,s.Next.Pt,o)?(d.Clipper.ExcludeOp(s.Next),s=d.Clipper.ExcludeOp(s),i-=2):d.Clipper.SlopesNearCollinear(s.Prev.Pt,s.Pt,s.Next.Pt,o)?(s=d.Clipper.ExcludeOp(s),i--):(s.Idx=1,s=s.Next);i<3&&(i=0);var a=new Array(i);for(n=0;n<i;++n)a[n]=new d.FPoint1(s.Pt),s=s.Next;return r=null,a},d.Clipper.CleanPolygons=function(t,e){for(var i=new Array(t.length),r=0,n=t.length;r<n;r++)i[r]=d.Clipper.CleanPolygon(t[r],e);return i},d.Clipper.Minkowski=function(t,e,i,r){var n=r?1:0,o=t.length,s=e.length,a=new Array;if(i)for(var h=0;h<s;h++){for(var l=new Array(o),u=0,p=t.length,c=t[u];u<p;c=t[++u])l[u]=new d.FPoint2(e[h].X+c.X,e[h].Y+c.Y);a.push(l)}else for(h=0;h<s;h++){for(l=new Array(o),u=0,p=t.length,c=t[u];u<p;c=t[++u])l[u]=new d.FPoint2(e[h].X-c.X,e[h].Y-c.Y);a.push(l)}var f=new Array;for(h=0;h<s-1+n;h++)for(u=0;u<o;u++){var v=new Array;v.push(a[h%s][u%o]),v.push(a[(h+1)%s][u%o]),v.push(a[(h+1)%s][(u+1)%o]),v.push(a[h%s][(u+1)%o]),d.Clipper.Orientation(v)||v.reverse(),f.push(v)}return f},d.Clipper.MinkowskiSum=function(t,e,i){if(e[0]instanceof Array){h=e;for(var r=new d.Paths,n=(s=new d.Clipper,0);n<h.length;++n){var o=d.Clipper.Minkowski(t,h[n],!0,i);if(s.AddPaths(o,d.PolyType.ptSubject,!0),i){a=d.Clipper.TranslatePath(h[n],t[0]);s.AddPath(a,d.PolyType.ptClip,!0)}}return s.Execute(d.ClipType.ctUnion,r,d.PolyFillType.pftNonZero,d.PolyFillType.pftNonZero),r}var s,a=e,h=d.Clipper.Minkowski(t,a,!0,i);return(s=new d.Clipper).AddPaths(h,d.PolyType.ptSubject,!0),s.Execute(d.ClipType.ctUnion,h,d.PolyFillType.pftNonZero,d.PolyFillType.pftNonZero),h},d.Clipper.TranslatePath=function(t,e){for(var i=new d.Path,r=0;r<t.length;r++)i.push(new d.FPoint2(t[r].X+e.X,t[r].Y+e.Y));return i},d.Clipper.MinkowskiDiff=function(t,e){var i=d.Clipper.Minkowski(t,e,!1,!0),r=new d.Clipper;return r.AddPaths(i,d.PolyType.ptSubject,!0),r.Execute(d.ClipType.ctUnion,i,d.PolyFillType.pftNonZero,d.PolyFillType.pftNonZero),i},d.Clipper.PolyTreeToPaths=function(t){var e=new Array;return d.Clipper.AddPolyNodeToPaths(t,d.Clipper.NodeType.ntAny,e),e},d.Clipper.AddPolyNodeToPaths=function(t,e,i){var r=!0;switch(e){case d.Clipper.NodeType.ntOpen:return;case d.Clipper.NodeType.ntClosed:r=!t.IsOpen}t.m_polygon.length>0&&r&&i.push(t.m_polygon);for(var n=0,o=t.Childs(),s=o.length,a=o[n];n<s;a=o[++n])d.Clipper.AddPolyNodeToPaths(a,e,i)},d.Clipper.OpenPathsFromPolyTree=function(t){for(var e=new d.Paths,i=0,r=t.ChildCount();i<r;i++)t.Childs()[i].IsOpen&&e.push(t.Childs()[i].m_polygon);return e},d.Clipper.ClosedPathsFromPolyTree=function(t){var e=new d.Paths;return d.Clipper.AddPolyNodeToPaths(t,d.Clipper.NodeType.ntClosed,e),e},f(d.Clipper,d.ClipperBase),d.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},d.ClipperOffset=function(t,e){void 0===t&&(t=2),void 0===e&&(e=d.ClipperOffset.def_arc_tolerance),this.m_destPolys=new d.Paths,this.m_srcPoly=new d.Path,this.m_destPoly=new d.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new d.FPoint0,this.m_polyNodes=new d.PolyNode,this.MiterLimit=t,this.ArcTolerance=e,this.m_lowest.X=-1},d.ClipperOffset.two_pi=6.28318530717959,d.ClipperOffset.def_arc_tolerance=.25,d.ClipperOffset.prototype.Clear=function(){d.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},d.ClipperOffset.prototype.AddPath=function(t,e,i){var r=t.length-1;if(!(r<0)){var n=new d.PolyNode;if(n.m_jointype=e,n.m_endtype=i,i===d.EndType.etClosedLine||i===d.EndType.etClosedPolygon)for(;r>0&&d.FPoint.op_Equality(t[0],t[r]);)r--;n.m_polygon.push(t[0]);for(var o=0,s=0,a=1;a<=r;a++)d.FPoint.op_Inequality(n.m_polygon[o],t[a])&&(o++,n.m_polygon.push(t[a]),(t[a].Y>n.m_polygon[s].Y||t[a].Y===n.m_polygon[s].Y&&t[a].X<n.m_polygon[s].X)&&(s=o));if(!(i===d.EndType.etClosedPolygon&&o<2)&&(this.m_polyNodes.AddChild(n),i===d.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new d.FPoint2(this.m_polyNodes.ChildCount()-1,s);else{var h=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(n.m_polygon[s].Y>h.Y||n.m_polygon[s].Y===h.Y&&n.m_polygon[s].X<h.X)&&(this.m_lowest=new d.FPoint2(this.m_polyNodes.ChildCount()-1,s))}}},d.ClipperOffset.prototype.AddPaths=function(t,e,i){for(var r=0,n=t.length;r<n;r++)this.AddPath(t[r],e,i)},d.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!d.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var t=0;t<this.m_polyNodes.ChildCount();t++){((e=this.m_polyNodes.Childs()[t]).m_endtype===d.EndType.etClosedPolygon||e.m_endtype===d.EndType.etClosedLine&&d.Clipper.Orientation(e.m_polygon))&&e.m_polygon.reverse()}else for(t=0;t<this.m_polyNodes.ChildCount();t++){var e;(e=this.m_polyNodes.Childs()[t]).m_endtype!==d.EndType.etClosedLine||d.Clipper.Orientation(e.m_polygon)||e.m_polygon.reverse()}},d.ClipperOffset.GetUnitNormal=function(t,e){var i=e.X-t.X,r=e.Y-t.Y;if(0===i&&0===r)return new d.FPoint2(0,0);var n=1/Math.sqrt(i*i+r*r);return i*=n,r*=n,new d.FPoint2(r,-i)},d.ClipperOffset.prototype.DoOffset=function(t){var e=this;if(this.m_destPolys=new Array,this.m_delta=t,d.ClipperBase.near_zero(t))for(var i=0;i<this.m_polyNodes.ChildCount();i++){(o=e.m_polyNodes.Childs()[i]).m_endtype===d.EndType.etClosedPolygon&&e.m_destPolys.push(o.m_polygon)}else{var r;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,r=this.ArcTolerance<=0?d.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(t)*d.ClipperOffset.def_arc_tolerance?Math.abs(t)*d.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var n=3.14159265358979/Math.acos(1-r/Math.abs(t));this.m_sin=Math.sin(d.ClipperOffset.two_pi/n),this.m_cos=Math.cos(d.ClipperOffset.two_pi/n),this.m_StepsPerRad=n/d.ClipperOffset.two_pi,t<0&&(this.m_sin=-this.m_sin);for(i=0;i<this.m_polyNodes.ChildCount();i++){var o=e.m_polyNodes.Childs()[i];e.m_srcPoly=o.m_polygon;var s=e.m_srcPoly.length;if(!(0===s||t<=0&&(s<3||o.m_endtype!==d.EndType.etClosedPolygon)))if(e.m_destPoly=new Array,1!==s){e.m_normals.length=0;for(c=0;c<s-1;c++)e.m_normals.push(d.ClipperOffset.GetUnitNormal(e.m_srcPoly[c],e.m_srcPoly[c+1]));if(o.m_endtype===d.EndType.etClosedLine||o.m_endtype===d.EndType.etClosedPolygon?e.m_normals.push(d.ClipperOffset.GetUnitNormal(e.m_srcPoly[s-1],e.m_srcPoly[0])):e.m_normals.push(new d.FPoint1(e.m_normals[s-2])),o.m_endtype===d.EndType.etClosedPolygon){var a=s-1;for(c=0;c<s;c++)a=e.OffsetPoint(c,a,o.m_jointype);e.m_destPolys.push(e.m_destPoly)}else if(o.m_endtype===d.EndType.etClosedLine){for(a=s-1,c=0;c<s;c++)a=e.OffsetPoint(c,a,o.m_jointype);e.m_destPolys.push(e.m_destPoly),e.m_destPoly=new Array;var h=e.m_normals[s-1];for(c=s-1;c>0;c--)e.m_normals[c]=new d.FPoint2(-e.m_normals[c-1].X,-e.m_normals[c-1].Y);e.m_normals[0]=new d.FPoint2(-h.X,-h.Y),a=0;for(c=s-1;c>=0;c--)a=e.OffsetPoint(c,a,o.m_jointype);e.m_destPolys.push(e.m_destPoly)}else{var l;for(a=0,c=1;c<s-1;++c)a=e.OffsetPoint(c,a,o.m_jointype);if(o.m_endtype===d.EndType.etOpenButt){c=s-1;l=new d.FPoint2(e.m_srcPoly[c].X+e.m_normals[c].X*t,e.m_srcPoly[c].Y+e.m_normals[c].Y*t),e.m_destPoly.push(l),l=new d.FPoint2(e.m_srcPoly[c].X-e.m_normals[c].X*t,e.m_srcPoly[c].Y-e.m_normals[c].Y*t),e.m_destPoly.push(l)}else{c=s-1;a=s-2,e.m_sinA=0,e.m_normals[c]=new d.FPoint2(-e.m_normals[c].X,-e.m_normals[c].Y),o.m_endtype===d.EndType.etOpenSquare?e.DoSquare(c,a):e.DoRound(c,a)}for(c=s-1;c>0;c--)e.m_normals[c]=new d.FPoint2(-e.m_normals[c-1].X,-e.m_normals[c-1].Y);e.m_normals[0]=new d.FPoint2(-e.m_normals[1].X,-e.m_normals[1].Y);for(c=(a=s-1)-1;c>0;--c)a=e.OffsetPoint(c,a,o.m_jointype);o.m_endtype===d.EndType.etOpenButt?(l=new d.FPoint2(e.m_srcPoly[0].X-e.m_normals[0].X*t,e.m_srcPoly[0].Y-e.m_normals[0].Y*t),e.m_destPoly.push(l),l=new d.FPoint2(e.m_srcPoly[0].X+e.m_normals[0].X*t,e.m_srcPoly[0].Y+e.m_normals[0].Y*t),e.m_destPoly.push(l)):(a=1,e.m_sinA=0,o.m_endtype===d.EndType.etOpenSquare?e.DoSquare(0,1):e.DoRound(0,1)),e.m_destPolys.push(e.m_destPoly)}}else{if(o.m_jointype===d.JoinType.jtRound)for(var u=1,p=0,c=1;c<=n;c++){e.m_destPoly.push(new d.FPoint2(e.m_srcPoly[0].X+u*t,e.m_srcPoly[0].Y+p*t));var f=u;u=u*e.m_cos-e.m_sin*p,p=f*e.m_sin+p*e.m_cos}else{u=-1,p=-1;for(var c=0;c<4;++c)e.m_destPoly.push(new d.FPoint2(e.m_srcPoly[0].X+u*t,e.m_srcPoly[0].Y+p*t)),u<0?u=1:p<0?p=1:u=-1}e.m_destPolys.push(e.m_destPoly)}}}},d.ClipperOffset.prototype.Execute=function(){var t=arguments,e=t[0]instanceof d.PolyTree;if(e){o=t[0],s=t[1];if(o.Clear(),this.FixOrientations(),this.DoOffset(s),(n=new d.Clipper(0)).AddPaths(this.m_destPolys,d.PolyType.ptSubject,!0),s>0)n.Execute(d.ClipType.ctUnion,o,d.PolyFillType.pftPositive,d.PolyFillType.pftPositive);else{h=d.Clipper.GetBounds(this.m_destPolys);if((a=new d.Path).push(new d.FPoint2(h.left-10,h.bottom+10)),a.push(new d.FPoint2(h.right+10,h.bottom+10)),a.push(new d.FPoint2(h.right+10,h.top-10)),a.push(new d.FPoint2(h.left-10,h.top-10)),n.AddPath(a,d.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(d.ClipType.ctUnion,o,d.PolyFillType.pftNegative,d.PolyFillType.pftNegative),1===o.ChildCount()&&o.Childs()[0].ChildCount()>0){var i=o.Childs()[0];o.Childs()[0]=i.Childs()[0],o.Childs()[0].m_Parent=o;for(var r=1;r<i.ChildCount();r++)o.AddChild(i.Childs()[r])}else o.Clear()}}else{var n,o=t[0],s=t[1];if(d.Clear(o),this.FixOrientations(),this.DoOffset(s),(n=new d.Clipper(0)).AddPaths(this.m_destPolys,d.PolyType.ptSubject,!0),s>0)n.Execute(d.ClipType.ctUnion,o,d.PolyFillType.pftPositive,d.PolyFillType.pftPositive);else{var a,h=d.Clipper.GetBounds(this.m_destPolys);(a=new d.Path).push(new d.FPoint2(h.left-10,h.bottom+10)),a.push(new d.FPoint2(h.right+10,h.bottom+10)),a.push(new d.FPoint2(h.right+10,h.top-10)),a.push(new d.FPoint2(h.left-10,h.top-10)),n.AddPath(a,d.PolyType.ptSubject,!0),n.ReverseSolution=!0,n.Execute(d.ClipType.ctUnion,o,d.PolyFillType.pftNegative,d.PolyFillType.pftNegative),o.length>0&&o.splice(0,1)}}},d.ClipperOffset.prototype.OffsetPoint=function(t,e,i){if(this.m_sinA=this.m_normals[e].X*this.m_normals[t].Y-this.m_normals[t].X*this.m_normals[e].Y,0===this.m_sinA)return e;if(this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1),this.m_sinA*this.m_delta<0)this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_normals[e].X*this.m_delta,this.m_srcPoly[t].Y+this.m_normals[e].Y*this.m_delta)),this.m_destPoly.push(new d.FPoint1(this.m_srcPoly[t])),this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta,this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta));else switch(i){case d.JoinType.jtMiter:var r=this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y+1;r>=this.m_miterLim?this.DoMiter(t,e,r):this.DoSquare(t,e);break;case d.JoinType.jtSquare:this.DoSquare(t,e);break;case d.JoinType.jtRound:this.DoRound(t,e)}return e=t},d.ClipperOffset.prototype.DoSquare=function(t,e){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y)/4);this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[e].X-this.m_normals[e].Y*i),this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[e].Y+this.m_normals[e].X*i))),this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_delta*(this.m_normals[t].X+this.m_normals[t].Y*i),this.m_srcPoly[t].Y+this.m_delta*(this.m_normals[t].Y-this.m_normals[t].X*i)))},d.ClipperOffset.prototype.DoMiter=function(t,e,i){var r=this.m_delta/i;this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+(this.m_normals[e].X+this.m_normals[t].X)*r,this.m_srcPoly[t].Y+(this.m_normals[e].Y+this.m_normals[t].Y)*r))},d.ClipperOffset.prototype.DoRound=function(t,e){for(var i,r=this,n=Math.atan2(this.m_sinA,this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y),o=Math.max(Math.round(this.m_StepsPerRad*Math.abs(n)),1),s=this.m_normals[e].X,a=this.m_normals[e].Y,h=0;h<o;++h)r.m_destPoly.push(new d.FPoint2(r.m_srcPoly[t].X+s*r.m_delta,r.m_srcPoly[t].Y+a*r.m_delta)),i=s,s=s*r.m_cos-r.m_sin*a,a=i*r.m_sin+a*r.m_cos;this.m_destPoly.push(new d.FPoint2(this.m_srcPoly[t].X+this.m_normals[t].X*this.m_delta,this.m_srcPoly[t].Y+this.m_normals[t].Y*this.m_delta))},d.Error=function(t){try{throw new Error(t)}catch(t){alert(t.message)}},d.JS={},d.JS.AreaOfPolygon=function(t){return d.Clipper.Area(t)},d.JS.AreaOfPolygons=function(t){for(var e=0,i=0;i<t.length;i++)e+=d.Clipper.Area(t[i]);return e},d.JS.BoundsOfPath=function(t){return d.JS.BoundsOfPaths([t])},d.JS.BoundsOfPaths=function(t){return d.Clipper.GetBounds(t)},d.JS.Clean=function(t,e){if(!(t instanceof Array))return[];var i=t[0]instanceof Array;t=d.JS.Clone(t);if("number"!=typeof e||null===e)return d.Error("Delta is not a number in Clean()."),t;if(0===t.length||1===t.length&&0===t[0].length||e<0)return t;i||(t=[t]);for(var r,n,o,s,a,h,l,u=t.length,p=[],c=0;c<u;c++)if(0!==(r=(n=t[c]).length))if(r<3)o=n,p.push(o);else{for(o=n,s=e*e,a=n[0],h=1,l=1;l<r;l++)(n[l].X-a.X)*(n[l].X-a.X)+(n[l].Y-a.Y)*(n[l].Y-a.Y)<=s||(o[h]=n[l],a=n[l],h++);a=n[h-1],(n[0].X-a.X)*(n[0].X-a.X)+(n[0].Y-a.Y)*(n[0].Y-a.Y)<=s&&h--,h<r&&o.splice(h,r-h),o.length&&p.push(o)}return!i&&p.length?p=p[0]:i||0!==p.length?i&&0===p.length&&(p=[[]]):p=[],p},d.JS.Clone=function(t){if(!(t instanceof Array))return[];if(0===t.length)return[];if(1===t.length&&0===t[0].length)return[[]];var e=t[0]instanceof Array;e||(t=[t]);var i,r,n,o,s=t.length,a=new Array(s);for(r=0;r<s;r++){for(i=t[r].length,o=new Array(i),n=0;n<i;n++)o[n]={X:t[r][n].X,Y:t[r][n].Y};a[r]=o}return e||(a=a[0]),a},d.JS.Lighten=function(t,e){if(!(t instanceof Array))return[];if("number"!=typeof e||null===e)return d.Error("Tolerance is not a number in Lighten()."),d.JS.Clone(t);if(0===t.length||1===t.length&&0===t[0].length||e<0)return d.JS.Clone(t);var i,r,n,o,s,a,h,l,u,p,c,f,v,y,g,m,_=t[0]instanceof Array;_||(t=[t]);var x=t.length,b=e*e,P=[];for(i=0;i<x;i++)if(0!==(a=(n=t[i]).length)){for(o=0;o<1e6;o++){for(s=[],n[(a=n.length)-1].X!==n[0].X||n[a-1].Y!==n[0].Y?(c=1,n.push({X:n[0].X,Y:n[0].Y}),a=n.length):c=0,p=[],r=0;r<a-2;r++)h=n[r],u=n[r+1],l=n[r+2],g=h.X,m=h.Y,f=l.X-g,v=l.Y-m,0===f&&0===v||((y=((u.X-g)*f+(u.Y-m)*v)/(f*f+v*v))>1?(g=l.X,m=l.Y):y>0&&(g+=f*y,m+=v*y)),(f=u.X-g)*f+(v=u.Y-m)*v<=b&&(p[r+1]=1,r++);for(s.push({X:n[0].X,Y:n[0].Y}),r=1;r<a-1;r++)p[r]||s.push({X:n[r].X,Y:n[r].Y});if(s.push({X:n[a-1].X,Y:n[a-1].Y}),c&&n.pop(),!p.length)break;n=s}s[(a=s.length)-1].X===s[0].X&&s[a-1].Y===s[0].Y&&s.pop(),s.length>2&&P.push(s)}return _||(P=P[0]),void 0===P&&(P=[]),P},d.JS.PerimeterOfPath=function(t,e){if(void 0===t)return 0;var i,r,n=Math.sqrt,o=0,s=0,a=0,h=0,l=0,u=t.length;if(u<2)return 0;for(e&&(t[u]=t[0],u++);--u;)s=(i=t[u]).X,a=i.Y,o+=n((s-(h=(r=t[u-1]).X))*(s-h)+(a-(l=r.Y))*(a-l));return e&&t.pop(),o},d.JS.PerimeterOfPaths=function(t,e){for(var i=0,r=0;r<t.length;r++)i+=d.JS.PerimeterOfPath(t[r],e);return i},d.ExPolygons=function(){return[]},d.ExPolygon=function(){this.outer=null,this.holes=null},d.JS.AddOuterPolyNodeToExPolygons=function(t,e){var i=new d.ExPolygon;i.outer=t.Contour();var r,n,o,s,a,h,l=t.Childs(),u=l.length;for(i.holes=new Array(u),o=0;o<u;o++)for(r=l[o],i.holes[o]=r.Contour(),s=0,h=(a=r.Childs()).length;s<h;s++)n=a[s],d.JS.AddOuterPolyNodeToExPolygons(n,e);e.push(i)},d.JS.ExPolygonsToPaths=function(t){var e,i,r,n,o=new d.Paths;for(e=0,r=t.length;e<r;e++)for(o.push(t[e].outer),i=0,n=t[e].holes.length;i<n;i++)o.push(t[e].holes[i]);return o},d.JS.PolyTreeToExPolygons=function(t){var e,i,r,n,o=new d.ExPolygons;for(i=0,n=(r=t.Childs()).length;i<n;i++)e=r[i],d.JS.AddOuterPolyNodeToExPolygons(e,o);return o};var v=d;function y(t,e){return t<e?-1:t>e?1:0}var g=Object.freeze({__proto__:null,default:class{constructor(t=[],e=y){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}}peek(){return this.data[0]}_up(t){for(var{data:e,compare:i}=this,r=e[t];t>0;){var n=t-1>>1,o=e[n];if(i(r,o)>=0)break;e[t]=o,t=n}e[t]=r}_down(t){for(var{data:e,compare:i}=this,r=this.length>>1,n=e[t];t<r;){var o=1+(t<<1),s=e[o],a=o+1;if(a<this.length&&i(e[a],s)<0&&(o=a,s=e[a]),i(s,n)>=0)break;e[t]=s,t=o}e[t]=n}}}),m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})})),e}function x(t){var e={exports:{}};return t(e,e.exports),e.exports}var b=_(g);b.default&&(b=b.default);var P=E,w=E;function E(t,e,i){var r,n,o,s;e=e||1;for(var a=0;a<t[0].length;a++){var h=t[0][a];(!a||h[0]<r)&&(r=h[0]),(!a||h[1]<n)&&(n=h[1]),(!a||h[0]>o)&&(o=h[0]),(!a||h[1]>s)&&(s=h[1])}var l=o-r,u=s-n,p=Math.min(l,u),c=p/2;if(0===p){var d=[r,n];return d.distance=0,d}for(var f=new b(void 0,T),v=r;v<o;v+=p)for(var y=n;y<s;y+=p)f.push(new C(v+c,y+c,c,t));var g=function(t){for(var e=0,i=0,r=0,n=t[0],o=0,s=n.length,a=s-1;o<s;a=o++){var h=n[o],l=n[a],u=h[0]*l[1]-l[0]*h[1];i+=(h[0]+l[0])*u,r+=(h[1]+l[1])*u,e+=3*u}return 0===e?new C(n[0][0],n[0][1],0,t):new C(i/e,r/e,0,t)}(t),m=new C(r+l/2,n+u/2,0,t);m.d>g.d&&(g=m);for(var _=f.length;f.length;){var x=f.pop();x.d>g.d&&(g=x,i&&console.log("found best %d after %d probes",Math.round(1e4*x.d)/1e4,_)),x.max-g.d<=e||(c=x.h/2,f.push(new C(x.x-c,x.y-c,c,t)),f.push(new C(x.x+c,x.y-c,c,t)),f.push(new C(x.x-c,x.y+c,c,t)),f.push(new C(x.x+c,x.y+c,c,t)),_+=4)}i&&(console.log("num probes: "+_),console.log("best distance: "+g.d));var P=[g.x,g.y];return P.distance=g.d,P}function T(t,e){return e.max-t.max}function C(t,e,i,r){this.x=t,this.y=e,this.h=i,this.d=function(t,e,i){for(var r=!1,n=1/0,o=0;o<i.length;o++)for(var s=i[o],a=0,h=s.length,l=h-1;a<h;l=a++){var u=s[a],p=s[l];u[1]>e!=p[1]>e&&t<(p[0]-u[0])*(e-u[1])/(p[1]-u[1])+u[0]&&(r=!r),n=Math.min(n,I(t,e,u,p))}return 0===n?0:(r?1:-1)*Math.sqrt(n)}(t,e,r),this.max=this.d+this.h*Math.SQRT2}function I(t,e,i,r){var n=i[0],o=i[1],s=r[0]-n,a=r[1]-o;if(0!==s||0!==a){var h=((t-n)*s+(e-o)*a)/(s*s+a*a);h>1?(n=r[0],o=r[1]):h>0&&(n+=s*h,o+=a*h)}return(s=t-n)*s+(a=e-o)*a}P.default=w;var S,O="undefined"!=typeof Float32Array?Float32Array:Array;function A(){var t=new O(6);return O!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}function M(){var t=new O(2);return O!=Float32Array&&(t[0]=0,t[1]=0),t}function L(t,e){var i=new O(2);return i[0]=t,i[1]=e,i}function N(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t}function R(t,e){return t[0]*e[0]+t[1]*e[1]}function D(t,e,i){var r=e[0],n=e[1];return t[0]=i[0]*r+i[2]*n+i[4],t[1]=i[1]*r+i[3]*n+i[5],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),M();var F=new Uint8Array(16);function k(){if(!S&&!(S="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return S(F)}var B=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function U(t){return"string"==typeof t&&B.test(t)}for(var z=[],X=0;X<256;++X)z.push((X+256).toString(16).substr(1));function j(t,e,i){var r=(t=t||{}).random||(t.rng||k)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){i=i||0;for(var n=0;n<16;++n)e[i+n]=r[n];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(z[t[e+0]]+z[t[e+1]]+z[t[e+2]]+z[t[e+3]]+"-"+z[t[e+4]]+z[t[e+5]]+"-"+z[t[e+6]]+z[t[e+7]]+"-"+z[t[e+8]]+z[t[e+9]]+"-"+z[t[e+10]]+z[t[e+11]]+z[t[e+12]]+z[t[e+13]]+z[t[e+14]]+z[t[e+15]]).toLowerCase();if(!U(i))throw TypeError("Stringified UUID is invalid");return i}(r)}function Y(){}Y.prototype={on:function(t,e,i){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var r=this;function n(){r.off(t,n),e.apply(i,arguments)}return n._=e,this.on(t,n,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),r=0,n=i.length;r<n;r++)i[r].fn.apply(i[r].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),r=i[t],n=[];if(r&&e)for(var o=0,s=r.length;o<s;o++)r[o].fn!==e&&r[o].fn._!==e&&n.push(r[o]);return n.length?i[t]=n:delete i[t],this}};var H=Y,G=Y;H.TinyEmitter=G;var W,V,q=x((function(t,e){var i=function(){var t={},e=Math.PI/180,i=180/Math.PI,r=6378137,n=20037508.342789244;function o(t){return Number(t)===t&&t%1!=0}function s(e){if(e=e||{},this.size=e.size||256,this.expansion=!0===e.antimeridian?2:1,!t[this.size]){var i=this.size,r=t[this.size]={};r.Bc=[],r.Cc=[],r.zc=[],r.Ac=[];for(var n=0;n<30;n++)r.Bc.push(i/360),r.Cc.push(i/(2*Math.PI)),r.zc.push(i/2),r.Ac.push(i),i*=2}this.Bc=t[this.size].Bc,this.Cc=t[this.size].Cc,this.zc=t[this.size].zc,this.Ac=t[this.size].Ac}return s.prototype.px=function(t,i){if(o(i)){var r=this.size*Math.pow(2,i),n=r/2,s=r/360,a=r/(2*Math.PI),h=r,l=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),u=n+t[0]*s,p=n+.5*Math.log((1+l)/(1-l))*-a;return u>h*this.expansion&&(u=h*this.expansion),p>h&&(p=h),[u,p]}n=this.zc[i],l=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),u=Math.round(n+t[0]*this.Bc[i]),p=Math.round(n+.5*Math.log((1+l)/(1-l))*-this.Cc[i]);return u>this.Ac[i]*this.expansion&&(u=this.Ac[i]*this.expansion),p>this.Ac[i]&&(p=this.Ac[i]),[u,p]},s.prototype.ll=function(t,e){if(o(e)){var r=this.size*Math.pow(2,e),n=r/360,s=r/(2*Math.PI),a=r/2,h=(t[1]-a)/-s;return[(t[0]-a)/n,i*(2*Math.atan(Math.exp(h))-.5*Math.PI)]}h=(t[1]-this.zc[e])/-this.Cc[e];return[(t[0]-this.zc[e])/this.Bc[e],i*(2*Math.atan(Math.exp(h))-.5*Math.PI)]},s.prototype.bbox=function(t,e,i,r,n){r&&(e=Math.pow(2,i)-1-e);var o=[t*this.size,(+e+1)*this.size],s=[(+t+1)*this.size,e*this.size],a=this.ll(o,i).concat(this.ll(s,i));return"900913"===n?this.convert(a,"900913"):a},s.prototype.xyz=function(t,e,i,r){"900913"===r&&(t=this.convert(t,"WGS84"));var n=[t[0],t[1]],o=[t[2],t[3]],s=this.px(n,e),a=this.px(o,e),h=[Math.floor(s[0]/this.size),Math.floor((a[0]-1)/this.size)],l=[Math.floor(a[1]/this.size),Math.floor((s[1]-1)/this.size)],u={minX:Math.min.apply(Math,h)<0?0:Math.min.apply(Math,h),minY:Math.min.apply(Math,l)<0?0:Math.min.apply(Math,l),maxX:Math.max.apply(Math,h),maxY:Math.max.apply(Math,l)};if(i){var p={minY:Math.pow(2,e)-1-u.maxY,maxY:Math.pow(2,e)-1-u.minY};u.minY=p.minY,u.maxY=p.maxY}return u},s.prototype.convert=function(t,e){return"900913"===e?this.forward(t.slice(0,2)).concat(this.forward(t.slice(2,4))):this.inverse(t.slice(0,2)).concat(this.inverse(t.slice(2,4)))},s.prototype.forward=function(t){var i=[r*t[0]*e,r*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return i[0]>n&&(i[0]=n),i[0]<-n&&(i[0]=-n),i[1]>n&&(i[1]=n),i[1]<-n&&(i[1]=-n),i},s.prototype.inverse=function(t){return[t[0]*i/r,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/r)))*i]},s}();t.exports=i}));function Z(t,e){var i;return i=e?st(e):{x:0,y:0,z:0},J(st(t),i)}function J(t,e){e||(e={x:0,y:0,z:0});var i=rt(e,t);return Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z)}function K(t,e){e||(e={x:0,z:0});var i=nt(e,t);return Math.sqrt(i.x*i.x+i.z*i.z)}function Q(t){var e=K(t);return{x:t.x/e,z:t.z/e}}function $(t,e){return t||(t={x:0,z:0}),ht(180*Math.atan2(-e.z+t.z,e.x-t.x)/Math.PI,2)}function tt(t,e,i,r){return{x:((r.x-i.x)*(e.x*t.z-t.x*e.z)-(e.x-t.x)*(r.x*i.z-i.x*r.z))/((r.z-i.z)*(e.x-t.x)-(e.z-t.z)*(r.x-i.x)),z:((t.z-e.z)*(r.x*i.z-i.x*r.z)-(i.z-r.z)*(e.x*t.z-t.x*e.z))/((r.z-i.z)*(e.x-t.x)-(e.z-t.z)*(r.x-i.x))}}function et(t,e,i,r=0){var n,o,s=nt(t,e),a=nt(t,i),h=nt(i,e),l=J((n=st(s),o=st(a),{x:n.y*o.z-n.z*o.y,y:n.z*o.x-n.x*o.z,z:n.x*o.y-n.y*o.x})),u=function(t,e){return t.x*e.x+t.z*e.z}(h,s);return ht(l,4)<=2*r&&u>=0&&K(s)<=K(h)}function it(t,e){return{x:t.x+e.x,y:t.y+e.y,z:t.z+e.z}}function rt(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}function nt(t,e){return{x:t.x-e.x,z:t.z-e.z}}function ot(t,e){return{x:t.x*e,z:t.z*e}}function st(t){return{x:t.x,y:(null==t?void 0:t.y)||0,z:t.z}}function at(t){return 2==t.length?{x:t[0],y:0,z:t[1]}:{x:t[0],y:t[1],z:t[2]}}function ht(t,e=0){var i=Math.pow(10,e);return Math.round(t*i)/i}function lt(t){var e=xt(t),i=v.Clipper.GetBounds(e);return{x:i.left,x2:i.right,z:i.top,z2:i.bottom,length:i.right-i.left,width:i.bottom-i.top}}function ut(t){if(!Array.isArray(t))throw new Error("Union failed, input not Array");if(!t.length||!t[0])throw new Error("Union failed, empty Array");var e=xt(t),i=[e[0]],r=e.slice(1),n=new v.Clipper;n.AddPaths(i,v.PolyType.ptSubject,!0),n.AddPaths(r,v.PolyType.ptClip,!0);var o=new v.Paths;return n.Execute(v.ClipType.ctUnion,o,v.PolyFillType.pftNonZero,v.PolyFillType.pftNonZero),bt(o)}function pt(t,e=.1,i,r){if(void 0===i&&(i=v.EndType.etClosedPolygon),!(t=r?t:mt(t)).length||!t[0].length)return[];e=e&&"number"==typeof e?e:.1;var n=xt(t),o=new v.ClipperOffset(2),s=new v.Paths;return o.AddPaths(n,v.JoinType.jtMiter,i),o.Execute(s,e),bt(s)}function ct(t,e,i,r){if(!Array.isArray(t))throw new Error("Difference failed, input not Array");if(!t.length||!t[0])throw new Error("Difference failed, empty Array");var n=xt(t),o=xt(i?pt(e,i):e),s=new v.Clipper;s.AddPaths(n,v.PolyType.ptSubject,!r),s.AddPaths(o,v.PolyType.ptClip,!0);var a=r?new v.PolyTree:new v.Paths;return s.Execute(v.ClipType.ctDifference,a,v.PolyFillType.pftNonZero,v.PolyFillType.pftNonZero),bt(r?v.Clipper.PolyTreeToPaths(a):a)}function dt(t=[],e=[],i=!1){if(!Array.isArray(t))throw new Error("Intersection failed, input not Array");if(!t.length||!t[0])throw new Error("Intersection failed, empty Array");var r=xt(t),n=e.length&&xt(e),o=n?r:[r[0]],s=n||r.slice(1),a=new v.Clipper;a.AddPaths(o,v.PolyType.ptSubject,!i),a.AddPaths(s,v.PolyType.ptClip,!0);var h=v.PolyFillType.pftNonZero,l=v.PolyFillType.pftNonZero,u=v.ClipType.ctIntersection,p=i?new v.PolyTree:new v.Paths;return a.Execute(u,p,h,l),bt(i?v.Clipper.PolyTreeToPaths(p):p)}function ft(t,e,i=[]){var r=new v.FPoint(t[0],t[1]),n=xt([e])[0],o=v.Clipper.PointInPolygon(r,n);return i.forEach((e=>{var i=ft(t,e);1===i?o=0:-1===i&&(o=-1)})),o}function vt(t,e,i=[]){var r=new v.FPoint(t[0],t[1]),n=e[0],o=v.Clipper.PointInPolygon(r,n);return i.forEach((e=>{var i=ft(t,e);1===i?o=0:-1===i&&(o=-1)})),o}function yt(t){var e=xt([t]);return v.JS.AreaOfPolygon(e[0])}function gt(t){return Math.abs(yt(t))}function mt(t,e=.01){var i=xt(t);return bt(v.Clipper.CleanPolygons(i,e))}function _t(t,e=.01){return mt([t],e)[0]}function xt(t=[]){for(var e=[],i=0;i<t.length;i++){var r=t[i]||[];e[i]=[];for(var n=0;n<r.length;n++){var o=r[n];Number.isFinite(o[0])&&Number.isFinite(o[1])?e[i][n]={X:o[0],Y:o[1]}:console.warn("invalid number",o[0],o[1])}}var s=[];for(var a of e){!a.length?console.warn("empty polygon"):s.push(a)}if(!s.length)throw new Error("empty polygon invalid input");return s}function bt(t){for(var e=[],i=0;i<t.length;i++){var r=t[i]||[];e[i]=[];for(var n=0;n<r.length;n++){var o=r[n];e[i][n]=[o.X,o.Y]}}return e}function Pt(t,e,i=1e-4){return![t[0]-e[0],t[1]-e[1]].some((t=>Math.abs(t)>i))}function wt(t,e,i){if(t.length!=e.length)return!1;var r=!0;if(t.forEach(((t,i)=>{t.length!=e[i].length&&(r=!1)})),!r)return!1;for(var n=!0,o=function(r){var o=Pt(t[r][0],e[r][0]),s=0;return o||(s=e[r].findIndex((e=>Pt(t[r][0],e)))),s<0?(n=!1,"break"):t[r].every(((t,n)=>{var o=n+s<=e[r].length-1?n+s:n+s-e[r].length;return Pt(t,e[r][o],i)}))?void 0:(n=!1,"break")},s=0;s<t.length;s++){if("break"===o(s))break}return n}function Et(t,e=!0){for(var i=0,r=e?t.length:t.length-1,n=0;n<r;n++){i+=K({x:t[n][0],z:t[n][1]},{x:t[n<t.length-1?n+1:0][0],z:t[n<t.length-1?n+1:0][1]})}return i}function Tt(t,e){var i,r,n=Ct(t[0],t[1]);if(0==n)return[];for(var o=[(t[1][0]-t[0][0])/n,(t[1][1]-t[0][1])/n],s=[-o[1],o[0]],a=[],h=0;h<e.length;h++){if(0!=Ct(i=e[h],r=e[(h+1)%e.length])){var l=[r[0]-i[0],r[1]-i[1]];if(Math.abs(At(s,i)-At(s,t[0]))<=.01&&Math.abs(At(s,r)-At(s,t[0]))<=.01)if(Mt(l,o)){var u=At(l,i)>At(l,t[0])?i:t[0],p=At(l,r)<At(l,t[1])?r:t[1];if(At(l,u)<At(l,p)){var c=u==i?0:Ct(i,u);a.push({l:Ct(u,p),pos:c,start:u,end:p,edgeIdx:h})}}else if(Mt(l,[-o[0],-o[1]])){var d=At(l,i)>At(l,t[1])?i:t[1],f=At(l,r)<At(l,t[0])?r:t[0];if(At(l,d)<At(l,f)){var v=d==i?0:Ct(i,d);a.push({l:Ct(d,f),pos:v,start:d,end:f,edgeIdx:h})}}}}return a}function Ct(t,e){var i=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(i*i+r*r)}function It(t){var{min:e,max:i}=function(t){var e=[1/0,1/0],i=[-1/0,-1/0];return t.forEach((t=>{t[0]<e[0]&&(e[0]=t[0]),t[1]<e[1]&&(e[1]=t[1]),t[0]>i[0]&&(i[0]=t[0]),t[1]>i[1]&&(i[1]=t[1])})),{min:e,max:i}}(t);return[e[0]+(i[0]-e[0])/2,e[1]+(i[1]-e[1])/2]}function St(t,e){e=e||It(t);var i=t.map((t=>[t[0]-e[0],t[1]-e[1]]));return{center:e,polygon:i}}function Ot(t=[]){var e=[...t];return Pt(e[0],e[e.length-1])||e.push(e[0]),e}function At(t,e){return t[0]*e[0]+t[1]*e[1]}function Mt(t,e,i=.01){var r=Math.atan2(t[1],t[0]),n=Math.atan2(e[1],e[0]),o=Math.abs(r-n);return o<=i||o>=2*Math.PI-i}function Lt(t,e=[]){return gt(t)<.1?It(t):P([t,...e],.1)}function Nt(t,e,i=!1){var r=0,n=e.x,o=e.z;if(e.controlLine&&e.w&&(r="front"===e.controlLine?e.w:"center"===e.controlLine?e.w/2:0),r){var s=e.ry/180*Math.PI;n-=r*Math.sin(s),o-=r*Math.cos(s)}var a,h,l=t.ry||0,u=e.ry||0,p=L(t.x,t.z),c=L(n,o),d=-u*Math.PI/180,f=A(),v=M();h=c,(a=f)[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=h[0],a[5]=h[1],function(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],h=e[5],l=Math.sin(i),u=Math.cos(i);t[0]=r*u+o*l,t[1]=n*u+s*l,t[2]=r*-l+o*u,t[3]=n*-l+s*u,t[4]=a,t[5]=h}(f,f,d),D(v,p,f);var y={x:v[0],z:v[1],y:t.y+e.y||0,ry:l+u};return i?Object.assign(t,y):Object.assign({},t,y)}function Rt(t,e,i=!1){var r=0,n=e.x,o=e.z;if(e.controlLine&&e.w&&(r="front"===e.controlLine?e.w:"center"===e.controlLine?e.w/2:0),r){var s=e.ry/180*Math.PI;n-=r*Math.sin(s),o-=r*Math.cos(s)}var a=t.ry||0,h=e.ry||0,l=L(t.x,t.z),u=L(n,o),p=h*Math.PI/180,c=A(),d=M(),f=M();!function(t,e){t[0]=-e[0],t[1]=-e[1]}(f,u),function(t,e){var i=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=i,t[2]=-i,t[3]=r,t[4]=0,t[5]=0}(c,p),function(t,e,i){var r=e[0],n=e[1],o=e[2],s=e[3],a=e[4],h=e[5],l=i[0],u=i[1];t[0]=r,t[1]=n,t[2]=o,t[3]=s,t[4]=r*l+o*u+a,t[5]=n*l+s*u+h}(c,c,f),D(d,l,c);var v={x:d[0],z:d[1],y:t.y-e.y||0,ry:a-h};return i?Object.assign(t,v):Object.assign({},t,v)}function Dt(t){if("object"!=typeof t)throw new Error("Get el data, invalid type");var i,r,n,o,s,a,h,l,u,p,c,d,{x:f,z:v,l:y,ry:g}=e({},t),m="a:helper:spaceDivider"===t.type;if(!m&&!Number.isFinite(t.w)||!Number.isFinite(y)||!Number.isFinite(f)||!Number.isFinite(v)){var _={type:t.type,id:t.id,x:f,z:v,l:y,ry:g,w:t.w};throw new Error("Get el vectors, params missing ".concat(JSON.stringify(_)))}return i=g/180*Math.PI,r=t.barCounter?t.w+.25:t.w,m&&(r=0),s={x:r*Math.sin(i),z:r*Math.cos(i)},a=m?s:Q(s),l=Q(h={x:y*Math.cos(i),z:-y*Math.sin(i)}),n=t.barCounter?f+-.25*a.x:f,o=t.barCounter?v+-.25*a.z:v,d=0,"front"===t.controlLine?d=-t.w:"center"===t.controlLine&&(d=-t.w/2),{l1:c={x:n,z:o},l2:{x:n+h.x,z:o+h.z},p1:u={x:c.x+a.x*d,z:c.z+a.z*d},p2:p={x:u.x+h.x,z:u.z+h.z},p3:{x:u.x+s.x,z:u.z+s.z},p4:{x:p.x+s.x,z:p.z+s.z},w:s,l:h,nW:a,nL:l}}function Ft(t){var e,i;return"column"===t.type?i=function(t){if("column"===t.type){var e=[];if("square"===t.shape){var i=t.l/2;e=kt(t,e=[[-i,-i],[i,-i],[i,i],[-i,i]])}else if("circle"===t.shape)for(var r=2*Math.PI/25,n=0,o=t.l/2,s=0;s<25;s++)e.push([t.x-o*Math.cos(n),t.z+o*Math.sin(n)]),n+=r;else"polygon"===t.shape&&(e=kt(t,t.polygon));return e}}(t):(e=Dt(t),i=("a:helper:spaceDivider"===t.type?[e.l1,e.l2]:[e.p1,e.p2,e.p4,e.p3]).map((t=>[t.x,t.z]))),i}function kt(t,e){return e.map((e=>{var i=Nt({x:e[0],z:e[1]},t);return[i.x,i.z]}))}(V=W||(W={}))[V.etOpenSquare=0]="etOpenSquare",V[V.etOpenRound=1]="etOpenRound",V[V.etOpenButt=2]="etOpenButt",V[V.etClosedLine=3]="etClosedLine",V[V.etClosedPolygon=4]="etClosedPolygon";var Bt=(t,e={})=>{var i={},r=e.keepTransient;return Object.keys(t).forEach((e=>{var n="_"===e.slice(0,1);"_ryOrg"!==e?n&&!r||null!==t[e]&&void 0!==t[e]&&"children"!==e&&(i[e]=t[e]):i.ry=t[e]})),t.children?i.children=t.children.map((t=>Bt(t,e))):i.children=[],i};function Ut(t,e){var i=Rt(t,e);return t.parent.removeChild(t),e.addChild(Bt(i),{setDefaults:!1})}function zt(t){return t.children.slice().forEach((t=>{"group"===t.type&&(zt(t),Xt(t))})),t}function Xt(t){for(var e=t.parent,i=[],r=t.children.length-1;r>=0;r--){var n=t.children[r],o=Bt(Nt(n,t));t.removeChild(n);var s=e.addChild(o,{setDefaults:!1});i.push(s)}return e.removeChild(t),i}function jt(t,e){for(var i=[],r=t.map(gt),n=0;n<t.length;n++)for(var o=t[n],s=0;s<e.length;s++){if(ft(e[s][0],o))if(i[s])r[i[s]]>r[n]&&(i[s]=n);else i[s]=n}var a=[];return i.forEach(((t,i)=>{a[t]||(a[t]=[]),a[t].push(e[i])})),a}function Yt(t){return{counterClockwise:t.filter((t=>yt(t)>0)),clockwise:t.filter((t=>yt(t)<0))}}function Ht(t){var e=[...t];return yt(e)<0?e:e.reverse()}function Gt(t){var e=[...t];return yt(e)>0?e:e.reverse()}function Wt({uuid:t,scene:e,node:i}){if(!(i=i||e.nodesById[t]))return[];var r=i.getWorldPosition();if(!r.polygon||!r.polygon.length)throw new Error("Invalid space"+JSON.stringify(r,null,2));var n=Gt(r.polygon);if(!(n=_t(n))||!n.length)return console.warn("Space",i.id,"is too small and will be ignored, area:",Math.round(1e3*yt(i.polygon))/1e3),[];var o=r.polygonHoles||[];return o=(o=o.map((t=>_t(Ht(t)))).filter((t=>t.length))).filter((t=>t.length)),[kt(r,n),...o.map((t=>kt(r,t)))]}function Vt({uuid:t,polygons:e,scene:i,structureEls:r,openingsOnly:n=!1}){var o;if(0==(o=(null==e?void 0:e.length)?e:Wt({uuid:t,scene:i})).length)return console.warn("Space node not found or polygon too small"),{openings:[],walls:{polylines:[],length:0},gaps:{polylines:[],length:0},polygons:[]};var{openings:s,walls:a}=r||qt(i),h=n?{wallPolylines:[],wallLength:0,gapPolylines:[],gapLength:0}:function(t=[],e=[]){var i=.005;if(!t.length||!e.length||!e[0].length)return console.warn("no polyline or wall to match"),{wallPolylines:[],wallLength:0,gapPolylines:[],gapLength:0};var r=t.map((t=>t.contour)).filter((t=>null==t?void 0:t.length)),n=[Ot(e[0]),...e.slice(1).map(Ot)],o=r.map((t=>pt([t],i)[0])),s=dt(n,o,!0),a=ct(n,o,0,!0),h={wallPolylines:[],wallLength:0,gapPolylines:[],gapLength:0};for(var l of s){var u=Et(l,!1);!u||u<.1||(h.wallPolylines.push(l),h.wallLength+=u)}for(var p of a){var c=Et(p,!1);!c||c<.1||(h.gapPolylines.push(p),h.gapLength+=c)}return h}(a,o),l=s.filter((t=>{for(var e=0;e<o.length;e++){var i=o[e],r=Zt(t,i);if(r){for(var n of(t.line=r,t.segments=Tt(r,i),t.segments))n.edgeIdx=[e,n.edgeIdx];return!0}}return!1}));return{openings:l,walls:{polylines:h.wallPolylines,length:h.wallLength},gaps:{polylines:h.gapPolylines,length:h.gapLength},polygons:o}}function qt(t){var e=t.nodesByType.window,i=t.nodesByType.door,r=e.concat(i).filter((t=>{var e=t.parent;return"wall"!==e.type&&console.log(t.type,"not in wall",t.id),"wall"===e.type})),n=t.nodesByType.column.map((t=>t.getWorldPosition())),o=t.nodesByType.wall.map((t=>t.getWorldPosition())),s=t.nodesByType["a:helper:spaceDivider"].map((t=>t.getWorldPosition())),a=(o=o.filter((t=>((t.l<=0||t.w<=0)&&console.warn("invalid wall"),t.l>0&&t.w>0)))).map((t=>({node:t,contour:Ft(t)}))),h=n.map((t=>({node:t,contour:Ft(t)}))),l=s.map((t=>({node:t,contour:Ft(t)})));return{openings:r.map((t=>{var e=t.parent,i=t.getWorldPosition();return i.w=e.w,{node:i,contour:Ft(i)}})),walls:a,dividers:l,columns:h}}function Zt(t,e){var i,r=Gt(e),n=t.contour,o=[[n[0][0]+(n[3][0]-n[0][0])/2,n[0][1]+(n[3][1]-n[0][1])/2],[n[1][0]+(n[2][0]-n[1][0])/2,n[1][1]+(n[2][1]-n[1][1])/2]],s=[o[0][0]+(o[1][0]-o[0][0])/2,o[0][1]+(o[1][1]-o[0][1])/2],a=[o[1][0]-o[0][0],o[1][1]-o[0][1]],h=(i=a,Math.sqrt(i[0]*i[0]+i[1]*i[1])),l=[-a[1]/h,a[0]/h],u=t.node.w,p=[[s[0]-l[0]*u,s[1]-l[1]*u],[s[0]+l[0]*u,s[1]+l[1]*u],s],c=[];for(var d of r)c.push({x:d[0],z:d[1]});var f=[];for(var v of n)f.push({x:v[0],z:v[1]});var y=[];for(var g of p)y.push(vt(g,xt([r])));return y[0]===y[1]?function(t,e){for(var i of e)if(et(i,t[0],t[1],.001))return[[t[0].x,t[0].z],[t[1].x,t[1].z]];for(var r of e)if(et(r,t[2],t[3],.001))return[[t[2].x,t[2].z],[t[3].x,t[3].z]];return!1}(f,c):y[0]?y[2]?[n[2],n[3]]:[n[0],n[1]]:y[2]?[n[0],n[1]]:[n[2],n[3]]}function Jt({scene:t,spaces:e}){var i=t.nodesByType.polyfloor,{walls:r,openings:n,dividers:o,columns:s}=qt(t),a=i.map((i=>{var a=function(t,e){var i={},r=[e.polygon,...e.polygonHoles||[]],n=e.getWorldPosition();return r.forEach(((e,r)=>{e.forEach(((o,s)=>{var a=s<e.length-1?s+1:0,h=[o,e[a]],l=kt(n,h),u=r+"-"+s;i[u]={},t.forEach((t=>{var e=Tt([l[0],l[1]],t.contour);e[0]&&(i[u][t.node.id]=e[0].edgeIdx)}))}))})),i}([...r,...n,...o,...s],i),h={};return Object.entries(a).forEach((([e,i])=>{Object.entries(i).forEach((([i,r])=>{h[i]||(h[i]={node:t.nodesById[i],relation:"edge",edgeRelations:[]});var n=parseInt(e.split("-")[0]),o=parseInt(e.split("-")[1]);h[i].edgeRelations.push({edgeIndex:[n,o],nodeContourIndex:r})}))})),(null==e?void 0:e.find((t=>t.id===i.id))).interiors.forEach((e=>{h[e.id]={node:t.nodesById[e.id],relation:"contained"}})),{node:i,relationsById:h,relationsByEdgeIndex:a}}));return a}function Kt(t,e="",i=!1,r,n){var o,s,a={"a:helper:spaceDivider":["plan","level","group"],wall:["plan","level","group"],interior:["plan","level","interior","group","level"],window:["plan","level","wall"],door:["plan","level","wall"],polyfloor:["plan","level"],group:["plan","level","group"]},h=i?(o=Bt(t),JSON.parse(JSON.stringify(o))):t,l=[];if(i&&r&&(h=Nt(h,r)),n||h.type!==e){if(n&&h.id===n)return[h]}else l.push(h);var u=0;if(h.children&&(!a[e]||a[e].includes(h.type)))for(var p=0;p<h.children.length;p++){var c=h.children[p];"level"===c.type&&u++,u>1||(s=Kt(c,e,i,h,n),l=l.concat(s))}return l}function Qt(t,e){return Kt(t,e,!0)}var $t={"a:helper:spaceDivider":[],"a:reference:externalId":[],"a:relation:wall":[],"a:settings:display":[],"a:settings:generatedGroup":[],box:[],"camera-bookmark":[],closet:[],column:[],curtain:[],door:[],floor:[],floorplan:[],group:[],interior:[],kitchen:[],level:[],marker:[],object:[],plan:[],polybox:[],polyfloor:[],railing:[],roomStamp:[],stairs:[],tag:[],wall:[],window:[]},te=Object.keys($t);function ee(t,e={}){var i=ie(t,{});return ne(t,null,null,i),e.exportIdMap&&(t.idMap=i),t}function ie(t,e){return void 0!==t.id&&(e[t.id]=j()),t.children.forEach((t=>ie(t,e))),e}var re=t=>"[object Object]"===Object.prototype.toString.call(t);function ne(t,e,i,r){var n;"string"==typeof t?(void 0!==e&&void 0!==i&&r[t]&&(e[i]=r[t]),"string"==typeof i&&void 0!==e&&void 0!==i&&r[i]&&(e[r[i]]=t,delete e[i])):(re(t)||(n=t,"[object Array]"===Object.prototype.toString.call(n)))&&(re(t)&&t.type&&void 0===t.id&&(t.id=j()),Object.entries(t).forEach((([e,i])=>ne(i,t,e,r))))}var oe={colorDiffuse:{type:"array"},colorSpecular:{type:"array"},wireframeColor:{type:"array"},size:{type:"array"},specularCoef:{type:"number"},opacity:{type:"number"},wireframeOpacity:{type:"number"},wireframeThickness:{type:"number"},wireframeThresholdAngle:{type:"number"},lightEmissionCoef:{type:"number"},bsdfType:{type:"string"},wrap:{type:"string"},receiveRealTimeShadows:{type:"boolean"},hideAfterBaking:{type:"boolean"},castRealTimeShadows:{type:"boolean"},no2dOutline:{type:"boolean"},mapDiffuse:{type:"string"},mapDiffusePreview:{type:"string"},mapDiffuseSource:{type:"string"},mapDiffuseKey:{type:"string"},mapSpecular:{type:"string"},mapSpecularPreview:{type:"string"},mapSpecularSource:{type:"string"},mapSpecularKey:{type:"string"},mapNormal:{type:"string"},mapNormalPreview:{type:"string"},mapNormalSource:{type:"string"},mapNormalKey:{type:"string"},mapAlpha:{type:"string"},mapAlphaPreview:{type:"string"},mapAlphaSource:{type:"string"},mapAlphaKey:{type:"string"}},se=t=>{var e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"number"!==e||Number.isFinite(t)?e:"undefined"},ae={group:"a:settings:generatedGroup"},he={properties:{x:{type:"number"},y:{type:"number"},z:{type:"number"},ry:{type:"number"},id:{type:"string"}}};class le{constructor({node:t,parent:e,scene:i,emitter:r,options:n={}}){var o;if("object"!=typeof t)throw new Error("node has to be type object: "+t);if(!t.type)throw new Error("node invalid, type is missing: "+JSON.stringify(t));void 0===n.setDefaults&&(n.setDefaults=!1),void 0===n.regenerateIds&&(n.regenerateIds=!1),this._scene=i,this._emitter=r;var s=t.children||[];t.children=[],!t.id||n.setDefaults||n.regenerateIds?this._update(fe(t,this.schema,n)):this._update(t),this._parent=e,e&&e.children.push(this),(null==(o=this._scene)?void 0:o.registerNode)&&this._scene.registerNode(this);var a="add-child";this._emitter&&this._emitter.emit(a,{node:e,args:this,options:n,event:a}),s.filter((t=>(t.type||console.warn("Prevent import from scene structure: Invalid type",t.type+""),t.type))).forEach((t=>this.addChild(t,n)))}get parent(){return this._parent}get scene(){return this._scene}get schema(){var t;return null==(t=this._scene)?void 0:t.schema}_update(t={}){var e,i,r=null==(i=null==(e=this._scene)?void 0:e.schema)?void 0:i[this.type],{properties:n}=r||he;for(var o in t){var s=null==n?void 0:n[o];if(!r||s||"_"===o[0]){var{minimum:a,maximum:h,type:l,enum:u}=s||{};if("number"===l){if("string"==typeof t[o]&&(t[o]=Number(t[o]),console.log(this.type+"."+o,"converted from string to number")),!Number.isFinite(t[o]))throw new Error("".concat(this.type,".").concat(o," = ").concat(t[o]," is invalid"));var p=Number.isFinite(a)&&t[o]<a,c=Number.isFinite(h)&&t[o]>h;if(p||c){var d=p?"min:"+a:"max:"+h;throw new Error("".concat(this.type,".").concat(o," = ").concat(t[o]," is out of range ").concat(d))}}if("string"===l){if("string"!=typeof t[o])throw new Error("".concat(this.type,".").concat(o," = '").concat(t[o],"' is invalid"));if(u&&!u.includes(t[o]))throw new Error("".concat(this.type,".").concat(o," = '").concat(t[o],"' is invalid"))}("_isSelected"!==o||t[o])&&("_highlight"!==o||t[o])?this[o]=t[o]:delete this[o]}else delete t[o]}}set(t={},e={}){if(this.locked&&!e.force){var i=[];for(var r in t)switch(r){case"locked":case"_highlight":case"_isSelected":i.push(r)}if(!(i.length>0))return void console.log("Node ID ".concat(this.id," is locked and cannot be altered."));var n={};for(var o of i)n[o]=t[o];t=n}t.id&&delete t.id,t.src&&delete t.src,t.children&&delete t.children;var s={};for(var a in t)s[a]=this[a];try{this._update(t)}catch(t){return void console.warn(t.message)}if(this._emitter){var h=0,l=0;for(var u in t)switch(t[u]===s[u]&&(delete t[u],delete s[u]),h++,u){case"x":case"y":case"z":case"ry":l++}var p=l===h?"set-transform":"set";Object.keys(t).length&&this._emitter.emit(p,{node:this,args:t,prevState:s,options:e,event:p})}}setTransform({x:t,y:e,z:i,ry:r}={},n={}){if(!this.locked||n.force){var o={},s={};if(void 0!==t){var a=Number(t);this.x!==a&&Number.isFinite(a)&&(s.x=this.x,o.x=this.x=a)}if(void 0!==e){var h=Number(e);this.y!==h&&Number.isFinite(h)&&(s.y=this.y,o.y=this.y=h)}if(void 0!==i){var l=Number(i);this.z!==l&&Number.isFinite(l)&&(s.z=this.z,o.z=this.z=l)}if(void 0!==r){var u=Number(r);this.ry!==u&&Number.isFinite(u)&&(s.ry=this.ry,o.ry=this.ry=u)}var p="set-transform";this._emitter&&Object.keys(o).length&&this._emitter.emit(p,{node:this,args:o,prevState:s,options:n,event:p})}else console.log("Node ID ".concat(this.id," is locked and cannot be altered."))}setMaterials(t={},i={}){var r=this;if(!this.locked||i.force){var n=Object.keys(oe),o={},s=0,a={},h=function(e){var i=t[e],h=se(i),l="string"===h,u="object"===h&&Object.keys(i).every((t=>{var e,r=n.includes(t),o=r&&se(i[t])===(null==(e=oe[t])?void 0:e.type);return r&&o}));(l||u)&&(a[e]=r[e],o[e]=t[e],s++)};for(var l in t)h(l);if(s<1)console.log("no valid material definitions in",t);else{var u=e(e({},this.materials||{}),t);try{this._update({materials:u})}catch(t){return void console.warn(t.message)}var p="set-materials";this._emitter&&this._emitter.emit(p,{node:this,args:t,prevState:a,options:i,event:p})}}else console.log("Node ID ".concat(this.id," is locked and cannot set materials."))}setTransient(t={},i={}){var r={},n=0,o={};for(var s in t)"_"===s[0]&&(o[s]=this[s],r[s]=t[s],n++);if(n<1)console.log("no transient values in",t,"use underscore");else{try{this._update(e({},r))}catch(t){return void console.warn(t.message)}var a="set-transient";this._emitter&&this._emitter.emit(a,{node:this,args:t,prevState:o,options:i,event:a})}}setHighlight(t={},i={}){var r,n={_highlight:this._highlight},{fill:o,fillOpacity:s,outline:a,outlineWidth:h}=t;o&&Array.isArray(o)&&(r={fill:o,fillOpacity:s}),a&&Array.isArray(a)&&(r=e(e({},r||{}),{},{outline:a,outlineWidth:h}));var l={_highlight:r};try{this._update(l)}catch(t){return void console.warn(t.message)}var u="set-transient";this._emitter&&this._emitter.emit(u,{node:this,args:l,prevState:n,options:i,event:u})}find(t={}){return t.id||t.type&&"string"==typeof t.type&&te.includes(t.type)?(this.traverse((i=>{e||(t.id&&i.id===t.id||t.type&&i.type===t.type)&&(e=i)})),e):(console.warn("type missing or invalid"),null);var e}findAll(t={}){if(!t.type||"string"!=typeof t.type||!te.includes(t.type))return console.warn("type missing or invalid"),[];var e=[];return this.traverse((i=>i.type===t.type&&e.push(i))),e}addChild(t,e={}){var i,r;if(t.type&&"string"==typeof t.type&&te.includes(t.type))if(!this.locked||["level","plan"].includes(this.type)||e.force){if(!t.id||!(null==(r=null==(i=this.scene)?void 0:i.nodesById)?void 0:r[t.id])||e.regenerateIds)return void 0===e.setDefaults&&(e.setDefaults=!0),new le({node:t,parent:this,scene:this._scene,emitter:this._emitter,options:e});console.warn("Node with id ".concat(t.id," already exists and can not be added - use options.regenerateIds = true"))}else console.log("Node ID ".concat(this.id," is locked and cannot add children."));else console.warn("type missing or invalid")}removeChild(t,e={}){var i;if(t.id)if(!this.locked||["level","plan"].includes(this.type)||e.force){for(var r,n=0;n<this.children.length;n++)if(this.children[n].id===t.id){r=n;break}if(Number.isFinite(r)){for(var o=t.children||[],s=o.length-1;s>=0;s--)t instanceof le&&o[s]&&t.removeChild(o[s],e);(null==(i=this._scene)?void 0:i.unregisterNode)&&this._scene.unregisterNode(t),this.children.splice(r,1);var a="remove-child";this._emitter&&this._emitter.emit(a,{node:this,args:t,options:e,event:a}),((null==t?void 0:t.getReferringNodes)?t.getReferringNodes():[]).forEach((t=>t.remove(e)))}else console.warn("Node does not exist or is already removed",t)}else console.log("Node ID ".concat(this.id," is locked and cannot remove children."));else console.error("not valid")}remove(t){!this.locked||t.force?this.parent.removeChild(this,t):console.warn("Node ID ".concat(this.id," is locked and cannot be removed."))}getReferringNodes(){var t,e,i=[],r=null==(t=this._scene)?void 0:t.nodesByType["a:relation:"+this.type];r&&r.forEach((t=>{var e;(null==(e=null==t?void 0:t.nodeIds)?void 0:e.hasOwnProperty(this.id))&&i.push(t)}));var n=ae[this.type]||"a:settings:"+this.type,o=null==(e=this._scene)?void 0:e.nodesByType[n];return o&&o.forEach((t=>{(null==t?void 0:t.nodeId)==this.id&&i.push(t)})),i}getWorldPosition(){return ce(this)}getLocalPositionFromWorld(t){var e=this.getParents();return(null==e?void 0:e.length)&&e.reverse().forEach((e=>{t=Rt(t,e)})),t}getParents(){return de(this)}toJson(t={}){var e=Bt(this,t),i=JSON.parse(JSON.stringify(e));return t.regenerateIds&&ee(i,t),i}traverse(t){"function"==typeof t&&(t(this),this.children.forEach((e=>{e.traverse(t)})))}}var ue,pe,ce=(t,e)=>{var i=e?e.parent:t.parent;if(!i)return console.warn("no parent found"),t;var r=Nt(t,i);return i.parent&&(r=ce(r,i)),r},de=t=>{var e=[],i=t.parent;return i&&e.push(i),(null==i?void 0:i.parent)&&(e=e.concat(de(i))),e},fe=(t,e,{setDefaults:i,regenerateIds:r})=>{if(!e&&i)throw new Error("schema is missing");if(!t)throw new Error("node missing");var n,o=e&&e[t.type];if(o&&i){if(n=((t,e)=>{if(e&&e.properties){var i={};return Object.keys(e.properties).forEach((t=>{var r=e.properties[t],n=r.const||r.default;void 0!==n&&(i[t]=n)})),"interior"!==t||i.src||(i.src="!7dddc882-1def-4497-80e3-d1de834a1a7b"),JSON.parse(JSON.stringify(i))}console.warn("schema is missing for type ".concat(t))})(t.type,o),!n)throw new Error("no defaults found")}else n={};var s=Object.assign(n,t);if(!s)throw new Error("applying defaults failed");return t.id&&!r||(s.id=j()),s};(pe=ue||(ue={})).residential="residential",pe.office="office";var ve={work:{name:"Work",isHidden:!0,description:"space for individual head-down work",spaceUsage:{privateOffice:{name:"Private office",category:[ue.office]},openWorkspace:{name:"Open workspace",category:[ue.office]},enclosedWorkspace:{name:"Enclosed workspace",category:[ue.office]},closedWorkspace:{name:"Closed workspace",isDeprecated:!0,category:[ue.office]},executiveOffice:{name:"Executive office",isDeprecated:!0,category:[ue.office]}}},meet:{name:"Meet",isHidden:!0,spaceUsage:{meetingRoom:{name:"Meeting room",category:[ue.office]},hub:{name:"Hub",category:[ue.office]},assembly:{name:"Assembly",category:[ue.office]},boardRoom:{name:"Board Room",category:[ue.office]},trainingRoom:{name:"Training Room",category:[ue.office]},collaboration:{name:"Collaboration",isDeprecated:!0,category:[ue.office]}}},live:{name:"live",isHidden:!0,spaceUsage:{living:{name:"Living",category:[ue.residential]},dining:{name:"Dining",category:[ue.residential]},dining_living:{name:"Living & Dining",category:[ue.residential]},homeOffice:{name:"Home office",category:[ue.residential]},bedroom:{name:"Bedroom",category:[ue.residential]}}},socialize:{name:"Socialize",isHidden:!0,spaceUsage:{lobby:{name:"Lobby",category:[ue.office,ue.residential]},reception:{name:"Reception",category:[ue.office]},lounge:{name:"Lounge",category:[ue.office]},cafe:{name:"Cafe",category:[ue.office]},canteen:{name:"Canteen",category:[ue.office]},pantry:{name:"Pantry",category:[ue.office]},terrace:{name:"Terrace",isOutdoor:!0,category:[ue.office,ue.residential]},balcony:{name:"Balcony",isOutdoor:!0,category:[ue.office,ue.residential]},rooftop:{name:"Rooftop",isOutdoor:!0,category:[ue.office,ue.residential]},courtyard:{name:"Courtyard",isOutdoor:!0,category:[ue.office,ue.residential]},garden:{name:"Garden",isOutdoor:!0,category:[ue.residential]},common:{name:"Common",isDeprecated:!0,category:[ue.office]}}},support:{name:"Support",isHidden:!0,spaceUsage:{printStation:{name:"Print station",category:[ue.office]},storage:{name:"Storage",category:[ue.residential,ue.office]},mailRoom:{name:"Mail room",category:[ue.office]},operationalRoom:{name:"Operational room",category:[ue.office]},serviceRoom:{name:"Service room",category:[ue.office]},laundryRoom:{name:"Laundry room",category:[ue.residential]},operate:{name:"Operate",isDeprecated:!0,category:[ue.office]},services:{name:"Services",isDeprecated:!0,category:[ue.office,ue.residential]}}},care:{name:"Care",isHidden:!0,spaceUsage:{kitchen:{name:"Kitchen",category:[ue.residential]},wellnessRoom:{name:"Wellness room",category:[ue.office]},restroom:{name:"Restroom",category:[ue.office]},bathroom:{name:"Bathroom",category:[ue.residential]},shower:{name:"Shower",category:[ue.office,ue.residential]},toilet:{name:"Toilet",category:[ue.residential]}}},circulate:{name:"Circulate",isHidden:!0,spaceUsage:{corridor:{name:"Corridor",category:[ue.residential,ue.office]},staircase:{name:"Staircase",category:[ue.residential,ue.office]},elevator:{name:"Elevator",category:[ue.residential,ue.office]},foyer:{name:"Foyer",category:[ue.residential,ue.office]},garage:{name:"Garage",category:[ue.residential,ue.office]}}},void:{isHidden:!0,name:"Void",spaceUsage:{shaft:{name:"Shaft",category:[ue.residential,ue.office]},buildingOpening:{name:"Building opening",category:[ue.residential,ue.office]},floorOpening:{name:"Floor opening",category:[ue.residential,ue.office]}}},undefined:{isHidden:!0,spaceUsage:{undefined:{name:"",category:[ue.residential,ue.office],isHidden:!0}}}},ye={};Object.keys(ve).forEach((t=>{var i=ve[t];ye[t]={name:i.name,type:"program",category:[]},i.isHidden&&(ye[t].isHidden=i.isHidden);var r={};Object.keys(ve[t].spaceUsage).forEach((i=>{var n=ve[t].spaceUsage[i];ye[i]=e(e({},n),{},{type:"space",program:t}),n.category.forEach((t=>{r[t]=!0}))})),ye[t].category=Object.keys(r)}));var ge=(t="")=>{"officeWorking"===t?t="work":"officeMeeting"===t&&(t="meet");var e=ye[t];return e?e.name:""},me=(t="")=>{var e,i=ye[t];return i&&(e="program"===i.type?t:i.program),e};function _e({scene:t,uuid:e}){var i=t.nodesByType.polyfloor;e&&(i=i.filter((t=>t.id===e)));var r=t.nodesByType.interior.map((t=>t.getWorldPosition())),n=i.map((e=>{var i=Wt({node:e});if(i.length){var n=Math.abs(i.reduce(((t,e)=>t+yt(e)),0)),o=Lt(i[0],i.slice(1)),s=lt(i),{interiors:a}=function({uuid:t,polygons:e,scene:i,interiors:r}){var n,o=(n=e&&e.length?e:Wt({uuid:t,scene:i}))[0],s=n.slice(1);return o=pt([o],.05)[0],r||(r=i.nodesByType.interior.map((t=>t.getWorldPosition()))),{interiors:r.filter((t=>{if(t.src&&t.x&&t.z)return ft([t.x,t.z],o,s)}))}}({polygons:i,scene:t,interiors:r});return{node:e,boundingBox:s,id:e.id,usage:e.usage,usageName:ge(e.usage),program:me(e.usage),polygons:i,interiors:a,area:n,center:o,customId:e.customId,name:e.name}}}));return n.flatMap((t=>t?[t]:[]))}function xe(t){var e=.01,i=t.nodesByType.column.map((t=>t.getWorldPosition())),r=t.nodesByType.wall.map((t=>t.getWorldPosition())),n=t.nodesByType["a:helper:spaceDivider"].map((t=>t.getWorldPosition())).map(Ft);n=pt(n,e,0,!0);var o=[...r,...i].map((t=>{var i=Ft(t);if(i.length&&yt(i))return i=pt([i],e)[0]})).flatMap((t=>t?[t]:[])),s=o.length?ut([...o,...n]):[];s.length&&(s=mt(s).filter((t=>t.length)));var{clockwise:a,counterClockwise:h}=Yt(s);a.length&&(a=a.map((t=>{var i=pt([t],e);if(i.length)return(i=i.sort(((t,e)=>gt(t)>gt(e)?-1:1)))[0]})).flatMap((t=>t&&yt(t)>.1?[t]:[])).map(Gt));var l=h.sort(((t,e)=>gt(t)>gt(e)?-1:1)),u=l.length?l[0]:[];u.length&&(u=pt([u],-.01)[0]);var p=jt(a,h);return{spaces:a,holes:p=p.map((t=>t.length?t.map((t=>pt([t],-.01)[0])).filter((t=>t)).map(Ht):t)),outline:u}}class be{constructor({schema:t}={}){this.sceneId=null,this.node=null,this._apiVersion="2.2.0",this.nodesById={},this.nodesByType=JSON.parse(JSON.stringify($t)),this.nodesByName={},this._schema=t||{},this._emitter=new G}get emitter(){return this._emitter}get schema(){return this._schema}set schema(t){"object"==typeof t&&(this._schema=t)}loadSceneStructure(t,e={}){if(this._emitter.emit("scene-structure-loading",this),!t||"plan"!==t.type)throw new Error("invalid sceneStructure");this.nodesById={},this.nodesByType=JSON.parse(JSON.stringify($t)),this.node=null;var i=JSON.parse(JSON.stringify(t));return Number.isFinite(e.planRotation)&&(i._ryOrg=t.ry,i.ry=e.planRotation),this.node=new le({node:i,scene:this,emitter:this.emitter,options:e}),this.setSceneType(),this._emitter.emit("scene-structure-loaded",this),this.node}setSceneType(){var t=this.node.class;if(null==t?void 0:t.length)t.includes("residential")?this.type="residential":t.includes("commercial")&&(this.type="commercial");else{var e=this.nodesByType.polyfloor.map((t=>t.usage));e.includes("bedroom")?this.type="residential":(e.includes("work")||e.includes("meetingRoom")||e.includes("openWorkspace"))&&(this.type="commercial")}}getFloorArea(){var t=_e({scene:this}).reduce(((t,e)=>t+e.area),0);return Math.round(10*t)/10}registerNode(t){this.nodesById[t.id]&&console.error("Duplicate id",t.id),this.nodesById[t.id]=t,this.nodesByType[t.type]=this.nodesByType[t.type]||[],this.nodesByType[t.type].push(t),t.name&&(this.nodesByName[t.name]=this.nodesByName[t.name]||[],this.nodesByName[t.name].push(t))}unregisterNode(t){t.id&&delete this.nodesById[t.id];var e=(e,i)=>{if(e[t[i]]){var r=e[t[i]].findIndex((e=>e.id===t.id));Number.isFinite(r)&&e[t[i]].splice(r,1)}};e(this.nodesByType,"type"),e(this.nodesByName,"name")}on(t,e,i){t&&e?this._emitter.on(t,e,i):console.log("invalid event listener")}once(t,e,i){t&&e?this._emitter.once(t,e,i):console.log("invalid event listener")}off(t,e){t&&e?this._emitter.off(t,e):console.log("invalid request")}emit(t,e,i,r,n){this._emitter.emit(t,e,i,r,n)}get apiVersion(){return this._apiVersion}}function Pe(t,e){return{type:"line",start:t,end:e}}function we(t,e,i,r=!1){return{type:"rect",position:t,width:e,height:i,isContour:r}}function Ee(t,e){return{type:"circle",position:t,r:e}}new q({size:256});var Te=({points:t,oldRotation:i,newRotation:r,rootNode:n})=>t.map((t=>{var o={ry:0,x:t[0],z:t[1],y:0};return Rt(o,{x:n.x,y:n.y,z:n.z,ry:i},!0),[(o=Nt(o,e(e({},n),{},{ry:r}))).x,o.z]})),Ce=({gfx:t,points:e,state:i,doneDrawing:r=!1})=>{var n=[{type:"polygon",points:r?e:[...e,i.snapCursor.pos],isContour:!0,props:{fill:16777215,fillOpacity:1,isContour:!0,stroke:4605266,strokeWidth:.5,native:!0}}];t.draw({shapes:n})},Ie=(t,e)=>t.map(((i,r)=>{var n=t[r+1]||t[0];return((t,e)=>{var i=(t.x*e.x+t.y*e.y)/(Math.sqrt(t.x*t.x+t.y*t.y)*Math.sqrt(e.x*e.x+e.y*e.y));return(-.6981317007977321*i*i-.8726646259971648)*i+1.5707963267948966})({x:i[0]-e[0],y:i[1]-e[1]},{x:n[0]-e[0],y:n[1]-e[1]})})),Se={start:!0,end:!0,drag:!0},Oe={x:"number",z:"number",ry:"number"},Ae={box:Oe,closet:Se,column:Oe,curtain:Se,door:Se,floor:{x:"number",z:"number",l:"number"},floorplan:Oe,group:Oe,interior:Oe,object:Oe,kitchen:Se,polybox:e(e({},Oe),{},{polygon:!0}),polyfloor:{},railing:Se,stairs:Se,wall:Se,"a:helper:spaceDivider":Se,window:Se};function Me(t){var i,r,n,o;if(!this)throw new Error("Viewport context is missing");var s=this._dragStart||{},a=t.data.global||{},h=Math.abs(a.x-s.x),l=Math.abs(a.y-s.y);if(h<5&&l<5&&!this.isDragging){var u,p=(new Date).getTime();if(this.lastClick){var c=p-this.lastClick.time,d=this.lastClick.pos&&Math.max(Math.abs(a.x-this.lastClick.pos.x),Math.abs(a.y-this.lastClick.pos.y));u=c<400&&d<10}var f=null==t||null===(i=t.target)||void 0===i||null===(r=i._handlerType)||void 0===r?void 0:r.includes("polygon-point");this.lastClick={time:p,pos:e({},a)};var v=this._getState(),y=u?"dblclick":"click",g=null===(n=t.target)||void 0===n?void 0:n._nodeId,{x:m,y:_}=(null===(o=t.data)||void 0===o?void 0:o.global)||{},x=v.getPlanPosition([m,_]);v.cursor=[...x];var b={sourceEvent:t,nodeId:g,pos:x,isDoubleClick:!!u,polygonClick:f&&t.target._handlerType};if(null!=g&&g.length&&g.includes("marker_")){var P,w,E,T,C=g.replace("marker_",""),I=v.markerPins.find((t=>t.id===C)),S=null===(P=I.events)||void 0===P||null===(w=P.click)||void 0===w?void 0:w.callback,O=null===(E=I.events)||void 0===E||null===(T=E.click)||void 0===T?void 0:T.context;if(S)return void(O?S.bind(O)(b):S(b))}if(v._splitWallHelper)return v._splitWallHelper.split(),void v.setActive({nodeId:v.active[0].id});v.emit(y,b)}}function Le(t){var e=this._getState();"Viewport"===t.target.constructor.name&&e.setActive();var{x:i,y:r}=t.data.global;e.windowPos=[i,r],e.lastSceneClick=e.getPlanPosition(e.windowPos),e.rightClick=!0}function Ne({sourceEvent:t,nodeId:e,state:i,forceSelect:r=!1,activateGroup:n=!1,isDoubleClick:o,isMultiselect:s,polygonClick:a}={}){var h=(null==t?void 0:t.currentTarget)||i&&i._getViewport();i=i||h&&h._getState();var l=s||t&&t.data.originalEvent.shiftKey;if(i&&h&&i.settings.selectElements&&(!i.isDragging||i.altKey)&&h._getHandler&&!i.isMeasuring&&!i.isCreatingElement){if(i.rightClick)return i.emit("context-menu",{sourceEvent:t,nodeId:e}),void(i.rightClick=!1);var u=h._getHandler();if(o){var p,c,d=null===(p=i.active[0])||void 0===p?void 0:p.type;if(null!==(c=Ae[d])&&void 0!==c&&c.polygon){var{x:f,y:v}=t.data.global,y=i.getPlanPosition([f,v]);if(a)(({handler:t,index:e,state:i})=>{if(i.active[0].polygon.length<4)i.setMessage("A polygon requires at least 3 points");else if(!isNaN(e)){var r=i.active[0].polygon.slice();r.splice(e,1),i.active[0].set({polygon:r}),t._update({handler:t,state:i})}})({handler:u,index:Number(a.split("_")[1]),state:i});else(({handler:t,pos:e,state:i})=>{var r=i.active[0].getLocalPositionFromWorld({x:e[0],z:e[1]}),{x:n,z:o}=Rt(r,i.active[0]),s=Ie(i.active[0].polygon,[n,o]),a=s.indexOf(Math.max(...s)),h=i.active[0].polygon.slice();h.splice(a+1,0,[n,o]),i.active[0].set({polygon:h}),t._update({handler:t,state:i})})({handler:u,pos:y,state:i});return}n=!0}if(i.active.length&&i.active.forEach((t=>{i.scene.nodesById[t.id]&&t.setTransient({_isSelected:!1})})),e){l||(i.active=[]);var g=l&&i.active.findIndex((t=>t.id===e)),m=Number.isFinite(g)&&g>=0;m&&i.active.splice(g,1);var _=i.scene.nodesById[e],x=!!i.active.find((t=>"polyfloor"===t.type));if(i.active.length>0&&(x&&"polyfloor"!==_.type||!x&&"polyfloor"===_.type))return i.active.forEach((t=>t.setTransient({_isSelected:!0}))),void i.emit("select",{node:i.active[0]});if(!_)return;if(i.settings.selectAllowList.length&&!i.settings.selectAllowList.includes(_.type))return i.active=[],i.activeGroup=null,u.visible=!1,void i.emit("select",{});var b,P=_.getParents(),w=i.activeGroup&&P.some((t=>t.id===i.activeGroup));if(!r)for(var E of P){if("group"!==E.type||i.activeGroup===E.id)break;b=E}var T=!!b||"group"===_.type;if(i.activeGroup&&!w)return i.emit("draw-xray",{xrayMode:!1}),i.activeGroup=null,void(u.visible=!1);if(n&&T)return i.activeGroup&&i.emit("draw-xray",{xrayMode:!1}),i.activeGroup=b?b.id:e,i.emit("draw-xray",{xrayMode:!0}),u.visible=!1,i.active=[],void i.emit("select",{});if(b?i.active.push(b):m||i.active.push(_),i.active.forEach((t=>t.setTransient({_isSelected:!0}))),t&&t.data){var{x:C,y:I}=t.data.global;i.windowPos=[C,I],i.lastSceneClick=i.getPlanPosition(i.windowPos)}var S=i.active[0].getWorldPosition();u.visible=!0,u.x=S.x*i.scale,u.y=S.z*i.scale,u.rotation=Math.PI/180*-S.ry,1===i.active.length&&i.active[0].locked||i.emit("handler",{handler:u,state:i}),i.viewportNeedsUpdate=!0}else i.active=[],i.activeGroup&&i.emit("draw-xray",{xrayMode:!1}),i.activeGroup=null,u.visible=!1;i.emit("select",{node:i.active[0]})}}var Re=o.debug;function De({walls:t,data:e,options:i={updateState:!0,singleConnect:!1,preservePos:!1}}){if(t){e||(e=t.map(Dt));var r=t.every((t=>"a:helper:spaceDivider"===t.type)),n=i.actionId,o=t[0].ry<=180?t[0].ry:t[0].ry-180,s=t[1].ry<=180?t[1].ry:t[1].ry-180,a=Math.abs(parseInt(o)-parseInt(s));if(a<1)return{};if(i.preservePos&&a>170&&a<190)return{};var h,l,u,p,c,d,f,v,y,g,m,_,x,b,P=2,w=[e[0].p1,e[1].p1],E=[e[0].p2,e[1].p2],T=[e[0].p3,e[1].p3],C=[e[0].p4,e[1].p4],I=[e[0].nL,e[1].nL],S=[],O=[e[0].w,e[1].w],A=[],M=[],L=[],N=[],R=[];for(h=tt(w[0],E[0],w[1],E[1]),u=rt(l=tt(w[0],E[0],T[1],C[1]),O[1]),c=rt(p=tt(T[0],C[0],w[1],E[1]),O[0]),f=rt(d=tt(T[0],C[0],T[1],C[1]),O[0]),v=rt(d,O[1]),b=0;b<P;b++)y=Z(w[b],h),(g=Z(E[b],h))>y?(A[b]=g,N[b]={x:E[b].x,z:E[b].z},L[b]=!1,R[b]=y>20):(A[b]=y,N[b]={x:w[b].x,z:w[b].z},L[b]=!0,R[b]=g>20),S[b]={x:(N[b].x-h.x)/A[b],z:(N[b].z-h.z)/A[b]},M[b]=Z(N[b],b<1?f:v);if(R[0]&&R[1])return Re&&console.log("intersection too far away"),{};if(_=Fe(I[0],I[1]),(x=Fe(S[0],S[1]))<10)return Re&&console.log("angle too small"),{};i.singleConnect&&(P=1);var D=[];for(b=0;b<P;b++){r?m=h:Math.round(_)>=88&&Math.round(_)<=92?m=L[0]===L[1]?M[0]<A[0]?_>90?b<1?l:v:b<1?f:v:_>90&&b<1?c:h:M[0]<A[0]?b<1?l:u:b<1?c:p:_<90?x<=90||M[0]<A[0]?m=h:M[0]>A[0]&&(m=b<1?f:v):x<=90?m=b<1?l:u:M[0]<A[0]?m=b<1?c:p:M[0]>A[0]&&(m=b<1?l:u);var F=t[b].l;if(!m)return Re&&console.log("pSnap failed"),{};var k=Z(N[b],m);if(Math.abs(k-F)>.5&&Re&&console.log("delta",ht(k-F),"new",ht(k),"old",ht(F)),L[b])t[b].set({l:k},{updateState:i.updateState,actionId:n}),D[b]="end";else{"back"!==t[b].controlLine&&(m.x+=-e[b].p1.x+e[b].l1.x,m.z+=-e[b].p1.z+e[b].l1.z),t[b].set({x:m.x,z:m.z,l:k},{updateState:i.updateState,actionId:n}),D[b]="start";var B=t[b].children||[];if(B.length>0)for(var U=0;U<B.length;U++){var z=B[U].x-F+k;z=Math.max(0,z),z=Math.min(k-B[U].l,z),B[U].set({x:z},{updateState:i.updateState,actionId:n})}}}return{walls:t,connections:D}}}function Fe(t,e){return ht(180*Math.acos(t.x*e.x+t.z*e.z)/Math.PI,2)}var ke=({state:t,wall1:e,wall2:i,rel1:r,rel2:n,actionId:o})=>{if(e&&i){var s=[...Be({state:t,wall:e}),...Be({state:t,wall:i})].reduce(((t,e)=>t.find((t=>t.node.id===e.node.id))?t:t.concat(e)),[]);if(!s.some((t=>{var o=t.node.nodeIds;return o[e.id]&&o[i.id]&&o[e.id]===r&&o[i.id]===n}))){s.forEach((t=>{var s=t.node.nodeIds;"edge"!==r&&s[e.id]&&s[e.id]===r&&t.node.remove({actionId:o}),"edge"!==n&&s[i.id]&&s[i.id]===n&&t.node.remove({actionId:o})}));var a={type:"a:relation:wall",nodeIds:{[e.id]:r,[i.id]:n}};return t.getActiveLevel().addChild(a,{actionId:o})}}},Be=({state:t,wall:e})=>t.computed.relations.walls.filter((t=>Object.keys(t.node.nodeIds).includes(e.id))),Ue=(t,e,i,r=!1)=>{var n=e.find((e=>e.id===Object.keys(t.nodeIds)[0]));if(n&&n.id){var o,s,a,h,l=Object.keys(t.nodeIds),u=l.map((e=>{var r=i.scene.nodesById[e];return r&&{relation:t.nodeIds[r.id],node:r}})).filter((t=>t));if(u.length<2)return console.log("invalid wall relation"),void t.remove();if(l.forEach((i=>{"start"===t.nodeIds[i]&&(o=e.find((t=>t.id===i))),"edge"===t.nodeIds[i]&&(s=e.find((t=>t.id===i))),"end"===t.nodeIds[i]&&(a=e.find((t=>t.id===i)))})),o){var{x:p,z:c}=o;h=[p,c]}else if(a){var d=Dt(a).l2;h=[d.x,d.z]}return h?{node:t,point:h,isEdge:!!s,relatedNodes:u}:(console.log("invalid wall relation"),void t.remove())}r&&t.remove()},ze=t=>{if(!t.settings.loadWallRelations)return[];var e=t.scene.nodesByType["a:relation:wall"]||[];if(!e.length)return[];var i=t.scene.nodesByType.wall.map((t=>t.getWorldPosition())),r=t.scene.nodesByType["a:helper:spaceDivider"].map((t=>t.getWorldPosition()));return e.map((e=>Ue(e,i.concat(r),t))).filter((t=>t))},Xe=(t,e=[],i)=>{e.forEach((e=>{var r=e.isEdge;De({walls:e.relatedNodes.sort(((t,e)=>"edge"===t.relation?1:"edge"===e.relation?-1:void 0)).map((t=>t.node)),options:{updateState:!1,singleConnect:r,actionId:i}}),((t,e,i)=>{if(t.computed.relations.walls){var r=Ue(e,i,t,!0),n=t.computed.relations.walls.findIndex((t=>t.node.id===e.id));r?t.computed.relations.walls[n]=r:t.computed.relations.walls.splice(n,1)}})(t,e.node,[e.relatedNodes[0].node.getWorldPosition(),e.relatedNodes[1].node.getWorldPosition()])}))},je="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ye="object"==typeof je&&je&&je.Object===Object&&je,He="object"==typeof self&&self&&self.Object===Object&&self,Ge=Ye||He||Function("return this")(),We=Ge.Symbol,Ve=Object.prototype,qe=Ve.hasOwnProperty,Ze=Ve.toString,Je=We?We.toStringTag:void 0;var Ke=Object.prototype.toString;var Qe=We?We.toStringTag:void 0;function $e(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Qe&&Qe in Object(t)?function(t){var e=qe.call(t,Je),i=t[Je];try{t[Je]=void 0;var r=!0}catch(t){}var n=Ze.call(t);return r&&(e?t[Je]=i:delete t[Je]),n}(t):function(t){return Ke.call(t)}(t)}function ti(t){return null!=t&&"object"==typeof t}function ei(t){return"symbol"==typeof t||ti(t)&&"[object Symbol]"==$e(t)}function ii(t,e){for(var i=-1,r=null==t?0:t.length,n=Array(r);++i<r;)n[i]=e(t[i],i,t);return n}var ri=Array.isArray,ni=We?We.prototype:void 0,oi=ni?ni.toString:void 0;function si(t){if("string"==typeof t)return t;if(ri(t))return ii(t,si)+"";if(ei(t))return oi?oi.call(t):"";var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e}var ai=/\s/;var hi=/^\s+/;function li(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&ai.test(t.charAt(e)););return e}(t)+1).replace(hi,""):t}function ui(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var pi=/^[-+]0x[0-9a-f]+$/i,ci=/^0b[01]+$/i,di=/^0o[0-7]+$/i,fi=parseInt;function vi(t){if("number"==typeof t)return t;if(ei(t))return NaN;if(ui(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ui(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=li(t);var i=ci.test(t);return i||di.test(t)?fi(t.slice(2),i?2:8):pi.test(t)?NaN:+t}function yi(t){return t}function gi(t){if(!ui(t))return!1;var e=$e(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var mi=Ge["__core-js_shared__"],_i=function(){var t=/[^.]+$/.exec(mi&&mi.keys&&mi.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();var xi=Function.prototype.toString;function bi(t){if(null!=t){try{return xi.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Pi=/^\[object .+?Constructor\]$/,wi=Function.prototype,Ei=Object.prototype,Ti=wi.toString,Ci=Ei.hasOwnProperty,Ii=RegExp("^"+Ti.call(Ci).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Si(t){return!(!ui(t)||(e=t,_i&&_i in e))&&(gi(t)?Ii:Pi).test(bi(t));var e}function Oi(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return Si(i)?i:void 0}var Ai=Oi(Ge,"WeakMap"),Mi=Object.create,Li=function(){function t(){}return function(e){if(!ui(e))return{};if(Mi)return Mi(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();function Ni(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}function Ri(t,e){var i=-1,r=t.length;for(e||(e=Array(r));++i<r;)e[i]=t[i];return e}var Di=Date.now;var Fi,ki,Bi,Ui=function(){try{var t=Oi(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),zi=Ui,Xi=zi?function(t,e){return zi(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:yi,ji=(Fi=Xi,ki=0,Bi=0,function(){var t=Di(),e=16-(t-Bi);if(Bi=t,e>0){if(++ki>=800)return arguments[0]}else ki=0;return Fi.apply(void 0,arguments)});var Yi=/^(?:0|[1-9]\d*)$/;function Hi(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Yi.test(t))&&t>-1&&t%1==0&&t<e}function Gi(t,e,i){"__proto__"==e&&zi?zi(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function Wi(t,e){return t===e||t!=t&&e!=e}var Vi=Object.prototype.hasOwnProperty;function qi(t,e,i){var r=t[e];Vi.call(t,e)&&Wi(r,i)&&(void 0!==i||e in t)||Gi(t,e,i)}function Zi(t,e,i,r){var n=!i;i||(i={});for(var o=-1,s=e.length;++o<s;){var a=e[o],h=r?r(i[a],t[a],a,i,t):void 0;void 0===h&&(h=t[a]),n?Gi(i,a,h):qi(i,a,h)}return i}var Ji=Math.max;function Ki(t,e){return ji(function(t,e,i){return e=Ji(void 0===e?t.length-1:e,0),function(){for(var r=arguments,n=-1,o=Ji(r.length-e,0),s=Array(o);++n<o;)s[n]=r[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=r[n];return a[e]=i(s),Ni(t,this,a)}}(t,e,yi),t+"")}function Qi(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function $i(t){return null!=t&&Qi(t.length)&&!gi(t)}function tr(t,e,i){if(!ui(i))return!1;var r=typeof e;return!!("number"==r?$i(i)&&Hi(e,i.length):"string"==r&&e in i)&&Wi(i[e],t)}var er=Object.prototype;function ir(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||er)}function rr(t){return ti(t)&&"[object Arguments]"==$e(t)}var nr=Object.prototype,or=nr.hasOwnProperty,sr=nr.propertyIsEnumerable,ar=rr(function(){return arguments}())?rr:function(t){return ti(t)&&or.call(t,"callee")&&!sr.call(t,"callee")};var hr="object"==typeof exports&&exports&&!exports.nodeType&&exports,lr=hr&&"object"==typeof module&&module&&!module.nodeType&&module,ur=lr&&lr.exports===hr?Ge.Buffer:void 0,pr=(ur?ur.isBuffer:void 0)||function(){return!1},cr={};function dr(t){return function(e){return t(e)}}cr["[object Float32Array]"]=cr["[object Float64Array]"]=cr["[object Int8Array]"]=cr["[object Int16Array]"]=cr["[object Int32Array]"]=cr["[object Uint8Array]"]=cr["[object Uint8ClampedArray]"]=cr["[object Uint16Array]"]=cr["[object Uint32Array]"]=!0,cr["[object Arguments]"]=cr["[object Array]"]=cr["[object ArrayBuffer]"]=cr["[object Boolean]"]=cr["[object DataView]"]=cr["[object Date]"]=cr["[object Error]"]=cr["[object Function]"]=cr["[object Map]"]=cr["[object Number]"]=cr["[object Object]"]=cr["[object RegExp]"]=cr["[object Set]"]=cr["[object String]"]=cr["[object WeakMap]"]=!1;var fr="object"==typeof exports&&exports&&!exports.nodeType&&exports,vr=fr&&"object"==typeof module&&module&&!module.nodeType&&module,yr=vr&&vr.exports===fr&&Ye.process,gr=function(){try{var t=vr&&vr.require&&vr.require("util").types;return t||yr&&yr.binding&&yr.binding("util")}catch(t){}}(),mr=gr,_r=mr&&mr.isTypedArray,xr=_r?dr(_r):function(t){return ti(t)&&Qi(t.length)&&!!cr[$e(t)]},br=Object.prototype.hasOwnProperty;function Pr(t,e){var i=ri(t),r=!i&&ar(t),n=!i&&!r&&pr(t),o=!i&&!r&&!n&&xr(t),s=i||r||n||o,a=s?function(t,e){for(var i=-1,r=Array(t);++i<t;)r[i]=e(i);return r}(t.length,String):[],h=a.length;for(var l in t)!e&&!br.call(t,l)||s&&("length"==l||n&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Hi(l,h))||a.push(l);return a}function wr(t,e){return function(i){return t(e(i))}}var Er=wr(Object.keys,Object),Tr=Object.prototype.hasOwnProperty;function Cr(t){return $i(t)?Pr(t):function(t){if(!ir(t))return Er(t);var e=[];for(var i in Object(t))Tr.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}var Ir=Object.prototype.hasOwnProperty;function Sr(t){if(!ui(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=ir(t),i=[];for(var r in t)("constructor"!=r||!e&&Ir.call(t,r))&&i.push(r);return i}function Or(t){return $i(t)?Pr(t,!0):Sr(t)}var Ar=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mr=/^\w*$/;function Lr(t,e){if(ri(t))return!1;var i=typeof t;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=t&&!ei(t))||(Mr.test(t)||!Ar.test(t)||null!=e&&t in Object(e))}var Nr=Oi(Object,"create");var Rr=Object.prototype.hasOwnProperty;var Dr=Object.prototype.hasOwnProperty;function Fr(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}function kr(t,e){for(var i=t.length;i--;)if(Wi(t[i][0],e))return i;return-1}Fr.prototype.clear=function(){this.__data__=Nr?Nr(null):{},this.size=0},Fr.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Fr.prototype.get=function(t){var e=this.__data__;if(Nr){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Rr.call(e,t)?e[t]:void 0},Fr.prototype.has=function(t){var e=this.__data__;return Nr?void 0!==e[t]:Dr.call(e,t)},Fr.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Nr&&void 0===e?"__lodash_hash_undefined__":e,this};var Br=Array.prototype.splice;function Ur(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}Ur.prototype.clear=function(){this.__data__=[],this.size=0},Ur.prototype.delete=function(t){var e=this.__data__,i=kr(e,t);return!(i<0)&&(i==e.length-1?e.pop():Br.call(e,i,1),--this.size,!0)},Ur.prototype.get=function(t){var e=this.__data__,i=kr(e,t);return i<0?void 0:e[i][1]},Ur.prototype.has=function(t){return kr(this.__data__,t)>-1},Ur.prototype.set=function(t,e){var i=this.__data__,r=kr(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this};var zr=Oi(Ge,"Map");function Xr(t,e){var i,r,n=t.__data__;return("string"==(r=typeof(i=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==i:null===i)?n["string"==typeof e?"string":"hash"]:n.map}function jr(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}jr.prototype.clear=function(){this.size=0,this.__data__={hash:new Fr,map:new(zr||Ur),string:new Fr}},jr.prototype.delete=function(t){var e=Xr(this,t).delete(t);return this.size-=e?1:0,e},jr.prototype.get=function(t){return Xr(this,t).get(t)},jr.prototype.has=function(t){return Xr(this,t).has(t)},jr.prototype.set=function(t,e){var i=Xr(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this};function Yr(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var i=function(){var r=arguments,n=e?e.apply(this,r):r[0],o=i.cache;if(o.has(n))return o.get(n);var s=t.apply(this,r);return i.cache=o.set(n,s)||o,s};return i.cache=new(Yr.Cache||jr),i}Yr.Cache=jr;var Hr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gr=/\\(\\)?/g,Wr=function(t){var e=Yr(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Hr,(function(t,i,r,n){e.push(r?n.replace(Gr,"$1"):i||t)})),e})),Vr=Wr;function qr(t,e){return ri(t)?t:Lr(t,e)?[t]:Vr(function(t){return null==t?"":si(t)}(t))}function Zr(t){if("string"==typeof t||ei(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e}function Jr(t,e){for(var i=0,r=(e=qr(e,t)).length;null!=t&&i<r;)t=t[Zr(e[i++])];return i&&i==r?t:void 0}function Kr(t,e){for(var i=-1,r=e.length,n=t.length;++i<r;)t[n+i]=e[i];return t}var Qr=We?We.isConcatSpreadable:void 0;function $r(t){return ri(t)||ar(t)||!!(Qr&&t&&t[Qr])}function tn(t,e,i,r,n){var o=-1,s=t.length;for(i||(i=$r),n||(n=[]);++o<s;){var a=t[o];e>0&&i(a)?e>1?tn(a,e-1,i,r,n):Kr(n,a):r||(n[n.length]=a)}return n}var en=wr(Object.getPrototypeOf,Object),rn=Function.prototype,nn=Object.prototype,on=rn.toString,sn=nn.hasOwnProperty,an=on.call(Object);function hn(t){var e=this.__data__=new Ur(t);this.size=e.size}hn.prototype.clear=function(){this.__data__=new Ur,this.size=0},hn.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},hn.prototype.get=function(t){return this.__data__.get(t)},hn.prototype.has=function(t){return this.__data__.has(t)},hn.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Ur){var r=i.__data__;if(!zr||r.length<199)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new jr(r)}return i.set(t,e),this.size=i.size,this};var ln="object"==typeof exports&&exports&&!exports.nodeType&&exports,un=ln&&"object"==typeof module&&module&&!module.nodeType&&module,pn=un&&un.exports===ln?Ge.Buffer:void 0,cn=pn?pn.allocUnsafe:void 0;function dn(t,e){if(e)return t.slice();var i=t.length,r=cn?cn(i):new t.constructor(i);return t.copy(r),r}function fn(){return[]}var vn=Object.prototype.propertyIsEnumerable,yn=Object.getOwnPropertySymbols,gn=yn?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,r=null==t?0:t.length,n=0,o=[];++i<r;){var s=t[i];e(s,i,t)&&(o[n++]=s)}return o}(yn(t),(function(e){return vn.call(t,e)})))}:fn,mn=gn;var _n=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Kr(e,mn(t)),t=en(t);return e}:fn;function xn(t,e,i){var r=e(t);return ri(t)?r:Kr(r,i(t))}function bn(t){return xn(t,Cr,mn)}function Pn(t){return xn(t,Or,_n)}var wn=Oi(Ge,"DataView"),En=Oi(Ge,"Promise"),Tn=Oi(Ge,"Set"),Cn=bi(wn),In=bi(zr),Sn=bi(En),On=bi(Tn),An=bi(Ai),Mn=$e;(wn&&"[object DataView]"!=Mn(new wn(new ArrayBuffer(1)))||zr&&"[object Map]"!=Mn(new zr)||En&&"[object Promise]"!=Mn(En.resolve())||Tn&&"[object Set]"!=Mn(new Tn)||Ai&&"[object WeakMap]"!=Mn(new Ai))&&(Mn=function(t){var e=$e(t),i="[object Object]"==e?t.constructor:void 0,r=i?bi(i):"";if(r)switch(r){case Cn:return"[object DataView]";case In:return"[object Map]";case Sn:return"[object Promise]";case On:return"[object Set]";case An:return"[object WeakMap]"}return e});var Ln=Mn,Nn=Object.prototype.hasOwnProperty;var Rn=Ge.Uint8Array;function Dn(t){var e=new t.constructor(t.byteLength);return new Rn(e).set(new Rn(t)),e}var Fn=/\w*$/;var kn=We?We.prototype:void 0,Bn=kn?kn.valueOf:void 0;function Un(t,e){var i=e?Dn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}function zn(t,e,i){var r,n,o,s=t.constructor;switch(e){case"[object ArrayBuffer]":return Dn(t);case"[object Boolean]":case"[object Date]":return new s(+t);case"[object DataView]":return function(t,e){var i=e?Dn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}(t,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Un(t,i);case"[object Map]":case"[object Set]":return new s;case"[object Number]":case"[object String]":return new s(t);case"[object RegExp]":return(o=new(n=t).constructor(n.source,Fn.exec(n))).lastIndex=n.lastIndex,o;case"[object Symbol]":return r=t,Bn?Object(Bn.call(r)):{}}}function Xn(t){return"function"!=typeof t.constructor||ir(t)?{}:Li(en(t))}var jn=mr&&mr.isMap,Yn=jn?dr(jn):function(t){return ti(t)&&"[object Map]"==Ln(t)};var Hn=mr&&mr.isSet,Gn=Hn?dr(Hn):function(t){return ti(t)&&"[object Set]"==Ln(t)},Wn={};function Vn(t,e,i,r,n,o){var s,a=1&e,h=2&e,l=4&e;if(i&&(s=n?i(t,r,n,o):i(t)),void 0!==s)return s;if(!ui(t))return t;var u=ri(t);if(u){if(s=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&Nn.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t),!a)return Ri(t,s)}else{var p=Ln(t),c="[object Function]"==p||"[object GeneratorFunction]"==p;if(pr(t))return dn(t,a);if("[object Object]"==p||"[object Arguments]"==p||c&&!n){if(s=h||c?{}:Xn(t),!a)return h?function(t,e){return Zi(t,_n(t),e)}(t,function(t,e){return t&&Zi(e,Or(e),t)}(s,t)):function(t,e){return Zi(t,mn(t),e)}(t,function(t,e){return t&&Zi(e,Cr(e),t)}(s,t))}else{if(!Wn[p])return n?t:{};s=zn(t,p,a)}}o||(o=new hn);var d=o.get(t);if(d)return d;o.set(t,s),Gn(t)?t.forEach((function(r){s.add(Vn(r,e,i,r,t,o))})):Yn(t)&&t.forEach((function(r,n){s.set(n,Vn(r,e,i,n,t,o))}));var f=u?void 0:(l?h?Pn:bn:h?Or:Cr)(t);return function(t,e){for(var i=-1,r=null==t?0:t.length;++i<r&&!1!==e(t[i],i,t););}(f||t,(function(r,n){f&&(r=t[n=r]),qi(s,n,Vn(r,e,i,n,t,o))})),s}Wn["[object Arguments]"]=Wn["[object Array]"]=Wn["[object ArrayBuffer]"]=Wn["[object DataView]"]=Wn["[object Boolean]"]=Wn["[object Date]"]=Wn["[object Float32Array]"]=Wn["[object Float64Array]"]=Wn["[object Int8Array]"]=Wn["[object Int16Array]"]=Wn["[object Int32Array]"]=Wn["[object Map]"]=Wn["[object Number]"]=Wn["[object Object]"]=Wn["[object RegExp]"]=Wn["[object Set]"]=Wn["[object String]"]=Wn["[object Symbol]"]=Wn["[object Uint8Array]"]=Wn["[object Uint8ClampedArray]"]=Wn["[object Uint16Array]"]=Wn["[object Uint32Array]"]=!0,Wn["[object Error]"]=Wn["[object Function]"]=Wn["[object WeakMap]"]=!1;function qn(t){return Vn(t,5)}function Zn(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new jr;++e<i;)this.add(t[e])}function Jn(t,e){for(var i=-1,r=null==t?0:t.length;++i<r;)if(e(t[i],i,t))return!0;return!1}Zn.prototype.add=Zn.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Zn.prototype.has=function(t){return this.__data__.has(t)};function Kn(t,e,i,r,n,o){var s=1&i,a=t.length,h=e.length;if(a!=h&&!(s&&h>a))return!1;var l=o.get(t),u=o.get(e);if(l&&u)return l==e&&u==t;var p=-1,c=!0,d=2&i?new Zn:void 0;for(o.set(t,e),o.set(e,t);++p<a;){var f=t[p],v=e[p];if(r)var y=s?r(v,f,p,e,t,o):r(f,v,p,t,e,o);if(void 0!==y){if(y)continue;c=!1;break}if(d){if(!Jn(e,(function(t,e){if(s=e,!d.has(s)&&(f===t||n(f,t,i,r,o)))return d.push(e);var s}))){c=!1;break}}else if(f!==v&&!n(f,v,i,r,o)){c=!1;break}}return o.delete(t),o.delete(e),c}function Qn(t){var e=-1,i=Array(t.size);return t.forEach((function(t,r){i[++e]=[r,t]})),i}function $n(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i}var to=We?We.prototype:void 0,eo=to?to.valueOf:void 0;var io=Object.prototype.hasOwnProperty;var ro="[object Object]",no=Object.prototype.hasOwnProperty;function oo(t,e,i,r,n,o){var s=ri(t),a=ri(e),h=s?"[object Array]":Ln(t),l=a?"[object Array]":Ln(e),u=(h="[object Arguments]"==h?ro:h)==ro,p=(l="[object Arguments]"==l?ro:l)==ro,c=h==l;if(c&&pr(t)){if(!pr(e))return!1;s=!0,u=!1}if(c&&!u)return o||(o=new hn),s||xr(t)?Kn(t,e,i,r,n,o):function(t,e,i,r,n,o,s){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Rn(t),new Rn(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Wi(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Qn;case"[object Set]":var h=1&r;if(a||(a=$n),t.size!=e.size&&!h)return!1;var l=s.get(t);if(l)return l==e;r|=2,s.set(t,e);var u=Kn(a(t),a(e),r,n,o,s);return s.delete(t),u;case"[object Symbol]":if(eo)return eo.call(t)==eo.call(e)}return!1}(t,e,h,i,r,n,o);if(!(1&i)){var d=u&&no.call(t,"__wrapped__"),f=p&&no.call(e,"__wrapped__");if(d||f){var v=d?t.value():t,y=f?e.value():e;return o||(o=new hn),n(v,y,i,r,o)}}return!!c&&(o||(o=new hn),function(t,e,i,r,n,o){var s=1&i,a=bn(t),h=a.length;if(h!=bn(e).length&&!s)return!1;for(var l=h;l--;){var u=a[l];if(!(s?u in e:io.call(e,u)))return!1}var p=o.get(t),c=o.get(e);if(p&&c)return p==e&&c==t;var d=!0;o.set(t,e),o.set(e,t);for(var f=s;++l<h;){var v=t[u=a[l]],y=e[u];if(r)var g=s?r(y,v,u,e,t,o):r(v,y,u,t,e,o);if(!(void 0===g?v===y||n(v,y,i,r,o):g)){d=!1;break}f||(f="constructor"==u)}if(d&&!f){var m=t.constructor,_=e.constructor;m==_||!("constructor"in t)||!("constructor"in e)||"function"==typeof m&&m instanceof m&&"function"==typeof _&&_ instanceof _||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,i,r,n,o))}function so(t,e,i,r,n){return t===e||(null==t||null==e||!ti(t)&&!ti(e)?t!=t&&e!=e:oo(t,e,i,r,so,n))}function ao(t){return t==t&&!ui(t)}function ho(t,e){return function(i){return null!=i&&(i[t]===e&&(void 0!==e||t in Object(i)))}}function lo(t){var e=function(t){for(var e=Cr(t),i=e.length;i--;){var r=e[i],n=t[r];e[i]=[r,n,ao(n)]}return e}(t);return 1==e.length&&e[0][2]?ho(e[0][0],e[0][1]):function(i){return i===t||function(t,e,i,r){var n=i.length,o=n,s=!r;if(null==t)return!o;for(t=Object(t);n--;){var a=i[n];if(s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++n<o;){var h=(a=i[n])[0],l=t[h],u=a[1];if(s&&a[2]){if(void 0===l&&!(h in t))return!1}else{var p=new hn;if(r)var c=r(l,u,h,t,e,p);if(!(void 0===c?so(u,l,3,r,p):c))return!1}}return!0}(i,t,e)}}function uo(t,e){return null!=t&&e in Object(t)}function po(t,e){return null!=t&&function(t,e,i){for(var r=-1,n=(e=qr(e,t)).length,o=!1;++r<n;){var s=Zr(e[r]);if(!(o=null!=t&&i(t,s)))break;t=t[s]}return o||++r!=n?o:!!(n=null==t?0:t.length)&&Qi(n)&&Hi(s,n)&&(ri(t)||ar(t))}(t,e,uo)}function co(t,e){return Lr(t)&&ao(e)?ho(Zr(t),e):function(i){var r=function(t,e,i){var r=null==t?void 0:Jr(t,e);return void 0===r?i:r}(i,t);return void 0===r&&r===e?po(i,t):so(e,r,3)}}function fo(t){return Lr(t)?(e=Zr(t),function(t){return null==t?void 0:t[e]}):function(t){return function(e){return Jr(e,t)}}(t);var e}function vo(t){return"function"==typeof t?t:null==t?yi:"object"==typeof t?ri(t)?co(t[0],t[1]):lo(t):fo(t)}var yo,go=function(t,e,i){for(var r=-1,n=Object(t),o=i(t),s=o.length;s--;){var a=o[yo?s:++r];if(!1===e(n[a],a,n))break}return t},mo=go;var _o=function(t,e){return function(i,r){if(null==i)return i;if(!$i(i))return t(i,r);for(var n=i.length,o=e?n:-1,s=Object(i);(e?o--:++o<n)&&!1!==r(s[o],o,s););return i}}((function(t,e){return t&&mo(t,e,Cr)})),xo=_o,bo=function(){return Ge.Date.now()},Po=Math.max,wo=Math.min;function Eo(t,e,i){var r,n,o,s,a,h,l=0,u=!1,p=!1,c=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function d(e){var i=r,o=n;return r=n=void 0,l=e,s=t.apply(o,i)}function f(t){return l=t,a=setTimeout(y,e),u?d(t):s}function v(t){var i=t-h;return void 0===h||i>=e||i<0||p&&t-l>=o}function y(){var t=bo();if(v(t))return g(t);a=setTimeout(y,function(t){var i=e-(t-h);return p?wo(i,o-(t-l)):i}(t))}function g(t){return a=void 0,c&&r?d(t):(r=n=void 0,s)}function m(){var t=bo(),i=v(t);if(r=arguments,n=this,h=t,i){if(void 0===a)return f(h);if(p)return clearTimeout(a),a=setTimeout(y,e),d(h)}return void 0===a&&(a=setTimeout(y,e)),s}return e=vi(e)||0,ui(i)&&(u=!!i.leading,o=(p="maxWait"in i)?Po(vi(i.maxWait)||0,e):o,c="trailing"in i?!!i.trailing:c),m.cancel=function(){void 0!==a&&clearTimeout(a),l=0,r=h=n=a=void 0},m.flush=function(){return void 0===a?s:g(bo())},m}function To(t,e,i){(void 0!==i&&!Wi(t[e],i)||void 0===i&&!(e in t))&&Gi(t,e,i)}function Co(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Io(t,e,i,r,n,o,s){var a=Co(t,i),h=Co(e,i),l=s.get(h);if(l)To(t,i,l);else{var u,p=o?o(a,h,i+"",t,e,s):void 0,c=void 0===p;if(c){var d=ri(h),f=!d&&pr(h),v=!d&&!f&&xr(h);p=h,d||f||v?ri(a)?p=a:ti(u=a)&&$i(u)?p=Ri(a):f?(c=!1,p=dn(h,!0)):v?(c=!1,p=Un(h,!0)):p=[]:function(t){if(!ti(t)||"[object Object]"!=$e(t))return!1;var e=en(t);if(null===e)return!0;var i=sn.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&on.call(i)==an}(h)||ar(h)?(p=a,ar(a)?p=function(t){return Zi(t,Or(t))}(a):ui(a)&&!gi(a)||(p=Xn(h))):c=!1}c&&(s.set(h,p),n(p,h,r,o,s),s.delete(h)),To(t,i,p)}}function So(t,e,i,r,n){t!==e&&mo(e,(function(o,s){if(n||(n=new hn),ui(o))Io(t,e,s,i,So,r,n);else{var a=r?r(Co(t,s),o,s+"",t,e,n):void 0;void 0===a&&(a=o),To(t,s,a)}}),Or)}var Oo,Ao=(Oo=function(t,e,i){So(t,e,i)},Ki((function(t,e){var i=-1,r=e.length,n=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(n=Oo.length>3&&"function"==typeof n?(r--,n):void 0,o&&tr(e[0],e[1],o)&&(n=r<3?void 0:n,r=1),t=Object(t);++i<r;){var s=e[i];s&&Oo(t,s,i,n)}return t}))),Mo=Ao;function Lo(t,e){if(t!==e){var i=void 0!==t,r=null===t,n=t==t,o=ei(t),s=void 0!==e,a=null===e,h=e==e,l=ei(e);if(!a&&!l&&!o&&t>e||o&&s&&h&&!a&&!l||r&&s&&h||!i&&h||!n)return 1;if(!r&&!o&&!l&&t<e||l&&i&&n&&!r&&!o||a&&i&&n||!s&&n||!h)return-1}return 0}function No(t,e,i){e=e.length?ii(e,(function(t){return ri(t)?function(e){return Jr(e,1===t.length?t[0]:t)}:t})):[yi];var r=-1;e=ii(e,dr(vo));var n=function(t,e){var i=-1,r=$i(t)?Array(t.length):[];return xo(t,(function(t,n,o){r[++i]=e(t,n,o)})),r}(t,(function(t,i,n){return{criteria:ii(e,(function(e){return e(t)})),index:++r,value:t}}));return function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t}(n,(function(t,e){return function(t,e,i){for(var r=-1,n=t.criteria,o=e.criteria,s=n.length,a=i.length;++r<s;){var h=Lo(n[r],o[r]);if(h)return r>=a?h:h*("desc"==i[r]?-1:1)}return t.index-e.index}(t,e,i)}))}var Ro,Do=Ki((function(t,e){if(null==t)return[];var i=e.length;return i>1&&tr(t,e[0],e[1])?e=[]:i>2&&tr(e[0],e[1],e[2])&&(e=[e[0]]),No(t,tn(e,1),[])})),Fo=Do;function ko(t={}){this.maxResolvedCache=t.maxResolvedCache||1e3,this._pendingPromises={},this._resolvedPromises={}}ko.prototype={add:function(t,e){var i=this;if(this._pendingPromises[t])return this._pendingPromises[t];if(this._resolvedPromises[t])return this._resolvedPromises[t];var r={key:t,timestamp:Date.now(),promise:e};return this._pendingPromises[t]=r,e.then((function(e){var r=i._pendingPromises[t];delete i._pendingPromises[t],r.data=e,i._resolvedPromises[t]=r}),(function(){delete i._pendingPromises[t]})),this._collectGarbage(),r},get:function(t){var e=this._pendingPromises[t]||this._resolvedPromises[t];return!!e&&(e.timestamp=Date.now(),e.promise)},purge:function(){for(var t in this._resolvedPromises)delete this._resolvedPromises[t]},_collectGarbage:function(){var t=Fo(this._resolvedPromises,(function(t){return t.timestamp})),e=t.length-this.maxResolvedCache;if(!(e<=0))for(var i=0;i<e;i++)delete this._resolvedPromises[t[i].key]}};class Bo{constructor(t="keyval-store",e="keyval"){this.storeName=e,this._dbp=new Promise(((i,r)=>{var n=indexedDB.open(t,1);n.onerror=()=>r(n.error),n.onsuccess=()=>i(n.result),n.onupgradeneeded=()=>{n.result.createObjectStore(e)}}))}_withIDBStore(t,e){return this._dbp.then((i=>new Promise(((r,n)=>{var o=i.transaction(this.storeName,t);o.oncomplete=()=>r(),o.onabort=o.onerror=()=>n(o.error),e(o.objectStore(this.storeName))}))))}}function Uo(){return Ro||(Ro=new Bo),Ro}function zo(t,e=Uo()){var i;return e._withIDBStore("readonly",(e=>{i=e.get(t)})).then((()=>i.result))}function Xo(t,e,i=Uo()){return i._withIDBStore("readwrite",(i=>{i.put(e,t)}))}var jo=new Bo("al-kvs","al-keyval"),Yo=!0;function Ho(t,e,i){return Go.apply(this,arguments)}function Go(){return(Go=r((function*(t,e,i){i=i||2592e6;try{var r={timeStamp:(new Date).getTime(),content:e,maxAge:i};if(Yo)yield Xo(t,JSON.stringify(r),jo);else{var n=window&&window.localStorage;if(!n||!t||"string"!=typeof t)return;n.setItem(t,JSON.stringify(r))}return t}catch(t){return}}))).apply(this,arguments)}function Wo(t,e){return Vo.apply(this,arguments)}function Vo(){return(Vo=r((function*(t,e){var i,r=e||2592e6,n=(new Date).getTime();try{if(Yo)i=yield zo(t,jo);else{var o=window&&window.localStorage;if(!o||!t||"string"!=typeof t)return;i=o.getItem(t)}if(n-(i=JSON.parse(i)).timeStamp>Math.min(i.maxAge,r))return;if(i.content)return i.content}catch(t){return}}))).apply(this,arguments)}function qo(t){return t&&"string"==typeof t?t.toLowerCase().replace(/[()+&!?;,:_)]/g,"").replace(/\s+/g,"-"):""}function Zo(t,e){var i,r,n=null===(i=t.src)||void 0===i?void 0:i.substring(1),o=function(t={},e){var i=e&&e.length&&e[0].split(":")[0],r=Object.keys(t);return i&&"default"!==i&&(r=r.filter((t=>t===i))),1===r.length?r[0]:r.filter((t=>!t.toLowerCase().includes("base")))[0]}(t.materials,null===(r=e.products[n])||void 0===r?void 0:r.colours);return o&&qo(t.materials[o])}function Jo(t,e){var i,r=null===(i=t.src)||void 0===i?void 0:i.substring(1),n=Zo(t,e);return r+(n=n?"_"+n:"")}jo._dbp.then((()=>{Yo=!0})).catch((t=>{Yo=!1,console.log("indexedDb initialisation failed",t)}));var Ko={kitchen:function(t){var e=[],i=/90$/g.test(t.cooktopType),r=function(t){var e=t.elementLength,i=t.highCabinetLeft*e,r=t.highCabinetRight*e;return Math.max(0,t.l-i-r)}(t),n=function(t,e,i){var r,n=t.elementLength,o=.9,s=t.highCabinetLeft*n,a=[],h=0,l=0;for(r=0;r<t.highCabinetLeft;r++){var u=t.l-h;h+=u>n?n:u,a[r]=h,l++}for(;h+n<s+e;){h+=l===t.cooktopPos-1&&"none"!==t.cooktopType&&i?o:n,l++,a.push(h)}for(r=t.highCabinetRight;r>0;r--)h=t.l-n*r+n,a.push(h);return a=a.map((t=>Math.round(10*t)/10))}(t,r,i),o=function(t,e){var i,r=[];for(i=0;i<t.highCabinetLeft;i++)r.push(i);for(i=0;i<t.highCabinetRight;i++)r.push(e.length-1-i);return r}(t,n),s=function(t,e){return"number"==typeof t.sinkPos&&t.sinkPos>t.highCabinetLeft&&t.sinkPos<=e.length-t.highCabinetRight&&"none"!==t.sinkType?t.sinkPos:null}(t,n),a=function(t,e){return"number"==typeof t.cooktopPos&&t.cooktopPos>t.highCabinetLeft&&t.cooktopPos<=e.length-t.highCabinetRight&&"none"!==t.cooktopType?t.cooktopPos:null}(t,n);for(var h of(e.push(we([0,t.barCounter?-.25:0],t.l,t.barCounter?t.w+.25:t.w,!0)),n.forEach((i=>{e.push(Pe([i,t.w],[i,t.w-.075]))})),r&&t.barCounter&&e.push(Pe([t.highCabinetLeft*t.elementLength,0],[t.l-t.highCabinetRight*t.elementLength,0])),o)){var l=n[h],u=l-.6;e.push(Pe([u||0,t.w],[u||0,0]),Pe([u||0,0],[l,t.w]),Pe([u||0,t.w],[l,0]),Pe([l,t.w],[l,0]))}if(s&&n[s-2]){var p={type:"group",position:[n[s-2],0],children:[we([.05,t.w-.5],"double"!==t.sinkType?.5:1.1,.45),we([.1,t.w-.4],"double"!==t.sinkType?.4:.35,.3),we(["double"!==t.sinkType?t.elementLength/2-.02:.48,t.w-.45],.04,.18)]};"double"===t.sinkType&&p.children.push(we([.55,t.w-.4],.35,.3),Pe([.95,t.w-.4],[.95,t.w-.1]),Pe([1,t.w-.4],[1,t.w-.1]),Pe([1.05,t.w-.4],[1.05,t.w-.1]),Pe([1.1,t.w-.4],[1.1,t.w-.1])),e.push(p)}if(a&&n[a-2]){var c={type:"group",position:[n[a-2],0],children:[we([.05,t.w-.55],i?.8:.5,.5)]};i?c.children.push(Ee([.225,t.w-.4],.08),Ee([.675,t.w-.4],.08),Ee([.45,t.w-.3],.08),Ee([.225,t.w-.2],.08),Ee([.675,t.w-.2],.08)):c.children.push(Ee([.2,t.w-.4],.08),Ee([.4,t.w-.4],.08),Ee([.2,t.w-.2],.08),Ee([.4,t.w-.2],.08)),e.push(c)}return r&&t.wallCabinet&&e.push(Pe([t.highCabinetLeft*t.elementLength,t.wallCabinetWidth],[t.l-t.highCabinetRight*t.elementLength,t.wallCabinetWidth])),e},column:function(t){var e=[];return"square"===t.shape?e.push({type:"rect",position:[-t.l/2,-t.l/2],width:t.l,height:t.l,isContour:!0}):"circle"===t.shape?e.push({type:"circle",position:[0,0],r:t.l/2,isContour:!0}):"polygon"===t.shape&&e.push({type:"polygon",points:t.polygon,isContour:!0}),e},stairs:function(t,i={}){var r,n=e({w:1.2,l:4},t),o="labelled"!==i.style,s="left"===t.circulation,a=.3,h=t.stairType||"straight",l=t.l,u=t.stepWidth;"straightLanding"===t.stairType?l=t.l-1:"lShaped"===t.stairType?l=t.l+t.w-2*u:"winder"===t.stairType?l=t.l+t.w-u:"halfLanding"===t.stairType?l=2*(t.l-u):"2QuarterLanding"===t.stairType?l=2*(t.l-u)+t.w-2*u:"doubleWinder"===t.stairType&&(l=2*t.l+t.w-2*u);var p,c,d,f=(l/t.h+1.2321)/.10357/100,v=Math.round(l/f),y=l/v,g={shape:[],runs:[]};switch(h){case"straight":case"straightLanding":g.shape=[[0,0],[t.l,0],[t.l,t.w],[0,t.w]];break;case"lShaped":case"winder":g.shape=[[0,0],[t.l,0],[t.l,t.w],[t.l-u,t.w],[t.l-u,u],[0,u]];break;case"halfLanding":case"2QuarterLanding":case"doubleWinder":g.shape=[[0,0],[t.l,0],[t.l,t.w],[0,t.w],[0,t.w-u],[t.l-u,t.w-u],[t.l-u,u],[0,u]]}if(o)switch(h){case"straight":g.runs=[{type:"straight",data:[0,0,v,y,0]}];break;case"straightLanding":c=v-(p=Math.ceil(v/2)),g.runs=[{type:"straight",data:[0,0,p,y,0]},{type:"straight",data:[p*y+1,0,c,y,0]}];break;case"lShaped":c=v-(p=Math.floor((t.l-u)/y)),g.runs=[{type:"straight",data:[0,0,p,(t.l-u)/p,0]},{type:"straight",data:[t.l,u,c,(t.w-u)/c,-90]}];break;case"winder":c=2*Math.round((u/2+a)/y),d=v-(p=Math.round((t.l-u-a)/y))-c,g.runs=[{type:"straight",data:[0,0,p,(t.l-u-a)/p,0]},{type:"winder",data:[t.l-u-a,0,c,0]}],d>0&&g.runs.push({type:"straight",data:[t.l,u+a,d,(t.w-u-a)/d,-90]});break;case"halfLanding":p=v/2,c=v/2,g.runs=[{type:"straight",data:[0,0,p,y,0]},{type:"straight",data:[p*y,t.w,c,y,180]}];break;case"2QuarterLanding":d=p=Math.round((t.l-u)/y),c=v-2*p,y=(t.l-u)/p,g.runs=[{type:"straight",data:[0,0,p,(t.l-u)/p,0]},{type:"straight",data:[t.l,u,c,(t.w-2*u)/c,-90]},{type:"straight",data:[p*y,t.w,d,(t.l-u)/p,180]}];break;case"doubleWinder":c=4*Math.round((u/2+a)/y),d=Math.round((t.w-2*(u+a))/y),p=Math.round((v-c-d)/2),g.runs=[],p>0&&g.runs.push({type:"straight",data:[0,0,p,(t.l-u-a)/p,0]}),g.runs.push({type:"winder",data:[t.l-u-a,0,c/2,0]}),d>0&&g.runs.push({type:"straight",data:[t.l,u+a,d,(t.w-2*(u+a))/d,-90]}),g.runs.push({type:"winder",data:[t.l,t.w-u-a,c/2,-90]}),p>0&&g.runs.push({type:"straight",data:[t.l-u-a,t.w,p,(t.l-u-a)/p,180]})}var m,_=[];if("labelled"!==i.style){var x=[["M",y/2-.06,u/2+.12],["L",y/2+.06,u/2],["L",y/2-.06,u/2-.12]];_.push({type:"path",segments:x})}if("spiral"!==h)m={type:"polygon",points:g.shape,isContour:!0},g.runs.forEach((t=>{"straight"===t.type?_=_.concat(function(t,e,i,r,n=0){for(var o={type:"group",position:[t,e],rotation:n=n||0,children:[]},s=0;s<i;s++)o.children.push({type:"path",segments:[["M",s*r,0],["L",s*r,u]]});return o}(...t.data)):"winder"===t.type&&(_=_.concat(function(t,e,i,r){for(var n,o,s=i/2,a=(u+.3)/s,h=.3/s,l=0,p=0,c={type:"group",rotation:r=r||0,rotationOrigin:[t,e],children:[]},d=0;d<s;d++)n=["M",t+l,e+u],o=["L",t+p,e],c.children.push({type:"path",segments:[n,o]}),l+=h,p+=a;for(t+=l,l=0,p=0,d=0;d<s;d++)n=["M",t,e+u+l],o=["L",t+u,e+p],c.children.push({type:"path",segments:[n,o]}),l+=h,p+=a;return c}(...t.data)))}));else if("spiral"===h){var b,P,w,E,T,C,I;w=(P=(b=t.w)-u)+u/2,I=(E=t.l/w)/v,E>2*Math.PI&&(E=2*Math.PI-.01),T=[Math.sin(E)*b,Math.cos(E)*b-b],C=[Math.sin(E)*P,Math.cos(E)*P-b];var S=E>Math.PI?1:0;if(m={type:"path",segments:[["M",0,0],["A",b,b,0,S,1,T[0],-T[1]],["L",C[0],-C[1]],["A",P,P,0,S,0,0,u],["Z"]],isContour:!0},o)for(var O=0,A=0;A<v&&!(O>=E);A++)T=[Math.sin(O)*b,Math.cos(O)*b-b],C=[Math.sin(O)*P,Math.cos(O)*P-b],_.push({type:"path",segments:[["M",T[0],-T[1]],["L",C[0],-C[1]]]}),O+=I}s&&(m={type:"group",position:[0,-t.w],children:[m,..._]});var M=["stairs"];(null==(r=t.class)?void 0:r.length)&&(M=M.concat(t.class));var L=[{type:"group",position:[n.x,n.z],rotation:n.ry,scale:[1,s?-1:1],children:[m]}];return s||L[0].children.push(..._),L},wall:function(t){return[{type:"rect",position:[0,"center"===t.controlLine?-t.w/2:"front"===t.controlLine?-t.w:0],width:t.l,height:t.w,isContour:!0}]}};function Qo(t={},e={},i={},r){return Ko[t.type]?Ko[t.type](t,e):$o[t.type]&&$o[t.type](t,e,i,r)}var $o={box:t=>es(t),curtain:t=>{for(var e,i,r,n=Math.min(Math.max(t.folds||10,Math.round(5*t.l)),Math.round(15*t.l)),o=.05,s=t.w,a=t.l/n,h=[],l=[],u=0,p=s/2,c=.025,d=t.id.replace(/-/gi,""),f=d.length,v=0;v<n;v++){i=c,r=p;var y=parseInt(d[v%f],16)/20;c=.025+y*o/2*(v%2==0?-1:1),p=s/2+y*s/2*(v%2==0?-1:1),e=u,u=a*(v+1),l.push([e,r]),h.push([e,i]),v===n-1&&(l.push([u,p]),h.push([u,c]))}var g=ts(l),m=ts(h.reverse());return m[0][0]="L",m.push(["Z"]),[{type:"path",isContour:!0,segments:[...g,...m]}]},railing:t=>es(t),floor:t=>es(t),door:(t,e)=>{var i=function(t,e){var i=[],r=t.doorType||"singleSwing",n=t.l,o=e.w,s=t.doorAngle;if(s<20&&(s=20),"singleSwing"===r){var a=s*Math.PI/180,h=Math.round(100*(n/2-n*Math.cos(a)))/100,l=Math.round(100*(n*Math.sin(a)+o/2))/100;i.push({type:"path",segments:[["M",-n/2,o/2],["A",n,n,0,0,0,h,l],["L",n/2,o/2]]})}else if("doubleSwing"===r){var u=s*Math.PI/180,p=n/2+n/2*-Math.cos(u),c=n/2*Math.sin(u);i.push({type:"path",segments:[["M",-n/2,o/2],["L",-p,c],["A",n/2,n/2,0,0,0,0,o/2]]}),i.push({type:"path",segments:[["M",0,o/2],["A",n/2,n/2,0,0,0,p,c],["L",n/2,o/2]]})}return i}(t,e);return[...i,...[{type:"rect",isContour:!0,position:[-t.l/2,-e.w/2],width:t.l,height:e.w}]]},window:(t,e)=>es(t,e),closet:t=>es(t),interior:(t,e,i,r)=>((r=r||t.src&&i.productContours[t.src.substring(1)])||(r=t.src&&i.productBoundingBoxes[t.src.substring(1)]),r?(r=r.sort(((t,e)=>gt(t)>gt(e)?-1:1)))&&r.length?[{type:"polygon",isContour:!0,points:r[0],holes:r.slice(1)}]:void 0:[{type:"circle",position:[0,0],r:.01}]),polyfloor:t=>[{type:"polygon",isContour:!0,points:t.polygon,holes:t.polygonHoles||[]}],polybox:t=>[{type:"polygon",isContour:!0,points:t.polygon}],"a:helper:spaceDivider":t=>[{type:"rect",isContour:!0,position:[0,-.02],height:.04,width:t.l}],floorplan:t=>[{type:"rect",position:[-t.l/2,-t.w/2],width:t.l,height:t.w}]},ts=(t=[],e=1)=>{var i=e,r=[];return t.forEach(((e,n)=>{var o=n<t.length-1?t[n+1]:[e[0],t[0][1]],s=[e[0]+(o[0]-e[0])/2,e[1]+(o[1]-e[1])/2];if(0===n)r.push(["M",ht(e[0]*i,3),ht(e[1]*i,3)]);else{var a=[ht(e[0]*i,3),ht(e[1]*i,3)],h=[ht(s[0]*i,3),ht(s[1]*i,3)];r.push(["Q",...a,...h])}})),r};function es(t={},e={}){var i=0,r=t.w;return"wall"===t.type&&(i="front"===t.controlLine?t.w:"center"===t.controlLine?t.w/2:0),"window"===t.type&&(r=e.w,i="front"===e.controlLine?e.w:"center"===e.controlLine?e.w/2:0),[{type:"polygon",isContour:!0,points:[[0,0-i],[t.l,0-i],[t.l,r-i],[0,r-i]]}]}function is(t,e){return rs.apply(this,arguments)}function rs(){return(rs=r((function*(t,e){if(e._promiseCache||(e._promiseCache=new ko),e._debugLoading||(e._debugLoading={}),t&&t.src){var i=t.src.substring(1);return e._productQueue[i]||(e._productQueue[i]={loadStage:0,nodes:[]}),e._productQueue[i].nodes.push(t),e.products[i]||(yield ls(i,e)),e.settings.hideElements.includes("interior")||ns(t,e),Promise.resolve()}}))).apply(this,arguments)}function ns(t,e){return os.apply(this,arguments)}function os(){return(os=r((function*(t,e){var i=t.src.substring(1),r=e.products[i];if(r){var n=Jo(t,e);if(hs(e,t),!e._textureQueue[n]){var s=o.api.staticProductThumb+"/"+n+".png";e._textureQueue[n]={productId:i,loadStage:0,nodes:[],textureUrl:s,applyFilter:!0},e.settings.theme.showAssetTextures&&e.emit("product-load-texture",{textureId:n,productData:r})}e._textureQueue[n].nodes.push(t),2!==e._textureQueue[n].loadStage?(e.productBoundingBoxes[i]||(e.productBoundingBoxes[i]=ss(r),e._productQueue[i].loadStage=2),2===e._productQueue[i].loadStage&&e.emit("product-load-stage",{node:t,args:{_loadStage:2}}),e.productContours[i]||as(r,e).then((()=>{var i,r;1===(null===(i=e._textureQueue[n])||void 0===i?void 0:i.loadStage)||null!==(r=e._textureQueue[n])&&void 0!==r&&r.error?e.emit("product-contour",n,e):e.settings.theme.showAssetTextures&&!e.settings.svgMode||e.emit("product-load-stage",{node:t,args:{_loadStage:3}})})),e._promiseCache._collectGarbage()):e.emit("product-load-stage",{node:t,args:{_loadStage:3,_textureId:n}})}}))).apply(this,arguments)}var ss=t=>{var e,i=t.boundingPoints;if(i)return e=[[i.min[0],i.min[2]],[i.min[0],i.max[2]],[i.max[0],i.max[2]],[i.max[0],i.min[2]]],t._loadStage=1,[e]},as=function(){var t=r((function*(t,e){var{productId:i}=t,r="fpe-pc1-"+i,n=e._promiseCache.get(r);if(n)return n;e._debugLoading[i]||(e._debugLoading[i]=0),e._debugLoading[i]++;var o=t.fileKey,s=function(t,e,i){var r,n,o=null==i||null===(r=i.settings)||void 0===r||null===(n=r.api)||void 0===n?void 0:n.productContourCacheAge,s=o||864e6;if(!t)return Promise.reject("product id missing");var a="fpe-dc2-"+t,h=i._promiseCache.get(a);if(h)return h;if("string"!=typeof e)return Promise.reject("fileKey not string");if(!e.includes("data3d.buffer")){var l=e.split("/")[e.split("/").length-1];return Promise.reject("unsupported geometry "+l)}var u=Wo(a,o).then((e=>e||c.product.outline(t).then((t=>(Ho(a,t,s),t))))).catch((t=>{console.warn(t)}));return i._promiseCache.add(a,u),u}(i,o,e).then((r=>{var n=r;e.productContours[i]=n,t._shapes=Qo({type:"interior"},null,e,n),e._productQueue[i].loadStage=3})).catch((()=>{}));return e._promiseCache.add(r,s),s}));return function(e,i){return t.apply(this,arguments)}}();function hs(t,e){if(e&&"interior"===e.type){var i=e.src&&e.src.substring(1);if(i){var r=Zo(e,t);r&&!t.products[i].materials.includes(r)&&t.products[i].materials.splice(0,0,r)}}}function ls(t,e){var i,r,n=null==e||null===(i=e.settings)||void 0===i||null===(r=i.api)||void 0===r?void 0:r.productDataCacheAge,s=n||864e5;if(!t)return Promise.reject("product id missing");var a="fpe-pr1-"+t,h=e._promiseCache.get(a);if(h)return h;var l=Wo(a,n).then((e=>e&&e.matColors?e:c.product.read(t).then((t=>(t.matColors={},t.colours&&t.colours.length&&t.colours.forEach((e=>{if(e.includes(":")){var i=e.split(":"),r=qo(i[1]);t.matColors[r]=i[2]}})),Ho(a,t,s),t))))).then((i=>(e.products[t]=function(t){if(t){var e,i,r,n=t.subCategories.includes("ceilingLight"),s=t.subCategories.includes("rug"),a=t.productResourceId,h=o.api.staticProductThumb+"/"+a+".png";return{preview:t.preview,manufacturer:t.manufacturer,productId:a,name:t.productDisplayName,fileKey:t.fileKey,tags:t.tags,categories:t.categories,subCategories:t.subCategories,boundingPoints:t.boundingPoints,boundingBox:t.boundingBox,texture:h,materials:[],matColors:t.matColors,colours:t.colours,order:(e=t,i={10:["ceilingLight","wallLight"],9:["modularMeetingRoom","phoneBooth"],8:["floorLamp","tableLamp","deskDivider","cushion","plant","officeSupply","tableware","decoration","laundry","electronics","kitchen","car"],7:["shelf","cabinet","wardrobe","storageCombination","outdoor","bicycle","people","sink"],6:["highTable","diningTable","conferenceTable","desk"],5:["sofa","armchair","loungeChair","ottoman","sideboard","pedestal"],4:["taskChair","diningChair","conferenceChair","stool","barStool","bench"],3:["shower"],2:["singleBed","doubleBed","daybed","toilet","bathtub"],1:["sideTable","coffeeTable","radiator","nightstand"],0:["rug"]},r=0,e.subCategories.forEach((t=>{Object.keys(i).forEach((e=>{i[e].includes(t)&&e>r&&(r=parseInt(e))}))})),1===r&&e.categories.includes("tables")&&e.boundingBox.height>.6&&(r=6),parseInt(r)),isCeilingLamp:n,isCarpet:s,createdAt:t.createdAt,updatedAt:t.updatedAt,link:t.link}}}(i),e._productQueue[t].loadStage=1,e.products[t]))).catch((t=>{console.warn(t.message)}));return e._promiseCache.add(a,l),l}var us=function(){var t=r((function*({node:t,event:e,args:i,state:r,options:n}){var o=null==n?void 0:n.interiorUpdate,s="add-child"===e||"remove-child"===e,a="set-materials"===e,h=r.active.reduce(((t,e)=>t.concat(e.findAll({type:"interior"}))),[]),l=[];if(o?l=r.scene.nodesByType.interior:s?l="add-child"===e?[i]:[]:a?l=[t]:r.active.length&&(l=h),l=l.filter((t=>"interior"===t.type)),(o||s||a)&&(yield Promise.all(l.map((t=>is(t,r).catch((t=>console.error(t))))))),l.forEach((t=>{var e=cs(t,r);if(e){ps(e,r);var i=r.resources.assets.findIndex((e=>e.id===t.id));i>-1?r.resources.assets[i]=e:r.resources.assets.push(e)}})),"remove-child"===e){var u=r.resources.assets.findIndex((t=>t.id===i.id));u>-1&&r.resources.assets.splice(u,1),ps({id:i.id},r)}return r.active.length&&hs(r,r.active[0]),r.emit("scene-loaded",!0),Promise.resolve(!0)}));return function(e){return t.apply(this,arguments)}}();function ps(t,e){if(null!=t&&t.id){var i=t.position&&function(t,e){for(var i,r=0;r<e.resources.spaces.length;r++){var n=e.resources.spaces[r];if(ft([t.x,t.z],n.polygons[0],n.polygons.slice(1))){i=n;break}}return i}(t.position,e);i&&!i.assets.includes(t.id)&&i.assets.push(t.id),e.resources.spaces.forEach((e=>{if(!i||e.id!==i.id){var r=e.assets.findIndex((e=>e===t.id));r>-1&&e.assets.splice(r,1)}}))}}function cs(t,e){if(t){var i=t.getWorldPosition(),r=t.src&&t.src.substring(1),n=e.products[r];if(n){var o=n.boundingPoints,s=o&&[[o.min[0],o.min[2]],[o.min[0],o.max[2]],[o.max[0],o.max[2]],[o.max[0],o.min[2]]];s=o&&kt(i,s);var a=o&<([s]);return{id:t.id,customId:t.customId,node:t,polygon:s,boundingBox:a,name:n.name,manufacturer:n.manufacturer,productId:r,tags:n.tags,categories:n.categories,subCategories:n.subCategories,dimensions:n.boundingBox,position:{x:i.x,y:i.y,z:i.z},rotation:i.ry}}console.error("no productData",r,t)}}var ds={actions:{},active:[],activeGroup:null,activeBb:{},products:{},productContours:{},productBoundingBoxes:{},resources:{spaces:[],assets:[]},computed:{connectedSpaces:[],facade:{},mergedSpace:{},relations:{walls:[],spaces:[]},snapPoints:[],wallContours:[]},listeners:{},schemaLoaded:new class{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}reset(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}},isSceneStructureLoaded:!1,sceneBBox:{},guide:null,schema:{},materials:[],isMobile:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),cursor:[0,0],snapCursor:null,windowPos:[0,0],lastSceneClick:[0,0],clickStart:[],history:[],viewportInFocus:!0,keyString:null,_productQueue:{},_textureQueue:{},_gfxNodes:{},_gfxLayers:{},viewbox:{},client:[],zoom:1,scale:100,key:"",shiftKey:!1,altKey:!1,ctrlKey:!1,isDragging:!1,isPanning:!1,isMeasuring:!1,isDrawingRectangle:!1,isDrawingPolygon:!1,editingRectangle:null,editingPolygon:null,dragElement:null,isCreatingElement:!1,editPolygon:!1,infoWindows:[],htmlMarkers:[],markerPins:[]};function fs(t,{format:e,fileName:i,quality:r}={}){if("svg"!==e){var n=new Image;n.src=t,n.onload=function(){var t=document.createElement("canvas");t.width=n.naturalWidth,t.height=n.naturalHeight;var o=t.getContext("2d");o.imageSmoothingEnabled=!1,o.drawImage(n,0,0),function(t,{format:e="png",fileName:i="floorplan",quality:r=.95}){var n=document.createElement("a");n.download=i+"."+e;var o="png"===e?[]:["image/jpeg",r];t.toBlob((function(t){n.href=URL.createObjectURL(t),n.click()}),...o)}(t,{format:e,fileName:i,quality:r})}}}function vs(t,i,r,n){if((i.length||null!=n&&n.forceUpdate)&&(null==n||!n.skipHistory)){var o=r.resources.spaces,s={};o.forEach((t=>{r._debugSpaceMatching&&t.node.setHighlight(),s[t.id]=t}));var a=0,h=0,l=0,u=0,p=r.getActiveLevel(),c=null==n?void 0:n.actionId;return t.forEach((t=>{var i,n,l,d;t.holes=t.holes.filter((t=>gt(t)>.05)),t.center=Lt(t.boundary.shape,t.holes),t.polygons=[t.boundary.shape,...t.holes];for(var f=0;f<o.length;f++){var v=o[f];if(s[v.id]){if(wt(v.polygons,t.polygons)){n=v,delete s[v.id];break}var y=t.polygons.slice(1).filter((t=>gt(t)>1));if(0!==ft(v.center,t.polygons[0],y)){l=v,delete s[v.id];break}}if(0!==ft(t.center,v.polygons[0],v.polygons.slice(1))){d=v;break}}if(n)u++;else{var g=function(t,e){var i=e.getParents().reverse();i.push(e);var r=Object.assign({},t);return i.forEach((t=>Rt(r,t,!0))),r}({x:0,y:0,z:0,ry:0},p),m=kt(g,t.boundary.shape),{polygon:_,center:x}=St(m),b={polygon:_,polygonHoles:t.holes?t.holes.map((t=>St(kt(g,t),x).polygon)):[],x:x[0],z:x[1],ry:0};if(null!==(i=l)&&void 0!==i&&i.node)a++,l.node.set(b,{updateState:!1,actionId:c}),r._debugSpaceMatching&&l.node.setHighlight({fill:[255,240,180]});else{var P;h++,null!==(P=d)&&void 0!==P&&P.node?b=e(e({},d.node.toJson({regenerateIds:!0})),b):b.type="polyfloor";var w=p.addChild(b,{updateState:!1,actionId:c});r._debugSpaceMatching&&w.setHighlight({fill:[200,255,180]})}}})),Object.values(s).forEach((t=>{l++,p.removeChild(t.node,{updateState:!1,actionId:c})})),r._debugSpaceMatching&&console.log("matched",u,"transformed",a,"created",h,"deleted",l),a+h+l}}class ys{constructor({options:t}={}){var e=qn(ds);Object.keys(e).forEach((t=>this[t]=e[t])),this.settings={},this.updateSettings(t),this.changeOptions=t=>this.emit("change-options",t),this.scene=null,this._emitter=new H}initScene(t){var e,i;this._gfxNodes={},this.isSceneStructureLoaded=!1,this.scene||(this.scene=t),gs(this),this.isSceneStructureLoaded=!0,this.emit("state-loaded",!0),this.settings.theme.wallContours&&this.updateWallContours(),this.getSpaces(),this.computed.relations.walls=ze(this),(e=this,i=e.scene.nodesByType.interior,Promise.all(i.map((t=>is(t,e).catch((t=>console.error(t)))))).then((()=>{e.resources.assets=i.map((t=>cs(t,e))).filter((t=>t))}))).then((()=>{this.emit("scene-loaded",!0)})),this.settings.computeConnectedSpaces&&this.getConnectedSpaces()}on(t,e,i){t&&e?this._emitter.on(t,e,i):console.log("invalid event listener")}off(t,e,i){t&&e?this._emitter.off(t,e,i):console.log("invalid request")}once(t,e,i){t&&e?this._emitter.once(t,e,i):console.log("invalid event listener")}emit(t,e,i,r,n){this._emitter&&this._emitter.emit(t,e,i,r,n)}getActiveLevel(){return this.scene.nodesByType.level&&this.scene.nodesByType.level[0]}getScene(){return this.scene.node}getSceneBoundingBox(t=0){if(this.settings.svgMode){var i=this.scene.nodesByType.wall.map((t=>t.getWorldPosition())).map(Ft),r=this.scene.nodesByType.floor.map((t=>t.getWorldPosition())).map(Ft),n=this.scene.nodesByType.stairs.map((t=>t.getWorldPosition())).map(Ft),o=[...i,...this.resources.spaces.map((t=>t.polygons[0])),...this.resources.assets.map((t=>t.polygon)).filter((t=>t)),...r,...n].reduce(((t,e)=>t.concat(e)),[]),s={x:1/0,z:1/0,x2:-1/0,z2:-1/0};return o.forEach((t=>{t[0]<s.x&&(s.x=t[0]),t[0]>s.x2&&(s.x2=t[0]),t[1]<s.z&&(s.z=t[1]),t[1]>s.z2&&(s.z2=t[1])})),s.x-=t,s.z-=t,s.x2+=t,s.z2+=t,e(e({},s),{},{length:s.x2-s.x,width:s.z2-s.z})}var a=this._getViewport&&this._getViewport();if(a){var h=a.children.find((t=>t._sceneLayer));if(!h)return new Promise.resolve(!1);var{x:l,y:u,width:p,height:c}=h.getLocalBounds(),d={x:l/this.scale-t,z:u/this.scale-t,length:p/this.scale+2*t,width:c/this.scale+2*t};return d.x2=d.x+d.length,d.z2=d.z+d.width,d}}getElementBoundingBox(t,e=0){var i,r;if(t&&(t instanceof le?r=t.getWorldPosition():"string"==typeof t&&(r=(i=this.scene.nodesById[t].find({id:t}))&&i.getWorldPosition()),r)){var n;if("interior"===r.type&&r.src){var o=r.src.substring(1),s=this.productBoundingBoxes[o]||this.productContours[o];n=s&&kt(r,s[0])}else n="polyfloor"===r.type?kt(r,r.polygon):"group"!==r.type?Ft(r):[[r.x-2,r.z-2],[r.x+2,r.z-2],[r.x+2,r.z+2],[r.x-2,r.z+2]];var a=lt([n]);return{x:a.x-e,z:a.z-e,x2:a.x2+e,z2:a.z2+e,length:a.length+2*e,width:a.width+2*e}}}setBb(t,e=!1){var i=this.getElementBoundingBox(t,1,e);i&&(e?this.activeGroupBb={w:i.width,h:i.height,x:i.x,y:i.y}:this.activeBb={w:i.width,h:i.height,cx:i.cx,cy:i.cy})}setActive(t={}){Ne(e(e({},t),{},{state:this}))}updateSpaceRelations(){var t=this.resources.spaces.map((t=>{var i=e({},t),r=i.assets;return delete i.assets,e(e({},i),{},{interiors:r.map((t=>this.scene.nodesById[t]))})}));this.computed.relations.spaces=Jt({scene:this.scene,spaces:t}),this.emit("space-relations")}getConnectedSpaces(t){if(!this.settings.svgMode){var{connectedSpaces:e,facade:i}=function(t){var{spaces:e,holes:i,outline:r}=xe(t),n=e.map(((t,e)=>({boundary:{shape:t},holes:i[e]||[]})));return{connectedSpaces:n,facade:{boundary:{shape:r}}}}(this.scene);if(this.settings.updateFloors&&e.length&&this.resources.spaces)vs(e,this.computed.connectedSpaces,this,t)&&this.getSpaces();this.updateSpaceRelations(),this.computed.connectedSpaces=e,this.computed.facade=i;var r=this.computed.facade.boundary.shape,{openings:n}=Vt({polygons:[r],scene:this.scene});this.computed.facade.boundary.openings=n,e.length&&(ms({state:this}),this.settings.computeMergedSpace&&this.computeMergedSpace(this.scene))}}getSpaces(t=!1){var i=_e({scene:this.scene});this.resources.spaces=i.map((t=>{var i=t.interiors;return delete t.interiors,e(e({},t),{},{assets:i.map((t=>t.id))})})),ms({state:this},t);var r=this._getViewport&&this._getViewport();r&&r._updateRoomStamps&&r._updateRoomStamps()}computeMergedSpace(t){var e=function(t){var{spaces:e,holes:i,outline:r}=xe(t),n=t.nodesByType.door.map((t=>{var e=t.getWorldPosition();return e.w=t.parent.w,e})),o=t.nodesByType.window.map((t=>{var e=t.getWorldPosition();return e.w=t.parent.w,e})).filter((t=>{var e;return null==(e=t.class)?void 0:e.includes("slidingDoor")})),s=(n=[...n,...o]).map((t=>{var e=Ft(t);return Gt(e=pt([e],.05)[0])})),a=i.reduce(((t,e)=>t.concat(e)),[]),h=jt(a,e).reduce(((t,e)=>t.concat(e)),[]),l=a.length?ct(a,[...s,...h]):[],u=ut([...e,...s]),{counterClockwise:p,clockwise:c}=Yt(u);return{boundary:{shape:(p=p.sort(((t,e)=>{var i=gt(t),r=gt(e);return i>r?-1:i<r?1:0})))[0]},holes:[...l,...c],outline:r}}(t),i=[e.boundary.shape],{openings:r}=Vt({polygons:i,scene:t});e.boundary.openings=r,e.x=0,e.z=0,this.computed.mergedSpace=e}exportImage({format:t,fileName:e,quality:i,output:n,maxWidth:o,download:s=!1}={}){var a=this;return r((function*(){var r={format:t,quality:i,output:n,maxWidth:o};s&&"svg"!==t&&(r.format="png"),s&&"svg"===t&&(r.output="text");var h=yield function(t,{format:e="png",quality:i=.95}){return new Promise((r=>{var n=document.querySelector("#"+t.settings.editorId+" canvas");r("jpg"===e?n.toDataURL("image/jpeg",i):n.toDataURL())}))}(a,r).catch((t=>t));if(!s)return h;fs(h,{format:t,fileName:e,quality:i})}))()}getResourcesFromPosition(t){var e=this.resources.spaces.filter((e=>ft(t,e.polygons[0],e.polygons.slice(1)))),i=[];return e.forEach((e=>{var r=this.resources.assets.filter((t=>e.assets.includes(t.id))).filter((e=>{var i;if((null===(i=this.products[e.productId])||void 0===i||!i.isCeilingLamp||this.settings.showCeilingLamps)&&e.polygon&&e.polygon.length)return ft(t,e.polygon)}));i.push(...r)})),{spaces:e,assets:i}}rotatePlan({rotDelta:t,newRotation:i}){var r=this.scene.node.ry;void 0===i&&(i=(this.settings.planRotation+t)%360),this.updateSettings(e(e({},this.settings),{},{planRotation:i})),this.lastSceneClick=Te({points:[this.lastSceneClick],oldRotation:r,newRotation:i,rootNode:this.scene})[0],this.infoWindows=this.infoWindows.map((t=>{var n=Te({points:[t.pos],oldRotation:r,newRotation:i,rootNode:this.scene})[0];return e(e({},t),{},{pos:n})})),this.once("scene-rendered",(()=>this.zoomExtents(1,500)))}updateWallContours(){this.computed.wallContours=((t,e=!0,i=!1)=>{var r=t.nodesByType.column.map((t=>t.getWorldPosition())),n=[...t.nodesByType.wall.map((t=>t.getWorldPosition())),...r].map((t=>{var r=Ft(t);if(e&&(r=pt([r],.001)[0]),i)return[r];var n=Qt(t,"window"),o=Qt(t,"door"),s=n.concat(o);return(null==(s=s.map((e=>(e.w=t.w,e))))?void 0:s.length)?ct([r],s.map(Ft),.002):[r]})),o=n.reduce(((t,e)=>t.concat(e)),[]),s=o.length?ut(o):[],{counterClockwise:a,clockwise:h}=Yt(s),l=jt(a,h),u=a.map(((t,e)=>[t,...l[e]||[]]));return u})(this.scene),this.emit("wall-contours-computed",this.computed.wallContours)}updateSettings(t){var e,i,r,n,s,a=Mo(qn(o),t);if(null!=t&&t.selectAllowList&&(a.selectAllowList=[...t.selectAllowList]),this.settings=a,null!==(e=this.settings)&&void 0!==e&&null!==(i=e.theme)&&void 0!==i&&null!==(r=i.elements)&&void 0!==r&&null!==(n=r.space)&&void 0!==n&&n.program){var h=this.settings.theme.elements.space.program,l={wash:"care",operate:"support",common:"socialize"};Object.keys(h).forEach((t=>{Object.keys(l).includes(t)&&(h[l[t]]=h[t],delete h[t])}))}this.scene&&this.scene.node&&(!a.theme.wallContours||null!==(s=this.computed.wallContours)&&void 0!==s&&s.length||this.updateWallContours(),this.scene.node.ry!==a.planRotation&&Number.isFinite(a.planRotation)&&(this.scene.node.set({ry:parseFloat(a.planRotation)}),this.updateState(),this.computed.wallContours&&this.updateWallContours()),a.computeConnectedSpaces&&!this.computed.connectedSpaces.length&&this.getConnectedSpaces(),this.getSpaces());return this._redrawScene&&this._redrawScene(),this.emit("update-settings",this.settings),this.settings}updateState({node:t,args:e={},options:i={},event:n}={}){var o=this;return r((function*(){var r=!t&&!n,s="add-child"===n||"remove-child"===n,a="set-materials"===n||e.materials,h=null==t?void 0:t.type,l="plan"===h||"level"===h,u=!(!1===i.updateState)&&(r||!0===i.updateState||s||a||l),p=null==e?void 0:e.type,c=["wall","column","a:helper:spaceDivider"],d=c.includes(h)||c.includes(p);if(u&&(r||o.isSceneStructureLoaded)){var f=0,v=0;for(var y in e)if(f++,"_isSelected"===y)v++;if(!f||f!==v){var g="interior"===p||"interior"===h||"group"===h||i.interiorUpdate;gs(o),g?yield us({node:t,event:n,args:e,options:i,state:o}):["floor","polyfloor"].includes(h)?o.getSpaces():d?(o.settings.computeConnectedSpaces&&o.getConnectedSpaces(i),o.computed.relations.walls=ze(o)):h&&"level"!==h&&"plan"!==h||("plan"===h&&o.scene.setSceneType(o.scene),s||!o.settings.computeConnectedSpaces||o.computed.connectedSpaces.length||o.getConnectedSpaces(i),o.getSpaces(),o.computed.relations.walls=ze(o)),o.emit("state-updated",{})}}}))()}destroy(){var t;this._emitter.off(),null===(t=this.scene)||void 0===t||t._emitter.off(),this.scene=null,this._emitter=null,this.computed=null}}var gs=function(t,e,i){var r=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return ui(i)&&(r="leading"in i?!!i.leading:r,n="trailing"in i?!!i.trailing:n),Eo(t,e,{leading:r,maxWait:e,trailing:n})}((function(t){var e=t.getSceneBoundingBox();e&&e.x&&(t.sceneBBox=e)}),200),ms=({state:t},e)=>{var i=[],r=[];if(t.settings.snapWallContours){var n=t.computed.connectedSpaces.reduce(((t,e)=>t.concat([e.boundary.shape,...e.holes])),[]);t.computed.facade.boundary&&n.push(t.computed.facade.boundary.shape),i=n.reduce(((t,e)=>t.concat(e)),[])}if(t.settings.snapSpaces){var o=!!t.active.length&&t.active[0].id;r=(e?t.resources.spaces:t.resources.spaces.filter((t=>t.id!==o))).reduce(((t,e)=>t.concat(e.polygons)),[]).reduce(((t,e)=>t.concat(e)),[])}t.computed.snapPoints=[...i,...r]},_s=t=>{var e=3.28084,i=t*e,r=Math.sign(t),n=t>0?Math.floor(t*e):Math.ceil(t*e),o=Math.round(39.3701*t%12);return 12===o&&(n+=1,o=0),{feet:i,feetInt:n,inchInt:o,inchDisplay:o*r}},xs=t=>({sqft:10.7639111056*t}),bs=t=>t/180*Math.PI;class Ps{constructor(t,e){t&&e&&(this.data={cursor:[0,0]},this._state=e,this._state.on("mousemove",this.update,this),this.mount(t),this.update())}update(){if(this.rootEl){var t=[0,0];if("imperial"===this._state.settings.units.system){var{feetInt:e,inchDisplay:i}=_s(this._state.cursor[0]),{feetInt:r,inchDisplay:n}=_s(this._state.cursor[1]);t=["".concat(e,"′ ").concat(i,"″"),"".concat(r,"′ ").concat(n,"″")]}else t=[this._state.cursor[0].toFixed(2),this._state.cursor[1].toFixed(2)];this.setData({cursor:t})}}setData(t={}){for(var e in t)this.data[e]=t[e];this.rootEl.innerHTML=this.template(this.data)}template(t={}){return'<span class="fpe-coordinates__unit">x:'.concat(t.cursor[0],'</span>\n <span class="fpe-coordinates__unit">z:').concat(t.cursor[1],"</span>")}mount(t){this.rootEl||(this.rootEl=document.createElement("div"),this.rootEl.classList.add("fpe-coordinates"),t.appendChild(this.rootEl))}destroy(){this._state.off("mousemove",this.update),delete this._state._cursorCoordinates,this.rootEl.remove(),delete this._state,delete this.data}}var ws=100,Es=80;class Ts{constructor({width:t,height:e,pos:i=[0,0],html:r="",closeButton:n=!0,floorPlan:o}={}){this._floorPlan=o,this.pos=i,this.html=r,this.closeButton=n,this._anchorPos=null;var s=t||ws;this.width=Math.max(100,s);var a=e||Es;this.height=Math.max(50,a),this._getPosition=()=>{this._anchorPos=this._floorPlan.state.getScreenPosition(this.pos),this._updateInfoWindow()},this._getPosition(),this._createInfoWindow(),this._floorPlan.on("viewbox",this._getPosition,this),this._floorPlan.on("resize-canvas",this._getPosition,this)}_createInfoWindow(){var t=document.querySelector("#".concat(this._floorPlan.state.settings.editorId,".fpe")),e=t.querySelector("canvas");this.el||(this.el=document.createElement("div"),this.el.classList.add("fpe-info-window"),t.appendChild(this.el),this.el.addEventListener("wheel",(t=>{var i=new WheelEvent(t.type,t);e.dispatchEvent(i)}))),this._setContent(),this._updateInfoWindow()}_setContent(){var t='<div class="fpe-info-window__content">'.concat(this.html,"</div>");this.closeButton&&(t+='<div class="fpe-info-window__close" @click="infoWindow.remove">'.concat('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">\n <g fill="none" stroke="#000" stroke-width="1.2" stroke-miterlimit="10">\n <path d="M11.8 11.8l16.4 16.4M11.8 28.2l16.3-16.4" />\n </g>\n</svg>',"</div>")),this.el.innerHTML=t;var e=this.el.querySelector(".fpe-info-window__close");e&&e.addEventListener("click",this.remove.bind(this))}_updateInfoWindow(){if(this.el){var t=this._floorPlan.state.isPanning?"pointer-events: none;":"",e=this._anchorPos[0]-47,i=this._anchorPos[1]-this.height-15,r=1e3+2*this.pos[1],n=this.height,o=this.width;this.el.setAttribute("style","transform: translate(".concat(e,"px, ").concat(i,"px);").concat(t," height:").concat(n,"px; width:").concat(o,"px; z-index:").concat(r))}}set({width:t,height:e,pos:i,html:r,closeButton:n}){void 0!==i&&(this.pos=i),void 0!==t&&(this.width=Math.max(100,t)),void 0!==e&&(this.height=Math.max(50,e)),void 0!==r&&(this.html=r),void 0!==n&&(this.closeButton=n),void 0===r&&void 0===n||this._setContent(),this._getPosition()}remove(){this._floorPlan.off("viewbox",this._getPosition),this._floorPlan.off("resize-canvas",this._getPosition),this.el.remove(),this._floorPlan=null}}class Cs{constructor({pos:t=[0,0],offset:e=[0,0],el:i,floorPlan:r}){if(n(this,"_updateHtmlMarker",(()=>{this.el&&(this.isHidden=!(([t,e],i,r=0)=>i.x-r<t&&i.x+i.length+r>t&&i.z-r<e&&i.z+i.width+r>e)(this.pos,this._floorPlan.state.viewbox,5),this.el.classList.toggle("fpe-marker--hidden",this.isHidden),this.isHidden||(this._anchorPos=this._floorPlan.getScreenPosition(this.pos),this._updateHtmlMarkerStyle()))})),r)if(i instanceof Element!=!1){this.el=i;var o=document.querySelector("#".concat(r.state.settings.editorId,".fpe")),s=o.querySelector("canvas");o.appendChild(this.el),this.el.classList.add("fpe-marker");var{width:a,height:h}=i.getBoundingClientRect();this.el.addEventListener("wheel",(t=>{var e=new WheelEvent(t.type,t);s.dispatchEvent(e)})),this.id=j(),this._floorPlan=r,this.pos=t,this.size=[a,h],this.offset=e,this._updateHtmlMarker(),this._floorPlan.on("viewbox",this._updateHtmlMarker),this._floorPlan.on("drag-end",this._updateHtmlMarker),this._floorPlan.on("resize-canvas",this._updateHtmlMarker)}else console.warn("no Element provided")}_updateHtmlMarkerStyle(){var t=this._floorPlan.state.isPanning?"pointer-events: none":"",e=this.offset?this.offset:[0,0],i=this._anchorPos[0]-this.size[0]/2+e[0],r=this._anchorPos[1]-this.size[1]/2+e[1];this.el.setAttribute("style","transform: translate(".concat(i,"px, ").concat(r,"px);").concat(t))}set({pos:t,offset:e}){void 0!==t&&(this.pos=t),void 0!==e&&(this.offset=e),this._updateHtmlMarker()}remove(){this._floorPlan.off("viewbox",this._updateHtmlMarker),this._floorPlan.off("resize-canvas",this._updateHtmlMarker),this._floorPlan.off("drag-end",this._updateHtmlMarker),this.el.remove(),this._floorPlan=null}}var Is,Ss,Os,As,Ms,Ls,Ns,Rs,Ds,Fs,ks,Bs,Us,zs,Xs,js,Ys,Hs,Gs,Ws=(t,e,i=[0,0],r=.15)=>{for(var n,o,s,a,h=0;h<e.length;h++)if(n=e[h],!((o=Math.abs(t[0]-i[0]-n[0]))>r)&&(s=Math.abs(t[1]-i[1]-n[1]),o<r&&s<r)){a=n;break}return a},Vs=(t,e,i=.15)=>{for(var r,n=0;n<e.length;n++){var o=e[n][0],s=e[n][1],a=[Math.min(o[0],s[0]),Math.min(o[1],s[1])],h=[Math.max(o[0],s[0]),Math.max(o[1],s[1])],l=t[0]>a[0]-i&&t[0]<h[0]+i,u=t[1]>a[1]-i&&t[1]<h[1]+i;if(l&&u){var p={x:o[0]-s[0],z:o[1]-s[1]},c={x:p.z,z:-p.x},d={x:t[0],z:t[1]},f=tt({x:o[0],z:o[1]},{x:s[0],z:s[1]},d,it(d,c));if(Z(d,f)<=i){r=[f.x,f.z];break}}}return r},qs=({point:t,walls:e,offset:i=[0,0],margin:r=.15,node:n,isWallChild:o})=>{var s,a,h,l=o,u=o;o&&n&&n.parent&&(e=e.filter((t=>t.node.id===n.parent.id)),r=20);for(var p=0;p<e.length;p++){var c=e[p].points;if(s=!l&&Ws(t,c,i,r)){h={point:s,node:e[p].node};break}var d=[[c[0],c[1]],[c[2],c[3]]];if(a=Vs(t,d,r)){h={point:a,node:e[p].node,isEdge:!0};break}}if(!h&&!u){var f=((t,e,i,r=.15)=>{for(var n,o,s,a=[],h=0;h<e.length;h++)n=e[h],o=Math.abs(t[0]-i[0]-n[0]),s=Math.abs(t[1]-i[1]-n[1]),o<r&&s<10?a.push({distance:s,point:[n[0],t[1]],refPoint:n}):o<10&&s<r&&a.push({distance:o,point:[t[0],n[1]],refPoint:n});return a.sort(((t,e)=>t.distance-e.distance))})(t,e.reduce(((t,e)=>t.concat(e.points)),[]),i,r);f.length&&(h=f[0])}return h};!function(t){t[t.WEBGL_LEGACY=0]="WEBGL_LEGACY",t[t.WEBGL=1]="WEBGL",t[t.WEBGL2=2]="WEBGL2"}(Is||(Is={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.WEBGL=1]="WEBGL",t[t.CANVAS=2]="CANVAS"}(Ss||(Ss={})),function(t){t[t.COLOR=16384]="COLOR",t[t.DEPTH=256]="DEPTH",t[t.STENCIL=1024]="STENCIL"}(Os||(Os={})),function(t){t[t.NORMAL=0]="NORMAL",t[t.ADD=1]="ADD",t[t.MULTIPLY=2]="MULTIPLY",t[t.SCREEN=3]="SCREEN",t[t.OVERLAY=4]="OVERLAY",t[t.DARKEN=5]="DARKEN",t[t.LIGHTEN=6]="LIGHTEN",t[t.COLOR_DODGE=7]="COLOR_DODGE",t[t.COLOR_BURN=8]="COLOR_BURN",t[t.HARD_LIGHT=9]="HARD_LIGHT",t[t.SOFT_LIGHT=10]="SOFT_LIGHT",t[t.DIFFERENCE=11]="DIFFERENCE",t[t.EXCLUSION=12]="EXCLUSION",t[t.HUE=13]="HUE",t[t.SATURATION=14]="SATURATION",t[t.COLOR=15]="COLOR",t[t.LUMINOSITY=16]="LUMINOSITY",t[t.NORMAL_NPM=17]="NORMAL_NPM",t[t.ADD_NPM=18]="ADD_NPM",t[t.SCREEN_NPM=19]="SCREEN_NPM",t[t.NONE=20]="NONE",t[t.SRC_OVER=0]="SRC_OVER",t[t.SRC_IN=21]="SRC_IN",t[t.SRC_OUT=22]="SRC_OUT",t[t.SRC_ATOP=23]="SRC_ATOP",t[t.DST_OVER=24]="DST_OVER",t[t.DST_IN=25]="DST_IN",t[t.DST_OUT=26]="DST_OUT",t[t.DST_ATOP=27]="DST_ATOP",t[t.ERASE=26]="ERASE",t[t.SUBTRACT=28]="SUBTRACT",t[t.XOR=29]="XOR"}(As||(As={})),function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(Ms||(Ms={})),function(t){t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL"}(Ls||(Ls={})),function(t){t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z"}(Ns||(Ns={})),function(t){t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT"}(Rs||(Rs={})),function(t){t[t.FLOAT=0]="FLOAT",t[t.INT=1]="INT",t[t.UINT=2]="UINT"}(Ds||(Ds={})),function(t){t[t.NEAREST=0]="NEAREST",t[t.LINEAR=1]="LINEAR"}(Fs||(Fs={})),function(t){t[t.CLAMP=33071]="CLAMP",t[t.REPEAT=10497]="REPEAT",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(ks||(ks={})),function(t){t[t.OFF=0]="OFF",t[t.POW2=1]="POW2",t[t.ON=2]="ON",t[t.ON_MANUAL=3]="ON_MANUAL"}(Bs||(Bs={})),function(t){t[t.NPM=0]="NPM",t[t.UNPACK=1]="UNPACK",t[t.PMA=2]="PMA",t[t.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",t[t.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",t[t.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA"}(Us||(Us={})),function(t){t[t.NO=0]="NO",t[t.YES=1]="YES",t[t.AUTO=2]="AUTO",t[t.BLEND=0]="BLEND",t[t.CLEAR=1]="CLEAR",t[t.BLIT=2]="BLIT"}(zs||(zs={})),function(t){t[t.AUTO=0]="AUTO",t[t.MANUAL=1]="MANUAL"}(Xs||(Xs={})),function(t){t.LOW="lowp",t.MEDIUM="mediump",t.HIGH="highp"}(js||(js={})),function(t){t[t.NONE=0]="NONE",t[t.SCISSOR=1]="SCISSOR",t[t.STENCIL=2]="STENCIL",t[t.SPRITE=3]="SPRITE"}(Ys||(Ys={})),function(t){t[t.NONE=0]="NONE",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=8]="HIGH"}(Hs||(Hs={})),function(t){t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER"}(Gs||(Gs={}));
|
|
9
9
|
/*!
|
|
10
10
|
* @pixi/math - v6.1.3
|
|
11
11
|
* Compiled Mon, 13 Sep 2021 15:29:31 UTC
|