1
0
mirror of synced 2024-11-16 20:13:50 +00:00
CuttingBoard/docs/js/app.9efdd4b6.js

2 lines
23 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(t){function e(e){for(var n,i,s=e[0],c=e[1],l=e[2],u=0,h=[];u<s.length;u++)i=s[u],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&h.push(o[i][0]),o[i]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(t[n]=c[n]);d&&d(e);while(h.length)h.shift()();return a.push.apply(a,l||[]),r()}function r(){for(var t,e=0;e<a.length;e++){for(var r=a[e],n=!0,s=1;s<r.length;s++){var c=r[s];0!==o[c]&&(n=!1)}n&&(a.splice(e--,1),t=i(i.s=r[0]))}return t}var n={},o={app:0},a=[];function i(e){if(n[e])return n[e].exports;var r=n[e]={i:e,l:!1,exports:{}};return t[e].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=t,i.c=n,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="";var s=window["webpackJsonp"]=window["webpackJsonp"]||[],c=s.push.bind(s);s.push=e,s=s.slice();for(var l=0;l<s.length;l++)e(s[l]);var d=c;a.push([0,"chunk-vendors"]),r()})({0:function(t,e,r){t.exports=r("56d7")},"3c4e":function(t,e,r){},"4c86":function(t,e,r){},"56d7":function(t,e,r){"use strict";r.r(e);r("e260"),r("e6cf"),r("cca6"),r("a79d");var n=r("7a23"),o={class:"app-settings"},a=Object(n["f"])("h1",null,"Settings",-1),i=Object(n["f"])("h1",null,"Layers",-1),s=Object(n["f"])("h1",null,"Wood types",-1),c=Object(n["f"])("h1",null,"Save / load",-1),l={class:"loadSave block"},d=Object(n["f"])("p",null," Below you can download the current settings or load them again from a file. You can also bookmark the current page or copy the URL from the address bar instead, as it is automatically updated whenever you change anything. ",-1),u={type:"file",ref:"loadFile",accept:".json"},h=Object(n["f"])("h1",null,"About / feedback",-1),f=Object(n["f"])("div",{class:"about block"},[Object(n["f"])("p",null,[Object(n["e"])(" Created by Mark van Renswoude. Open-source and available under the Unlicense to the public domain on "),Object(n["f"])("a",{href:"https://github.com/MvRens/CuttingBoard",target:"_blank"},"Github"),Object(n["e"])(", where feedback is welcome under Issues. ")]),Object(n["f"])("p",null,[Object(n["e"])(" Heavily inspired by "),Object(n["f"])("a",{href:"http://www.lastalias.com/cbdesigner/"},"CBdesigner"),Object(n["e"])(". ")])],-1),b={class:"app-preview"},g=Object(n["f"])("h1",null,"Edge grain",-1),p=Object(n["f"])("h1",null,"End grain",-1);function m(t,e,r,m,v,O){var j=Object(n["m"])("Settings"),y=Object(n["m"])("Layers"),w=Object(n["m"])("Wood"),x=Object(n["m"])("EdgeGrainPreview"),P=Object(n["m"])("EndGrainPreview");return Object(n["h"])(),Object(n["c"])(n["a"],null,[Object(n["f"])("div",o,[a,Object(n["f"])(j,{class:"block"}),i,Object(n["f"])(y,{class:"block"}),s,Object(n["f"])(w,{class:"block"}),c,Object(n["f"])("div",l,[d,Object(n["f"])("p",null,[Object(n["r"])(Object(n["f"])("input",{type:"text","onUpdate:modelValue":e[1]||(e[1]=function(t){return v.saveFilename=t})},null,512),[[n["p"],v.saveFilename]]),Object(n["f"])("button",{onClick:e[2]||(e[2]=function(t){return O.save()})},"Save")]),Object(n["f"])("p",null,[Object(n["f"])("input",u,null,512),Object(n["f"])("button",{onClick:e[3]||(e[3]=function(t){return O.load()})},"Load")])]),h,f]),Object(n["f"])("div",b,[g,Object(n["f"])(x,{scale:1}),p,Object(n["f"])(P,{scale:1})])],64)}r("b0c0"),r("8a79");var v=Object(n["t"])("data-v-7f9fc5e0");Object(n["j"])("data-v-7f9fc5e0");var O={class:"settings"},j=Object(n["f"])("h2",null,"Designer",-1),y=Object(n["f"])("label",{for:"units"},"Units",-1),w=Object(n["f"])("option",{value:"mm"},"Millimeters",-1),x=Object(n["f"])("option",{value:"cm"},"Centimeters",-1),P=Object(n["f"])("option",{value:"inchdecimal"},"Inches (decimal)",-1),k=Object(n["f"])("label",{for:"borders"},"Show borders",-1),L=Object(n["f"])("h2",null,"Material",-1),W=Object(n["f"])("label",{for:"boardThickness"},"Board thickness",-1),T=Object(n["f"])("label",{for:"boardLength"},"Board length",-1),$=Object(n["f"])("label",{for:"bladeKerf"},"Blade kerf",-1),M=Object(n["f"])("h2",null,"End grain",-1),C=Object(n["f"])("label",{for:"crosscutWidth"},"Crosscut width",-1),S=Object(n["f"])("label",{for:"alternateDirection"},"Alternate direction",-1);Object(n["i"])();var D=v((function(t,e,r,o,a,i){return Object(n["h"])(),Object(n["c"])("div",O,[j,y,Object(n["f"])("select",{id:"units",value:i.settings.units,onChange:e[1]||(e[1]=function(e){return t.$store.commit("updateSettings",{units:e.target.value})})},[w,x,P],40,["value"]),k,Object(n["f"])("input",{id:"borders",type:"checkbox",checked:i.settings.borders,onChange:e[2]||(e[2]=function(e){return t.$store.commit("updateSettings",{borders:e.target.checked})})},null,40,["checked"]),L,W,Object(n["f"])("input",{id:"boardThickness",type:"number",value:i.settings.boardThickness,onChange:e[3]||(e[3]=function(e){return t.$store.commit("updateSettings",{boardThickness:i.parseFloatDef(e.target.value)})})},null,40,["value"]),T,Object(n["f"])("input",{id:"boardLength",type:"number",value:i.settings.boardLength,onChange:e[4]||(e[4]=function(e){return t.$store.commit("updateSettings",{boardLength:i.parseFloatDef(e.target.value)})})},null,40,["value"]),$,Object(n["f"])("input",{id:"bladeKerf",type:"number",value:i.settings.bladeKerf,onChange:e[5]||(e[5]=function(e){return t.$store.commit("updateSettings",{bladeKerf:i.parseFloatDef(e.target.value)})})},null,40,["value"]),M,C,Object(n["f"])("input",{id:"crosscutWidth",type:"number",value:i.settings.crosscutWidth,onChange:e[6]||(e[6]=function(e){return t.$store.commit("updateSettings",{crosscutWidth:i.parseFloatDef(e.target.value)})})},null,40,["value"]),S,Object(n["f"])("input",{id:"alternateDirection",type:"checkbox",checked:i.settings.alternateDirection,onChange:e[7]||(e[7]=function(e){return t.$store.commit("updateSettings",{alternateDirection:e.target.checked})})},null,40,["checked"])])})),E=(r("2b19"),25.4),B=10,F=1,H={convert:function(t,e,r){var n=this.toMillimeters(t,e);return this.fromMillimeters(n,r)},toPixels:function(t,e){return Math.ceil(this.toMillimeters(t,e)*F)},toMillimeters:function(t,e){switch(e){case"mm":return t;case"cm":return t*B;case"inchdecimal":return t*E}return console.error("Invalid units type: "+e),0},fromMillimeters:function(t,e){switch(e){case"mm":return t;case"cm":return t/B;case"inchdecimal":return t/E}return console.error("Invalid units type: "+e),0},display:function(t,e){var r=this.limitDecimals(t,3);switch(e){case"mm":return r+" mm";case"cm":return r+" cm";case"inchdecimal":return r+" inch"}return console.error("Invalid units type: "+e),r},limitDecimals:function(t,e){var r=Math.pow(10,e);return Math.round(t*r)/r}},I={computed:{settings:function(){return this.$store.state.settings}},methods:{parseFloatDef:function(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e}}};r("83e0");I.render=D,I.__scopeId="data-v-7f9fc5e0";var U=I,A=Object(n["t"])("data-v-631d833e");Object(n["j"])("data-v-631d833e");var _={class:"layers"},N={class:"add"},R=Object(n["d"])('<div class="hint" data-v-631d833e> Tip: click and drag the layer number to move a layer </div><span class="header" data-v-631d833e> </span><span class="header" data-v-631d833e>Wood type</span><span class="header" data-v-631d833e>Width</span><span class="header" data-v-631d833e> </span>',5),K={class:"remove"};Object(n["i"])();var V=A((function(t,e,r,o,a,i){return Object(n["h"])(),Object(n["c"])("div",_,[Object(n["f"])("div",N,[Object(n["f"])("button",{onClick:e[1]||(e[1]=function(t){return i.addLayer()})},"Add layer")]),R,(Object(n["h"])(!0),Object(n["c"])(n["a"],null,Object(n["l"])(i.layers,(function(t,e){return Object(n["h"])(),Object(n["c"])(n["a"],null,[Object(n["f"])("div",{class:["index",{dropTargetAbove:a.dropTarget===e,dropTargetBelow:a.dropTarget===i.layers.length&&e===i.layers.length-1}],ref:"layer"+e,onMousedown:Object(n["s"])((function(t){return i.startDrag(e)}),["prevent"])},Object(n["n"])(e+1),43,["onMousedown"]),Object(n["r"])(Object(n["f"])("select",{"onUpdate:modelValue":function(e){return t.wood=e},class:"wood"},[(Object(n["h"])(!0),Object(n["c"])(n["a"],null,Object(n["l"])(i.wood,(function(t,e){return Object(n["h"])(),Object(n["c"])("option",{value:e},Object(n["n"])(t.name),9,["value"])})),256))],8,["onUpdate:modelValue"]),[[n["o"],t.wood]]),Object(n["f"])("input",{type:"number",class:"width",value:t.width,onInput:function(e){return t.width=i.parseFloatDef(e.target.value)}},null,40,["value","onInput"]),Object(n["f"])("div",K,[Object(n["f"])("button",{onClick:function(t){return i.removeLayer(e)}},"X",8,["onClick"])])],64)})),256))])})),G={data:function(){return{dragIndex:null,dropTarget:null}},computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers}},methods:{parseFloatDef:function(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e},addLayer:function(){this.$store.commit("addLayer",0)},removeLayer:function(t){this.$store.commit("removeLayer",{board:0,layer:t})},startDrag:function(t){var e=this;this.dragIndex=t,this.dropTarget=t;var r,n=function(t){e.dropTarget=e.getTargetLayer(t.pageY)};r=function(){document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),e.dragIndex!==e.dropTarget&&e.$store.commit("moveLayer",{board:0,from:e.dragIndex,to:e.dropTarget}),e.dropTarget=null,e.dragIndex=null},document.addEventListener("mousemove",n),document.addEventListener("mouseup",r)},getTargetLayer:function(t){if(0==this.layers.length)return null;var e=this.getPageOffsetRect(this.$refs.layer0),r=this.getPageOffsetRect(this.$refs["layer"+(this.layers.length-1)]);if(t<=e.bottom)return 0;if(t>=r.bottom)return this.layers.length;if(t>=r.top)return this.layers.length-1;if(null!==this.dropTarget&&this.dropTarget>0&&this.dropTarget<this.layers.length-1){var n=this.getPageOffsetRect(this.$refs["layer"+this.dropTarget]);if(t>=n.top&&t<n.bottom)return this.dropTarget}for(var o=1;o<this.layers.length-1;o++){var a=this.getPageOffsetRect(this.$refs["layer"+o]);if(t>=a.top&&t<a.bottom)return o}return null},getPageOffsetRect:function(t){var e=t.getBoundingClientRect(),r=window.pageXOffset||document.documentElement.scrollLeft,n=window.pageYOffset||document.documentElement.scrollTop;return{top:e.top+n,left:e.left+r,right:e.right+r,bottom:e.bottom+n}}}};r("e40c");G.render=V,G.__scopeId="data-v-631d833e";var J=G,Y=Object(n["t"])("data-v-55181d8c");Object(n["j"])("data-v-55181d8c");var X={class:"wood"},z={class:"add"},q=Object(n["f"])("span",{class:"header"}," ",-1),Q=Object(n["f"])("span",{class:"header"},"Name",-1),Z=Object(n["f"])("span",{class:"header"},"Colour",-1),tt=Object(n["f"])("span",{class:"header"}," ",-1),et=Object(n["f"])("span",null," ",-1),rt={class:"remove"};Object(n["i"])();var nt=Y((function(t,e,r,o,a,i){return Object(n["h"])(),Object(n["c"])("div",X,[Object(n["f"])("div",z,[Object(n["f"])("button",{onClick:e[1]||(e[1]=function(t){return i.addWood()})},"Add wood type")]),q,Q,Z,tt,(Object(n["h"])(!0),Object(n["c"])(n["a"],null,Object(n["l"])(i.wood,(function(t,e){return Object(n["h"])(),Object(n["c"])(n["a"],null,[et,Object(n["r"])(Object(n["f"])("input",{type:"text",class:"name","onUpdate:modelValue":function(e){return t.name=e}},null,8,["onUpdate:modelValue"]),[[n["p"],t.name]]),Object(n["r"])(Object(n["f"])("input",{type:"color",class:"color","onUpdate:modelValue":function(e){return t.color=e}},null,8,["onUpdate:modelValue"]),[[n["p"],t.color]]),Object(n["f"])("div",rt,[Object(n["f"])("button",{onClick:function(t){return i.removeWood(e)}},"X",8,["onClick"])])],64)})),256))])})),ot={computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood}},methods:{addWood:function(){this.$store.commit("addWood")},removeWood:function(t){this.$store.commit("removeWood",t)}}};r("667a");ot.render=nt,ot.__scopeId="data-v-55181d8c";var at=ot,it={class:"preview"},st={class:"dimensions"},ct={id:"strip"};function lt(t,e,r,o,a,i){return Object(n["h"])(),Object(n["c"])("div",it,[Object(n["f"])("div",st,"Dimensions: "+Object(n["n"])(i.display(i.boardWidth))+" x "+Object(n["n"])(i.display(i.boardHeight))+" x "+Object(n["n"])(i.display(i.settings.crosscutWidth)),1),(Object(n["h"])(),Object(n["c"])("svg",{width:i.viewportWidth,height:i.viewportHeight,viewBox:i.viewBox},[Object(n["f"])("defs",null,[Object(n["f"])("g",ct,[(Object(n["h"])(!0),Object(n["c"])(n["a"],null,Object(n["l"])(i.layers,(function(t,e){return Object(n["h"])(),Object(n["c"])("rect",{width:i.toPixels(i.settings.boardThickness),height:i.toPixels(t.width),x:"0",y:i.getLayerOffset(e),style:i.getLayerStyle(e)},null,12,["width","height","y"])})),256))])]),(Object(n["h"])(!0),Object(n["c"])(n["a"],null,Object(n["l"])(i.stripsPerBoard,(function(t,e){return Object(n["h"])(),Object(n["c"])("use",{"xlink:href":"#strip",x:i.toPixels(e*i.settings.boardThickness),y:"0",transform:i.getLayerTransform(e)},null,8,["x","transform"])})),256))],8,["width","height","viewBox"]))])}r("d81d"),r("13d5"),r("a9e3");var dt={props:{scale:Number},computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers},stripsPerBoard:function(){var t=this.settings.crosscutWidth+this.settings.bladeKerf;return 0===t?0:Math.floor((this.settings.boardLength+this.settings.bladeKerf)/t)},boardWidth:function(){return this.stripsPerBoard*this.settings.boardThickness},boardHeight:function(){return 0==this.layers.length?0:this.layers.map((function(t){return t.width})).reduce((function(t,e){return t+e}))},boardPixelWidth:function(){return this.toPixels(this.boardWidth)},boardPixelHeight:function(){return this.toPixels(this.boardHeight)},viewportWidth:function(){return Math.floor(this.boardPixelWidth*this.scale)},viewportHeight:function(){return Math.floor(this.boardPixelHeight*this.scale)},viewBox:function(){return"0 0 "+this.boardPixelWidth+" "+this.boardPixelHeight}},methods:{toPixels:function(t){return H.toPixels(t,this.settings.units)},display:function(t){return H.display(t,this.settings.units)},getLayerOffset:function(t){if(t<0||t>=this.layers.length)return 0;for(var e=0,r=0;r<t;r++)e+=this.layers[r].width;return this.toPixels(e)},getLayerStyle:function(t){if(t<0||t>=this.layers.length)return"fill: fuchsia";var e=this.layers[t].wood;if(null===e)return"";var r=this.settings.borders?"; stroke-width: 1; stroke: black":"";return"fill: "+this.wood[e].color+r},getLayerTransform:function(t){return this.settings.alternateDirection&&t%2!=0?"scale(1, -1) translate(0, -"+this.boardPixelHeight+")":""}}};dt.render=lt;var ut=dt,ht={class:"preview"},ft={class:"dimensions"};function bt(t,e,r,o,a,i){return Object(n["h"])(),Object(n["c"])("div",ht,[Object(n["f"])("div",ft,"Dimensions: "+Object(n["n"])(i.display(i.boardWidth))+" x "+Object(n["n"])(i.display(i.boardHeight))+" x "+Object(n["n"])(i.display(i.settings.boardThickness)),1),(Object(n["h"])(),Object(n["c"])("svg",{width:i.viewportWidth,height:i.viewportHeight,viewBox:i.viewBox},[(Object(n["h"])(!0),Object(n["c"])(n["a"],null,Object(n["l"])(i.layers,(function(t,e){return Object(n["h"])(),Object(n["c"])("rect",{width:i.toPixels(i.settings.boardLength),height:i.toPixels(t.width),x:"0",y:i.getLayerOffset(e),style:i.getLayerStyle(e)},null,12,["width","height","y"])})),256))],8,["width","height","viewBox"]))])}var gt={props:{scale:Number},computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers},boardWidth:function(){return this.settings.boardLength},boardHeight:function(){return 0==this.layers.length?0:this.layers.map((function(t){return t.width})).reduce((function(t,e){return t+e}))},boardPixelWidth:function(){return this.toPixels(this.boardWidth)},boardPixelHeight:function(){return this.toPixels(this.boardHeight)},viewportWidth:function(){return Math.floor(this.boardPixelWidth*this.scale)},viewportHeight:function(){return Math.floor(this.boardPixelHeight*this.scale)},viewBox:function(){return"0 0 "+this.boardPixelWidth+" "+this.boardPixelHeight}},methods:{toPixels:function(t){return H.toPixels(t,this.settings.units)},display:function(t){return H.display(t,this.settings.units)},getLayerOffset:function(t){if(t<0||t>=this.layers.length)return 0;for(var e=0,r=0;r<t;r++)e+=this.layers[r].width;return this.toPixels(e)},getLayerStyle:function(t){if(t<0||t>=this.layers.length)return"fill: fuchsia";var e=this.layers[t].wood;if(null===e)return"";var r=this.settings.borders?"; stroke-width: 1; stroke: black":"";return"fill: "+this.wood[e].color+r}}};gt.render=bt;var pt=gt,mt=r("21a6"),vt=(r("c975"),r("d3b7"),r("5cc6"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"]),Ot=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function jt(t){if(t>=Ot.length)throw new Error("Unable to parse base64 string.");var e=Ot[t];if(255===e)throw new Error("Unable to parse base64 string.");return e}function yt(t){var e,r="",n=t.length;for(e=2;e<n;e+=3)r+=vt[t[e-2]>>2],r+=vt[(3&t[e-2])<<4|t[e-1]>>4],r+=vt[(15&t[e-1])<<2|t[e]>>6],r+=vt[63&t[e]];return e===n+1&&(r+=vt[t[e-2]>>2],r+=vt[(3&t[e-2])<<4],r+="=="),e===n&&(r+=vt[t[e-2]>>2],r+=vt[(3&t[e-2])<<4|t[e-1]>>4],r+=vt[(15&t[e-1])<<2],r+="="),r}function wt(t){if(t.length%4!==0)throw new Error("Unable to parse base64 string.");var e=t.indexOf("=");if(-1!==e&&e<t.length-2)throw new Error("Unable to parse base64 string.");for(var r,n=t.endsWith("==")?2:t.endsWith("=")?1:0,o=t.length,a=new Uint8Array(o/4*3),i=0,s=0;i<o;i+=4,s+=3)r=jt(t.charCodeAt(i))<<18|jt(t.charCodeAt(i+1))<<12|jt(t.charCodeAt(i+2))<<6|jt(t.charCodeAt(i+3)),a[s]=r>>16,a[s+1]=r>>8&255,a[s+2]=255&r;return a.subarray(0,a.length-n)}var xt={name:"App",components:{EndGrainPreview:ut,EdgeGrainPreview:pt,Settings:U,Layers:J,Wood:at},data:function(){return{saveFilename:"My cutting board"}},created:function(){var t=this,e=function(){if(location.hash){var e=location.hash.substring(1);try{var r=wt(e);r&&t.$store.commit("loadMsgPack",r)}catch(n){console.error(n)}}};e(),window.addEventListener("hashchange",(function(){e()}))},computed:{hash:function(){return yt(this.$store.getters.saveMsgPack)}},methods:{save:function(){var t=this.$store.getters.save,e=new Blob([t],{type:"text/plain; charset=utf-8"});Object(mt["saveAs"])(e,this.saveFilename+".json")},load:function(){var t=this,e=this.$refs.loadFile.files[0];if(e){this.saveFilename=e.name.toLowerCase().endsWith(".json")?e.name.substring(0,e.name.length-5):e.name;var r=new FileReader;r.addEventListener("load",(function(e){t.$store.commit("load",e.target.result)})),r.readAsBinaryString(e)}}},watch:{hash:function(t){history.replaceState({},"","#"+t)}}};r("f7d3");xt.render=m;var Pt=xt,kt=(r("4160"),r("a434"),r("159b"),r("5502")),Lt=r("d8b3");function Wt(t,e){for(var r in t)t.hasOwnProperty(r)&&e.hasOwnProperty(r)&&(e[r]=t[r])}function Tt(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e}function $t(t,e){if(e.hasOwnProperty("settings")&&Wt(e.settings,t.settings),e.hasOwnProperty("boards")){var r=e.boards.map((function(t){return t.hasOwnProperty("layers")?{layers:t.layers.map((function(t){return{wood:Tt(t.wood),width:Tt(t.width)}}))}:{layers:[]}}));0===r.length&&r.push({layers:[]}),t.boards=r}if(e.hasOwnProperty("wood")){var n=e.wood.map((function(t){return{name:t.name,color:t.color}}));t.wood=n}}var Mt=Object(kt["a"])({state:{settings:{units:"cm",borders:!1,boardThickness:2,boardLength:70,bladeKerf:.35,crosscutWidth:3,alternateDirection:!0},wood:[{name:"Walnut",color:"#58443f"},{name:"Maple",color:"#f2e0aa"},{name:"Cherry",color:"#bb8359"},{name:"Mahogany",color:"#98473f"},{name:"Yellowheart",color:"#ffff84"},{name:"White oak",color:"#fdf4b9"},{name:"Bubinga",color:"#7e3c34"},{name:"Jatoba",color:"#9b281c"},{name:"Padouk",color:"#933350"}],boards:[{layers:[{wood:8,width:1},{wood:1,width:1.5},{wood:8,width:2},{wood:1,width:2},{wood:8,width:15},{wood:1,width:2},{wood:8,width:1.5},{wood:1,width:1}]}]},mutations:{addLayer:function(t,e){e<0||e>=t.boards.length||t.boards[e].layers.push({wood:0,width:H.fromMillimeters(20,t.settings.units)})},removeLayer:function(t,e){if(!(e.board<0||e.board>=t.boards.length)){var r=t.boards[e.board];e.layer<0||e.layer>=r.layers.length||r.layers.splice(e.layer,1)}},moveLayer:function(t,e){if(!(e.board<0||e.board>=t.boards.length)){var r=t.boards[e.board];if(!(e.from<0||e.from>=r.layers.length)&&!(e.to<0||e.to>r.layers.length))if(e.to==r.layers.length)r.layers.push(r.layers[e.from]),r.layers.splice(e.from,1);else{var n=r.layers[e.from];r.layers.splice(e.from,1),e.to>e.from&&e.to--,r.layers.splice(e.to,0,n)}}},addWood:function(t){t.wood.push({name:"Wood #"+(t.wood.length+1),color:"#f2e0aa"})},removeWood:function(t,e){e<0||e>=t.wood.length||(t.boards.forEach((function(t){t.layers.forEach((function(t){t.wood===e?t.wood=null:t.wood>e&&t.wood--}))})),t.wood.splice(e,1))},updateSettings:function(t,e){var r=t.settings.units;Wt(e,t.settings),r!==t.settings.units&&(t.settings.boardThickness=H.limitDecimals(H.convert(t.settings.boardThickness,r,t.settings.units),3),t.settings.boardLength=H.limitDecimals(H.convert(t.settings.boardLength,r,t.settings.units),3),t.settings.bladeKerf=H.limitDecimals(H.convert(t.settings.bladeKerf,r,t.settings.units),3),t.settings.crosscutWidth=H.limitDecimals(H.convert(t.settings.crosscutWidth,r,t.settings.units),3),t.boards.forEach((function(e){e.layers.forEach((function(e){e.width=H.limitDecimals(H.convert(e.width,r,t.settings.units),3)}))})))},load:function(t,e){var r=JSON.parse(e);$t(t,r)},loadMsgPack:function(t,e){try{var r=Object(Lt["deserialize"])(e);$t(t,r)}catch(n){console.error(n)}}},getters:{save:function(t){return JSON.stringify(t)},saveMsgPack:function(t){return Object(Lt["serialize"])(t)}}});Object(n["b"])(Pt).use(Mt).mount("#app")},"667a":function(t,e,r){"use strict";r("6ac4")},"6ac4":function(t,e,r){},"83e0":function(t,e,r){"use strict";r("4c86")},a408:function(t,e,r){},e40c:function(t,e,r){"use strict";r("a408")},f7d3:function(t,e,r){"use strict";r("3c4e")}});
//# sourceMappingURL=app.9efdd4b6.js.map