vendor: 24,468 bytes, lines 1-8
1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/krushos.functions-BYiOQwm1.js","assets/index-DsFUcwKT.js","assets/jsx-runtime-DUAcabCT.js","assets/link-DtGJd5Cj.js","assets/invariant-DEEwAagU.js","assets/react-6OGjdfot.js","assets/redirect-DCb_aIiF.js","assets/invites.functions-C-WdCBwk.js","assets/pdf-DyAsWaKN.js"])))=>i.map(i=>d[i]); 2import{i as e,n as t,t as n}from"./jsx-runtime-DUAcabCT.js";import{t as r}from"./react-6OGjdfot.js";import{d as i,l as a,o,s}from"./index-DsFUcwKT.js";import{a as c,i as l,o as u,r as d,t as f}from"./invites.functions-C-WdCBwk.js";import{t as p}from"./krush-logo-white.png.asset-Cw4PnO_c.js";import{t as m}from"./krush-logo-full.png.asset-CyCHehkO.js";var h=e(r(),1),g=a({method:`POST`}).middleware([u]).handler(i(`b4d4a6df9dcec2bef15bbfc749d2c1b13fbbb97e4578c5bfc84c12e4b4fa16a2`)),_=a({method:`GET`}).middleware([u]).handler(i(`65dbdd42678d4cf3348f8143806993df600c6d6e2d11eded1594324413609a95`)),v=a({method:`POST`}).middleware([u]).handler(i(`ca52dd5f0ae7d8cddfacb9246d750fb3c49602f3843006ef4bc02acff09188cf`)),y=a({method:`POST`}).middleware([u]).handler(i(`044ab69b9007f2d1a845465c72c6a928e843be4df147cb8c727bb902627da97d`)),b=a({method:`POST`}).middleware([u]).handler(i(`69ac75fc5cbafe3df356a5bf595b5cada332242bd12201512fde273c33f48d36`)),x=a({method:`POST`}).middleware([u]).handler(i(`64bea37e7e8ee4c103e16467af2bf7dd9c3f8889214646425ae3675237556693`)),S=a({method:`POST`}).middleware([u]).handler(i(`a42e5a88954ec7dc3fc92a8070cfd2ffe22d2b8b51db635d0bb47191cccbfb81`)),C=a({method:`POST`}).middleware([u]).handler(i(`c14f6a5e8009a4d8835cde70e8295e4e63263f70cdaaf9491d8b9961401798f4`)),w=a({method:`POST`}).middleware([u]).handler(i(`3bfcd0f19a17cd09de4b143134e5472cbacd1b7e993796c8d6ea403fb662fae2`)),T=a({method:`POST`}).middleware([u]).handler(i(`154da85bc7e5915df5164155bbb68a97441082079312d44aab513dabc82f59c3`)),E=a({method:`POST`}).middleware([u]).handler(i(`2a37071ab689f09bad6b8f633f83e2a90187b1bbdfc1b65551f939b4b6b1ed81`)),D=a({method:`POST`}).middleware([u]).handler(i(`5b151b9347bd53c7a03c63eaf8460fab77d80ca8041ea9e00357ac684e9e105c`)),O=a({method:`GET`}).middleware([u]).handler(i(`965618f35b7affdbd53da3bffed7d0210535f6c2267fdf375556037137100bd6`)),k=a({method:`GET`}).middleware([u]).handler(i(`51229ea15817886b24a83c6e33a976ece52a8fe14725af94fc785dcfb505ad3b`)),ee=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),A=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),j=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),te=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),ne=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),re=t((e=>{var t=A().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),M=t((e=>{var t=A().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),ie=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),ae=t((e=>{var t=j(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),N=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),oe=t((e=>{var t=N();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),se=t(((e,t)=>{var n=oe();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),ce=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),le=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r 3]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),ue=t((e=>{var t=ce(),n=le();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),de=t((e=>{var t=A(),n=ae(),r=j(),i=ue(),a=ce(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),fe=t((e=>{var t=A(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),pe=t(((e,t)=>{var n=ue();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),me=t(((e,t)=>{var n=ue(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),he=t(((e,t)=>{var n=ue();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),ge=t(((e,t)=>{var n=ue(),r=A();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+` 4Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),_e=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),ve=t((e=>{var t=ue(),n=pe(),r=me(),i=he(),a=ge(),o=le(),s=A(),c=_e();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`. 5 Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),ye=t((e=>{var t=A(),n=j(),r=te(),i=ne(),a=re(),o=M(),s=ie(),c=ae(),l=se(),u=de(),d=fe(),f=ue(),p=ve();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(` 6The chosen QR Code version cannot contain this amount of data. 7Minimum version required to store current data is: `+c+`. 8`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),be=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),xe=t((e=>{var t=be();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Se=t((e=>{var t=be();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>
80&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg> 9`;return typeof a==`function`&&a(null,p),p}})),Ce=e(t((e=>{var t=ee(),n=ye(),r=xe(),i=Se();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),P=n(),we=[`draft`,`confirmed`,`in_production`,`qc`,`shipped`,`delivered`,`cancelled`],Te=[`pending`,`approved`,`rejected`],Ee=[`draft`,`sent`,`paid`,`overdue`,`void`];function De(e){return`$${(e/100).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function F(e){if(!e)return`â`;try{return new Date(e).toLocaleString()}catch{return e}}function Oe(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(`overview`),[i,a]=(0,h.useState)(!0),[o,s]=(0,h.useState)(null),c=(0,h.useCallback)(async()=>{a(!0),s(null);try{t(await _())}catch(e){let t=e?.message??String(e??``);/<html|FORCE_RELOAD|401|Unauthorized/i.test(t)?s(`Your session expired. Please sign out and sign back in to continue.`):s(t||`Failed to load admin data`)}finally{a(!1)}},[]);(0,h.useEffect)(()=>{c()},[c]);let l=(0,h.useMemo)(()=>{let t=new Map;return(e?.users??[]).forEach(e=>t.set(e.id,{email:e.email})),t},[e]),u=e=>l.get(e)?.email||e.slice(0,8);return(0,P.jsxs)(`div`,{style:{fontSize:13},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,gap:4,borderBottom:`1px solid #E5E5E3`,marginBottom:18,flexWrap:`wrap`},children:[[[`overview`,`Overview`],[`clients`,`Clients (${e?.profiles.length??0})`],[`invites`,`Invites`],[`signups`,`Signups (${e?.users.length??0})`],[`users`,`Users (${e?.users.length??0})`],[`orders`,`Orders (${e?.orders.length??0})`],[`documents`,`Documents (${e?.documents.length??0})`],[`invoices`,`Invoices (${e?.invoices.length??0})`],[`operations`,`Operations (${e?.shipments?.length??0})`],[`concierge`,`Concierge (${e?.messages.length??0})`]].map(([e,t])=>(0,P.jsx)(`button`,{onClick:()=>r(e),className:`caps`,style:{padding:`10px 14px`,background:`none`,border:`none`,cursor:`pointer`,fontSize:11,letterSpacing:`0.14em`,color:n===e?`#1E1E20`:`#7A7A7C`,borderBottom:`2px solid ${n===e?`#1E1E20`:`transparent`}`,fontWeight:600},children:t},e)),(0,P.jsxs)(`div`,{style:{marginLeft:`auto`,display:`flex`,alignItems:`center`,gap:10},children:[i&&(0,P.jsx)(`span`,{style:{color:`#7A7A7C`,fontSize:11},children:`Loadingâ¦`}),(0,P.jsx)(`button`,{onClick:c,style:{padding:`6px 12px`,background:`#1E1E20`,color:`#fff`,border:`none`,borderRadius:4,cursor:`pointer`,fontSize:11,fontWeight:600,letterSpacing:`0.1em`,textTransform:`uppercase`},children:`Refresh`})]})]}),o&&(0,P.jsx)(`div`,{style:{padding:12,border:`1px solid #E4B4B4`,background:`#FBEEEE`,color:`#8A2A2A`,borderRadius:4,marginBottom:14,fontSize:12},children:o}),!e&&!o&&!i&&(0,P.jsx)(`div`,{children:`No data.`}),e&&n===`overview`&&(0,P.jsx)(ke,{data:e}),e&&n===`clients`&&(0,P.jsx)(Ae,{data:e}),n===`invites`&&(0,P.jsx)(Ne,{}),e&&n===`signups`&&(0,P.jsx)(Me,{data:e,reload:c}),e&&n===`users`&&(0,P.jsx)(Ie,{data:e,reload:c}),e&&n===`orders`&&(0,P.jsx)(Be,{data:e,reload:c,emailFor:u}),e&&n===`documents`&&(0,P.jsx)(Ve,{data:e,reload:c,emailFor:u}),e&&n===`invoices`&&(0,P.jsx)(He,{data:e,reload:c,emailFor:u}),e&&n===`operations`&&(0,P.jsx)(Pe,{data:e,emailFor:u}),e&&n===`concierge`&&(0,P.jsx)(Ue,{data:e,emailFor:u})]})}function I({label:e,value:t,hint:n}){return(0,P.jsxs)(`div`,{style:{border:`1px solid #E5E5E3`,borderRadius:6,padding:`14px 16px`,background:`#FCFCFB`},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:10,letterSpacing:`0.12em`,color:`#7A7A7C`,fontWeight:600},children:e}),(0,P.jsx)(`div`,{style:{fontSize:22,fontWeight:600,marginTop:6,color:`#1E1E20`},children:t}),n&&(0,P.jsx)(`div`,{style:{fontSize:11,color:`#7A7A7C`,marginTop:4},children:n})]})}function ke({data:e}){let t=Date.now(),n=(e,n=30)=>!!e&&t-new Date(e).getTime()<n*864e5,r=e.orders.filter(e=>![`delivered`,`cancelled`].includes(String(e.status))),i=e.invoices.filter(e=>[`sent`,`overdue`,`draft`].includes(String(e.status))),a=e.invoices.filter(e=>String(e.status)===`overdue`),o=e.invoices.filter(e=>String(e.status)===`paid`&&n(e.updated_at||e.created_at)),s=e.documents.filter(e=>
9String(e.status)===`pending`),c=e.users.filter(e=>n(e.created_at)),l=e.users.filter(e=>!e.email_confirmed_at),u=(e,t)=>e.reduce((e,n)=>e+(Number(n[t])||0),0),d=(e.shipments??[]).filter(e=>![`delivered`,`cancelled`].includes(String(e.status)));return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(190px, 1fr))`,gap:12},children:[(0,P.jsx)(I,{label:`Accounts`,value:String(e.users.length),hint:`${c.length} new in 30 days`}),(0,P.jsx)(I,{label:`Unverified emails`,value:String(l.length),hint:`Awaiting email confirmation`}),(0,P.jsx)(I,{label:`Open orders`,value:String(r.length),hint:`${e.orders.length} total on record`}),(0,P.jsx)(I,{label:`Shipments in transit`,value:String(d.length),hint:`${(e.shipments??[]).length} total`}),(0,P.jsx)(I,{label:`Docs pending review`,value:String(s.length),hint:`${e.documents.length} documents total`}),(0,P.jsx)(I,{label:`Receivables open`,value:De(u(i,`amount_cents`)),hint:`${a.length} overdue`}),(0,P.jsx)(I,{label:`Collected (30d)`,value:De(u(o,`amount_cents`)),hint:`${o.length} invoices paid`}),(0,P.jsx)(I,{label:`QR traces`,value:String((e.traces??[]).length),hint:`Public COA/spec links`}),(0,P.jsx)(I,{label:`Concierge messages`,value:String(e.messages.length),hint:`Support conversation volume`})]}),(0,P.jsx)(`div`,{style:{marginTop:22,fontSize:12,color:`#7A7A7C`},children:`Needs attention`}),(0,P.jsxs)(`ul`,{style:{margin:`8px 0 0`,paddingLeft:18,fontSize:13,lineHeight:1.7},children:[s.length>0&&(0,P.jsxs)(`li`,{children:[s.length,` document(s) awaiting approval.`]}),a.length>0&&(0,P.jsxs)(`li`,{children:[a.length,` overdue invoice(s) totalling `,De(u(a,`amount_cents`)),`.`]}),l.length>0&&(0,P.jsxs)(`li`,{children:[l.length,` account(s) never confirmed their email.`]}),r.filter(e=>!e.lot_code).length>0&&(0,P.jsxs)(`li`,{children:[r.filter(e=>!e.lot_code).length,` open order(s) without a lot code.`]}),s.length===0&&a.length===0&&l.length===0&&(0,P.jsx)(`li`,{children:`Nothing outstanding â all clear.`})]})]})}function Ae({data:e}){let[t,n]=(0,h.useState)(``),[r,i]=(0,h.useState)(`revenue`),[a,o]=(0,h.useState)(null),s=(0,h.useMemo)(()=>{let t=Date.now(),n=new Map(e.users.map(e=>[e.id,e])),r=(e,t)=>{let n=new Map;for(let r of e??[]){let e=String(r[t]??``);n.has(e)||n.set(e,[]),n.get(e).push(r)}return n},i=r(e.orders,`customer_id`),a=r(e.invoices,`customer_id`),o=r(e.documents,`customer_id`),s=r(e.shipments??[],`customer_id`),c=r(e.reservations??[],`customer_id`),l=r(e.subscriptions??[],`customer_id`),u=(e,t)=>e.reduce((e,n)=>e+(Number(n[t])||0),0);return e.profiles.map(e=>{let r=n.get(e.id)??{},d=i.get(e.id)??[],f=a.get(e.id)??[],p=o.get(e.id)??[],m=s.get(e.id)??[],h=c.get(e.id)??[],g=l.get(e.id)??[],_=f.filter(e=>String(e.status)===`paid`),v=f.filter(e=>[`sent`,`overdue`,`draft`].includes(String(e.status))),y=f.filter(e=>String(e.status)===`overdue`),b=u(_,`amount_cents`),x=_.filter(e=>t-new Date(e.paid_at||e.updated_at||e.created_at).getTime()<90*864e5),S=d.filter(e=>![`delivered`,`cancelled`].includes(String(e.status))),C=d.length?Math.max(...d.map(e=>new Date(e.created_at).getTime())):0;return{id:e.id,email:r.email||e.email||e.id.slice(0,8),name:e.legal_name||e.dba||[e.first_name,e.last_name].filter(Boolean).join(` `)||r.email||`â`,profile:e,auth:r,orders:d,invoices:f,docs:p,shipments:m,reservations:h,subs:g,kpis:{revenue:b,revenue90:u(x,`amount_cents`),outstanding:u(v,`amount_cents`),overdue:u(y,`amount_cents`),ordersTotal:d.length,openOrders:S.length,units:u(d,`quantity`),aov:_.length?Math.round(b/_.length):0,filtersHeld:u(h,`units_remaining`),activeSubs:g.filter(e=>String(e.status)===`active`).length,pendingDocs:p.filter(e=>String(e.status)===`pending`).length,inTransit:m.filter(e=>![`delivered`,`cancelled`].includes(String(e.status))).length,lastOrderAt:C,daysSinceOrder:C?Math.floor((t-C)/864e5):null}}})},[e]),c=(0,h.useMemo)(()=>{let e=t.trim().toLowerCase(),n=e?s.filter(t=>[t.name,t.email,t.profile.dba,t.profile.company_domain].filter(Boolean).some(t=>String(t).toLowerCase().includes(e))):s.slice();return n.sort((e,t)=>
9r===`name`?String(e.name).localeCompare(String(t.name)):r===`orders`?t.kpis.ordersTotal-e.kpis.ordersTotal:r===`outstanding`?t.kpis.outstanding-e.kpis.outstanding:r===`recent`?t.kpis.lastOrderAt-e.kpis.lastOrderAt:t.kpis.revenue-e.kpis.revenue),n},[s,t,r]),l=(0,h.useMemo)(()=>{let e={revenue:0,outstanding:0,orders:0,units:0,filters:0};for(let t of s)e.revenue+=t.kpis.revenue,e.outstanding+=t.kpis.outstanding,e.orders+=t.kpis.ordersTotal,e.units+=t.kpis.units,e.filters+=t.kpis.filtersHeld;return e},[s]),u=c.find(e=>e.id===a)??null;return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(180px, 1fr))`,gap:12},children:[(0,P.jsx)(I,{label:`Clients`,value:String(s.length),hint:`${s.filter(e=>e.kpis.ordersTotal>0).length} have ordered`}),(0,P.jsx)(I,{label:`Lifetime collected`,value:De(l.revenue),hint:`All paid invoices`}),(0,P.jsx)(I,{label:`Outstanding`,value:De(l.outstanding),hint:`Draft / sent / overdue`}),(0,P.jsx)(I,{label:`Orders`,value:String(l.orders),hint:`${l.units.toLocaleString()} units ordered`}),(0,P.jsx)(I,{label:`Filters held`,value:l.filters.toLocaleString(),hint:`Filter Bank balances`})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:10,alignItems:`center`,margin:`18px 0 10px`,flexWrap:`wrap`},children:[(0,P.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`Search client, email or domainâ¦`,style:{padding:`8px 10px`,border:`1px solid #E5E5E3`,borderRadius:4,fontSize:12,minWidth:260}}),(0,P.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),style:{padding:`8px 10px`,border:`1px solid #E5E5E3`,borderRadius:4,fontSize:12},children:[(0,P.jsx)(`option`,{value:`revenue`,children:`Sort: lifetime revenue`}),(0,P.jsx)(`option`,{value:`orders`,children:`Sort: order count`}),(0,P.jsx)(`option`,{value:`outstanding`,children:`Sort: outstanding balance`}),(0,P.jsx)(`option`,{value:`recent`,children:`Sort: most recent order`}),(0,P.jsx)(`option`,{value:`name`,children:`Sort: name`})]}),(0,P.jsxs)(`span`,{style:{fontSize:11,color:`#7A7A7C`},children:[c.length,` shown`]})]}),(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Client`}),(0,P.jsx)(R,{children:`Terms`}),(0,P.jsx)(R,{children:`Orders`}),(0,P.jsx)(R,{children:`Units`}),(0,P.jsx)(R,{children:`Lifetime`}),(0,P.jsx)(R,{children:`Last 90d`}),(0,P.jsx)(R,{children:`AOV`}),(0,P.jsx)(R,{children:`Outstanding`}),(0,P.jsx)(R,{children:`Filters held`}),(0,P.jsx)(R,{children:`Subs`}),(0,P.jsx)(R,{children:`Last order`}),(0,P.jsx)(R,{children:`Profile`})]})}),(0,P.jsxs)(`tbody`,{children:[c.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(z,{children:[(0,P.jsx)(`div`,{style:{fontWeight:600},children:e.name}),(0,P.jsx)(`div`,{style:{fontSize:11,color:`#7A7A7C`},children:e.email})]}),(0,P.jsx)(z,{children:e.profile.payment_terms||`â`}),(0,P.jsxs)(z,{children:[e.kpis.ordersTotal,e.kpis.openOrders?` (${e.kpis.openOrders} open)`:``]}),(0,P.jsx)(z,{children:e.kpis.units.toLocaleString()}),(0,P.jsx)(z,{children:De(e.kpis.revenue)}),(0,P.jsx)(z,{children:De(e.kpis.revenue90)}),(0,P.jsx)(z,{children:De(e.kpis.aov)}),(0,P.jsxs)(z,{children:[De(e.kpis.outstanding),e.kpis.overdue>0&&(0,P.jsxs)(`span`,{style:{color:`#8A2A2A`,fontSize:11},children:[` · `,De(e.kpis.overdue),` overdue`]})]}),(0,P.jsx)(z,{children:e.kpis.filtersHeld.toLocaleString()}),(0,P.jsx)(z,{children:e.kpis.activeSubs}),(0,P.jsx)(z,{children:e.kpis.daysSinceOrder==null?`Never`:`${e.kpis.daysSinceOrder}d ago`}),(0,P.jsx)(z,{children:(0,P.jsx)(`button`,{onClick:()=>o(a===e.id?null:e.id),style:{padding:`5px 10px`,border:`1px solid #E5E5E3`,background:a===e.id?`#1E1E20`:`#fff`,color:a===e.id?`#fff`:`#1E1E20`,borderRadius:4,cursor:`pointer`,fontSize:11,fontWeight:600},children:`View`})})]},e.id)),c.length===0&&(0,P.jsx)(`tr`,{children:(0,P.jsx)(z,{children:`No clients match this search.`})})]})]})}),u&&(0,P.jsx)(je,{row:u,onClose:()=>o(null)})]})}function L({label:e,value:t}){return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:10,letterSpacing:`0.12em`,color:`#7A7A7C`,fontWeight:600},children:e}),(0,P.jsx)(`div`,{style:{fontSize:13,marginTop:3},children:t==null||t===``?`â`:String(t)})]})}function je({row:e,onClose:t}){let n=e.profile,r=(e,t)=>`$${((e??t)/100).toFixed(3)}`,i=e=>[n[`${e}_line1`],n[`${e}_line2`],n[`${e}_city`],n[`${e}_region`],n[`${e}_postal`],n[`${e}
9_country`]].filter(Boolean).join(`, `);return(0,P.jsxs)(`div`,{style:{marginTop:22,border:`1px solid #E5E5E3`,borderRadius:6,padding:18,background:`#FCFCFB`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:12},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:16,fontWeight:600},children:e.name}),(0,P.jsxs)(`div`,{style:{fontSize:12,color:`#7A7A7C`},children:[e.email,` · joined `,F(e.auth.created_at||n.created_at)]})]}),(0,P.jsx)(`button`,{onClick:t,style:{padding:`5px 10px`,border:`1px solid #E5E5E3`,background:`#fff`,borderRadius:4,cursor:`pointer`,fontSize:11},children:`Close`})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(170px, 1fr))`,gap:12,marginTop:16},children:[(0,P.jsx)(I,{label:`Lifetime collected`,value:De(e.kpis.revenue),hint:`${e.invoices.length} invoices`}),(0,P.jsx)(I,{label:`Outstanding`,value:De(e.kpis.outstanding),hint:`${De(e.kpis.overdue)} overdue`}),(0,P.jsx)(I,{label:`Orders`,value:String(e.kpis.ordersTotal),hint:`${e.kpis.openOrders} open`}),(0,P.jsx)(I,{label:`Units ordered`,value:e.kpis.units.toLocaleString(),hint:`AOV ${De(e.kpis.aov)}`}),(0,P.jsx)(I,{label:`Filters held`,value:e.kpis.filtersHeld.toLocaleString(),hint:`${e.reservations.length} reservations`}),(0,P.jsx)(I,{label:`Shipments in transit`,value:String(e.kpis.inTransit),hint:`${e.shipments.length} total`}),(0,P.jsx)(I,{label:`Docs pending`,value:String(e.kpis.pendingDocs),hint:`${e.docs.length} documents`}),(0,P.jsx)(I,{label:`Active subscriptions`,value:String(e.kpis.activeSubs),hint:`${e.subs.length} on record`})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(220px, 1fr))`,gap:14,marginTop:20},children:[(0,P.jsx)(L,{label:`Contact`,value:[n.first_name,n.last_name].filter(Boolean).join(` `)}),(0,P.jsx)(L,{label:`Phone`,value:n.phone}),(0,P.jsx)(L,{label:`Legal name`,value:n.legal_name}),(0,P.jsx)(L,{label:`DBA`,value:n.dba}),(0,P.jsx)(L,{label:`Business type`,value:n.business_type}),(0,P.jsx)(L,{label:`Tax ID`,value:n.tax_id}),(0,P.jsx)(L,{label:`Website`,value:n.website}),(0,P.jsx)(L,{label:`Company domain`,value:n.company_domain}),(0,P.jsx)(L,{label:`Payment terms`,value:n.payment_terms}),(0,P.jsx)(L,{label:`Credit status`,value:n.credit_status}),(0,P.jsx)(L,{label:`Credit limit`,value:De(Number(n.credit_limit_cents)||0)}),(0,P.jsx)(L,{label:`PO approval threshold`,value:De(Number(n.po_approval_threshold_cents)||0)}),(0,P.jsx)(L,{label:`Compliance status`,value:n.compliance_status}),(0,P.jsx)(L,{label:`Licence`,value:n.cannabis_license_number||n.license_number}),(0,P.jsx)(L,{label:`Licence expiry`,value:n.license_expiry?F(n.license_expiry):null}),(0,P.jsx)(L,{label:`Last sign-in`,value:F(e.auth.last_sign_in_at)}),(0,P.jsx)(L,{label:`Email verified`,value:e.auth.email_confirmed_at?`Yes`:`No`}),(0,P.jsx)(L,{label:`Billing address`,value:i(`billing`)}),(0,P.jsx)(L,{label:`Shipping address`,value:i(`shipping`)})]}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:11,letterSpacing:`0.14em`,fontWeight:600,marginTop:20,marginBottom:8},children:`Contracted rates`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(160px, 1fr))`,gap:14},children:[(0,P.jsx)(L,{label:`Blank cone`,value:`${r(n.rate_cone_blank_cents,5)} / cone${n.rate_cone_blank_cents==null?` (default)`:``}`}),(0,P.jsx)(L,{label:`Custom cone`,value:`${r(n.rate_cone_custom_cents,6)} / cone${n.rate_cone_custom_cents==null?` (default)`:``}`}),(0,P.jsx)(L,{label:`Filter`,value:`${r(n.rate_filter_cents,3)} / filter${n.rate_filter_cents==null?` (default)`:``}`}),(0,P.jsx)(L,{label:`Hemp blunt`,value:`${r(n.rate_hemp_cents,6)} / unit${n.rate_hemp_cents==null?` (default)`:``}`})]}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:11,letterSpacing:`0.14em`,fontWeight:600,marginTop:20,marginBottom:8},children:`Recent orders`}),(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Created`}),(0,P.jsx)(R,{children:`Product`}),(0,P.jsx)(R,{children:`Qty`}),(0,P.jsx)(R,{children:`Status`}),(0,P.jsx)(R,{children:`Lot`}),(0,P.jsx)(R,{children:`ETA`})]})}),(0,P.jsxs)(`tbody`,{children:[e.orders.slice(0,8).map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{children:F(e.created_at)}),(0,P.jsx)(z,{children:e.product}
9),(0,P.jsx)(z,{children:Number(e.quantity||0).toLocaleString()}),(0,P.jsx)(z,{children:e.status}),(0,P.jsx)(z,{mono:!0,children:e.lot_code||`â`}),(0,P.jsx)(z,{children:F(e.eta)})]},e.id)),e.orders.length===0&&(0,P.jsx)(`tr`,{children:(0,P.jsx)(z,{children:`No orders yet.`})})]})]})})]})}function Me({data:e,reload:t}){let n=new Map(e.profiles.map(e=>[e.id,e])),r=[...e.users].sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()),[i,a]=(0,h.useState)(null),[o,s]=(0,h.useState)(null),c=async(e,n)=>{a(e),s(null);try{await v({data:{user_id:e,status:n}}),s(`Access ${n}.`),t()}catch(e){s(e?.message||`Failed to update access`)}finally{a(null)}},l=r.filter(e=>(n.get(e.id)?.access_status??`pending`)===`pending`).length;return(0,P.jsxs)(`div`,{style:{overflowX:`auto`},children:[(0,P.jsxs)(`div`,{style:{fontSize:12,color:`#7A7A7C`,marginBottom:10},children:[`Every registration, newest first. A copy of each signup is emailed to [email protected].`,` `,`New accounts stay locked out of the portal until approved here.`,l>0&&(0,P.jsxs)(`strong`,{children:[` `,l,` awaiting approval.`]})]}),o&&(0,P.jsx)(`div`,{style:{fontSize:12,marginBottom:10,color:`#1E1E20`},children:o}),(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Registered`}),(0,P.jsx)(R,{children:`Email`}),(0,P.jsx)(R,{children:`Contact`}),(0,P.jsx)(R,{children:`Business`}),(0,P.jsx)(R,{children:`Type / Tax ID`}),(0,P.jsx)(R,{children:`Billing`}),(0,P.jsx)(R,{children:`Verified`}),(0,P.jsx)(R,{children:`Last sign-in`}),(0,P.jsx)(R,{children:`Access`}),(0,P.jsx)(R,{children:`Approval`})]})}),(0,P.jsx)(`tbody`,{children:r.map(e=>{let t=n.get(e.id)??{},r=[t.billing_line1,t.billing_city,t.billing_region,t.billing_postal,t.billing_country].filter(Boolean).join(`, `),a=t.access_status??`pending`;return(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{children:F(e.created_at)}),(0,P.jsx)(z,{children:e.email}),(0,P.jsxs)(z,{children:[[t.first_name,t.last_name].filter(Boolean).join(` `)||`â`,t.phone?` · ${t.phone}`:``]}),(0,P.jsxs)(z,{children:[t.legal_name||`â`,t.dba?` (${t.dba})`:``]}),(0,P.jsx)(z,{children:[t.business_type,t.tax_id].filter(Boolean).join(` · `)||`â`}),(0,P.jsx)(z,{children:r||`â`}),(0,P.jsx)(z,{children:e.email_confirmed_at?`Yes`:`No`}),(0,P.jsx)(z,{children:F(e.last_sign_in_at)}),(0,P.jsxs)(z,{children:[(0,P.jsx)(`span`,{style:{fontSize:11,fontWeight:600,padding:`3px 8px`,borderRadius:999,background:a===`approved`?`#E7F3EC`:a===`rejected`?`#FBE9E9`:`#FCF3E2`,color:a===`approved`?`#1F6B3C`:a===`rejected`?`#8C2B2B`:`#8A6412`},children:a}),t.access_reviewed_at&&(0,P.jsx)(`div`,{style:{fontSize:10,color:`#9A9A9C`},children:F(t.access_reviewed_at)})]}),(0,P.jsx)(z,{children:(0,P.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[a!==`approved`&&(0,P.jsx)(`button`,{disabled:i===e.id,onClick:()=>c(e.id,`approved`),style:{padding:`5px 10px`,fontSize:11,fontWeight:600,cursor:`pointer`,border:`1px solid #1F6B3C`,background:`#1F6B3C`,color:`#fff`,borderRadius:4},children:`Approve`}),a!==`rejected`&&(0,P.jsx)(`button`,{disabled:i===e.id,onClick:()=>c(e.id,`rejected`),style:{padding:`5px 10px`,fontSize:11,fontWeight:600,cursor:`pointer`,border:`1px solid #D6D6D4`,background:`#fff`,color:`#8C2B2B`,borderRadius:4},children:`Reject`}),a!==`pending`&&(0,P.jsx)(`button`,{disabled:i===e.id,onClick:()=>c(e.id,`pending`),style:{padding:`5px 10px`,fontSize:11,cursor:`pointer`,border:`1px solid #D6D6D4`,background:`#fff`,color:`#7A7A7C`,borderRadius:4},children:`Reset`})]})})]},e.id)})})]})]})}function Ne(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(!0),[i,a]=(0,h.useState)(null),[o,s]=(0,h.useState)(null),[u,p]=(0,h.useState)({email:``,contact_name:``,company_name:``,message:``,role:`customer`,expires_days:30}),m=(0,h.useCallback)(async()=>{r(!0);try{t((await d()).invites)}catch(e){a(e?.message||`Failed to load invitations`)}finally{r(!1)}},[]);(0,h.useEffect)(()=>{m()},[m]);let g=async()=>{s(`new`),a(null);try{let e=await f({data:{email:u.email,contact_name:u.contact_name||null,company_name:u.company_name||null,message:u.message||null,role:u.role,expires_days:Number(u.expires_days)||30}});a(e.emailed?`Invitation emailed to ${u.email}.`:`Invitation created â email could not be delivered. Share this link: ${e.invite_url}`),p({email:``,contact_name:``,company_name:``,message:``,role:`customer`,expires_days:30}),m()}catch(e){a(e?.message||`Failed to send invitation`)}finally{s(null)}},_={padding:`8px 10px`,border:`1px solid #D6D6D4`,borderRadius:4,fontSize:12,width:`100%`,boxSizing:`border-box`};return(0,P.jsxs)(`div`,{style:{display:`grid`,gap:24},children:[(0,P.jsxs)(`div`,{style:{border:`1px solid #E5E5E3`,borderRadius:6,padding:16,maxWidth:720},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:11,letterSpacing:`0.14em`,fontWeight:600,marginBottom:10},children:`Invite someone to the platform`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:10,gridTemplateColumns:`1fr 1fr`},children:[(0,P.jsx)(`input`,{style:_,type:`email`,placeholder:`Email *`,value:u.email,onChange:e=>p({...u,email:e.target.value})}),(0,P.jsx)(`input`,{style:_,placeholder:`Contact name`,value:u.contact_name,onChange:e=>p({...u,contact_name:e.target.value})}),(0,P.jsx)(`input`,{style:_,placeholder:`Company`,value:u.company_name,onChange:e=>p({...u,company_name:e.target.value})}),(0,P.jsxs)(`select`,{style:_,value:u.role,onChange:e=>p({...u,role:e.target.value}),children:[(0,P.jsx)(`option`,{value:`customer`,children:`Client`}),(0,P.jsx)(`option`,{value:`staff`,children:`Staff`}),(0,P.jsx)(`option`,{value:`admin`,children:`Admin`})]}),(0,P.jsx)(`input`,{style:_,type:`number`,min:1,max:90,placeholder:`Expires (days)`,value:u.expires_days,onChange:e=>p({...u,expires_days:Number(e.target.value)})}),(0,P.jsx)(`input`,{style:_,placeholder:`Personal note (optional)`,value:u.message,onChange:e=>p({...u,message:e.target.value})})]}),(0,P.jsx)(`button`,{disabled:o===`new`||!u.email,onClick:g,style:{marginTop:12,padding:`8px 16px`,background:`#1E1E20`,color:`#fff`,border:`none`,borderRadius:4,fontSize:11,fontWeight:600,letterSpacing:`0.1em`,textTransform:`uppercase`,cursor:`pointer`},children:o===`new`?`Sendingâ¦`:`Send invitation`}),(0,P.jsx)(`div`,{style:{fontSize:11,color:`#7A7A7C`,marginTop:8},children:`Invited accounts are approved automatically when they sign up with the invited email.`}),i&&(0,P.jsx)(`div`,{style:{fontSize:12,marginTop:10,color:`#1E1E20`,wordBreak:`break-all`},children:i})]}),(0,P.jsxs)(`div`,{style:{overflowX:`auto`}
9,children:[(0,P.jsxs)(`div`,{className:`caps`,style:{fontSize:11,letterSpacing:`0.14em`,fontWeight:600,marginBottom:8},children:[`Invitations (`,e.length,`)`,n?` · loadingâ¦`:``]}),(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Sent`}),(0,P.jsx)(R,{children:`Email`}),(0,P.jsx)(R,{children:`Contact / Company`}),(0,P.jsx)(R,{children:`Role`}),(0,P.jsx)(R,{children:`Status`}),(0,P.jsx)(R,{children:`Expires`}),(0,P.jsx)(R,{children:`Actions`})]})}),(0,P.jsxs)(`tbody`,{children:[e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{children:F(e.created_at)}),(0,P.jsx)(z,{children:e.email}),(0,P.jsx)(z,{children:[e.contact_name,e.company_name].filter(Boolean).join(` · `)||`â`}),(0,P.jsx)(z,{children:e.role}),(0,P.jsx)(z,{children:(0,P.jsx)(`span`,{style:{fontSize:11,fontWeight:600,padding:`3px 8px`,borderRadius:999,background:e.status===`accepted`?`#E7F3EC`:e.status===`pending`?`#FCF3E2`:`#FBE9E9`,color:e.status===`accepted`?`#1F6B3C`:e.status===`pending`?`#8A6412`:`#8C2B2B`},children:e.status})}),(0,P.jsx)(z,{children:F(e.expires_at)}),(0,P.jsx)(z,{children:e.status===`pending`?(0,P.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,P.jsx)(`button`,{disabled:o===e.id,onClick:async()=>{s(e.id),a(null);try{let t=await l({data:{id:e.id}});a(t.emailed?`Resent to ${e.email}.`:`Link: ${t.invite_url}`),m()}catch(e){a(e?.message||`Failed to resend`)}finally{s(null)}},style:{padding:`5px 10px`,fontSize:11,cursor:`pointer`,border:`1px solid #D6D6D4`,background:`#fff`,color:`#1E1E20`,borderRadius:4},children:`Resend`}),(0,P.jsx)(`button`,{disabled:o===e.id,onClick:async()=>{s(e.id),a(null);try{await c({data:{id:e.id}}),a(`Invitation revoked.`),m()}catch(e){a(e?.message||`Failed to revoke`)}finally{s(null)}},style:{padding:`5px 10px`,fontSize:11,cursor:`pointer`,border:`1px solid #D6D6D4`,background:`#fff`,color:`#8C2B2B`,borderRadius:4},children:`Revoke`})]}):(0,P.jsx)(`span`,{style:{color:`#9A9A9C`},children:`â`})})]},e.id)),!n&&e.length===0&&(0,P.jsx)(`tr`,{children:(0,P.jsx)(z,{children:`No invitations yet.`})})]})]})]})]})}function Pe({data:e,emailFor:t}){let n=e.shipments??[];return(0,P.jsx)(`div`,{style:{display:`grid`,gap:26},children:(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`caps`,style:{fontSize:11,letterSpacing:`0.14em`,fontWeight:600,marginBottom:8},children:[`Shipments (`,n.length,`)`]}),(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Created`}),(0,P.jsx)(R,{children:`Customer`}),(0,P.jsx)(R,{children:`Status`}),(0,P.jsx)(R,{children:`Carrier`}),(0,P.jsx)(R,{children:`Tracking`}),(0,P.jsx)(R,{children:`Ship date`}),(0,P.jsx)(R,{children:`ETA`})]})}),(0,P.jsxs)(`tbody`,{children:[n.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{children:F(e.created_at)}),(0,P.jsx)(z,{children:t(e.customer_id)}),(0,P.jsx)(z,{children:e.status||`â`}),(0,P.jsx)(z,{children:e.carrier||`Shipping`}),(0,P.jsx)(z,{mono:!0,children:e.tracking||`â`}),(0,P.jsx)(z,{children:F(e.ship_date)}),(0,P.jsx)(z,{children:F(e.eta)})]},e.id)),n.length===0&&(0,P.jsx)(`tr`,{children:(0,P.jsx)(z,{children:`No shipments yet.`})})]})]})})]})})}function R({children:e}){return(0,P.jsx)(`th`,{className:`caps`,style:{textAlign:`left`,fontSize:10,letterSpacing:`0.12em`,color:`#7A7A7C`,fontWeight:600,padding:`10px 10px`,borderBottom:`1px solid #E5E5E3`,whiteSpace:`nowrap`},children:e})}function z({children:e,mono:t}){return(0,P.jsx)(`td`,{style:{padding:`10px 10px`,borderBottom:`1px solid #F0EFEC`,fontFamily:t?`IBM Plex Mono, ui-monospace, monospace`:void 0,fontSize:t?12:13,verticalAlign:`top`},children:e})}function Fe({children:e}){return(0,P.jsx)(`div`,{style:{overflowX:`auto`,border:`1px solid #E5E5E3`,borderRadius:4,background:`#fff`},children:(0,P.jsx)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:e})})}function Ie({data:e,reload:t}){let n=(0,h.useMemo)(()=>{let t=new Map;
9return e.roles.forEach(e=>{let n=t.get(e.user_id)??new Set;n.add(e.role),t.set(e.user_id,n)}),t},[e.roles]),r=(0,h.useMemo)(()=>{let t=new Map;return e.profiles.forEach(e=>t.set(e.id,e)),t},[e.profiles]),i=async(e,n,r)=>{await T({data:{user_id:e,role:n,action:r?`revoke`:`grant`}}),t()};return(0,P.jsxs)(Fe,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Email`}),(0,P.jsx)(R,{children:`Company`}),(0,P.jsx)(R,{children:`Signed up`}),(0,P.jsx)(R,{children:`Last login`}),(0,P.jsx)(R,{children:`Verified`}),(0,P.jsx)(R,{children:`Terms`}),(0,P.jsx)(R,{children:`Rates (¢/unit)`}),(0,P.jsx)(R,{children:`Roles`})]})}),(0,P.jsx)(`tbody`,{children:e.users.map(e=>{let a=n.get(e.id)??new Set,o=r.get(e.id),s=a.has(`admin`),c=a.has(`staff`),l=o?.payment_terms??`prepaid`;return(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{children:e.email}),(0,P.jsx)(z,{children:o?.legal_name||o?.dba||`â`}),(0,P.jsx)(z,{mono:!0,children:F(e.created_at)}),(0,P.jsx)(z,{mono:!0,children:F(e.last_sign_in_at)}),(0,P.jsx)(z,{children:e.email_confirmed_at?`Yes`:`No`}),(0,P.jsx)(z,{children:(0,P.jsxs)(`select`,{defaultValue:l,onChange:async n=>{await E({data:{user_id:e.id,payment_terms:n.target.value}}),t()},style:Ge,children:[(0,P.jsx)(`option`,{value:`prepaid`,children:`Prepaid`}),(0,P.jsx)(`option`,{value:`net30`,children:`Net 30`})]})}),(0,P.jsx)(z,{children:(0,P.jsx)(Re,{userId:e.id,profile:o,onSaved:t})}),(0,P.jsxs)(z,{children:[(0,P.jsx)(`button`,{onClick:()=>i(e.id,`admin`,s),style:Le(s,`#8A2A2A`),children:s?`Revoke admin`:`Make admin`}),` `,(0,P.jsx)(`button`,{onClick:()=>i(e.id,`staff`,c),style:Le(c,`#1E1E20`),children:c?`Revoke staff`:`Make staff`})]})]},e.id)})})]})}function Le(e,t){return{padding:`5px 10px`,borderRadius:3,border:`1px solid ${e?t:`#D6D6D3`}`,background:e?t:`#fff`,color:e?`#fff`:`#1E1E20`,fontSize:11,fontWeight:600,cursor:`pointer`}}function Re({userId:e,profile:t,onSaved:n}){let r={blank:5,custom:6,filter:3,hemp:6},[i,a]=(0,h.useState)({blank:t?.rate_cone_blank_cents??``,custom:t?.rate_cone_custom_cents??``,filter:t?.rate_filter_cents??``,hemp:t?.rate_hemp_cents??``}),[o,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(null),u=e=>{if(e===``||e==null)return null;let t=Number(e);if(!Number.isFinite(t)||t<0)throw Error(`Rates must be ⥠0`);return Math.round(t)},d=async()=>{s(!0),l(null);try{await D({data:{user_id:e,rate_cone_blank_cents:u(i.blank),rate_cone_custom_cents:u(i.custom),rate_filter_cents:u(i.filter),rate_hemp_cents:u(i.hemp)}}),n()}catch(e){l(e?.message??`Failed to save`)}finally{s(!1)}},f=(e,t)=>(0,P.jsx)(`input`,{type:`number`,min:0,step:1,value:i[e],placeholder:String(t),onChange:t=>a(n=>({...n,[e]:t.target.value})),style:{width:46,padding:`3px 5px`,fontSize:11,border:`1px solid #D6D6D3`,borderRadius:3,fontFamily:`ui-monospace, monospace`},title:`Override (blank = default ${t}¢)`});return(0,P.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,gap:4,alignItems:`center`,flexWrap:`wrap`},children:[(0,P.jsxs)(`label`,{style:ze,children:[`Blank `,f(`blank`,r.blank)]}),(0,P.jsxs)(`label`,{style:ze,children:[`Custom `,f(`custom`,r.custom)]}),(0,P.jsxs)(`label`,{style:ze,children:[`Filter `,f(`filter`,r.filter)]}),(0,P.jsxs)(`label`,{style:ze,children:[`Hemp `,f(`hemp`,r.hemp)]}),(0,P.jsx)(`button`,{onClick:d,disabled:o,style:{padding:`4px 8px`,fontSize:11,fontWeight:600,border:`1px solid #1E1E20`,background:`#1E1E20`,color:`#fff`,borderRadius:3,cursor:`pointer`},children:o?`â¦`:`Save`})]}),c&&(0,P.jsx)(`div`,{style:{color:`#8A2A2A`,fontSize:10},children:c})]})}var ze={display:`inline-flex`,alignItems:`center`,gap:3,fontSize:10,color:`#5A5A57`};function Be({data:e,reload:t,emailFor:n}){return e.orders.length===0?(0,P.jsx)(qe,{msg:`No orders yet. Orders created by customers will appear here.`}):(0,P.jsxs)(Fe,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Created`}),(0,P.jsx)(R,{children:`Customer`}),(0,P.jsx)(R,{children:`Product`}),(0,P.jsx)(R,{children:`Qty`}),(0,P.jsx)(R,{children:`Amount`}),(0,P.jsx)(R,{children:`Status`}),(0,P.jsx)(R,{children:`Lot`}),(0,P.jsx)(R,{children:`Tracking`})]})}),(0,P.jsx)(`tbody`,{children:e.orders.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{mono:!0,children:F(e.created_at)}),(0,P.jsx)(z,{children:n(e.customer_id)}),(0,P.jsx)(z,{children:e.product}
9),(0,P.jsx)(z,{mono:!0,children:e.quantity?.toLocaleString?.()??e.quantity}),(0,P.jsx)(z,{mono:!0,children:De((e.unit_price_cents??0)*(e.quantity??0))}),(0,P.jsx)(z,{children:(0,P.jsx)(`select`,{defaultValue:e.status,onChange:async n=>{await y({data:{id:e.id,status:n.target.value}}),t()},style:Ge,children:we.map(e=>(0,P.jsx)(`option`,{children:e},e))})}),(0,P.jsx)(z,{children:(0,P.jsx)(We,{value:e.lot_code,placeholder:`lot code`,onSave:async n=>{await y({data:{id:e.id,lot_code:n||null}}),t()}})}),(0,P.jsx)(z,{children:(0,P.jsx)(We,{value:e.tracking,placeholder:`tracking #`,onSave:async n=>{await y({data:{id:e.id,tracking:n||null}}),t()}})})]},e.id))})]})}function Ve({data:e,reload:t,emailFor:n}){let[r,i]=(0,h.useState)(!1),[a,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(null),[u,d]=(0,h.useState)(null),[f,p]=(0,h.useState)({customer_id:``,kind:`COA`,name:``,order_id:``,notes:``,file:null,product_model:`98/26`,production_date:``,lots:[{material:``,barcode:``,entry_date:``}]}),m=e.traces??[],g=(0,h.useMemo)(()=>{let e=new Map;for(let t of m)t.document_id&&e.set(t.document_id,t);return e},[m]);async function _(e){let t=m.find(t=>t.slug===e),n=t&&t.krushos_qr_url||`${window.location.origin}/trace/${e}`;d({slug:e,url:n,dataUrl:await Ce.toDataURL(n,{width:512,margin:2,errorCorrectionLevel:`M`})})}let v=e.users,y=f.customer_id?e.orders.filter(e=>e.customer_id===f.customer_id):[];async function C(){if(l(null),!f.customer_id||!f.name||!f.kind){l(`Customer, kind, and name are required.`);return}s(!0);try{let e=null;if(f.file){let t=f.file.name.replace(/[^\w.\-]+/g,`_`),n=`${f.customer_id}/${Date.now()}-${t}`,r=await o.storage.from(`coa-docs`).upload(n,f.file,{contentType:f.file.type||`application/octet-stream`,upsert:!1});if(r.error)throw r.error;e=n}let n=f.lots.map(e=>({material:e.material.trim(),barcode:e.barcode.trim(),entry_date:e.entry_date||null})).filter(e=>e.material&&e.barcode),r=await x({data:{customer_id:f.customer_id,kind:f.kind,name:f.name,file_url:e,order_id:f.order_id||null,status:`approved`,notes:f.notes||null,product_model:f.kind===`COA`&&f.product_model||null,production_date:f.kind===`COA`&&f.production_date||null,raw_material_lots:f.kind===`COA`?n:null}});p({customer_id:``,kind:`COA`,name:``,order_id:``,notes:``,file:null,product_model:`98/26`,production_date:``,lots:[{material:``,barcode:``,entry_date:``}]}),i(!1),t(),r?.trace_slug&&await _(r.trace_slug)}catch(e){l(e?.message??`Upload failed`)}finally{s(!1)}}async function w(e){if(/^https?:\/\//.test(e)){window.open(e,`_blank`,`noopener`);return}try{let{url:t}=await S({data:{path:e}});t&&window.open(t,`_blank`,`noopener`)}catch(e){alert(e?.message??`Could not open file`)}}return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginBottom:10},children:(0,P.jsx)(`button`,{onClick:()=>i(e=>!e),style:{padding:`7px 14px`,background:`#1E1E20`,color:`#fff`,border:`none`,borderRadius:4,cursor:`pointer`,fontSize:11,fontWeight:600,letterSpacing:`0.1em`,textTransform:`uppercase`},children:r?`Close`:`Upload COA / document`})}),r&&(0,P.jsxs)(`div`,{style:{border:`1px solid #E5E5E3`,borderRadius:4,padding:14,background:`#FAFAF8`,marginBottom:12,display:`grid`,gridTemplateColumns:`repeat(2, minmax(0,1fr))`,gap:10},children:[(0,P.jsxs)(`label`,{style:{fontSize:11,color:`#7A7A7C`},children:[`Customer`,(0,P.jsxs)(`select`,{value:f.customer_id,onChange:e=>p(t=>({...t,customer_id:e.target.value,order_id:``})),style:Ge,children:[(0,P.jsx)(`option`,{value:``,children:`Select customerâ¦`}),v.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.email},e.id))]})]}),(0,P.jsxs)(`label`,{style:{fontSize:11,color:`#7A7A7C`},children:[`Kind`,(0,P.jsxs)(`select`,{value:f.kind,onChange:e=>p(t=>({...t,kind:e.target.value})),style:Ge,children:[(0,P.jsx)(`option`,{value:`COA`,children:`COA`}),(0,P.jsx)(`option`,{value:`LOG`,children:`Lab log`}),(0,P.jsx)(`option`,{value:`FCS`,children:`Food contact statement`}),(0,P.jsx)(`option`,{value:`ACS`,children:`Allergen / cleaning statement`}),(0,P.jsx)(`option`,{value:`SPEC`,children:`Spec sheet`}),(0,P.jsx)(`option`,{value:`OTHER`,children:`Other`})]})]}),(0,P.jsxs)(`label`,{style:{fontSize:11,color:`#7A7A7C`},children:[`Name / lot`,(0,P.jsx)(`input`,{value:f.name,onChange:e=>p(t=>({...t,name:e.target.value})),placeholder:`e.g. LOT KR-84-2607-A`,style:Ke})]}),(0,P.jsxs)(`label`,{style:{fontSize:11,color:`#7A7A7C`},children:[`Linked order (optional)`,(0,P.jsxs)(`select`,{value:f.order_id,onChange:e=>p(t=>({...t,order_id:e.target.value})),style:Ge,disabled:!f.customer_id,children:[(0,P.jsx)(`option`,{value:``,children:`â none â`}),y.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.lot_code||e.id.slice(0,8),` · `,e.status]},e.id))]})]}),(0,P.jsxs)(`label`,{style:{fontSize:11,color:`#7A7A7C`,gridColumn:`1 / -1`},children:[`File (PDF preferred)`,(0,P.jsx)(`input`,{type:`file`,accept:`.pdf,.png,.jpg,.jpeg,.csv,.xlsx`,onChange:e=>p(t=>({...t,file:e.target.files?.[0]??null})),style:{display:`block`,marginTop:4,fontSize:12}})]}),(0,P.jsxs)(`label`,{style:{fontSize:11,color:`#7A7A7C`,gridColumn:`1 / -1`},children:[`Notes`,(0,P.jsx)(`textarea`,{value:f.notes,onChange:e=>p(t=>({...t,notes:e.target.value})),rows:2,style:{...Ke,resize:`vertical`}})]}),f.kind===`COA`&&(0,P.jsxs)(`div`,{style:{gridColumn:`1 / -1`,border:`1px dashed #D5D5D3`,borderRadius:4,padding:12,background:`#fff`,display:`grid`,gap:10},children:[(0,P.jsx)(`div`,{style:{fontSize:10.5,letterSpacing:`0.16em`,textTransform:`uppercase`,color:`#6C6C6E`,fontWeight:600},children:`Production trace (QR code)`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(2, minmax(0,1fr))`,gap:10},children:[(0,P.jsxs)(`label`,{style:{fontSize:11,color:`#7A7A7C`},children:[`Product model`,(0,P.jsxs)(`select`,{value:f.product_model,onChange:e=>p(t=>({...t,product_model:e.target.value})),style:Ge,children:[(0,P.jsx)(`option`,{children:`84/26`}),(0,P.jsx)(`option`,{children:`98/26`}),(0,P.jsx)(`option`,{children:`109/26`}),(0,P.jsx)(`option`,{children:`109/26 Hemp Blunt`})]})]}),(0,P.jsxs)(`label`,{style:{fontSize:11,color:`#7A7A7C`},children:[`Production date`,(0,P.jsx)(`input`,{type:`date`,value:f.production_date,onChange:e=>p(t=>({...t,production_date:e.target.value})),style:Ke})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:11,color:`#7A7A7C`,marginBottom:6},children:`Raw material lots`}),f.lots.map((e,t)=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.2fr 1fr 1fr auto`,gap:6,marginBottom:6},children:[(0,P.jsx)(`input`,{placeholder:`Material (e.g. Kraft paper)`,value:e.material,onChange:e=>p(n=>{let r=[...n.lots];return r[t]={...r[t],material:e.target.value},{...n,lots:r}}),style:Ke}),(0,P.jsx)(`input`,{placeholder:`Barcode / lot`,value:e.barcode,onChange:e=>p(n=>{let r=[...n.lots];return r[t]={...r[t],barcode:e.target.value},{...n,lots:r}}),style:{...Ke,fontFamily:`SFMono-Regular, Menlo, monospace`}}),(0,P.jsx)(`input`,{type:`date`,value:e.entry_date,onChange:e=>p(n=>{let r=[...n.lots];return r[t]={...r[t],entry_date:e.target.value},{...n,lots:r}}),style:Ke}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>p(e=>
9({...e,lots:e.lots.filter((e,n)=>n!==t)})),disabled:f.lots.length===1,style:{background:`transparent`,border:`1px solid #E5E5E3`,borderRadius:4,padding:`0 10px`,fontSize:11,cursor:f.lots.length===1?`default`:`pointer`,color:`#6C6C6E`},children:`Ã`})]},t)),(0,P.jsx)(`button`,{type:`button`,onClick:()=>p(e=>({...e,lots:[...e.lots,{material:``,barcode:``,entry_date:``}]})),style:{background:`transparent`,border:`1px dashed #C5C5C3`,borderRadius:4,padding:`6px 10px`,fontSize:11,cursor:`pointer`,color:`#6C6C6E`},children:`+ Add lot`})]})]}),c&&(0,P.jsx)(`div`,{style:{gridColumn:`1 / -1`,color:`#8A2A2A`,fontSize:12},children:c}),(0,P.jsx)(`div`,{style:{gridColumn:`1 / -1`,display:`flex`,justifyContent:`flex-end`},children:(0,P.jsx)(`button`,{onClick:C,disabled:a,style:{padding:`8px 16px`,background:a?`#7A7A7C`:`#1E1E20`,color:`#fff`,border:`none`,borderRadius:4,cursor:a?`default`:`pointer`,fontSize:11,fontWeight:600,letterSpacing:`0.1em`,textTransform:`uppercase`},children:a?`Uploadingâ¦`:`Upload`})})]}),e.documents.length===0?(0,P.jsx)(qe,{msg:`No documents uploaded yet. COAs, artwork PDFs, and spec sheets will appear here.`}):(0,P.jsxs)(Fe,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Uploaded`}),(0,P.jsx)(R,{children:`Customer`}),(0,P.jsx)(R,{children:`Kind`}
9),(0,P.jsx)(R,{children:`Name`}),(0,P.jsx)(R,{children:`File`}),(0,P.jsx)(R,{children:`Status`}),(0,P.jsx)(R,{children:`Trace`})]})}),(0,P.jsx)(`tbody`,{children:e.documents.map(e=>{let r=g.get(e.id);return(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{mono:!0,children:F(e.created_at)}),(0,P.jsx)(z,{children:n(e.customer_id)}),(0,P.jsx)(z,{children:e.kind}),(0,P.jsx)(z,{children:e.name}),(0,P.jsx)(z,{children:e.file_url?(0,P.jsx)(`button`,{onClick:()=>w(e.file_url),style:{background:`none`,border:`none`,padding:0,color:`#1E1E20`,fontSize:12,cursor:`pointer`,textDecoration:`underline`},children:`open`}):`â`}),(0,P.jsx)(z,{children:(0,P.jsx)(`select`,{defaultValue:e.status,onChange:async n=>{await b({data:{id:e.id,status:n.target.value}}),t()},style:Ge,children:Te.map(e=>(0,P.jsx)(`option`,{children:e},e))})}),(0,P.jsx)(z,{children:r?(0,P.jsx)(`button`,{onClick:()=>_(r.slug),style:{background:`none`,border:`1px solid #1E1E20`,padding:`3px 8px`,borderRadius:3,color:`#1E1E20`,fontSize:10.5,cursor:`pointer`,letterSpacing:`0.08em`,textTransform:`uppercase`,fontWeight:600},children:`QR`}):(0,P.jsx)(`span`,{style:{color:`#B5B5B7`,fontSize:11},children:`â`})})]},e.id)})})]}),u&&(0,P.jsx)(`div`,{onClick:()=>d(null),style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.55)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:9999,padding:20},children:(0,P.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:{background:`#fff`,padding:24,borderRadius:6,maxWidth:420,width:`100%`,textAlign:`center`},children:[(0,P.jsx)(`div`,{style:{fontSize:11,letterSpacing:`0.2em`,textTransform:`uppercase`,color:`#6C6C6E`,marginBottom:12},children:`Production QR`}),(0,P.jsx)(`img`,{src:u.dataUrl,alt:`QR code`,style:{width:260,height:260,imageRendering:`pixelated`}}),(0,P.jsx)(`div`,{style:{marginTop:12,fontSize:12,fontFamily:`SFMono-Regular, Menlo, monospace`,wordBreak:`break-all`,color:`#3A3A3C`},children:u.url}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:8,justifyContent:`center`,marginTop:16},children:[(0,P.jsx)(`a`,{href:u.dataUrl,download:`trace-${u.slug}.png`,style:{padding:`8px 14px`,background:`#1E1E20`,color:`#fff`,borderRadius:4,fontSize:11,fontWeight:600,letterSpacing:`0.1em`,textTransform:`uppercase`,textDecoration:`none`},children:`Download PNG`}),(0,P.jsx)(`button`,{onClick:()=>d(null),style:{padding:`8px 14px`,background:`#fff`,border:`1px solid #1E1E20`,color:`#1E1E20`,borderRadius:4,fontSize:11,fontWeight:600,letterSpacing:`0.1em`,textTransform:`uppercase`,cursor:`pointer`},children:`Close`})]})]})})]})}function He({data:e,reload:t,emailFor:n}){let[r,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)({customer_id:``,number:``,amount:``,due_date:``});return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginBottom:10},children:(0,P.jsx)(`button`,{onClick:()=>i(e=>!e),style:{padding:`7px 14px`,background:`#1E1E20`,color:`#fff`,border:`none`,borderRadius:4,cursor:`pointer`,fontSize:11,fontWeight:600,letterSpacing:`0.1em`,textTransform:`uppercase`},children:r?`Close`:`New invoice`})}),r&&(0,P.jsxs)(`div`,{style:{border:`1px solid #E5E5E3`,padding:14,borderRadius:4,background:`#fff`,marginBottom:12,display:`grid`,gap:10,gridTemplateColumns:`repeat(auto-fit, minmax(180px, 1fr))`},children:[(0,P.jsxs)(`select`,{value:a.customer_id,onChange:e=>o({...a,customer_id:e.target.value}),style:Ge,children:[(0,P.jsx)(`option`,{value:``,children:`Customerâ¦`}),e.users.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.email},e.id))]}),(0,P.jsx)(`input`,{placeholder:`Invoice number`,value:a.number,onChange:e=>o({...a,number:e.target.value}),style:Ke}),(0,P.jsx)(`input`,{placeholder:`Amount (CAD)`,value:a.amount,onChange:e=>o({...a,amount:e.target.value}),style:Ke}),(0,P.jsx)(`input`,{placeholder:`Due YYYY-MM-DD`,value:a.due_date,onChange:e=>o({...a,due_date:e.target.value}),style:Ke}),(0,P.jsx)(`button`,{onClick:async()=>{let e=Math.round(parseFloat(a.amount||`0`)*100);!a.customer_id||!a.number||!e||(await w({data:{customer_id:a.customer_id,number:a.number,amount_cents:e,due_date:a.due_date||null,status:`sent`}}),o({customer_id:``,number:``,amount:``,due_date:``}),i(!1),t())},style:{padding:`8px 14px`,background:`#1E1E20`,color:`#fff`,border:`none`,borderRadius:4,cursor:`pointer`,fontSize:12,fontWeight:600},children:`Create`})]}),e.invoices.length===0?(0,P.jsx)(qe,{msg:`No invoices yet.`}):(0,P.jsxs)(Fe,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`Created`}),(0,P.jsx)(R,{children:`Number`}),(0,P.jsx)(R,{children:`Customer`}),(0,P.jsx)(R,{children:`Amount`}),(0,P.jsx)(R,{children:`Due`}),(0,P.jsx)(R,{children:`Status`})]})}),(0,P.jsx)(`tbody`,{children:e.invoices.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{mono:!0,children:F(e.created_at)}),(0,P.jsx)(z,{mono:!0,children:e.number}),(0,P.jsx)(z,{children:n(e.customer_id)}),(0,P.jsx)(z,{mono:!0,children:De(e.amount_cents??0)}),(0,P.jsx)(z,{mono:!0,children:e.due_date??`â`}),(0,P.jsx)(z,{children:(0,P.jsx)(`select`,{defaultValue:e.status,onChange:async n=>{await C({data:{id:e.id,status:n.target.value}}),t()},style:Ge,children:Ee.map(e=>(0,P.jsx)(`option`,{children:e},e))})})]},e.id))})]})]})}function Ue({data:e,emailFor:t}){return e.messages.length===0?(0,P.jsx)(qe,{msg:`No concierge c
9onversations yet.`}):(0,P.jsxs)(Fe,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(R,{children:`When`}),(0,P.jsx)(R,{children:`User`}),(0,P.jsx)(R,{children:`Role`}),(0,P.jsx)(R,{children:`Message`})]})}),(0,P.jsx)(`tbody`,{children:e.messages.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(z,{mono:!0,children:F(e.created_at)}),(0,P.jsx)(z,{children:t(e.user_id)}),(0,P.jsx)(z,{children:e.role}),(0,P.jsx)(z,{children:(0,P.jsx)(`div`,{style:{maxWidth:640,whiteSpace:`pre-wrap`},children:e.content})})]},e.id))})]})}function We({value:e,placeholder:t,onSave:n}){let[r,i]=(0,h.useState)(e??``);return(0,h.useEffect)(()=>i(e??``),[e]),(0,P.jsx)(`input`,{value:r,placeholder:t,onChange:e=>i(e.target.value),onBlur:()=>{(e??``)!==r&&n(r)},style:{...Ke,minWidth:120}})}var Ge={padding:`6px 8px`,border:`1px solid #D6D6D3`,borderRadius:3,fontSize:12,background:`#fff`},Ke={padding:`6px 8px`,border:`1px solid #D6D6D3`,borderRadius:3,fontSize:12,background:`#fff`,fontFamily:`IBM Plex Mono, ui-monospace, monospace`};function qe({msg:e}){return(0,P.jsx)(`div`,{style:{border:`1px dashed #D6D6D3`,padding:24,borderRadius:4,color:`#7A7A7C`,textAlign:`center`,fontSize:13,background:`#fff`},children:e})}var Je=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Ye=t(((e,t)=>{var n=Je();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),B=e(t(((e,t)=>{t.exports=Ye()()}))(),1);function Xe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ze(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){$e(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qe(e){"@babel/helpers - typeof";return Qe=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Qe(e)}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function et(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function tt(e,t){if(e==null)return{};var n=et(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function nt(e,t){return rt(e)||it(e,t)||at(e,t)||st()}function rt(e){if(Array.isArray(e))return e}function it(e,t){var n=e&&(typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`]);if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function at(e,t){if(e){if(typeof e==`string`)return ot(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ot(e,t)}}function ot(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}
9function st(){throw TypeError(`Invalid attempt to destructure non-iterable instance. 10In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var ct=function(e,t,n){var r=!!n,i=h.useRef(n);h.useEffect(function(){i.current=n},[n]),h.useEffect(function(){if(!r||!e)return function(){};var n=function(){i.current&&i.current.apply(i,arguments)};return e.on(t,n),function(){e.off(t,n)}},[r,t,e,i])},lt=function(e){var t=h.useRef(e);return h.useEffect(function(){t.current=e},[e]),t.current},ut=function(e){return e!==null&&Qe(e)===`object`},dt=function(e){return ut(e)&&typeof e.then==`function`},ft=function(e){return ut(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},pt=`[object Object]`,mt=function e(t,n){if(!ut(t)||!ut(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===pt;if(i!==(Object.prototype.toString.call(n)===pt))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},ht=function(e,t,n){return ut(e)?Object.keys(e).reduce(function(r,i){var a=!ut(t)||!mt(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?Ze(Ze({},r||{}),{},$e({},i,e[i])):r},null):null},gt="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",_t=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:gt;if(e===null||ft(e))return e;throw Error(t)},vt=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:gt;if(dt(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return _t(e,t)})};var n=_t(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},yt=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:`react-stripe-js`,version:`6.2.0`}),e.registerAppInfo({name:`react-stripe-js`,version:`6.2.0`,url:`https://stripe.com/docs/stripe-js/react`}))},bt=h.createContext(null);bt.displayName=`ElementsContext`;var xt=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e},St=function(e){var t=e.stripe,n=e.options,r=e.children,i=h.useMemo(function(){return vt(t)},[t]),a=nt(h.useState(function(){return{stripe:i.tag===`sync`?i.stripe:null,elements:i.tag===`sync`?i.stripe.elements(n):null}}),2),o=a[0],s=a[1];h.useEffect(function(){var e=!0,t=function(e){s(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return i.tag===`async`&&!o.stripe?i.stripePromise.then(function(n){n&&e&&t(n)}):i.tag===`sync`&&!o.stripe&&t(i.stripe),function(){e=!1}},[i,o,n]);var c=lt(t);h.useEffect(function(){c!==null&&c!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[c,t]);var l=lt(n);return h.useEffect(function(){if(o.elements){var e=ht(n,l,[`clientSecret`,`fonts`]);e&&o.elements.update(e)}},[n,l,o.elements]),h.useEffect(function(){yt(o.stripe)},[o.stripe]),h.createElement(bt.Provider,{value:o},r)};St.propTypes={stripe:B.default.any,options:B.default.object};var Ct=function(e){return xt(h.useContext(bt),e)},wt=function(e){var t=e.children;return t(Ct(`mounts <ElementsConsumer>`))};wt.propTypes={children:B.default.func.isRequired};var Tt=h.createContext(null);Tt.displayName=`CheckoutContext`;var Et=function(e){var t=h.useContext(Tt),n=h.useContext(bt);if(t){if(n)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return t}else return xt(n,e)},Dt=[`mode`],Ot=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},V=function(e,t,n){var r=`${Ot(e)}Element`,i=t?function(e){Et(`mounts <${r}>`);var t=e.id,n=e.className;return h.createElement(`div`,{id:t,className:n})}:function(t){var n=t.id,i=t.className,a=t.options,o=a===void 0?{}:a,s=t.onBlur,c=t.onFocus,l=t.onReady,u=t.onChange,d=t.onEscape,f=t.onClick,p=t.onLoadError,m=t.onLoaderStart,g=t.onNetworksChange,_=t.onConfirm,v=t.onCancel,y=t.onShippingAddressChange,b=t.onShippingRateChange,x=t.onSavedPaymentMethodRemove,S=t.onSavedPaymentMethodUpdate,C=Et(`mounts <${r}>`),w=`elements`in C?C.elements:null,T=`checkoutState`in C?C.checkoutState:null,E=T?.type===`success`||T?.type===`loading`?T.s
10dk:null,D=nt(h.useState(null),2),O=D[0],k=D[1],ee=h.useRef(null),A=h.useRef(null);ct(O,`blur`,s),ct(O,`focus`,c),ct(O,`escape`,d),ct(O,`click`,f),ct(O,`loaderror`,p),ct(O,`loaderstart`,m),ct(O,`networkschange`,g),ct(O,`confirm`,_),ct(O,`cancel`,v),ct(O,`shippingaddresschange`,y),ct(O,`shippingratechange`,b),ct(O,`savedpaymentmethodremove`,x),ct(O,`savedpaymentmethodupdate`,S),ct(O,`change`,u);var j;l&&(j=e===`expressCheckout`?l:function(){l(O)}),ct(O,`ready`,j),h.useLayoutEffect(function(){if(ee.current===null&&A.current!==null&&(w||E)){var t=null;if(E){var n=E,i=E;switch(e){case`paymentForm`:t=i.createForm(o);break;case`payment`:t=n.createPaymentElement(o);break;case`address`:if(`mode`in o){var a=o.mode,s=tt(o,Dt);if(a===`shipping`)t=n.createShippingAddressElement(s);else if(a===`billing`)t=n.createBillingAddressElement(s);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(o);break;case`currencySelector`:t=E.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(o);break;case`contactDetails`:t=n.createContactDetailsElement();break;default:throw Error(`<${r}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else w&&(t=w.create(e,o));ee.current=t,k(t),t&&t.mount(A.current)}},[w,E,o]);var te=lt(o);return h.useEffect(function(){if(ee.current){var e=ht(o,te,[`paymentRequest`]);e&&`update`in ee.current&&ee.current.update(e)}},[o,te]),h.useLayoutEffect(function(){return function(){if(ee.current&&typeof ee.current.destroy==`function`)try{ee.current.destroy(),ee.current=null}catch{}}},[]),h.createElement(`div`,{id:n,className:i,ref:A})};return i.propTypes={id:B.default.string,className:B.default.string,onChange:B.default.func,onBlur:B.default.func,onFocus:B.default.func,onReady:B.default.func,onEscape:B.default.func,onClick:B.default.func,onLoadError:B.default.func,onLoaderStart:B.default.func,onNetworksChange:B.default.func,onConfirm:B.default.func,onCancel:B.default.func,onShippingAddressChange:B.default.func,onShippingRateChange:B.default.func,onSavedPaymentMethodRemove:B.default.func,onSavedPaymentMethodUpdate:B.default.func,options:B.default.object},i.displayName=r,i.__elementType=e,i},H=typeof window>`u`,kt=h.createContext(null);kt.displayName=`EmbeddedCheckoutProviderContext`;var At=function(){var e=h.useContext(kt);if(!e)throw Error(`<EmbeddedCheckout> must be used within <EmbeddedCheckoutProvider>`);return e},jt="Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",Mt=function(e){var t=e.stripe,n=e.options,r=e.children,i=h.useMemo(function(){return vt(t,jt)},[t]),a=h.useRef(null),o=h.useRef(null),s=nt(h.useState({embeddedCheckout:null}),2),c=s[0],l=s[1];h.useEffect(function(){if(!(o.current||a.current)){var e=function(e){o.current||a.current||(o.current=e,a.current=o.current.createEmbeddedCheckoutPage(n).then(function(e){l({embeddedCheckout:e})}))};i.tag===`async`&&!o.current&&(n.clientSecret||n.fetchClientSecret)?i.stripePromise.then(function(t){t&&e(t)}):i.tag===`sync`&&!o.current&&(n.clientSecret||n.fetchClientSecret)&&e(i.stripe)}},[i,n,c,o]),h.useEffect(function(){return function(){c.embeddedCheckout?(a.current=null,c.embeddedCheckout.destroy()):a.current&&a.current.then(function(){a.current=null,c.embeddedCheckout&&c.embeddedCheckout.destroy()})}},[c.embeddedCheckout]),h.useEffect(function(){yt(o)},[o]);var u=lt(t);h.useEffect(function(){u!==null&&u!==t&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.")},[u,t]);var d=lt(n);return h.useEffect(function(){if(d!=null){if(n==null){console.warn(`Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them.`);return}n.clientSecret===void 0&&n.fetchClientSecret===void 0&&console.warn("Invalid props passed to EmbeddedCheckoutProvider: You must provide one of either `options.fetchClientSecret` or `options.clientSecret`."),d.clientSecret!=null&&n.clientSecret!==d.clientSecret&&console.warn(`Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.`),d.fetchClientSecret!=null&&n.fetchClientSecret!==d.fetchClientSecret&&console.warn(`Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.`),d.onComplete!=null&&n.onComplete!==d.onComplete&&console.warn(`Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.`),d.onShippingDetailsChange!=null&&n.onShippingDetailsChange!==d.onShippingDetailsChange&&console.warn(`Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it.`),d.onLineItemsChange!=null&&n.onLineItemsChange!==d.onLineItemsChange&&console.warn(`Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.`)}},[d,n]),h.createElement(kt.Provider,{value:c},r)},Nt=H?function(e){var t=e.id,n=e.className;return At(),h.createElement(`div`,{id:t,className:n})}:function(e){var t=e.id,n=e.className,r=At().embeddedCheckout,i=h.useRef(!1),a=h.useRef(null);return h.useLayoutEffect(function(){return!i.current&&r&&a.current!==null&&(r.mount(a.current),i.current=!0),function(){if(i.current&&r)try{r.unmount(),i.current=!1}catch{}}},[r]),h.createElement(`div`,{ref:a,id:t,className:n})};V(`auBankAccount`,H),V(`card`,H),V(`cardNumber`,H),V(`cardExpiry`,H),V(`cardCvc`,H),V(`iban`,H),V(`payment`,H),V(`expressCheckout`,H),V(`paymentRequestButton`,H),V(`linkAuthentication`,H),V(`contactDetails`,H),V(`address`,H),V(`shippingAddress`,H),V(`paymentMethodMessaging`,H),V(`taxId`,H),V(`issu
10ingCardNumberDisplay`,H),V(`issuingCardCvcDisplay`,H),V(`issuingCardExpiryDisplay`,H),V(`issuingCardPinDisplay`,H),V(`issuingCardCopyButton`,H);function Pt(e){"@babel/helpers - typeof";return Pt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Pt(e)}var Ft=`dahlia`,It=function(e){return e===3?`v3`:e},Lt=`https://js.stripe.com`,Rt=`${Lt}/${Ft}/stripe.js`,zt=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Bt=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,Vt=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,Ht=function(e){return zt.test(e)||Bt.test(e)},Ut=function(){for(var e=document.querySelectorAll(`script[src^="${Lt}"]`),t=0;t<e.length;t++){var n=e[t];if(Ht(n.src))return n}return null},Wt=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${Rt}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},Gt=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:`stripe-js`,version:`9.2.0`,startTime:t})},Kt=null,qt=null,Jt=null,Yt=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},Xt=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},Zt=function(e){return Kt===null?(Kt=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(Vt),window.Stripe){t(window.Stripe);return}try{var r=Ut();if(r&&e)console.warn(Vt);else if(!r)r=Wt(e);else if(r&&Jt!==null&&qt!==null){var i;r.removeEventListener(`load`,Jt),r.removeEventListener(`error`,qt),(i=r.parentNode)==null||i.removeChild(r),r=Wt(e)}Jt=Xt(t,n),qt=Yt(n),r.addEventListener(`load`,Jt),r.addEventListener(`error`,qt)}catch(e){n(e);return}}),Kt.catch(function(e){return Kt=null,Promise.reject(e)})):Kt},Qt=function(e,t,n){if(e===null)return null;var r=t[0];if(typeof r!=`string`)throw Error(`Expected publishable key to be of type string, got type ${Pt(r)} instead.`);var i=r.match(/^pk_test/),a=It(e.version),o=Ft;i&&a!==o&&console.warn(`Stripe.js@${a} was loaded on the page, but @stripe/[email protected] expected Stripe.js@${o}. This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning`);var s=e.apply(void 0,t);return Gt(s,n),s},$t,en=!1,tn=function(){return $t||($t=Zt(null).catch(function(e){return $t=null,Promise.reject(e)}),$t)};Promise.resolve().then(function(){return tn()}).catch(function(e){en||console.warn(e)});var nn=function(){var e=[...arguments];en=!0;var t=Date.now();return tn().then(function(n){return Qt(n,e,t)})},rn=`pk_live_51TtG6sPIvPQqMWSXaatCqW89SA4vlWZnPOUfEv4bOy1CnCFc69K8kYb83vZIoCO3BksJczOkmdkOPInVeA5nykiW00elTRZVac`;function an(){if(rn.startsWith(`pk_test_`))return`sandbox`;if(rn.startsWith(`pk_live_`))return`live`;throw Error(`Payments are not configured for this build. Complete payments go-live in your Lovable project to accept real payments.`)}var on=null;function sn(){return on||=(an(),nn(rn)),on}function cn(){return an()}var ln=a({method:`POST`}).middleware([u]).handler(i(`6252a7dd0f23bd4f86f20a25a0394d13ccc9d53fd6523c4cc765e377f3bff0c6`));function un({invoiceId:e,invoiceNumber:t,amount:n,onClose:r}){let[i,a]=(0,h.useState)(null),[o,s]=(0,h.useState)(!0);return(0,h.useEffect)(()=>{try{cn()}catch(e){s(!1),a(e.message)}},[]),(0,P.jsx)(`div`,{style:{position:`fixed`,inset:0,background:`rgba(30,30,32,0.6)`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:20,zIndex:60},children:(0,P.jsxs)(`div`,{style:{background:`#fff`,borderRadius:8,width:`100%`,maxWidth:720,maxHeight:`92vh`,overflow:`auto`,padding:20,position:`relative`},children:[(0,P.jsx)(`button`,{onClick:r,"aria-label":`Close`,style:{position:`absolute`,top:12,right:12,background:`none`,border:`none`,cursor:`pointer`,fontSize:20},children:`Ã`}),(0,P.jsxs)(`div`,{style:{marginBottom:12},children:[(0,P.jsxs)(`div`,{style:{fontSize:11,letterSpacing:`0.12em`,textTransform:`uppercase`,color:`#666`},children:[`Pay invoice `,t]}),(0,P.jsxs)(`div`,{style:{fontFamily:`ui-monospace, monospace`,fontSize:24,fontWeight:600,marginTop:4},children:[`$`,n.toFixed(2),` CAD`]})]}),!o||i?(0,P.jsx)(`div`,{style:{padding:16,background:`#fee`,border:`1px solid #fbb`,borderRadius:6,color:`#900`},children:i??`Payments not configured`}):(0,P.jsx)(`div`,{id:`checkout`,children:(0,P.jsx)(Mt,{stripe:sn(),options:{fetchClientSecret:async()=>{let n=await ln({data:{invoiceId:e,returnUrl:`${window.location.origin}${window.location.pathname}?paid=${encodeURIComponent(t)}`,environment:cn()}});if(n&&`error`in n)throw Error(n.error);if(!n?.clientSecret)throw Error(`No client secret returned`);return n.clientSecret}},children:(0,P.jsx)(Nt,{})})})]})})}var dn=(...e)=>
vendor: 5,241 bytes, line 10
10e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),fn=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),pn=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),mn=e=>{let t=pn(e);return t.charAt(0).toUpperCase()+t.slice(1)},hn={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},gn=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},_n=(0,h.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,h.createElement)(`svg`,{ref:c,...hn,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:dn(`lucide`,i),...!a&&!gn(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,h.createElement)(e,t)),...Array.isArray(a)?a:[a]])),U=(e,t)=>{let n=(0,h.forwardRef)(({className:n,...r},i)=>(0,h.createElement)(_n,{ref:i,iconNode:t,className:dn(`lucide-${fn(mn(e))}`,`lucide-${e}`,n),...r}));return n.displayName=mn(e),n},vn=U(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),yn=U(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),bn=U(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),xn=U(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Sn=U(`building-2`,[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]]),Cn=U(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),wn=U(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Tn=U(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),En=U(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Dn=U(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),On=U(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),kn=U(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),An=U(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),jn=U(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Mn=U(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Nn=U(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),Pn=U(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Fn=U(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),In=U(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Ln=U(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Rn=U(`leaf`,[[`path`,{d:`M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z`,ke
10y:`nnexq3`}],[`path`,{d:`M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12`,key:`mt58a7`}]]),zn=U(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Bn=U(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Vn=U(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),Hn=U(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Un=U(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Wn=U(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Gn=U(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Kn=U(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),qn=U(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Jn=U(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),Yn=U(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Xn=U(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Zn=U(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Qn=U(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),$n=U(`shopping-cart`,[[`circle`,{cx:`8`,cy:`21`,r:`1`,key:`jimo8o`}],[`circle`,{cx:`19`,cy:`21`,r:`1`,key:`13723u`}],[`path`,{d:`M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12`,key:`9zh506`}]]),er=U(`slack`,[[`rect`,{width:`3`,height:`8`,x:`13`,y:`2`,rx:`1.5`,key:`diqz80`}],[`path`,{d:`M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5`,key:`183iwg`}],[`rect`,{width:`3`,height:`8`,x:`8`,y:`14`,rx:`1.5`,key:`hqg7r1`}],[`path`,{d:`M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5`,key:`76g71w`}],[`rect`,{width:`8`,height:`3`,x:`14`,y:`13`,rx:`1.5`,key:`1kmz0a`}],[`path`,{d:`M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5`,key:`jc4sz0`}],[`rect`,{width:`8`,height:`3`,x:`2`,y:`8`,rx:`1.5`,key:`1omvl4`}],[`path`,{d:`M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5`,key:`16f3cl`}]]),tr=U(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594
101.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),nr=U(`spray-can`,[[`path`,{d:`M3 3h.01`,key:`159qn6`}],[`path`,{d:`M7 5h.01`,key:`1hq22a`}],[`path`,{d:`M11 7h.01`,key:`1osv80`}],[`path`,{d:`M3 7h.01`,key:`1xzrh3`}],[`path`,{d:`M7 9h.01`,key:`19b3jx`}],[`path`,{d:`M3 11h.01`,key:`1eifu7`}],[`rect`,{width:`4`,height:`4`,x:`15`,y:`5`,key:`mri9e4`}],[`path`,{d:`m19 9 2 2v10c0 .6-.4 1-1 1h-6c-.6 0-1-.4-1-1V11l2-2`,key:`aib6hk`}],[`path`,{d:`m13 14 8-2`,key:`1d7bmk`}],[`path`,{d:`m13 19 8-2`,key:`1y2vml`}]]),rr=U(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),ir=U(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),ar=U(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),or=U(`truck`,[[`path`,{d:`M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2`,key:`wrbu53`}],[`path`,{d:`M15 18H9`,key:`1lyqi6`}],[`path`,{d:`M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14`,key:`lysw3i`}],[`circle`,{cx:`17`,cy:`18`,r:`2`,key:`332jqn`}],[`circle`,{cx:`7`,cy:`18`,r:`2`,key:`19iecd`}]]),sr=U(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),cr=U(`wallet`,[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]),lr=U(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function ur(e,t=`export.csv`){if(!e||!e.length)return;let n=Object.keys(e[0]),r=e=>{if(e==null)return``;let t=typeof e==`object`?JSON.stringify(e):String(e);return/[",\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t},i=[n.join(`,`),...e.map(e=>n.map(t=>r(e[t])).join(`,`))].join(` 11`),a=new Blob([i],{type:`text/csv;charset=utf-8`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=t,s.click(),setTimeout(()=>URL.revokeObjectURL(o),500)}function dr({rows:e,filename:t,label:n=`Export CSV`}){return(0,P.jsxs)(`button`,{onClick:()=>ur(e,t),disabled:!e?.length,style:{display:`inline-flex`,alignItems:`center`,gap:6,background:`#fff`,border:`1px solid #E3E3E5`,borderRadius:4,padding:`6px 10px`,fontSize:11,cursor:e?.length?`pointer`:`not-allowed`,color:`#1A1A1C`,fontWeight:600,opacity:e?.length?1:.5},children:[(0,P.jsx)(kn,{size:12}),` `,n]})}function fr(){let[e,t]=(0,h.useState)([]),n=async()=>{let{data:e}=await o.auth.getUser(),n=e?.user?.id;if(!n)return;let{data:r}=await o.from(`order_drafts`).select(`*`).eq(`user_id`,n).order(`updated_at`,{ascending:!1});t(r||[])};return(0,h.useEffect)(()=>{n()},[]),{drafts:e,reload:n,remove:async e=>{await o.from(`order_drafts`).delete().eq(`id`,e),n()}}}function pr({onResume:e}){let{drafts:t,remove:n}=fr();if(!t.length)return null;let r=t[0];return(0,P.jsxs)(`div`,{style:{background:`#FFF8E5`,border:`1px solid #F0D77A`,borderRadius:6,padding:`12px 14px`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,marginBottom:16},children:[(0,P.jsxs)(`div`,{style:{fontSize:12.5,color:`#4A3A00`},children:[(0,P.jsx)(`strong`,{children:`Draft order saved`}),` â `,r.label,` · `,(0,P.jsx)(`span`,{style:{color:`#8A7A3E`},children:new Date(r.updated_at).toLocaleString()}),t.length>1&&(0,P.jsxs)(`span`,{style:{color:`#8A7A3E`},children:[` · `,t.length-1,` more`]})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,P.jsx)(`button`,{onClick:()=>e?.(r),style:{background:`#1A1A1C`,color:`#fff`,border:0,borderRadius:4,padding:`6px 12px`,fontSize:11,fontWeight:700,cursor:`pointer`},children:`Resume`}),(0,P.jsx)(`button`,{onClick:()=>n(r.id),style:{background:`transparent`,border:`1px solid #D4B85E`,borderRadius:4,padding:`6px 10px`,fontSize:11,cursor:`pointer`,color:`#4A3A00`}
11,children:`Discard`})]})]})}function mr({orders:e,onReorder:t}){let n=(0,h.useMemo)(()=>{let t=new Map;return(e||[]).forEach(e=>{let n=e.product||e.sku||e.name;if(!n)return;let r=Number(e.quantity||e.pallets||0),i=t.get(n)||{key:n,product:n,quantity:0,count:0,last:null};i.quantity+=r,i.count+=1,i.last=i.last&&i.last>(e.createdAt||e.created_at||``)?i.last:e.createdAt||e.created_at||``,t.set(n,i)}),Array.from(t.values()).sort((e,t)=>t.count-e.count).slice(0,3)},[e]);return n.length?(0,P.jsxs)(`div`,{style:{marginBottom:18},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,letterSpacing:`0.2em`,color:`#6D6D71`,marginBottom:8},children:`Quick reorder`}),(0,P.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(220px, 1fr))`,gap:10},children:n.map(e=>(0,P.jsxs)(`div`,{style:{background:`#fff`,border:`1px solid #E3E3E5`,borderRadius:6,padding:12},children:[(0,P.jsx)(`div`,{style:{fontSize:12.5,fontWeight:700,color:`#1A1A1C`,marginBottom:2,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.product}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10.5,color:`#6D6D71`,marginBottom:8},children:[e.count,`à ordered · last `,e.last?new Date(e.last).toLocaleDateString():`â`]}),(0,P.jsxs)(`button`,{onClick:()=>t?.(e),style:{display:`inline-flex`,alignItems:`center`,gap:6,background:`#1A1A1C`,color:`#fff`,border:0,borderRadius:4,padding:`6px 10px`,fontSize:11,fontWeight:700,cursor:`pointer`},children:[(0,P.jsx)(Yn,{size:11}),` Reorder`]})]},e.key))})]}):null}function hr({nav:e,orders:t,invoices:n,onGo:r}){let[i,a]=(0,h.useState)(!1),[o,s]=(0,h.useState)(``),c=(0,h.useRef)(null);(0,h.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&(e.key===`k`||e.key===`K`)?(e.preventDefault(),a(e=>!e)):e.key===`Escape`&&a(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,h.useEffect)(()=>{i&&setTimeout(()=>c.current?.focus(),20)},[i]);let l=(0,h.useMemo)(()=>{let r=o.trim().toLowerCase(),i=(e||[]).map(e=>({kind:`page`,id:e.id,label:e.label,hint:`Jump to`})),a=(t||[]).slice(0,40).map(e=>({kind:`order`,id:e.id||e.uuid,label:`Order · ${e.product||`cones`}`,hint:`${e.quantity||0} · ${e.status||``}`,page:`tracker`})),s=(n||[]).slice(0,40).map(e=>({kind:`invoice`,id:e.number||e.id,label:`Invoice ${e.number||``}`,hint:`${e.status||``}`,page:`balance`})),c=[...i,...a,...s];return r?c.filter(e=>(e.label+` `+(e.hint||``)).toLowerCase().includes(r)).slice(0,20):c.slice(0,12)},[o,e,t,n]);return i?(0,P.jsx)(`div`,{onClick:()=>a(!1),style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.45)`,zIndex:100,display:`flex`,alignItems:`flex-start`,justifyContent:`center`,paddingTop:90},children:(0,P.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:{background:`#fff`,width:`min(560px, 92vw)`,borderRadius:8,boxShadow:`0 20px 60px rgba(0,0,0,0.3)`,overflow:`hidden`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`12px 14px`,borderBottom:`1px solid #E3E3E5`},children:[(0,P.jsx)(Xn,{size:16}),(0,P.jsx)(`input`,{ref:c,value:o,onChange:e=>s(e.target.value),placeholder:`Jump to a page, search orders or invoicesâ¦`,style:{flex:1,border:0,outline:`none`,fontSize:14}}),(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10,color:`#8A8A8E`},children:`ESC`})]}),(0,P.jsxs)(`div`,{style:{maxHeight:380,overflow:`auto`},children:[l.length===0&&(0,P.jsx)(`div`,{style:{padding:16,fontSize:12,color:`#6D6D71`},children:`No matches.`}),l.map((e,t)=>(0,P.jsxs)(`button`,{onClick:()=>{a(!1),r?.(e.page||e.id)},style:{display:`flex`,width:`100%`,justifyContent:`space-between`,alignItems:`center`,padding:`10px 14px`,background:`transparent`,border:0,borderBottom:`1px solid #F1F1F3`,cursor:`pointer`,textAlign:`left`},children:[(0,P.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[e.kind===`invoice`?(0,P.jsx)(Mn,{size:13}):e.kind===`order`?(0,P.jsx)(Yn,{size:13}):(0,P.jsx)(Xn,{size:13}),(0,P.jsx)(`span`,{style:{fontSize:13,fontWeight:600},children:e.label})]}),(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10.5,color:`#8A8A8E`},children:e.hint})]},t))]}),(0,P.jsxs)(`div`,{style:{padding:`8px 14px`,fontSize:10.5,color:`#8A8A8E`,borderTop:`1px solid #E3E3E5`},children:[`Tip: press `,(0,P.jsx)(`span`,{className:`mono`,children:`âK`}),` (or `,(0,P.jsx)(`span`,{className:`mono`,children:`Ctrl+K`}),`) from anywhere.`]})]})}):null}function gr(){let[e,t]=(0,h.useState)(!1),[n,r]=(0,h.useState)([]),[i,a]=(0,h.useState)(0),s=async()=>{let{data:e}=await o.auth.getUser(),t=e?.user?.id,[{data:n},{data:i}]=await Promise.all([o.from(`app_releases`).select(`*`).order(`released_at`,{ascending:!1}).limit(20),t?o.from(`app_release_reads`).select(`release_id`).eq(`user_id`,t):Promise.resolve({data:[]})]),s=new Set((i||[]).map(e=>e.release_id));r(n||[]),a((n||[]).filter(e=>!s.has(e.id)).length)};(0,h.useEffect)(()=>{s()},[]);let c=async()=>{let{data:e}=await o.auth.getUser(),t=e?.user?.id;if(!t)return;let r=n.map(e=>({user_id:t,release_id:e.id}));r.length&&await o.from(`app_release_reads`).upsert(r,{onConflict:`user_id,release_id`}),a(0)};return(0,P.jsxs)(`div`,{style:{position:`relative`},children:[(0,P.jsxs)(`button`,{onClick:()=>{t(e=>!e),e||c()},title:`What's new`,"aria-label":`What's new`,style:{position:`relative`,background:`transparent`,border:0,cursor:`pointer`,color:`#1A1A1C`,padding:4},children:[(0,P.jsx)(tr,{size:18}),i>0&&(0,P.jsx)(`span`,{style:{position:`absolute`,top:-2,right:-2,background:`#D4335A`,color:`#fff`,borderRadius:999,fontSize:9,fontWeight:700,padding:`1px 5px`,minWidth:14,textAlign:`center`},children:i})]}),e&&(0,P.jsxs)(`div`,{style:{position:`absolute`,right:0,top:30,width:340,background:`#fff`,border:`1px solid #E3E3E5`,borderRadius:6,boxShadow:`0 10px 30px rgba(0,0,0,0.15)`,zIndex:60},children:[(0,P.jsxs)(`div`,{style:{padding:`12px 14px`,borderBottom:`1px solid #E3E3E5`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,P.jsx)(`strong`,{style:{fontSize:12.5},children:`What's new`}),(0,P.jsx)(`button`,{onClick:()=>t(!1),style:{background:`transparent`,border:0,cursor:`pointer`},children:(0,P.jsx)(lr,{size:14})})]}),(0,P.jsxs)(`div`,{style:{maxHeight:360,overflow:`auto`}
11,children:[n.length===0&&(0,P.jsx)(`div`,{style:{padding:16,fontSize:12,color:`#6D6D71`},children:`No release notes yet.`}),n.map(e=>(0,P.jsxs)(`div`,{style:{padding:`12px 14px`,borderBottom:`1px solid #F1F1F3`},children:[(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10,color:`#8A8A8E`},children:[`v`,e.version,` · `,new Date(e.released_at).toLocaleDateString()]}),(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:700,margin:`3px 0 4px`},children:e.title}),(0,P.jsx)(`div`,{style:{fontSize:12,color:`#4A4A4E`,lineHeight:1.45},children:e.body})]},e.id))]})]})]})}var _r={background:`#fff`,border:`1px solid #E3E3E5`,borderRadius:8,padding:20},vr={fontSize:22,letterSpacing:`-0.01em`,color:`#1A1A1C`,margin:`0 0 4px`},yr={fontSize:12,color:`#6D6D71`,marginBottom:20},br={background:`#1A1A1C`,color:`#fff`,border:0,borderRadius:4,padding:`9px 16px`,fontSize:12,fontWeight:700,cursor:`pointer`},xr={background:`#fff`,color:`#1A1A1C`,border:`1px solid #C7C7CB`,borderRadius:4,padding:`9px 16px`,fontSize:12,fontWeight:700,cursor:`pointer`},Sr={width:`100%`,border:`1px solid #C7C7CB`,borderRadius:4,padding:`8px 10px`,fontSize:13,background:`#fff`},Cr={fontSize:10.5,letterSpacing:`0.16em`,color:`#8A8A8E`,textTransform:`uppercase`,marginBottom:4,display:`block`};function wr(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(`Blank cones â 109/26`),[i,a]=(0,h.useState)(115200),[s,c]=(0,h.useState)(!1),l=async()=>{let{data:e}=await o.auth.getUser();if(!e?.user)return;let{data:n}=await o.from(`subscriptions`).select(`*`).eq(`customer_id`,e.user.id).order(`created_at`,{ascending:!1});t(n||[])};(0,h.useEffect)(()=>
11{l()},[]);let u=async()=>{c(!0);let{data:e}=await o.auth.getUser();e?.user&&(await o.from(`subscriptions`).insert({customer_id:e.user.id,product:n,quantity:Number(i),cadence:`monthly`,discount_pct:10}),await l()),c(!1)},d=async(e,t)=>{await o.from(`subscriptions`).update({status:t}).eq(`id`,e),l()};return(0,P.jsxs)(`div`,{style:_r,children:[(0,P.jsx)(`h2`,{style:vr,children:`Auto-replenishment`}),(0,P.jsx)(`div`,{style:yr,children:`Monthly subscription with 10% off. Cancel anytime.`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`2fr 1fr auto`,gap:10,alignItems:`end`,marginBottom:16},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:Cr,children:`Product`}),(0,P.jsx)(`input`,{style:Sr,value:n,onChange:e=>r(e.target.value)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:Cr,children:`Cones / month`}),(0,P.jsx)(`input`,{type:`number`,style:Sr,value:i,onChange:e=>a(e.target.value)})]}),(0,P.jsx)(`button`,{style:br,disabled:s,onClick:u,children:`Add subscription`})]}),e.length===0?(0,P.jsx)(`div`,{style:{color:`#6D6D71`,fontSize:12},children:`No active subscriptions.`}):e.map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,borderTop:`1px solid #F1F1F3`,padding:`12px 0`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontWeight:700,fontSize:13},children:e.product}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:`#6D6D71`},children:[e.quantity.toLocaleString(),` cones · next `,e.next_run,` · `,e.discount_pct,`% off · `,e.status]})]}),(0,P.jsx)(`button`,{style:xr,onClick:()=>d(e.id,e.status===`active`?`paused`:`active`),children:e.status===`active`?`Pause`:`Resume`})]},e.id))]})}function Tr(){let[e,t]=(0,h.useState)([]),n=async()=>{let{data:e}=await o.auth.getUser();if(!e?.user)return;let{data:n}=await o.from(`referrals`).select(`*`).eq(`owner_id`,e.user.id).order(`created_at`,{ascending:!1});t(n||[])};return(0,h.useEffect)(()=>{n()},[]),(0,P.jsxs)(`div`,{style:_r,children:[(0,P.jsx)(`h2`,{style:vr,children:`Referral program`}),(0,P.jsx)(`div`,{style:yr,children:`Share a code. When a new company signs up and uses it, both accounts earn a $50 Filter Bank credit.`}),(0,P.jsx)(`button`,{style:br,onClick:async()=>{let{data:e}=await o.auth.getUser();if(!e?.user)return;let t=`KRUSH-`+Math.random().toString(36).slice(2,8).toUpperCase();await o.from(`referrals`).insert({owner_id:e.user.id,code:t,credit_cents:5e3}),n()},children:`Generate new referral code`}),(0,P.jsx)(`div`,{style:{marginTop:16},children:e.length===0?(0,P.jsx)(`div`,{style:{color:`#6D6D71`,fontSize:12},children:`No codes yet.`}):e.map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,borderTop:`1px solid #F1F1F3`,padding:`10px 0`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:13,fontWeight:700},children:e.code}),(0,P.jsxs)(`span`,{style:{marginLeft:12,fontSize:11,color:`#6D6D71`},children:[`$`,(e.credit_cents/100).toFixed(0),` credit`]})]}),(0,P.jsx)(`span`,{style:{fontSize:11,color:e.redeemed_at?`#2F7A4A`:`#8A8A8E`},children:e.redeemed_at?`Redeemed ${new Date(e.redeemed_at).toLocaleDateString()}`:`Unused`})]},e.id))})]})}function Er(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)({name:``,company:``,address:``,city:``,region:``,postal:``,country:`USA`}),[i,a]=(0,h.useState)(!1);(0,h.useEffect)(()=>{(async()=>{let{data:e}=await o.auth.getUser();if(!e?.user)return;let{data:n}=await o.from(`sample_kit_requests`).select(`*`).eq(`customer_id`,e.user.id).maybeSingle();t(n)})()},[]);let s=async()=>{let{data:e}=await o.auth.getUser();e?.user&&(await o.from(`sample_kit_requests`).insert({customer_id:e.user.id,ship_to:n}),a(!0))};return e||i?(0,P.jsxs)(`div`,{style:_r,children:[(0,P.jsx)(`h2`,{style:vr,children:`Sample kit`}),(0,P.jsxs)(`div`,{style:{background:`#F0F7EE`,border:`1px solid #C9E4C0`,borderRadius:6,padding:14,fontSize:13,color:`#2F7A4A`},children:[(0,P.jsx)(wn,{size:14,style:{verticalAlign:-2,marginRight:6}}),`Your sample kit request is on file. Status: `,(0,P.jsx)(`strong`,{children:e?.
11status||`pending`}),`.`]})]}):(0,P.jsxs)(`div`,{style:_r,children:[(0,P.jsx)(`h2`,{style:vr,children:`Request a sample kit`}),(0,P.jsx)(`div`,{style:yr,children:`Get a physical set of every cone diameter + tip finish. One kit per company.`}),(0,P.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10},children:[[`name`,`Contact name`],[`company`,`Company`],[`address`,`Street address`],[`city`,`City`],[`region`,`State/Prov.`],[`postal`,`Postal / ZIP`],[`country`,`Country`]].map(([e,t])=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:Cr,children:t}),(0,P.jsx)(`input`,{style:Sr,value:n[e],onChange:t=>r({...n,[e]:t.target.value})})]},e))}),(0,P.jsx)(`button`,{style:{...br,marginTop:14},onClick:s,disabled:!n.name||!n.address,children:`Submit request`})]})}function Dr(){let[e,t]=(0,h.useState)({coas:[],licenses:[],bols:[]});(0,h.useEffect)(()=>{(async()=>{let{data:e}=await o.auth.getUser();if(!e?.user)return;let[{data:n},{data:r}]=await Promise.all([o.from(`documents`).select(`*`).eq(`customer_id`,e.user.id),o.from(`license_documents`).select(`*`).eq(`customer_id`,e.user.id)]);t({coas:(n||[]).filter(e=>e.kind===`COA`),bols:(n||[]).filter(e=>(e.kind||``).toUpperCase().includes(`BOL`)),licenses:r||[]})})()},[]);let n=()=>{[...e.coas.map(e=>({name:`COA-${e.title||e.id}`,url:e.file_url})),...e.bols.map(e=>({name:`BOL-${e.title||e.id}`,url:e.file_url})),...e.licenses.map(e=>({name:`LICENSE-${e.license_type||e.id}`,url:e.file_url}))].filter(e=>e.url).forEach((e,t)=>setTimeout(()=>{let t=document.createElement(`a`);t.href=e.url,t.download=e.name,t.target=`_blank`,t.click()},t*250))},r=({title:e,items:t})=>(0,P.jsxs)(`div`,{style:{marginTop:16},children:[(0,P.jsxs)(`div`,{className:`caps`,style:{fontSize:10,letterSpacing:`0.2em`,color:`#8A8A8E`,marginBottom:8},children:[e,` · `,t.length]}),t.length===0?(0,P.jsx)(`div`,{style:{fontSize:12,color:`#6D6D71`},children:`None on file.`}):t.map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderTop:`1px solid #F1F1F3`},children:[(0,P.jsx)(`span`,{style:{fontSize:12.5},children:e.title||e.license_type||e.id}),e.file_url&&(0,P.jsx)(`a`,{href:e.file_url,target:`_blank`,rel:`noreferrer`,style:{fontSize:11.5,color:`#1A1A1C`},children:`Download`})]},e.id))]});return(0,P.jsxs)(`div`,{style:_r,children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:4},children:[(0,P.jsx)(`h2`,{style:vr,children:`Compliance vault`}),(0,P.jsxs)(`button`,{style:br,onClick:n,children:[(0,P.jsx)(kn,{size:12,style:{verticalAlign:-1,marginRight:4}}),` Download all`]})]}),(0,P.jsx)(`div`,{style:yr,children:`Every COA, license, and BOL on file â one place for audits.`}),(0,P.jsx)(r,{title:`Certificates of Analysis`,items:e.coas}),(0,P.jsx)(r,{title:`Licenses`,items:e.licenses}),(0,P.jsx)(r,{title:`Bills of Lading`,items:e.bols})]})}function Or({orders:e=[],invoices:t=[]}){let n=new Date().getFullYear(),r=(0,h.useMemo)(()=>{let r=(e||[]).filter(e=>new Date(e.createdAt||e.created_at||0).getFullYear()===n),i=r.reduce((e,t)=>e+Number(t.quantity||0),0);return{cones:i,spend:(t||[]).filter(e=>new Date(e.createdAt||e.created_at||0).getFullYear()===n&&(e.status===`paid`||e.status===`Paid`)).reduce((e,t)=>e+Number(t.amount||0),0),co2:Math.round(i*4e-4*100)/100,skus:new Set(r.map(e=>e.product)).size,orderCount:r.length}},[e,t,n]),i=({label:e,value:t,unit:n})=>(0,P.jsxs)(`div`,{style:{padding:18,background:`#FAFAF9`,border:`1px solid #E9E9E7`,borderRadius:6,textAlign:`center`},children:[(0,P.jsxs)(`div`,{style:{fontSize:26,fontWeight:700,color:`#1A1A1C`},children:[t,(0,P.jsx)(`span`,{style:{fontSize:12,color:`#6D6D71`,marginLeft:4},children:n})]}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,letterSpacing:`0.2em`,color:`#8A8A8E`,marginTop:4},children:e})]});return(0,P.jsxs)(`div`,{style:_r,children:[(0,P.jsxs)(`h2`,{style:vr,children:[n,` annual review`]}),(0,P.jsx)(`div`,{style:yr,children:`Your year in Krush cones.`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(140px, 1fr))`,gap:12},children:[(0,P.jsx)(i,{label:`Cones produced`,value:r.cones.toLocaleStr
11ing(),unit:``}),(0,P.jsx)(i,{label:`Orders placed`,value:r.orderCount,unit:``}),(0,P.jsx)(i,{label:`Unique SKUs`,value:r.skus,unit:``}),(0,P.jsx)(i,{label:`Total spend`,value:`$${r.spend.toLocaleString()}`,unit:``}),(0,P.jsx)(i,{label:`COâ saved (est.)`,value:r.co2,unit:`kg`})]}),(0,P.jsxs)(`div`,{style:{marginTop:14,fontSize:11,color:`#8A8A8E`},children:[`Estimates based on your recorded orders and invoices in `,n,`.`]}),(0,P.jsx)(`button`,{style:{...xr,marginTop:12},onClick:()=>window.print(),children:`Print / Save PDF`})]})}function kr(){let[e,t]=(0,h.useState)(``),[n,r]=(0,h.useState)(!1),[i,a]=(0,h.useState)(!1);(0,h.useEffect)(()=>{(async()=>{let{data:e}=await o.auth.getUser();if(!e?.user)return;let{data:n}=await o.from(`profiles`).select(`slack_webhook_url, notify_slack`).eq(`id`,e.user.id).maybeSingle();t(n?.slack_webhook_url||``),r(!!n?.notify_slack)})()},[]);let s=async()=>{let{data:t}=await o.auth.getUser();t?.user&&(await o.from(`profiles`).update({slack_webhook_url:e||null,notify_slack:n}).eq(`id`,t.user.id),a(!0),setTimeout(()=>a(!1),2e3))};return(0,P.jsxs)(`div`,{style:{..._r,marginTop:16},children:[(0,P.jsxs)(`h3`,{style:{fontSize:14,fontWeight:700,margin:`0 0 4px`,display:`flex`,alignItems:`center`,gap:6},children:[(0,P.jsx)(er,{size:14}),` Slack notifications`]}),(0,P.jsx)(`div`,{style:yr,children:`Paste your Slack Incoming Webhook URL. We'll mirror your portal alerts to that channel.`}),(0,P.jsx)(`label`,{style:Cr,children:`Webhook URL`}),(0,P.jsx)(`input`,{style:Sr,value:e,onChange:e=>t(e.target.value),placeholder:`https://hooks.slack.com/services/â¦`}),(0,P.jsxs)(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,marginTop:12,fontSize:12.5},children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),` Send notifications to Slack`]}),(0,P.jsx)(`button`,{style:{...br,marginTop:12},onClick:s,children:`Save`}),i&&(0,P.jsx)(`span`,{style:{marginLeft:10,color:`#2F7A4A`,fontSize:12},children:`Saved.`})]})}var Ar=[{title:`Welcome to Krush`,body:`This is your production portal â orders, filters, forecasting, and compliance in one place.`},{title:`Place an order`,body:`Use âPlace Orderâ for finished cones or filters. Blank cones are $0.05/ea, custom $0.06/ea, filters $0.025/ea.`},{title:`Filter Bank`,body:`Reserve filters at $0.025 each to lock in supply and slash lead times.`},{title:`Track everything`,body:`âTrack Ordersâ shows every production stage. You'll get email + in-app alerts at each step.`},{title:`Need help?`,body:`Ask the AI concierge in the sidebar. You can escalate to a human anytime.`}];function jr(){let[e,t]=(0,h.useState)(-1),[n,r]=(0,h.useState)(null);if((0,h.useEffect)(()=>{(async()=>{let{data:e}=await o.auth.getUser();if(!e?.user)return;r(e.user.id);let{data:n}=await o.from(`profiles`).select(`tour_completed_at`).eq(`id`,e.user.id).maybeSingle();n?.tour_completed_at||t(0)})()},[]),e<0)return null;let i=async()=>{t(-1),n&&await o.from(`profiles`).update({tour_completed_at:new Date().toISOString()}).eq(`id`,n)},a=Ar[e];return(0,P.jsx)(`div`,{style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.55)`,zIndex:200,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:20},children:(0,P.jsxs)(`div`,{style:{background:`#fff`,borderRadius:10,padding:24,maxWidth:420,width:`100%`},children:[(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10,color:`#8A8A8E`,letterSpacing:`0.2em`},children:[`STEP `,e+1,` / `,Ar.length]}),(0,P.jsx)(`h3`,{style:{fontSize:18,margin:`6px 0 8px`,color:`#1A1A1C`},children:a.title}),(0,P.jsx)(`div`,{style:{fontSize:13,color:`#4A4A4E`,lineHeight:1.5},children:a.body}),(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,marginTop:20},children:[(0,P.jsx)(`button`,{style:xr,onClick:i,children:`Skip tour`}),(0,P.jsx)(`button`,{style:br,onClick:()=>e===Ar.length-1?i():t(e+1),children:e===Ar.length-1?`Get started`:`Next`})]})]})})}var Mr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function e(n,r){t(this,e),this.data=n,this.text=r.text||n,this.options=r}}
11)),Nr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CODE39=void 0;var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=r(Mr());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(e){o(n,e);function n(e,t){return i(this,n),e=e.toUpperCase(),t.mod43&&(e+=f(m(e))),a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t))}return t(n,[{key:`encode`,value:function(){for(var e=u(`*`),t=0;t<this.data.length;t++)e+=u(this.data[t])+`0`;return e+=u(`*`),{data:e,text:this.text}}},{key:`valid`,value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),n}(n.default),c=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*`.split(``),l=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function u(e){return d(p(e))}function d(e){return l[e].toString(2)}function f(e){return c[e]}function p(e){return c.indexOf(e)}function m(e){for(var t=0,n=0;n<e.length;n++)t+=p(e[n]);return t%=43,t}e.CODE39=s})),Pr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t;function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=e.SET_A=0,i=e.SET_B=1,a=e.SET_C=2;e.SHIFT=98;var o=e.START_A=103,s=e.START_B=104,c=e.START_C=105;e.MODULO=103,e.STOP=106,e.FNC1=207,e.SET_BY_CODE=(t={},n(t,o,r),n(t,s,i),n(t,c,a),t),e.SWAP={101:r,100:i,99:a},e.A_START_CHAR=`Ã`,e.B_START_CHAR=`Ã`,e.C_START_CHAR=`Ã`,e.A_CHARS=`[\0-_Ã-Ã]`,e.B_CHARS=`[ -�Ã-Ã]`,e.C_CHARS=`(Ã*[0-9]{2}Ã*)`,e.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011]})),Fr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=i(Mr()),r=Pr();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){s(n,e);function n(e,t){a(this,n);var r=o(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e.substring(1),t));return r.bytes=e.split(``).map(function(e){return e.charCodeAt(0)}),r}return t(n,[{key:`valid`,value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:`encode`,value:function(){var e=this.bytes,t=e.shift()-105,i=r.SET_BY_CODE[t];if(i===void 0)throw RangeError(`The encoding does not start with a start character.`);this.shouldEncodeAsEan128()===!0&&e.unshift(r.FNC1);var a=n.next(e,1,i);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,``):this.text,data:n.getBar(t)+a.result+n.getBar((a.checksum+t)%r.MODULO)+n.getBar(r.STOP)}}},{key:`shouldEncodeAsEan128`,value:function(){var e=this.options.ean128||!1;return typeof e==`string`&&(e=e.toLowerCase()===`true`),e}}],[{key:`getBar`,value:function(e){return r.BARS[e]?r.BARS[e].toString():``}},{key:`correctIndex`,value:function(e,t){if(t===r.SET_A){var n=e.shift();return n<32?n+64:n-32}else if(t===r.SET_B)return e.shift()-32;else return(e.shift()-48)*10+e.shift()-48}},{key:`next`,value:function(e,t,i){if(!e.length)return{result:``,checksum:0};var a=void 0,o=void 0;if(e[0]>=200){o=e.shift()-105;var s=r.SWAP[o];s===void 0?((i===r.SET_A||i===r.SET_B)&&o===r.SHIFT&&(e[0]=i===r.SET_A?e[0]>95?e[0]-96:e[0]:e[0]<32?e[0]+96:e[0]),a=n.next(e,t+1,i)):a=n.next(e,t+1,s)}else o=n.correctIndex(e,i),a=n.next(e,t+1,i);var c=n.getBar(o),l=o*t;return{result:c+a.result,checksum:l+a.checksum}}}]),n}(n.default)})),Ir=t((e=>
11{Object.defineProperty(e,"__esModule",{value:!0});var t=Pr(),n=function(e){return e.match(RegExp(`^`+t.A_CHARS+`*`))[0].length},r=function(e){return e.match(RegExp(`^`+t.B_CHARS+`*`))[0].length},i=function(e){return e.match(RegExp(`^`+t.C_CHARS+`*`))[0]};function a(e,n){var r=n?t.A_CHARS:t.B_CHARS,i=e.match(RegExp(`^(`+r+`+?)(([0-9]{2}){2,})([^0-9]|$)`));if(i)return i[1]+`Ã`+o(e.substring(i[1].length));var s=e.match(RegExp(`^`+r+`+`))[0];return s.length===e.length?e:s+String.fromCharCode(n?205:206)+a(e.substring(s.length),!n)}function o(e){var t=i(e),o=t.length;if(o===e.length)return e;e=e.substring(o);var s=n(e)>=r(e);return t+String.fromCharCode(s?206:205)+a(e,s)}e.default=function(e){var s=void 0;if(i(e).length>=2)s=t.C_START_CHAR+o(e);else{var c=n(e)>r(e);s=(c?t.A_START_CHAR:t.B_START_CHAR)+a(e,c)}return s.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(e,t){return`Ã`+t})}})),Lr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r(Fr()),n=r(Ir());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){o(t,e);function t(e,r){if(i(this,t),/^[\x00-\x7F\xC8-\xD3]+$/.test(e))var o=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,(0,n.default)(e),r));else var o=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));return a(o)}return t}(t.default)})),Rr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=i(Fr()),r=Pr();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){s(n,e);function n(e,t){return a(this,n),o(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r.A_START_CHAR+e,t))}return t(n,[{key:`valid`,value:function(){return RegExp(`^`+r.A_CHARS+`+$`).test(this.data)}}]),n}(n.default)})),zr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=i(Fr()),r=Pr();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){s(n,e);function n(e,t){return a(this,n),o(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r.B_START_CHAR+e,t))}return t(n,[{key:`valid`,value:function(){return RegExp(`^`+r.B_CHARS+`+$`).test(this.data)}}]),n}(n.default)})),Br=t((e=>
11{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=i(Fr()),r=Pr();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){s(n,e);function n(e,t){return a(this,n),o(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r.C_START_CHAR+e,t))}return t(n,[{key:`valid`,value:function(){return RegExp(`^`+r.C_CHARS+`+$`).test(this.data)}}]),n}(n.default)})),Vr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CODE128C=e.CODE128B=e.CODE128A=e.CODE128=void 0;var t=a(Lr()),n=a(Rr()),r=a(zr()),i=a(Br());function a(e){return e&&e.__esModule?e:{default:e}}e.CODE128=t.default,e.CODE128A=n.default,e.CODE128B=r.default,e.CODE128C=i.default})),Hr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SIDE_BIN=`101`,e.MIDDLE_BIN=`01010`,e.BINARIES={L:[`0001101`,`0011001`,`0010011`,`0111101`,`0100011`,`0110001`,`0101111`,`0111011`,`0110111`,`0001011`],G:[`0100111`,`0110011`,`0011011`,`0100001`,`0011101`,`0111001`,`0000101`,`0010001`,`0001001`,`0010111`],R:[`1110010`,`1100110`,`1101100`,`1000010`,`1011100`,`1001110`,`1010000`,`1000100`,`1001000`,`1110100`],O:[`0001101`,`0011001`,`0010011`,`0111101`,`0100011`,`0110001`,`0101111`,`0111011`,`0110111`,`0001011`],E:[`0100111`,`0110011`,`0011011`,`0100001`,`0011101`,`0111001`,`0000101`,`0010001`,`0001001`,`0010111`]},e.EAN2_STRUCTURE=[`LL`,`LG`,`GL`,`GG`],e.EAN5_STRUCTURE=[`GGLLL`,`GLGLL`,`GLLGL`,`GLLLG`,`LGGLL`,`LLGGL`,`LLLGG`,`LGLGL`,`LGLLG`,`LLGLG`],e.EAN13_STRUCTURE=[`LLLLLL`,`LLGLGG`,`LLGGLG`,`LLGGGL`,`LGLLGG`,`LGGLLG`,`LGGGLL`,`LGLGLG`,`LGLGGL`,`LGGLGL`]}
11)),Ur=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Hr();e.default=function(e,n,r){var i=e.split(``).map(function(e,r){return t.BINARIES[n[r]]}).map(function(t,n){return t?t[e[n]]:``});if(r){var a=e.length-1;i=i.map(function(e,t){return t<a?e+r:e})}return i.join(``)}})),Wr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=Hr(),r=a(Ur()),i=a(Mr());function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function c(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){c(i,e);function i(e,t){o(this,i);var n=s(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,t));return n.fontSize=!t.flat&&t.fontSize>t.width*10?t.width*10:t.fontSize,n.guardHeight=t.height+n.fontSize/2+t.textMargin,n}return t(i,[{key:`encode`,value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:`leftText`,value:function(e,t){return this.text.substr(e,t)}},{key:`leftEncode`,value:function(e,t){return(0,r.default)(e,t)}},{key:`rightText`,value:function(e,t){return this.text.substr(e,t)}},{key:`rightEncode`,value:function(e,t){return(0,r.default)(e,t)}},{key:`encodeGuarded`,value:function(){var e={fontSize:this.fontSize},t={height:this.guardHeight};return[{data:n.SIDE_BIN,options:t},{data:this.leftEncode(),text:this.leftText(),options:e},{data:n.MIDDLE_BIN,options:t},{data:this.rightEncode(),text:this.rightText(),options:e},{data:n.SIDE_BIN,options:t}]}},{key:`encodeFlat`,value:function(){return{data:[n.SIDE_BIN,this.leftEncode(),n.MIDDLE_BIN,this.rightEncode(),n.SIDE_BIN].join(``),text:this.text}}}]),i}(i.default)})),Gr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=function e(t,n,r){t===null&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(i===void 0){var a=Object.getPrototypeOf(t);return a===null?void 0:e(a,n,r)}else if(`value`in i)return i.value;else{var o=i.get;return o===void 0?void 0:o.call(r)}},r=Hr(),i=a(Wr());function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function c(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=function(e){return(10-e.substr(0,12).split(``).map(function(e){return+e}).reduce(function(e,t,n){return n%2?e+t*3:e+t},0)%10)%10};e.default=function(e){c(i,e);function i(e,t){o(this,i),e.search(/^[0-9]{12}$/)!==-1&&(e+=l(e));var n=s(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,t));return n.lastChar=t.lastChar,n}return t(i,[{key:`valid`,value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===l(this.data)}},{key:`leftText`,value:function(){return n(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),`leftText`,this).call(this,1,6)}},{key:`leftEncode`,value:function(){var e=this.data.substr(1,6),t=r.EAN13_STRUCTURE[this.data[0]];return n(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),`leftEncode`,this).call(this,e,t)}},{key:`rightText`,value:function(){return n(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),`rightText`,this).call(this,7,6)}},{key:`rightEncode`,value:function(){var e=this.data.substr(7,6);return n(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),`rightEncode`,this).call(this,e,`RRRRRR`)}},{key:`encodeGuarded`,value:function(){var e=n(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),`encodeGuarded`,this).call(this);return this.options.displayValue&&(e.unshift({data:`000000000000`,text:this.text.substr(0,1),options:{textAlign:`left`,fontSize:this.fontSize}}),this.options.lastChar&&(e.push({data:`00`}),e.push({data:`00000`,text:this.options.lastChar,options:{fontSize:this.fontSize}}))),e}}]),i}(i.default)}
11)),Kr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=function e(t,n,r){t===null&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(i===void 0){var a=Object.getPrototypeOf(t);return a===null?void 0:e(a,n,r)}else if(`value`in i)return i.value;else{var o=i.get;return o===void 0?void 0:o.call(r)}},r=i(Wr());function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var c=function(e){return(10-e.substr(0,7).split(``).map(function(e){return+e}).reduce(function(e,t,n){return n%2?e+t:e+t*3},0)%10)%10};e.default=function(e){s(r,e);function r(e,t){return a(this,r),e.search(/^[0-9]{7}$/)!==-1&&(e+=c(e)),o(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t))}return t(r,[{key:`valid`,value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===c(this.data)}},{key:`leftText`,value:function(){return n(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),`leftText`,this).call(this,0,4)}},{key:`leftEncode`,value:function(){var e=this.data.substr(0,4);return n(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),`leftEncode`,this).call(this,e,`LLLL`)}},{key:`rightText`,value:function(){return n(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),`rightText`,this).call(this,4,4)}},{key:`rightEncode`,value:function(){var e=this.data.substr(4,4);return n(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),`rightEncode`,this).call(this,e,`RRRR`)}}]),r}(r.default)})),qr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=Hr(),r=a(Ur()),i=a(Mr());function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function c(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=function(e){return e.split(``).map(function(e){return+e}).reduce(function(e,t,n){return n%2?e+t*9:e+t*3},0)%10};e.default=function(e){c(i,e);function i(e,t){return o(this,i),s(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,t))}return t(i,[{key:`valid`,value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:`encode`,value:function(){var e=n.EAN5_STRUCTURE[l(this.data)];return{data:`1011`+(0,r.default)(this.data,e,`01`),text:this.text}}}]),i}(i.default)})),Jr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=Hr(),r=a(Ur()),i=a(Mr());function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function c(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){c(i,e);function i(e,t){return o(this,i),s(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,t))}return t(i,[{key:`valid`,value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:`encode`,value:function(){var e=n.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:`1011`+(0,r.default)(this.data,e,`01`),text:this.text}}}]),i}(i.default)})),Yr=t((e=>
11{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();e.checksum=l;var n=i(Ur()),r=i(Mr());function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var c=function(e){s(r,e);function r(e,t){a(this,r),e.search(/^[0-9]{11}$/)!==-1&&(e+=l(e));var n=o(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t));return n.displayValue=t.displayValue,t.fontSize>t.width*10?n.fontSize=t.width*10:n.fontSize=t.fontSize,n.guardHeight=t.height+n.fontSize/2+t.textMargin,n}return t(r,[{key:`valid`,value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==l(this.data)}},{key:`encode`,value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:`flatEncoding`,value:function(){var e=``;return e+=`101`,e+=(0,n.default)(this.data.substr(0,6),`LLLLLL`),e+=`01010`,e+=(0,n.default)(this.data.substr(6,6),`RRRRRR`),e+=`101`,{data:e,text:this.text}}},{key:`guardedEncoding`,value:function(){var e=[];return this.displayValue&&e.push({data:`00000000`,text:this.text.substr(0,1),options:{textAlign:`left`,fontSize:this.fontSize}}),e.push({data:`101`+(0,n.default)(this.data[0],`L`),options:{height:this.guardHeight}}),e.push({data:(0,n.default)(this.data.substr(1,5),`LLLLL`),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),e.push({data:`01010`,options:{height:this.guardHeight}}),e.push({data:(0,n.default)(this.data.substr(6,5),`RRRRR`),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),e.push({data:(0,n.default)(this.data[11],`R`)+`101`,options:{height:this.guardHeight}}),this.displayValue&&e.push({data:`00000000`,text:this.text.substr(11,1),options:{textAlign:`right`,fontSize:this.fontSize}}),e}}]),r}(r.default);function l(e){var t=0,n;for(n=1;n<11;n+=2)t+=parseInt(e[n]);for(n=0;n<11;n+=2)t+=parseInt(e[n])*3;return(10-t%10)%10}e.default=c})),Xr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=a(Ur()),r=a(Mr()),i=Yr();function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function c(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=[`XX00000XXX`,`XX10000XXX`,`XX20000XXX`,`XXX00000XX`,`XXXX00000X`,`XXXXX00005`,`XXXXX00006`,`XXXXX00007`,`XXXXX00008`,`XXXXX00009`],u=[[`EEEOOO`,`OOOEEE`],[`EEOEOO`,`OOEOEE`],[`EEOOEO`,`OOEEOE`],[`EEOOOE`,`OOEEEO`],[`EOEEOO`,`OEOOEE`],[`EOOEEO`,`OEEOOE`],[`EOOOEE`,`OEEEOO`],[`EOEOEO`,`OEOEOE`],[`EOEOOE`,`OEOEEO`],[`EOOEOE`,`OEEOEO`]],d=function(e){c(r,e);function r(e,t){o(this,r);var n=s(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t));if(n.isValid=!1,e.search(/^[0-9]{6}$/)!==-1)n.middleDigits=e,n.upcA=f(e,`0`),n.text=t.text||``+n.upcA[0]+e+n.upcA[n.upcA.length-1],n.isValid=!0;else if(e.search(/^[01][0-9]{7}$/)!==-1)if(n.middleDigits=e.substring(1,e.length-1),n.upcA=f(n.middleDigits,e[0]),n.upcA[n.upcA.length-1]===e[e.length-1])n.isValid=!0;else return s(n);else return s(n);return n.displayValue=t.displayValue,t.fontSize>t.width*10?n.fontSize=t.width*10:n.fontSize=t.fontSize,n.guardHeight=t.height+n.fontSize/2+t.textMargin,n}return t(r,[{key:`valid`,value:function(){return this.isValid}},{key:`encode`,value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:`flatEncoding`,value:function(){var e=``;
11return e+=`101`,e+=this.encodeMiddleDigits(),e+=`010101`,{data:e,text:this.text}}},{key:`guardedEncoding`,value:function(){var e=[];return this.displayValue&&e.push({data:`00000000`,text:this.text[0],options:{textAlign:`left`,fontSize:this.fontSize}}),e.push({data:`101`,options:{height:this.guardHeight}}),e.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),e.push({data:`010101`,options:{height:this.guardHeight}}),this.displayValue&&e.push({data:`00000000`,text:this.text[7],options:{textAlign:`right`,fontSize:this.fontSize}}),e}},{key:`encodeMiddleDigits`,value:function(){var e=this.upcA[0],t=this.upcA[this.upcA.length-1],r=u[parseInt(t)][parseInt(e)];return(0,n.default)(this.middleDigits,r)}}]),r}(r.default);function f(e,t){for(var n=l[parseInt(e[e.length-1])],r=``,a=0,o=0;o<n.length;o++){var s=n[o];s===`X`?r+=e[a++]:r+=s}return r=``+t+r,``+r+(0,i.checksum)(r)}e.default=d})),Zr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.UPCE=e.UPC=e.EAN2=e.EAN5=e.EAN8=e.EAN13=void 0;var t=s(Gr()),n=s(Kr()),r=s(qr()),i=s(Jr()),a=s(Yr()),o=s(Xr());function s(e){return e&&e.__esModule?e:{default:e}}e.EAN13=t.default,e.EAN8=n.default,e.EAN5=r.default,e.EAN2=i.default,e.UPC=a.default,e.UPCE=o.default})),Qr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.START_BIN=`1010`,e.END_BIN=`11101`,e.BINARIES=[`00110`,`10001`,`01001`,`11000`,`00101`,`10100`,`01100`,`00011`,`10010`,`01010`]})),$r=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=Qr(),r=i(Mr());function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){s(r,e);function r(){return a(this,r),o(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return t(r,[{key:`valid`,value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:`encode`,value:function(){var e=this,t=this.data.match(/.{2}/g).map(function(t){return e.encodePair(t)}).join(``);return{data:n.START_BIN+t+n.END_BIN,text:this.text}}},{key:`encodePair`,value:function(e){var t=n.BINARIES[e[1]];return n.BINARIES[e[0]].split(``).map(function(e,n){return(e===`1`?`111`:`1`)+(t[n]===`1`?`000`:`0`)}).join(``)}}]),r}(r.default)})),ei=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=r($r());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(e){var t=e.substr(0,13).split(``).map(function(e){return parseInt(e,10)}).reduce(function(e,t,n){return e+t*(3-n%2*2)},0);return Math.ceil(t/10)*10-t};e.default=function(e){o(n,e);function n(e,t){return i(this,n),e.search(/^[0-9]{13}$/)!==-1&&(e+=s(e)),a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t))}return t(n,[{key:`valid`,value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===s(this.data)}}]),n}(n.default)})),ti=t((e=>
11{Object.defineProperty(e,"__esModule",{value:!0}),e.ITF14=e.ITF=void 0;var t=r($r()),n=r(ei());function r(e){return e&&e.__esModule?e:{default:e}}e.ITF=t.default,e.ITF14=n.default})),ni=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=r(Mr());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(e){o(n,e);function n(e,t){return i(this,n),a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t))}return t(n,[{key:`encode`,value:function(){for(var e=`110`,t=0;t<this.data.length;t++){var n=parseInt(this.data[t]).toString(2);n=c(n,4-n.length);for(var r=0;r<n.length;r++)e+=n[r]==`0`?`100`:`110`}return e+=`1001`,{data:e,text:this.text}}},{key:`valid`,value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),n}(n.default);function c(e,t){for(var n=0;n<t;n++)e=`0`+e;return e}e.default=s})),ri=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.mod10=t,e.mod11=n;function t(e){for(var t=0,n=0;n<e.length;n++){var r=parseInt(e[n]);(n+e.length)%2==0?t+=r:t+=r*2%10+Math.floor(r*2/10)}return(10-t%10)%10}function n(e){for(var t=0,n=[2,3,4,5,6,7],r=0;r<e.length;r++){var i=parseInt(e[e.length-1-r]);t+=n[r%n.length]*i}return(11-t%11)%11}})),ii=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r(ni()),n=ri();function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){o(t,e);function t(e,r){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e+(0,n.mod10)(e),r))}return t}(t.default)})),ai=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r(ni()),n=ri();function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){o(t,e);function t(e,r){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e+(0,n.mod11)(e),r))}return t}(t.default)})),oi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r(ni()),n=ri();function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){o(t,e);function t(e,r){return i(this,t),e+=(0,n.mod10)(e),e+=(0,n.mod10)(e),a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return t}(t.default)})),si=t((e=>
11{Object.defineProperty(e,"__esModule",{value:!0});var t=r(ni()),n=ri();function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){o(t,e);function t(e,r){return i(this,t),e+=(0,n.mod11)(e),e+=(0,n.mod10)(e),a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return t}(t.default)})),ci=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MSI1110=e.MSI1010=e.MSI11=e.MSI10=e.MSI=void 0;var t=o(ni()),n=o(ii()),r=o(ai()),i=o(oi()),a=o(si());function o(e){return e&&e.__esModule?e:{default:e}}e.MSI=t.default,e.MSI10=n.default,e.MSI11=r.default,e.MSI1010=i.default,e.MSI1110=a.default})),li=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.pharmacode=void 0;var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=r(Mr());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.pharmacode=function(e){o(n,e);function n(e,t){i(this,n);var r=a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return r.number=parseInt(e,10),r}return t(n,[{key:`encode`,value:function(){for(var e=this.number,t=``;!isNaN(e)&&e!=0;)e%2==0?(t=`11100`+t,e=(e-2)/2):(t=`100`+t,e=(e-1)/2);return t=t.slice(0,-2),{data:t,text:this.text}}},{key:`valid`,value:function(){return this.number>=3&&this.number<=131070}}]),n}(n.default)})),ui=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.codabar=void 0;var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=r(Mr());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.codabar=function(e){o(n,e);function n(e,t){i(this,n),e.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(e=`A`+e+`A`);var r=a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e.toUpperCase(),t));return r.text=r.options.text||r.text.replace(/[A-D]/g,``),r}return t(n,[{key:`valid`,value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:`encode`,value:function(){for(var e=[],t=this.getEncodings(),n=0;n<this.data.length;n++)e.push(t[this.data.charAt(n)]),n!==this.data.length-1&&e.push(`0`);return{text:this.text,data:e.join(``)}}},{key:`getEncodings`,value:function(){return{0:`101010011`,1:`101011001`,2:`101001011`,3:`110010101`,4:`101101001`,5:`110101001`,6:`100101011`,7:`100101101`,8:`100110101`,9:`110100101`,"-":`101001101`,$:`101100101`,":":`1101011011`,"/":`1101101011`,".":`1101101101`,"+":`1011011011`,A:`1011001001`,B:`1001001011`,C:`1010010011`,D:`1010011001`}}}]),n}(n.default)})),di=t((e=>
11{Object.defineProperty(e,"__esModule",{value:!0}),e.SYMBOLS=`0,1,2,3,4,5,6,7,8,9,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,-,., ,$,/,+,%,($),(%),(/),(+),ÿ`.split(`,`),e.BINARIES=`100010100.101001000.101000100.101000010.100101000.100100100.100100010.101010000.100010010.100001010.110101000.110100100.110100010.110010100.110010010.110001010.101101000.101100100.101100010.100110100.100011010.101011000.101001100.101000110.100101100.100010110.110110100.110110010.110101100.110100110.110010110.110011010.101101100.101100110.100110110.100111010.100101110.111010100.111010010.111001010.101101110.101110110.110101110.100100110.111011010.111010110.100110010.101011110`.split(`.`),e.MULTI_SYMBOLS={"\0":[`(%)`,`U`],"�":[`($)`,`A`],"�":[`($)`,`B`],"�":[`($)`,`C`],"�":[`($)`,`D`],"�":[`($)`,`E`],"�":[`($)`,`F`],"\x07":[`($)`,`G`],"\b":[`($)`,`H`]," ":[`($)`,`I`],"\n":[`($)`,`J`],"\v":[`($)`,`K`],"\f":[`($)`,`L`],"\r":[`($)`,`M`],"�":[`($)`,`N`],"�":[`($)`,`O`],"�":[`($)`,`P`],"�":[`($)`,`Q`],"�":[`($)`,`R`],"�":[`($)`,`S`],"�":[`($)`,`T`],"�":[`($)`,`U`],"�":[`($)`,`V`],"�":[`($)`,`W`],"�":[`($)`,`X`],"�":[`($)`,`Y`],"�":[`($)`,`Z`],"\x1B":[`(%)`,`A`],"�":[`(%)`,`B`],"�":[`(%)`,`C`],"�":[`(%)`,`D`],"�":[`(%)`,`E`],"!":[`(/)`,`A`],'"':[`(/)`,`B`],"#":[`(/)`,`C`],"&":[`(/)`,`F`],"'":[`(/)`,`G`],"(":[`(/)`,`H`],")":[`(/)`,`I`],"*":[`(/)`,`J`],",":[`(/)`,`L`],":":[`(/)`,`Z`],";":[`(%)`,`F`],"<":[`(%)`,`G`],"=":[`(%)`,`H`],">":[`(%)`,`I`],"?":[`(%)`,`J`],"@":[`(%)`,`V`],"[":[`(%)`,`K`],"\\":[`(%)`,`L`],"]":[`(%)`,`M`],"^":[`(%)`,`N`],_:[`(%)`,`O`],"`":[`(%)`,`W`],a:[`(+)`,`A`],b:[`(+)`,`B`],c:[`(+)`,`C`],d:[`(+)`,`D`],e:[`(+)`,`E`],f:[`(+)`,`F`],g:[`(+)`,`G`],h:[`(+)`,`H`],i:[`(+)`,`I`],j:[`(+)`,`J`],k:[`(+)`,`K`],l:[`(+)`,`L`],m:[`(+)`,`M`],n:[`(+)`,`N`],o:[`(+)`,`O`],p:[`(+)`,`P`],q:[`(+)`,`Q`],r:[`(+)`,`R`],s:[`(+)`,`S`],t:[`(+)`,`T`],u:[`(+)`,`U`],v:[`(+)`,`V`],w:[`(+)`,`W`],x:[`(+)`,`X`],y:[`(+)`,`Y`],z:[`(+)`,`Z`],"{":[`(%)`,`P`],"|":[`(%)`,`Q`],"}":[`(%)`,`R`],"~":[`(%)`,`S`],"�":[`(%)`,`T`]}})),fi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=di(),r=i(Mr());function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){s(r,e);function r(e,t){return a(this,r),o(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t))}return t(r,[{key:`valid`,value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:`encode`,value:function(){var e=this.data.split(``).flatMap(function(e){return n.MULTI_SYMBOLS[e]||e}),t=e.map(function(e){return r.getEncoding(e)}).join(``),i=r.checksum(e,20),a=r.checksum(e.concat(i),15);return{text:this.text,data:r.getEncoding(`ÿ`)+t+r.getEncoding(i)+r.getEncoding(a)+r.getEncoding(`ÿ`)+`1`}}}],[{key:`getEncoding`,value:function(e){return n.BINARIES[r.symbolValue(e)]}},{key:`getSymbol`,value:function(e){return n.SYMBOLS[e]}},{key:`symbolValue`,value:function(e){return n.SYMBOLS.indexOf(e)}},{key:`checksum`,value:function(e,t){var n=e.slice().reverse().reduce(function(e,n,i){var a=i%t+1;return e+r.symbolValue(n)*a},0);return r.getSymbol(n%47)}}]),r}(r.default)})),pi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=r(fi());
11function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.default=function(e){o(n,e);function n(e,t){return i(this,n),a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t))}return t(n,[{key:`valid`,value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),n}(n.default)})),mi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CODE93FullASCII=e.CODE93=void 0;var t=r(fi()),n=r(pi());function r(e){return e&&e.__esModule?e:{default:e}}e.CODE93=t.default,e.CODE93FullASCII=n.default})),hi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GenericBarcode=void 0;var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=r(Mr());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}e.GenericBarcode=function(e){o(n,e);function n(e,t){return i(this,n),a(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t))}return t(n,[{key:`encode`,value:function(){return{data:`10101010101010101010101010101010101010101`,text:this.text}}},{key:`valid`,value:function(){return!0}}]),n}(n.default)})),gi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Nr(),n=Vr(),r=Zr(),i=ti(),a=ci(),o=li(),s=ui(),c=mi(),l=hi();e.default={CODE39:t.CODE39,CODE128:n.CODE128,CODE128A:n.CODE128A,CODE128B:n.CODE128B,CODE128C:n.CODE128C,EAN13:r.EAN13,EAN8:r.EAN8,EAN5:r.EAN5,EAN2:r.EAN2,UPC:r.UPC,UPCE:r.UPCE,ITF14:i.ITF14,ITF:i.ITF,MSI:a.MSI,MSI10:a.MSI10,MSI11:a.MSI11,MSI1010:a.MSI1010,MSI1110:a.MSI1110,pharmacode:o.pharmacode,codabar:s.codabar,CODE93:c.CODE93,CODE93FullASCII:c.CODE93FullASCII,GenericBarcode:l.GenericBarcode}})),_i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};e.default=function(e,n){return t({},e,n)}})),vi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(e){var t=[];function n(e){if(Array.isArray(e))for(var r=0;r<e.length;r++)n(e[r]);else e.text=e.text||``,e.data=e.data||``,t.push(e)}return n(e),t}})),yi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(e){return e.marginTop=e.marginTop||e.margin,e.marginBottom=e.marginBottom||e.margin,e.marginRight=e.marginRight||e.margin,e.marginLeft=e.marginLeft||e.margin,e}})),bi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(e){var t=[`width`,`height`,`textMargin`,`fontSize`,`margin`,`marginTop`,`marginBottom`,`marginLeft`,`marginRight`];for(var n in t)t.hasOwnProperty(n)&&(n=t[n],typeof e[n]==`string`&&(e[n]=parseInt(e[n],10)));return typeof e.displayValue==`string`&&(e.displayValue=e.displayValue!=`false`),e}})),xi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={width:2,height:100,format:`auto`,displayValue:!0,fontOptions:``,font:`monospace`,text:void 0,textAlign:`center`,textPosition:`bottom`,textMargin:2,fontSize:20,background:`#ffffff`,lineColor:`#000000`,margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}}})),Si=t((e=>
11{Object.defineProperty(e,"__esModule",{value:!0});var t=r(bi()),n=r(xi());function r(e){return e&&e.__esModule?e:{default:e}}function i(e){var r={};for(var i in n.default)n.default.hasOwnProperty(i)&&(e.hasAttribute(`jsbarcode-`+i.toLowerCase())&&(r[i]=e.getAttribute(`jsbarcode-`+i.toLowerCase())),e.hasAttribute(`data-`+i.toLowerCase())&&(r[i]=e.getAttribute(`data-`+i.toLowerCase())));return r.value=e.getAttribute(`jsbarcode-value`)||e.getAttribute(`data-value`),r=(0,t.default)(r),r}e.default=i})),Ci=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getTotalWidthOfEncodings=e.calculateEncodingAttributes=e.getBarcodePadding=e.getEncodingHeight=e.getMaximumHeightOfEncodings=void 0;var t=n(_i());function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){return t.height+(t.displayValue&&e.text.length>0?t.fontSize+t.textMargin:0)+t.marginTop+t.marginBottom}function i(e,t,n){if(n.displayValue&&t<e){if(n.textAlign==`center`)return Math.floor((e-t)/2);if(n.textAlign==`left`)return 0;if(n.textAlign==`right`)return Math.floor(e-t)}return 0}function a(e,n,a){for(var o=0;o<e.length;o++){var s=e[o],l=(0,t.default)(n,s.options),u=l.displayValue?c(s.text,l,a):0,d=s.data.length*l.width;s.width=Math.ceil(Math.max(u,d)),s.height=r(s,l),s.barcodePadding=i(u,d,l)}}function o(e){for(var t=0,n=0;n<e.length;n++)t+=e[n].width;return t}function s(e){for(var t=0,n=0;n<e.length;n++)e[n].height>t&&(t=e[n].height);return t}function c(e,t,n){var r;if(n)r=n;else if(typeof document<`u`)r=document.createElement(`canvas`).getContext(`2d`);else return 0;r.font=t.fontOptions+` `+t.fontSize+`px `+t.font;var i=r.measureText(e);return i?i.width:0}e.getMaximumHeightOfEncodings=s,e.getEncodingHeight=r,e.getBarcodePadding=i,e.calculateEncodingAttributes=a,e.getTotalWidthOfEncodings=o})),wi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=i(_i()),r=Ci();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(t,n,r){a(this,e),this.canvas=t,this.encodings=n,this.options=r}return t(e,[{key:`render`,value:function(){if(!this.canvas.getContext)throw Error(`The browser does not support canvas.`);this.prepareCanvas();for(var e=0;e<this.encodings.length;e++){var t=(0,n.default)(this.options,this.encodings[e].options);this.drawCanvasBarcode(t,this.encodings[e]),this.drawCanvasText(t,this.encodings[e]),this.moveCanvasDrawing(this.encodings[e])}this.restoreCanvas()}},{key:`prepareCanvas`,value:function(){var e=this.canvas.getContext(`2d`);e.save(),(0,r.calculateEncodingAttributes)(this.encodings,this.options,e);var t=(0,r.getTotalWidthOfEncodings)(this.encodings),n=(0,r.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=t+this.options.marginLeft+this.options.marginRight,this.canvas.height=n,e.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(e.fillStyle=this.options.background,e.fillRect(0,0,this.canvas.width,this.canvas.height)),e.translate(this.options.marginLeft,0)}},{key:`drawCanvasBarcode`,value:function(e,t){var n=this.canvas.getContext(`2d`),r=t.data,i=e.textPosition==`top`?e.marginTop+e.fontSize+e.textMargin:e.marginTop;n.fillStyle=e.lineColor;for(var a=0;a<r.length;a++){var o=a*e.width+t.barcodePadding;r[a]===`1`?n.fillRect(o,i,e.width,e.height):r[a]&&n.fillRect(o,i,e.width,e.height*r[a])}}},{key:`drawCanvasText`,value:function(e,t){var n=this.canvas.getContext(`2d`),r=e.fontOptions+` `+e.fontSize+`px `+e.font;if(e.displayValue){var i,a=e.textPosition==`top`?e.marginTop+e.fontSize-e.textMargin:e.height+e.textMargin+e.marginTop+e.fontSize;n.font=r,e.textAlign==`left`||t.barcodePadding>0?(i=0,n.textAlign=`left`):e.textAlign==`right`?(i=t.width-1,n.textAlign=`right`):(i=t.width/2,n.textAlign=`center`),n.fillText(t.text,i,a)}}},{key:`moveCanvasDrawing`,value:function(e){this.canvas.getContext(`2d`).translate(e.width,0)}},{key:`restoreCanvas`,value:function(){this.canvas.getContext(`2d`).restore(
11)}}]),e}()})),Ti=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),n=i(_i()),r=Ci();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}var o=`http://www.w3.org/2000/svg`;e.default=function(){function e(t,n,r){a(this,e),this.svg=t,this.encodings=n,this.options=r,this.document=r.xmlDocument||document}return t(e,[{key:`render`,value:function(){var e=this.options.marginLeft;this.prepareSVG();for(var t=0;t<this.encodings.length;t++){var r=this.encodings[t],i=(0,n.default)(this.options,r.options),a=this.createGroup(e,i.marginTop,this.svg);this.setGroupOptions(a,i),this.drawSvgBarcode(a,i,r),this.drawSVGText(a,i,r),e+=r.width}}},{key:`prepareSVG`,value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,r.calculateEncodingAttributes)(this.encodings,this.options);var e=(0,r.getTotalWidthOfEncodings)(this.encodings),t=(0,r.getMaximumHeightOfEncodings)(this.encodings),n=e+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(n,t),this.options.background&&this.drawRect(0,0,n,t,this.svg).setAttribute(`fill`,this.options.background)}},{key:`drawSvgBarcode`,value:function(e,t,n){for(var r=n.data,i=t.textPosition==`top`?t.fontSize+t.textMargin:0,a=0,o=0,s=0;s<r.length;s++)o=s*t.width+n.barcodePadding,r[s]===`1`?a++:a>0&&(this.drawRect(o-t.width*a,i,t.width*a,t.height,e),a=0);a>0&&this.drawRect(o-t.width*(a-1),i,t.width*a,t.height,e)}},{key:`drawSVGText`,value:function(e,t,n){var r=this.document.createElementNS(o,`text`);if(t.displayValue){var i,a;r.setAttribute(`font-family`,t.font),r.setAttribute(`font-size`,t.fontSize),t.fontOptions.includes(`bold`)&&r.setAttribute(`font-weight`,`bold`),t.fontOptions.includes(`italic`)&&r.setAttribute(`font-style`,`italic`),a=t.textPosition==`top`?t.fontSize-t.textMargin:t.height+t.textMargin+t.fontSize,t.textAlign==`left`||n.barcodePadding>0?(i=0,r.setAttribute(`text-anchor`,`start`)):t.textAlign==`right`?(i=n.width-1,r.setAttribute(`text-anchor`,`end`)):(i=n.width/2,r.setAttribute(`text-anchor`,`middle`)),r.setAttribute(`x`,i),r.setAttribute(`y`,a),r.appendChild(this.document.createTextNode(n.text)),e.appendChild(r)}}},{key:`setSvgAttributes`,value:function(e,t){var n=this.svg;n.setAttribute(`width`,e+`px`),n.setAttribute(`height`,t+`px`),n.setAttribute(`x`,`0px`),n.setAttribute(`y`,`0px`),n.setAttribute(`viewBox`,`0 0 `+e+` `+t),n.setAttribute(`xmlns`,o),n.setAttribute(`version`,`1.1`)}},{key:`createGroup`,value:function(e,t,n){var r=this.document.createElementNS(o,`g`);return r.setAttribute(`transform`,`translate(`+e+`, `+t+`)`),n.appendChild(r),r}},{key:`setGroupOptions`,value:function(e,t){e.setAttribute(`fill`,t.lineColor)}},{key:`drawRect`,value:function(e,t,n,r,i){var a=this.document.createElementNS(o,`rect`);return a.setAttribute(`x`,e),a.setAttribute(`y`,t),a.setAttribute(`width`,n),a.setAttribute(`height`,r),i.appendChild(a),a}}]),e}()})),Ei=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(t,r,i){n(this,e),this.object=t,this.encodings=r,this.options=i}return t(e,[{key:`render`,value:function(){this.object.encodings=this.encodings}}]),e}()})),Di=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=i(wi()),n=i(Ti()),r=i(Ei());function i(e){return e&&e.__esModule?e:{default:e}}e.default={CanvasRenderer:t.default,SVGRenderer:n.default,ObjectRenderer:r.default}})),Oi=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function n(e,t){if(!e)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return t&&(typeof t==`object`||typeof t==`function`)?t:e}function r(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function, not `+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(e){r(i,e);function i(e,r){t(this,i);var a=n(this,(i.__proto__||Object.getPrototypeOf(i)).call(this));return a.name=`InvalidInputException`,a.symbology=e,a.input=r,a.message=`"`+a.input+`" is not a valid input for `+a.symbology,a}return i}(Error),a=function(e){r(i,e);function i(){t(this,i);var e=n(this,(i.__proto__||Object.getPrototypeOf(i)).call(this));return e.name=`InvalidElementException`,e.message=`Not supported type to render on`,e}return i}(Error),o=function(e){r(i,e);function i(){t(this,i);var e=n(this,(i.__proto__||Object.getPrototypeOf(i)).call(this));return e.name=`NoElementException`,e.message=`No element to render on.`,e}return i}(Error);e.InvalidInputException=i,e.InvalidElementException=a,e.NoElementException=o})),ki=t((e=>
11{Object.defineProperty(e,"__esModule",{value:!0});var t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n=a(Si()),r=a(Di()),i=Oi();function a(e){return e&&e.__esModule?e:{default:e}}function o(e){if(typeof e==`string`)return s(e);if(Array.isArray(e)){for(var a=[],l=0;l<e.length;l++)a.push(o(e[l]));return a}else if(typeof HTMLCanvasElement<`u`&&e instanceof HTMLImageElement)return c(e);else if(e&&e.nodeName&&e.nodeName.toLowerCase()===`svg`||typeof SVGElement<`u`&&e instanceof SVGElement)return{element:e,options:(0,n.default)(e),renderer:r.default.SVGRenderer};else if(typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement)return{element:e,options:(0,n.default)(e),renderer:r.default.CanvasRenderer};else if(e&&e.getContext)return{element:e,renderer:r.default.CanvasRenderer};else if(e&&(e===void 0?`undefined`:t(e))===`object`&&!e.nodeName)return{element:e,renderer:r.default.ObjectRenderer};else throw new i.InvalidElementException}function s(e){var t=document.querySelectorAll(e);if(t.length!==0){for(var n=[],r=0;r<t.length;r++)n.push(o(t[r]));return n}}function c(e){var t=document.createElement(`canvas`);return{element:t,options:(0,n.default)(e),renderer:r.default.CanvasRenderer,afterRender:function(){e.setAttribute(`src`,t.toDataURL())}}}e.default=o})),Ai=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(t){n(this,e),this.api=t}return t(e,[{key:`handleCatch`,value:function(e){if(e.name===`InvalidInputException`)if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw e.message;else throw e;this.api.render=function(){}}},{key:`wrapBarcodeCall`,value:function(e){try{var t=e.apply(void 0,arguments);return this.api._options.valid(!0),t}catch(e){return this.handleCatch(e),this.api}}}]),e}()})),ji=e(t(((e,t)=>{var n=d(gi()),r=d(_i()),i=d(vi()),a=d(yi()),o=d(ki()),s=d(bi()),c=d(Ai()),l=Oi(),u=d(xi());function d(e){return e&&e.__esModule?e:{default:e}}var f=function(){},p=function(e,t,n){var r=new f;if(e===void 0)throw Error(`No element to render on was provided.`);return r._renderProperties=(0,o.default)(e),r._encodings=[],r._options=u.default,r._errorHandler=new c.default(r),t!==void 0&&(n||={},n.format||=_(),r.options(n)[n.format](t,n).render()),r};for(var m in p.getModule=function(e){return n.default[e]},n.default)n.default.hasOwnProperty(m)&&h(n.default,m);function h(e,t){f.prototype[t]=f.prototype[t.toUpperCase()]=f.prototype[t.toLowerCase()]=function(n,i){var a=this;return a._errorHandler.wrapBarcodeCall(function(){i.text=i.text===void 0?void 0:``+i.text;var o=(0,r.default)(a._options,i);o=(0,s.default)(o);var c=e[t],l=g(n,c,o);return a._encodings.push(l),a})}}function g(e,t,n){e=``+e;var a=new t(e,n);if(!a.valid())throw new l.InvalidInputException(a.constructor.name,e);var o=a.encode();o=(0,i.default)(o);for(var s=0;s<o.length;s++)o[s].options=(0,r.default)(n,o[s].options);return o}function _(){return n.default.CODE128?`CODE128`:Object.keys(n.default)[0]}f.prototype.options=function(e){return this._options=(0,r.default)(this._options,e),this},f.prototype.blank=function(e){var t=Array(e+1).join(`0`);return this._encodings.push({data:t}),this},f.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var e;for(var t in this._renderProperties){e=this._renderProperties[t];var i=(0,r.default)(this._options,e.options);i.format==`auto`&&(i.format=_()),this._errorHandler.wrapBarcodeCall(function(){var t=i.value,r=n.default[i.format.toUpperCase()],a=g(t,r,i);v(e,a,i)})}}},f.prototype.render=function(){if(!this._renderProperties)throw new l.NoElementException;if(Array.isArray(this._renderProperties))for(var e=0;e<this._renderProperties.length;e++)v(this._renderProperties[e],this._encodings,this._options);else v(this._renderProperties,this._encodings,this._options);return this},f.prototype._defaults=u.default;function v(e,t,n){t=(0,i.default)(t);for(var o=0;o<t.length;o++)t[o].options=(0,r.default)(n,t[o].options),(0,a.default)(t[o].options);(0,a.default)(n);var s=e.renderer;
11new s(e.element,t,n).render(),e.afterRender&&e.afterRender()}typeof window<`u`&&(window.JsBarcode=p),typeof jQuery<`u`&&(jQuery.fn.JsBarcode=function(e,t){var n=[];return jQuery(this).each(function(){n.push(this)}),p(n,e,t)}),t.exports=p}))(),1),Mi=a({method:`POST`}).middleware([u]).handler(i(`c06d0d22ffee86732278b1f689d7dc2e9402d66975aa7c15496b3ec9811fa364`)),W={bg:`#FAFAF9`,card:`#FFFFFF`,ink:`#2E2E30`,inkSoft:`#8A8A8E`,line:`#E9E9E7`,charcoal:`#3A3A3C`,silver:`#F3F3F1`,good:`#2F7D4F`,goodBg:`#EAF3ED`,warn:`#A97B1E`,warnBg:`#F7F0DE`};function Ni(e,t={}){try{let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return(0,ji.default)(n,String(e||`N/A`),{format:`CODE128`,width:2,height:60,displayValue:!0,fontSize:14,margin:4,...t}),new XMLSerializer().serializeToString(n)}catch{return``}}async function Pi(e){try{return await Ce.toDataURL(String(e||``),{width:320,margin:1,errorCorrectionLevel:`M`})}catch{return``}}async function Fi(e){if(!e)return null;if(e.krushos_qr_url)return e.krushos_qr_url;if(!e.order_id)return null;try{let{data:t}=await o.from(`production_traces`).select(`slug,krushos_qr_url`).eq(`order_id`,e.order_id).limit(1).maybeSingle();if(t?.krushos_qr_url)return t.krushos_qr_url;if(t?.slug)return`${window.location.origin}/trace/${t.slug}`}catch{}return null}function Ii(e,t){let n=window.open(``,`_blank`,`width=900,height=1100`);if(!n){alert(`Please allow pop-ups to view the document.`);return}n.document.write(`<!doctype html><html><head><meta charset="utf-8"/> 12 <title>${e}</title> 13 <style> 14 *{box-sizing:border-box} 15 body{font-family:-apple-system,Inter,Helvetica,Arial,sans-serif;color:#2E2E30;margin:0;padding:24px;background:#f5f5f3} 16 .sheet{background:#fff;padding:32px;max-width:820px;margin:0 auto 20px;border:1px solid #e5e5e2;box-shadow:0 1px 2px rgba(0,0,0,.04)} 17 h1{font-size:20px;letter-spacing:.18em;text-transform:uppercase;margin:0 0 4px} 18 h2{font-size:11px;letter-spacing:.16em;text-transform:uppercase;color:#8A8A8E;margin:18px 0 6px;border-bottom:1px solid #E9E9E7;padding-bottom:4px} 19 table{width:100%;border-collapse:collapse;font-size:12px} 20 td,th{padding:6px 8px;border:1px solid #E9E9E7;text-align:left;vertical-align:top} 21 th{background:#FAFAF9;font-size:10px;letter-spacing:.12em;text-transform:uppercase;color:#6C6C6E} 22 .row{display:grid;grid-template-columns:1fr 1fr;gap:24px} 23 .mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace} 24 .toolbar{max-width:820px;margin:0 auto 12px;display:flex;gap:8px;justify-content:flex-end} 25 button{padding:8px 14px;border:1px solid #ccc;background:#fff;border-radius:4px;font-size:12px;letter-spacing:.1em;text-transform:uppercase;cursor:pointer} 26 button.primary{background:#2E2E30;color:#fff;border-color:#2E2E30} 27 .label-sheet{page-break-after:always;padding:28px;border:2px solid #2E2E30} 28 .label-sheet:last-child{page-break-after:auto} 29 .brand{font-family:'Brush Script MT',cursive;font-size:38px;line-height:1} 30 @media print{ .toolbar,.no-print{display:none} body{background:#fff;padding:0} .sheet{border:none;box-shadow:none;margin:0} } 31 </style></head><body> 32 <div class="toolbar no-print"> 33 <button onclick="window.print()" class="primary">Print / Save PDF</button> 34 <button onclick="window.close()">Close</button> 35 </div> 36 ${t} 37 </body></html>`),n.document.close()}async function Li({shipment:e,order:t,customer:n,traceUrl:r}){let i=`BOL-${String(e.id).slice(0,8).toUpperCase()}`,a=Ni(i),o=await Pi(r||e.krushos_qr_url||`${window.location.origin}/portal?shipment=${e.id}`),s=t?.pallets||1,c=t?.product||e.notes||`â`,l=t?.lot_code||`â`,u=e.ship_date||new Date().toISOString().slice(0,10),d=e.tracking||`Pending assignment`;return` 38 <div class="sheet"> 39 <div style="display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:16px"> 40 <div> 41 <div class="brand">Krush</div> 42 <div style="font-size:10px;letter-spacing:.16em;text-transform:uppercase;color:#8A8A8E;margin-top:4px">Krush Cones Inc.</div> 43 </div> 44 <div style="text-align:right"> 45 <h1>Bill of Lading</h1> 46 <div class="mono" style="font-size:13px;font-weight:700">${i}</div> 47 <div style="font-size:11px;color:#8A8A8E">Issued ${u}</div> 48 </div> 49 </div> 50 <div class="row"> 51 <div> 52 <h2>Ship From</h2> 53 <div style="font-size:12px;line-height:1.55"> 54 Krush Cones Inc.<br/>Production & Fulfillment<br/>Ontario, Canada 55 </div> 56 </div> 57 <div> 58 <h2>Ship To</h2> 59 <div style="font-size:12px;line-height:1.55"> 60 ${n?.company||n?.email||`Customer`}<br/> 61 ${n?.email||``} 62 </div> 63 </div> 64 </div> 65 <h2>Shipment Details</h2> 66 <table> 67 <tr><th>Order Ref</th><td class="mono">${t?.id?String(t.id).slice(0,8).toUpperCase():`â`}</td> 68 <th>Carrier</th><td>
68Krush Logistics</td></tr> 69 <tr><th>Tracking</th><td class="mono">${d}</td> 70 <th>ETA</th><td>${e.eta||`â`}</td></tr> 71 <tr><th>Lot Code</th><td class="mono">${l}</td> 72 <th>Ship Date</th><td>${u}</td></tr> 73 </table> 74 <h2>Freight</h2> 75 <table> 76 <thead><tr><th>Pallet #</th><th>Product</th><th>Units / Pallet</th><th>Handling</th><th>Class</th></tr></thead> 77 <tbody> 78 ${Array.from({length:s}).map((e,n)=>` 79 <tr> 80 <td class="mono">${String(n+1).padStart(2,`0`)} / ${s}</td> 81 <td>${c}</td> 82 <td>${(t?.quantity?Math.round(t.quantity/s):`â`).toLocaleString?.()||`â`}</td> 83 <td>Stackable â do not double-stack</td> 84 <td>NMFC 156600</td> 85 </tr>`).join(``)} 86 </tbody> 87 </table> 88 <div class="row" style="margin-top:22px;align-items:center"> 89 <div>${a}</div> 90 <div style="text-align:right"><img src="${o}" style="width:120px;height:120px" alt="QR"/><div style="font-size:10px;color:#8A8A8E;margin-top:4px">Scan to verify</div></div> 91 </div> 92 <div class="row" style="margin-top:24px"> 93 <div><h2>Shipper Signature</h2><div style="height:44px;border-bottom:1px solid #2E2E30"></div><div style="font-size:10px;color:#8A8A8E;margin-top:4px">Name / Date</div></div> 94 <div><h2>Consignee Signature</h2><div style="height:44px;border-bottom:1px solid #2E2E30"></div><div style="font-size:10px;color:#8A8A8E;margin-top:4px">Name / Date</div></div> 95 </div> 96 </div>`}var Ri=24,zi=6,Bi=Ri*zi,Vi={pallet:{label:`Pallet`,title:`Pallet Label`},master_case:{label:`Master case`,title:`Master Case Label`},tower:{label:`Tower`,title:`Tower Label`},bol:{label:`BOL`,title:`Bill of Lading`}};async function Hi(e){let t=Vi[e.kind]||Vi.pallet,n=Ni(e.code,{height:80,fontSize:16}),r=e.lot_code?Ni(e.lot_code,{height:50,fontSize:12}):``,i=await Pi(e.qr_url||``),a=e.payload?.meta||[],o=e.payload?.coa||null,s=o?.url?await Pi(o.url):``;return` 97 <div class="sheet label-sheet"> 98 <div style="display:flex;justify-content:space-between;align-items:flex-start"> 99 <div class="brand">Krush</div> 100 <div style="text-align:right"> 101 <div style="font-size:10px;letter-spacing:.16em;text-transform:uppercase;color:#8A8A8E">${t.label}</div> 102 <div style="font-size:26px;font-weight:800">${e.sequence||1} / ${e.of_total||1}</div> 103 </div> 104 </div> 105 <div style="margin-top:14px;font-size:26px;font-weight:700">${e.product||`Product`}</div> 106 <div style="font-size:14px;color:#6C6C6E;margin-top:4px">${e.units?e.units.toLocaleString()+` units`:``}</div> 107 ${a.length?`<div style="font-size:12px;color:#6C6C6E;margin-top:6px">${a.join(` · `)}</div>`:``} 108 <div style="margin-top:22px">${n}</div> 109 <div class="row" style="margin-top:20px;align-items:center"> 110 <div> 111 ${e.lot_code?`<div style="font-size:10px;letter-spacing:.16em;text-transform:uppercase;color:#8A8A8E">Lot</div> 112 <div class="mono" style="font-size:16px;font-weight:700">${e.lot_code}</div> 113 <div style="margin-top:8px">${r}</div>`:``} 114 </div> 115 <div style="text-align:right"> 116 <img src="${i}" style="width:160px;height:160px" alt="QR"/> 117 <div style="font-size:10px;color:#8A8A8E;margin-top:4px">Scan for traceability</div> 118 </div> 119 </div> 120 ${o?`<div style="margin-top:18px;border:1px solid #E9E9E7;border-radius:4px;padding:12px;display:flex;justify-content:space-between;align-items:center;gap:16px"> 121 <div> 122 <div style="font-size:10px;letter-spacing:.16em;text-transform:uppercase;color:#8A8A8E">Certificate of Analysis</div> 123 <div style="font-size:15px;font-weight:700;margin-top:2px">${o.name||`COA`}</div> 124 ${o.reference?`<div class="mono" style="font-size:11px;color:#6C6C6E;margin-top:2px">${o.reference}</div>`:``} 125 ${o.issued?`<div style="font-size:11px;color:#6C6C6E;margin-top:2px">Issued ${o.issued}</div>`:``} 126 ${o.url?`<div style="font-size:10px;color:#8A8A8E;margin-top:4px">Scan the COA code to open the certificate</div>`:``} 127 </div> 128 ${s?`<div style="text-align:center"><img src="${s}" style="width:100px;height:100px" alt="COA QR"/><div style="font-size:9px;color:#8A8A8E;margin-top:2px">COA</div></div>`:``} 129 </div>`:``} 130 <div style="margin-top:22px;font-size:11px;color:#6C6C6E;border-top:1px solid #E9E9E7;padding-top:10px"> 131 Handle with care · Keep dry · Do not double-stack · Krush Cones Inc. 132 </div> 133 </div>`}async function Ui(e){if(e?.length)try{let t=await ia();if(!t)return;let n=e.map(e=>e.code),{data:r}=await o.from(`label_records`).select(`id,code,reprint_count`).eq(`customer_id`,t).in(`code`,n),i=new Map((r||[]).map(e=>[e.code,e])),a=e.filter(e=>!i.has(e.code)).map(e=>({...e,customer_id:t,generated_by:t}));a.length&&await o.from(`label_records`).insert(a);for(let e of r||[])await o.from(`label_records`).update({reprint_count:(e.reprint_count||0)+1,last_printed_at:new Date().toISOString()}).eq(`id`,e.id)}catch{}}function Wi(e){return String(e.id).slice(0,6).toUpperCase()}function Gi({shipment:e,order:t}){let n=t?.pallets||1;return{pallets:n,product:t?.product||e.notes||`Product`,lot:t?.lot_code||`LOT-${Wi(e)}`,perPallet:t?.quantity?Math.round(t.quantity/n):null}}async function Ki({shipment:e,order:t,traceUrl:n}){let{pallets:r,product:i,lot:a,perPallet:o}=Gi({shipment:e,order:t}),s=[];for(let c=1;c<=r;c++){let l=`PLT-${Wi(e)}-${String(c).padStart(2,`0`)}`;s.push({kind:`pallet`,code:l,product:i,lot_code:a,sequence:c,of_total:r,units:o,shipment_id:e.id,order_id:t?.id||e.order_id||null,qr_url:n||`${window.location.origin}/portal?pallet=${l}`,payload:{meta:[`${Ri} master cases`,`${Bi} towers`]}})}return s}async function qi({shipment:e,order:t,traceUrl:n,pallet:r,coa:i}
133){let{pallets:a,product:o,lot:s,perPallet:c}=Gi({shipment:e,order:t}),l=c?Math.round(c/Ri):null,u=[];for(let c=1;c<=Ri;c++){let d=`MC-${Wi(e)}-P${String(r).padStart(2,`0`)}-C${String(c).padStart(2,`0`)}`;u.push({kind:`master_case`,code:d,product:o,lot_code:s,sequence:c,of_total:Ri,units:l,shipment_id:e.id,order_id:t?.id||e.order_id||null,qr_url:n||`${window.location.origin}/portal?case=${d}`,payload:{pallet:r,pallets:a,coa:i||null,meta:[`Pallet ${r} of ${a}`,`${zi} towers per case`]}})}return u}async function Ji({shipment:e,order:t,traceUrl:n,pallet:r,caseNo:i,coa:a}){let{pallets:o,product:s,lot:c,perPallet:l}=Gi({shipment:e,order:t}),u=l?Math.round(l/Bi):null,d=[];for(let l=1;l<=zi;l++){let f=`TW-${Wi(e)}-P${String(r).padStart(2,`0`)}-C${String(i).padStart(2,`0`)}-T${l}`;d.push({kind:`tower`,code:f,product:s,lot_code:c,sequence:l,of_total:zi,units:u,shipment_id:e.id,order_id:t?.id||e.order_id||null,qr_url:n||`${window.location.origin}/portal?tower=${f}`,payload:{pallet:r,pallets:o,case:i,coa:a||null,meta:[`Pallet ${r} of ${o}`,`Master case ${i} of ${Ri}`]}})}return d}async function Yi(e){let t=[];for(let n of e)t.push(await Hi(n));return t.join(``)}var Xi={background:W.card,border:`1px solid ${W.line}`,borderRadius:6,padding:20,marginBottom:16},Zi={fontSize:12,letterSpacing:`0.18em`,textTransform:`uppercase`,fontWeight:700,color:W.ink,margin:`0 0 12px`},Qi={width:`100%`,padding:`9px 11px`,border:`1px solid ${W.line}`,borderRadius:4,background:`#FDFCF9`,fontSize:13,color:W.ink,boxSizing:`border-box`},$i={display:`block`,fontSize:10,color:W.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`,fontWeight:600,marginBottom:5},ea={padding:`10px 16px`,background:W.charcoal,color:`#FFF`,border:`none`,borderRadius:4,fontWeight:600,cursor:`pointer`,fontSize:12,letterSpacing:`0.12em`,textTransform:`uppercase`},ta={...ea,background:`transparent`,color:W.ink,border:`1px solid ${W.line}`},na=(e,t)=>({display:`inline-block`,padding:`3px 8px`,borderRadius:3,background:e,color:t,fontSize:10,fontWeight:700,letterSpacing:`0.1em`,textTransform:`uppercase`});function ra(e,t){let[n,r]=(0,h.useState)(()=>{try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch{return t}});return(0,h.useEffect)(()=>{try{localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]),[n,r]}async function ia(){let{data:e}=await o.auth.getUser();return e?.user?.id||null}var aa=[{id:`84/26`,category:`Cones`,name:`84/26`,palletUnits:129600},{id:`98/26`,category:`Cones`,name:`98/26 Classic`,palletUnits:115200},{id:`109/26`,category:`Cones`,name:`109/26 XL`,palletUnits:115200},{id:`109/26-hemp`,category:`Hemp blunts`,name:`109/26 Hemp Blunt`,palletUnits:115200}],oa=.05,sa=.06,ca=.025,la=.1,ua=.15;function da({onSubmitted:e}){let[t,n]=(0,h.useState)(0),[r,i]=(0,h.useState)({orderType:`cone`,skuId:`98/26`,paper:`Natural`,filterPaper:`Refined`,pallets:2,printed:!1,artwork:``,ship:`Standard freight`,notes:``,commitment:`none`}),[a,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(``),[d,f]=(0,h.useState)([]),[p,m]=(0,h.useState)(!1),[g,_]=(0,h.useState)(``),[v,y]=(0,h.useState)(!1),b=(0,h.useRef)(null),[x,S]=(0,h.useState)([]),[C,w]=(0,h.useState)(``),[T,E]=(0,h.useState)(!1),[D,O]=(0,h.useState)(``),[k,ee]=(0,h.useState)(null),[A,j]=(0,h.useState)(!1),[te,ne]=(0,h.useState)(``),re=(0,h.useCallback)(async()=>{E(!0);try{let e=await ia();if(!e){S([]);return}let{data:t}=await o.from(`artwork_items`).select(`id,name,version,status,created_at`).eq(`customer_id`,e).eq(`status`,`Approved`).order(`created_at`,{ascending:!1});S(t||[])}finally{E(!1)}},[]);(0,h.useEffect)(()=>{re()},[re]);let M=async e=>{let t=Array.from(e||[]).filter(Boolean);if(!t.length)return;_(``);let n=await ia();if(!n){_(`You must be signed in to upload artwork.`);return}for(let e of t)if(e.size>25*1024*1024){_(`${e.name} exceeds the 25 MB limit.`);return}m(!0);try{let e=[];for(let r of t){let t=r.name.replace(/[^\w.\-]+/g,`_`),i=`${n}/artwork/${Date.now()}-${t}`,{error:a}=await o.storage.from(`compliance-docs`).upload(i,r,{upsert:!1,contentType:r.type||void 0});if(a)throw a;e.push({name:r.name,size:r.size,path:i})}f(t=>[...t,...e])}catch(e){_(e.message||`Upload failed.`)}finally{m(!1)}},ie=async e=>{let t=d[e];if(t){try{await o.storage.from(`compliance-docs`).remove([t.path])}catch{}f(t=>
133t.filter((t,n)=>n!==e))}},ae=[`Product`,`Artwork`,`Shipping`,`Review`],N=(e,t)=>i({...r,[e]:t}),oe=aa.find(e=>e.id===r.skuId)||aa[1],se=oe.palletUnits,ce=r.orderType===`filter`?ca:r.printed?sa:oa,le=r.commitment===`prepaid12`?ua:r.commitment===`sub12`?la:0,ue=r.commitment===`prepaid12`?`12-month prepaid · 15% off`:r.commitment===`sub12`?`12-month subscription · 10% off`:null,de=ce*(1-le),fe=r.pallets*se,pe=fe*de,me=r.orderType===`filter`?`filters`:`cones`,he=oe.category||`Cones`,ge=r.orderType===`filter`||he===`Hemp blunts`||r.orderType===`cone`&&r.printed,_e=async()=>{u(``),c(!0);try{let t=await ia();if(!t)throw Error(`You must be signed in.`);if(ge&&!C)throw Error(`Select an approved artwork to link to this order. Upload and approve artwork in Artwork & Approvals first.`);let n=fe,i=r.orderType===`cone`&&r.printed?` · ${r.filterPaper} filter`:``,a=`${oe.name} â ${r.orderType===`filter`?`filters (${r.paper})`:r.paper}${i}`,{data:c,error:l}=await o.from(`orders`).insert({customer_id:t,product:a,quantity:n,unit_price_cents:Math.round(de*100),status:`Order received`,pallets:r.pallets,printed_filters:r.orderType===`cone`?!!r.printed:!1,carrier:r.ship,flow:r.orderType,notes:r.notes||null,artwork_id:ge?C:null,metadata:{artwork:r.artwork||null,artwork_files:d.map(e=>({name:e.name,path:e.path,size:e.size})),artwork_id:ge?C:null,ship_method:r.ship,sku:oe.id,paper:r.paper,filter_paper:r.orderType===`filter`?r.paper:r.printed?r.filterPaper:null,pallet_units:se,order_type:r.orderType}}).select(`id`).maybeSingle();if(l)throw l;let u=c?.id;if(u&&(D||k))try{await o.from(`orders`).update({po_number:D||null,po_file_url:k?.path||null}).eq(`id`,u)}catch{}if(d.length&&(await o.from(`artwork_items`).insert(d.map(e=>({customer_id:t,name:e.name,size_bytes:e.size,file_url:e.path,version:1,status:`Awaiting review`}))),await re()),u)try{let{forwardOrderToKrushOS:e}=await s(async()=>{let{forwardOrderToKrushOS:e}=await import(`./krushos.functions-BYiOQwm1.js`);return{forwardOrderToKrushOS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7]));e({data:{order_id:u}}).catch(()=>{})}catch{}e?.(pe,r)}catch(e){u(e.message||`Could not place order.`)}finally{c(!1)}};return(0,P.jsx)(`div`,{children:(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`div`,{style:{display:`flex`,gap:6,marginBottom:18},children:ae.map((e,n)=>(0,P.jsxs)(`div`,{style:{flex:1},children:[(0,P.jsx)(`div`,{style:{height:4,background:n<=t?W.charcoal:W.line,borderRadius:2}}),(0,P.jsxs)(`div`,{style:{fontSize:10,marginTop:6,color:n<=t?W.ink:W.inkSoft,fontWeight:n===t?700:500,letterSpacing:`0.12em`,textTransform:`uppercase`},children:[n+1,`. `,e]})]},e))}),t===0&&(0,P.jsxs)(`div`,{style:{display:`grid`,gap:14},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`What are you ordering?`}),(0,P.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10},children:[{id:`cone`,title:`Finished cones`,sub:`$${oa.toFixed(3)} blank · $${sa.toFixed(3)} custom`},{id:`filter`,title:`Filters only`,sub:`$${ca.toFixed(3)}/filter`}].map(e=>{let t=r.orderType===e.id;return(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i({...r,orderType:e.id,paper:e.id===`filter`?`Natural Kraft`:`Natural`}),style:{padding:14,borderRadius:6,textAlign:`left`,cursor:`pointer`,background:t?W.charcoal:`#FFF`,color:t?`#FFF`:W.ink,border:`1px solid ${t?W.charcoal:W.line}`},children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:700},children:e.title}),(0,P.jsx)(`div`,{style:{fontSize:11,marginTop:4,opacity:.85},children:e.sub})]},e.id)})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`SKU`}),(0,P.jsx)(`select`,{style:Qi,value:r.skuId,onChange:e=>N(`skuId`,e.target.value),children:Array.from(new Set(aa.map(e=>e.category||`Cones`))).map(e=>(0,P.jsx)(`optgroup`,{label:e,children:aa.filter(t=>(t.category||`Cones`)===e).map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.name,` â `,e.palletUnits.toLocaleString(),`/pallet`]},e.id))},e))})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:r.orderType===`filter`?`Filter paper`:`Cone paper`}
133),(0,P.jsx)(`select`,{style:Qi,value:r.paper,onChange:e=>N(`paper`,e.target.value),children:(r.orderType===`filter`?[`Refined`,`Natural Kraft`]:[`White`,`Natural`]).map(e=>(0,P.jsx)(`option`,{children:e},e))})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`label`,{style:$i,children:[`Pallets (`,se.toLocaleString(),` `,me,` ea.)`]}),(0,P.jsx)(`input`,{style:Qi,type:`number`,min:1,max:40,value:r.pallets,onChange:e=>N(`pallets`,Math.max(1,Number(e.target.value)||1))})]}),r.orderType===`cone`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`label`,{style:{display:`flex`,gap:8,alignItems:`center`,fontSize:13},children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:r.printed,onChange:e=>N(`printed`,e.target.checked)}),` Custom printed filter tips (+$0.01/cone · $0.06 CAD)`]}),r.printed&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`Filter paper`}),(0,P.jsx)(`select`,{style:Qi,value:r.filterPaper,onChange:e=>N(`filterPaper`,e.target.value),children:[`Refined`,`Natural Kraft`].map(e=>(0,P.jsx)(`option`,{children:e},e))})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`Commitment`}),(0,P.jsxs)(`select`,{style:Qi,value:r.commitment,onChange:e=>N(`commitment`,e.target.value),children:[(0,P.jsx)(`option`,{value:`none`,children:`Spot order â no commitment`}),(0,P.jsx)(`option`,{value:`sub12`,children:`12-month subscription â 10% off`}),(0,P.jsx)(`option`,{value:`prepaid12`,children:`12-month prepaid â 15% off`})]})]}),(0,P.jsxs)(`div`,{style:{fontSize:11.5,color:W.inkSoft},children:[r.pallets,` pallet`,r.pallets===1?``:`s`,` · `,fe.toLocaleString(),` `,me,` · $`,de.toFixed(4),`/`,me.slice(0,-1),le?` (${Math.round(le*100)}% off)`:``,` · est. $`,pe.toLocaleString(void 0,{maximumFractionDigits:2})]})]}),t===1&&(0,P.jsxs)(`div`,{style:{display:`grid`,gap:14},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`label`,{style:$i,children:[`Link approved artwork `,ge?(0,P.jsx)(`span`,{style:{color:`#B33A3A`},children:`*`}):(0,P.jsx)(`span`,{style:{color:W.inkSoft,fontWeight:400},children:`(optional for blank cones)`})]}),(0,P.jsxs)(`select`,{style:Qi,value:C,onChange:e=>w(e.target.value),children:[(0,P.jsx)(`option`,{value:``,children:T?`Loading approved artworkâ¦`:x.length?`â Select approved artwork â`:`No approved artwork on file yet`}),x.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.name,` â v`,e.version,` (Approved)`]},e.id))]}),(0,P.jsxs)(`div`,{style:{fontSize:11,color:W.inkSoft,marginTop:6},children:[ge?`Required â filter, hemp, and custom-printed cone orders can only be released against artwork that has passed review.`:`Blank cones don't need artwork. Add one only if you want it on file for this order.`,x.length===0&&ge&&(0,P.jsxs)(P.Fragment,{children:[` Upload artwork below, then approve it in `,(0,P.jsx)(`b`,{children:`Artwork & Approvals`}),` to link it here.`]})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`Artwork reference / brand`}),(0,P.jsx)(`input`,{style:Qi,value:r.artwork,onChange:e=>N(`artwork`,e.target.value),placeholder:`e.g. Blue Dream â v3 approved`})]}),(0,P.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>b.current?.click(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&b.current?.click()},onDragOver:e=>{e.preventDefault(),y(!0)},onDragLeave:()=>y(!1),onDrop:e=>{e.preventDefault(),y(!1),M(e.dataTransfer?.files)},style:{padding:22,border:`1px dashed ${v?W.charcoal:W.line}`,background:v?`#F5F5F4`:`transparent`,borderRadius:6,textAlign:`center`,color:W.inkSoft,fontSize:12,cursor:p?`wait`:`pointer`},children:[(0,P.jsx)(Dn,{size:22,style:{display:`block`,margin:`0 auto 8px`}}),(0,P.jsx)(`div`,{style:{color:W.ink,fontSize:13,fontWeight:600},children:p?`Uploadingâ¦`:`Click or drop tech specs / dielines`}),(0,P.jsx)(`div`,{style:{marginTop:4},children:`PDF, AI, EPS, PNG, JPG · up to 25 MB each`}),(0,P.jsx)(`input`,{ref:b,type:`file`,multiple:!0,accept:`.pdf,.ai,.eps,.png,.jpg,.jpeg,application/pdf,image/*`,style:{display:`none`},onChange:e=>{let t=e.target.files;e.target.value=``,M(t)}})]}),g&&(0,P.jsx)(`div`,{style:{color:`#B33A3A`,fontSize:12},children:g}),d.length>0&&(0,P.jsx)(`div`,{style:{display:`grid`,gap:6},children:d.map((e,t)=>(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:10,padding:`8px 12px`,border:`1px solid ${W.line}`,borderRadius:4,background:`#fff`},children:[(0,P.jsxs)(`div`,{style:{minWidth:0,overflow:`hidden`},children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e.name}),(0,P.jsxs)(`div`,{style:{fontSize:11,color:W.inkSoft},children:[(e.size/1024/1024).toFixed(2),` MB · uploaded`]})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ie(t),style:{background:`transparent`,border:`1px solid ${W.line}`,borderRadius:4,padding:`4px 10px`,fontSize:11,cursor:`pointer`},children:`Remove`})]},e.path))})]}),t===2&&(0,P.jsxs)(`div`,{style:{display:`grid`,gap:14},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`Ship method`}),(0,P.jsx)(`select`,{style:Qi,value:r.ship,onChange:e=>N(`ship`,e.target.value),children:[`Standard freight`,`Expedited freight`,`Customer pickup`].map(e=>(0,P.jsx)(`option`,{children:e},e))})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`Purchase order # (optional)`}),(0,P.jsx)(`input`,{style:Qi,value:D,onChange:e=>O(e.target.value),placeholder:`e.g. PO-2026-00142`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`PO document (optional PDF)`}),k?(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`8px 12px`,border:`1px solid ${W.line}`,borderRadius:4},children:[(0,P.jsxs)(`span`,{style:{fontSize:12},children:[k.name,` · `,(k.size/1024).toFixed(0),` KB`]}
133),(0,P.jsx)(`button`,{style:ta,type:`button`,onClick:async()=>{try{await o.storage.from(`compliance-docs`).remove([k.path])}catch{}ee(null)},children:`Remove`})]}):(0,P.jsx)(`input`,{type:`file`,accept:`.pdf`,disabled:A,onChange:async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){ne(``),j(!0);try{let e=await ia();if(!e)throw Error(`Not signed in.`);let n=`${e}/po/${Date.now()}-${t.name.replace(/[^\w.\-]+/g,`_`)}`,{error:r}=await o.storage.from(`compliance-docs`).upload(n,t,{upsert:!1,contentType:t.type});if(r)throw r;ee({name:t.name,size:t.size,path:n})}catch(e){ne(e.message||`Upload failed.`)}finally{j(!1)}}}}),te&&(0,P.jsx)(`div`,{style:{color:`#B33A3A`,fontSize:11,marginTop:4},children:te}),(0,P.jsx)(`div`,{style:{fontSize:11,color:W.inkSoft,marginTop:4},children:`Attach a signed PO if your organization requires one for accounts payable.`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`Notes (optional)`}),(0,P.jsx)(`textarea`,{style:{...Qi,minHeight:80},value:r.notes,onChange:e=>N(`notes`,e.target.value)})]})]}),t===3&&(0,P.jsxs)(`div`,{style:{display:`grid`,gap:10,fontSize:13},children:[(0,P.jsx)(fa,{k:`Order type`,v:r.orderType===`filter`?`Filters only`:`Finished cones`}),(0,P.jsx)(fa,{k:`SKU`,v:`${oe.name}${r.orderType===`cone`?` â ${r.paper}`:``}`}),(0,P.jsx)(fa,{k:`Pallets`,v:`${r.pallets} (${fe.toLocaleString()} ${me})`}),(0,P.jsx)(fa,{k:`Base price`,v:`$${ce.toFixed(3)} / ${me.slice(0,-1)}`}),ue&&(0,P.jsx)(fa,{k:`Commitment`,v:ue}),(0,P.jsx)(fa,{k:`Unit price`,v:`$${de.toFixed(4)} / ${me.slice(0,-1)}`}),r.orderType===`cone`&&(0,P.jsx)(fa,{k:`Printed filters`,v:r.printed?`Custom (+$0.01/cone)`:`No â blank`}),r.orderType===`cone`&&r.printed&&(0,P.jsx)(fa,{k:`Filter paper`,v:r.filterPaper}),(0,P.jsx)(fa,{k:`Artwork`,v:r.artwork||`â`}),(0,P.jsx)(fa,{k:`Approved artwork link`,v:C?(x.find(e=>e.id===C)?.name||`Selected`)+` (verified)`:ge?`â required â`:`Not linked`}),(0,P.jsx)(fa,{k:`Shipping`,v:r.ship}),(0,P.jsx)(fa,{k:`Estimated total`,v:`$${pe.toLocaleString(void 0,{maximumFractionDigits:2})}`})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,marginTop:22},children:[(0,P.jsx)(`button`,{style:ta,onClick:()=>n(e=>Math.max(0,e-1)),disabled:t===0,children:`Back`}),t<ae.length-1?(0,P.jsx)(`button`,{style:ea,onClick:()=>n(e=>e+1),children:`Continue`}):(0,P.jsx)(`button`,{style:ea,onClick:_e,disabled:a,children:a?`Submittingâ¦`:`Submit order`})]}),l&&(0,P.jsx)(`div`,{style:{marginTop:10,color:`#B33A3A`,fontSize:12},children:l})]})})}function fa({k:e,v:t}){return(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid ${W.line}`},children:[(0,P.jsx)(`span`,{style:{color:W.inkSoft,fontSize:12},children:e}),(0,P.jsx)(`span`,{style:{fontWeight:600},children:t})]})}var pa=[`Order received`,`Specs locked`,`Queued`,`In production`,`QC`,`Packing`,`Ready to ship`,`In transit`,`Delivered`];function ma({orders:e}){let t=e=>typeof e.stage==`number`?Math.max(0,Math.min(pa.length-1,e.stage)):e.receivedAt?8:e.tracking?7:0;return(0,P.jsxs)(`div`,{children:[(!e||!e.length)&&(0,P.jsx)(`div`,{style:{...Xi,textAlign:`center`,color:W.inkSoft},children:`No orders yet â place one from the Wizard.`}),e?.map(e=>{let n=t(e);return(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,marginBottom:12},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:13,fontWeight:700},children:e.id}),(0,P.jsx)(`div`,{style:{fontSize:12,color:W.inkSoft,marginTop:2},children:e.items}),e.date&&(0,P.jsxs)(`div`,{style:{fontSize:11,color:W.inkSoft,marginTop:2},children:[`Placed `,e.date]})]}),(0,P.jsxs)(`div`,{style:{textAlign:`right`},children:[(0,P.jsx)(`span`,{style:na(W.goodBg,W.good),children:e.status}),(0,P.jsxs)(`div`,{style:{fontSize:11,color:W.inkSoft,marginTop:6},children:[`ETA `,e.eta||`â`]})]})]}),(0,P.jsx)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:4,overflowX:`auto`},children:pa.map((e,t)=>(0,P.jsxs)(`div`,{style:{flex:1,minWidth:68,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:6},children:[t<=n?(0,P.jsx)(wn,{size:18,color:W.good}):(0,P.jsx)(En,{size:18,color:W.line}),(0,P.jsx)(`div`,{style:{fontSize:9.5,textAlign:`center`,color:t<=n?W.ink:W.inkSoft,fontWeight:t===n?700:500,letterSpacing:`0.08em`,textTransform:`uppercase`},children:e})]},e))})]},e.id)})]})}function ha({orders:e,onReorder:t}){let[n,r]=ra(`krush.subs`,[]),[i,a]=(0,h.useState)(`98mm Classic`),[o,s]=(0,h.useState)(`monthly`),[c,l]=(0,h.useState)(2),u=(e||[]).slice(0,6),[d,f]=(0,h.useState)(``),[p,m]=(0,h.useState)(``),g=async e=>{if(!e?.uuid){t?.(e);return}f(e.id),m(``);try{await Mi({data:{order_id:e.uuid}}),m(`Reorder placed from ${e.id}. Track it in Track Orders.`),t?.(e)}catch(e){m(e?.message||`Reorder failed.`)}finally{f(``)}};return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Reorder from history`}),u.length===0&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`No history yet.`}),p&&(0,P.jsx)(`div`,{style:{fontSize:12,color:W.good,marginBottom:8},children:p}),u.map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`10px 0`,borderBottom:`1px solid ${W.line}`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:e.items}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:W.inkSoft},children:[e.id,` · `,e.date]})]}),(0,P.jsxs)(`button`,{style:ta,disabled:d===e.id,onClick:()=>g(e),children:[d===e.id?`Placingâ¦`:`Reorder`,` `,(0,P.jsx)(Cn,{size:12})]})]},e.id))]}),(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Recurring subscriptions`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`2fr 1fr 1fr auto`,gap:10,alignItems:`end`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`SKU`}),(0,P.jsx)(`input`,{style:Qi,value:i,onChange:e=>a(e.target.value)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`Pallets`}),(0,P.jsx)(`input`,{style:Qi,type:`number`,min:1,value:c,onChange:e=>l(+e.target.value||1)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:$i,children:`Frequency`}),(0,P.jsxs)(`select`,{style:Qi,value:o,onChange:e=>s(e.target.value),children:[(0,P.jsx)(`option`,{value:`weekly`,children:`Weekly`}
133),(0,P.jsx)(`option`,{value:`biweekly`,children:`Bi-weekly`}),(0,P.jsx)(`option`,{value:`monthly`,children:`Monthly`})]})]}),(0,P.jsx)(`button`,{style:ea,onClick:()=>{r([...n,{id:`SUB-`+Date.now().toString().slice(-5),sku:i,freq:o,qty:c,next:ga(o)}])},children:(0,P.jsx)(qn,{size:14})})]}),(0,P.jsxs)(`div`,{style:{marginTop:16},children:[n.length===0&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:12},children:`No subscriptions yet.`}),n.map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`10px 0`,borderBottom:`1px solid ${W.line}`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:{fontSize:13,fontWeight:600},children:[e.sku,` â `,e.qty,` pallet(s)`]}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:W.inkSoft},children:[e.id,` · `,e.freq,` · next `,e.next]})]}),(0,P.jsx)(`button`,{style:ta,onClick:()=>r(n.filter(t=>t.id!==e.id)),children:(0,P.jsx)(rr,{size:13})})]},e.id))]})]})]})}function ga(e){let t=new Date,n=e===`weekly`?7:e===`biweekly`?14:30;return t.setDate(t.getDate()+n),t.toISOString().slice(0,10)}function _a(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(!0),[i,a]=(0,h.useState)({}),[s,c]=(0,h.useState)({}),[l,u]=(0,h.useState)(``),d=async()=>{let e=await ia();if(!e){r(!1);return}let{data:n}=await o.from(`artwork_items`).select(`*`).eq(`customer_id`,e).order(`created_at`,{ascending:!1});t(n||[]),r(!1);let i=(n||[]).map(e=>e.id);if(i.length){let{data:e}=await o.from(`artwork_revisions`).select(`*`).in(`artwork_id`,i).order(`version`,{ascending:!1}),t={};(e||[]).forEach(e=>{(t[e.artwork_id]||=[]).push(e)}),a(t)}else a({})};(0,h.useEffect)(()=>{d()},[]);let f=async(e,t)=>{if(t){u(e.id);try{let n=await ia(),r=i[e.id]||[],a=Math.max(e.version||1,...r.map(e=>e.version||1))+1,s=`${n}/artwork/${e.id}/v${a}-${Date.now()}-${t.name.replace(/[^\w.\-]+/g,`_`)}`,{error:c}=await o.storage.from(`compliance-docs`).upload(s,t,{upsert:!1,contentType:t.type});if(c)throw c;await o.from(`artwork_revisions`).insert({artwork_id:e.id,customer_id:n,uploaded_by:n,version:a,file_url:s,status:`pending`}),await o.from(`artwork_items`).update({status:`Awaiting review`}).eq(`id`,e.id),await d()}catch(e){alert(e.message||`Upload failed.`)}finally{u(``)}}},p=async e=>{let t=Array.from(e.target.files||[]);e.target.value=``;let n=await ia();if(!n||!t.length)return;let r=[];for(let e of t){let t=null;try{let r=`${n}/artwork/${Date.now()}-${e.name}`,{error:i}=await o.storage.from(`compliance-docs`).upload(r,e,{upsert:!1});i||(t=r)}catch{}r.push({customer_id:n,name:e.name,size_bytes:e.size,file_url:t,version:1,status:`Awaiting review`})}await o.from(`artwork_items`).insert(r),d()},m=async(e,t)=>{await o.from(`artwork_items`).update({status:t}).eq(`id`,e),d()},g=async e=>{await o.from(`artwork_items`).delete().eq(`id`,e),d()};return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Upload artwork / dielines`}),(0,P.jsxs)(`label`,{style:{display:`block`,padding:24,border:`2px dashed ${W.line}`,borderRadius:8,textAlign:`center`,cursor:`pointer`},children:[(0,P.jsx)(Dn,{size:22,style:{display:`block`,margin:`0 auto 8px`,color:W.inkSoft}}),(0,P.jsx)(`div`,{style:{fontSize:13,color:W.ink},children:`Click or drop PDF / AI files`}),(0,P.jsx)(`input`,{type:`file`,multiple:!0,accept:`.pdf,.ai,.eps,.png,.jpg`,style:{display:`none`},onChange:p})]})]}),(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Proofs & approvals`}),n&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`Loadingâ¦`}),!n&&e.length===0&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`No artwork submitted yet.`}),e.map(e=>(0,P.jsxs)(`div`,{style:{padding:`12px 0`,borderBottom:`1px solid ${W.line}`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:e.name}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:W.inkSoft},children:[`v`,e.version,` · `,(e.created_at||``).slice(0,10),e.size_bytes?` · ${(e.size_bytes/1024).toFixed(0)} KB`:``,i[e.id]?.length?` · ${i[e.id].length} revision${i[e.id].length===1?``:`s`}`:``]})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,P.jsx)(`span`,{style:na(e.status===`Approved`?W.goodBg:W.warnBg,e.status===`Approved`?W.good:W.warn),children:e.status}),e.status!==`Approved`&&(0,P.jsx)(`button`,{style:ta,onClick:()=>m(e.id,`Approved`),children:`Approve`}),(0,P.jsx)(`button`,{style:ta,onClick:()=>c(t=>
133({...t,[e.id]:!t[e.id]})),children:s[e.id]?`Hide`:`Revisions`}),(0,P.jsx)(`button`,{style:ta,onClick:()=>g(e.id),children:(0,P.jsx)(rr,{size:13})})]})]}),s[e.id]&&(0,P.jsxs)(`div`,{style:{marginTop:10,padding:12,background:W.bg,border:`1px solid ${W.line}`,borderRadius:6},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:8},children:[(0,P.jsx)(`div`,{style:{fontSize:11,letterSpacing:`0.14em`,textTransform:`uppercase`,color:W.inkSoft,fontWeight:700},children:`Revision history`}),(0,P.jsxs)(`label`,{style:{...ta,cursor:l===e.id?`wait`:`pointer`},children:[l===e.id?`Uploadingâ¦`:`Upload new revision`,(0,P.jsx)(`input`,{type:`file`,style:{display:`none`},accept:`.pdf,.ai,.eps,.png,.jpg`,onChange:t=>{let n=t.target.files?.[0];t.target.value=``,f(e,n)}})]})]}),(i[e.id]||[]).length===0?(0,P.jsx)(`div`,{style:{fontSize:12,color:W.inkSoft},children:`No revisions yet. Upload one when you need a new proof round.`}):(i[e.id]||[]).map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`6px 0`,borderTop:`1px solid ${W.line}`},children:[(0,P.jsxs)(`span`,{className:`mono`,style:{fontSize:12},children:[`v`,e.version,` · `,(e.created_at||``).slice(0,10)]}),(0,P.jsx)(`span`,{style:na(e.status===`approved`?W.goodBg:W.warnBg,e.status===`approved`?W.good:W.warn),children:e.status})]},e.id))]})]},e.id))]})]})}function va({orders:e,docs:t}){let[n,r]=(0,h.useState)([]),[i,a]=(0,h.useState)(!0),[s,c]=(0,h.useState)(null),[l,u]=(0,h.useState)(0),d=()=>u(e=>e+1);(0,h.useEffect)(()=>{(async()=>{let e=await ia();if(!e){a(!1);return}let{data:t}=await o.from(`profiles`).select(`*`).eq(`id`,e).maybeSingle();c(t||null);let{data:n}=await o.from(`shipments`).select(`*`).eq(`customer_id`,e).order(`created_at`,{ascending:!1});r(n||[]),a(!1)})()},[]);let f=(e||[]).filter(e=>e.tracking||e.carrier||e.status?.toLowerCase().includes(`ship`)),p=(0,h.useMemo)(()=>{let t=new Map;return(e||[]).forEach(e=>t.set(e.id,e)),t},[e]),m=(0,h.useMemo)(()=>(t||[]).filter(e=>String(e.kind||e.type||``).toUpperCase()===`COA`),[t]),[g,_]=(0,h.useState)(``);(0,h.useEffect)(()=>{!g&&m.length&&_(String(m[0].id))},[m,g]);let v=async()=>{let e=m.find(e=>String(e.id)===String(g));if(!e)return null;let t=e.file_url||null;if(t&&!/^https?:\/\//.test(t))try{let{data:e}=await o.storage.from(`coa-docs`).createSignedUrl(t,3600*24*7);t=e?.signedUrl||null}catch{t=null}return{name:e.title||e.name||`COA`,reference:`COA-${String(e.id).slice(0,8).toUpperCase()}`,issued:e.date||e.tested||null,url:t}},y=async e=>{let t=e.order_id?p.get(e.order_id):null,n=await Fi(e),r=await Li({shipment:e,order:t,customer:s,traceUrl:n});await Ui([{kind:`bol`,code:`BOL-${String(e.id).slice(0,8).toUpperCase()}`,product:t?.product||e.notes||`Shipment`,lot_code:t?.lot_code||null,sequence:1,of_total:1,units:t?.quantity||null,shipment_id:e.id,order_id:t?.id||e.order_id||null,qr_url:n||`${window.location.origin}/portal?shipment=${e.id}`,payload:{pallets:t?.pallets||1}}]),d(),Ii(`BOL â ${String(e.id).slice(0,8).toUpperCase()}`,r)},b=async(e,t,n,r={})=>{let i=await t({shipment:e,order:e.order_id?p.get(e.order_id):null,traceUrl:await Fi(e),...r}),a=await Yi(i);await Ui(i),d(),Ii(`${n} â ${Wi(e)}`,a)},x=e=>(e.order_id?p.get(e.order_id)?.pallets:null)||1;return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Bill of Lading & Labels`}),(0,P.jsxs)(`div`,{style:{fontSize:12,color:W.inkSoft,marginBottom:12},children:[`BOLs, pallet labels, master case labels and tower labels generate automatically for every shipment â 1 pallet = `,Ri,` master cases = `,Bi,` towers. Each label carries a Code-128 barcode plus a QR code linked to its production trace, and every label generated is archived in the label library below.`]}),i&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`Loadingâ¦`}),!i&&n.length===0&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`No shipments yet â BOLs will appear here the moment a shipment is registered.`}),n.map(e=>(0,P.jsxs)(`div`,{style:{padding:`14px 0`,borderBottom:`1px solid ${W.line}`},children:[(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.4fr 1fr 1fr`,gap:12,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:12,fontWeight:700},children:[`BOL-`,String(e.id).slice(0,8).toUpperCase()]}),(0,P.jsx)(`div`,{style:{fontSize:12,color:W.inkSoft},children:e.notes||`Shipment`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,
133color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`Ship date`}),(0,P.jsx)(`div`,{style:{fontSize:13},children:e.ship_date||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`Tracking`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:12},children:e.tracking||`â`})]})]}),(0,P.jsx)(xa,{shipment:e,pallets:x(e),onBol:()=>y(e),onPallets:()=>b(e,Ki,`Pallet Labels`),coaDocs:m,coaId:g,onCoaChange:_,onCases:async t=>b(e,qi,`Master Case Labels · P${t}`,{pallet:t,coa:await v()}),onTowers:async(t,n)=>b(e,Ji,`Tower Labels · P${t}C${n}`,{pallet:t,caseNo:n,coa:await v()})})]},`bol-${e.id}`))]}),(0,P.jsx)(Sa,{refreshKey:l}),(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Active shipments`}),i&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`Loadingâ¦`}),!i&&n.length===0&&f.length===0&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`No shipments in transit.`}),n.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.4fr 1fr 1fr 1fr 1fr`,gap:12,padding:`12px 0`,borderBottom:`1px solid ${W.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:12,fontWeight:700},children:[`SHP-`,String(e.id).slice(0,6).toUpperCase()]}),(0,P.jsx)(`div`,{style:{fontSize:12,color:W.inkSoft},children:e.notes||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`Carrier`}),(0,P.jsx)(`div`,{style:{fontSize:13},children:e.carrier||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`Tracking`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:12},children:e.tracking||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`Shipped`}),(0,P.jsx)(`div`,{style:{fontSize:13},children:e.ship_date||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`ETA`}),(0,P.jsx)(`div`,{style:{fontSize:13},children:e.eta||`â`})]})]},e.id)),f.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.4fr 1fr 1fr 1fr`,gap:12,padding:`12px 0`,borderBottom:`1px solid ${W.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:12,fontWeight:700},children:e.id}),(0,P.jsx)(`div`,{style:{fontSize:12,color:W.inkSoft},children:e.items})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`Carrier`}),(0,P.jsx)(`div`,{style:{fontSize:13},children:e.carrier||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`Tracking`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:12},children:e.tracking||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`ETA`}),(0,P.jsx)(`div`,{style:{fontSize:13},children:e.eta||`â`})]})]},e.id))]}),(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Documents`}),(!t||!t.length)&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`No documents on file.`}),t?.map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`10px 0`,borderBottom:`1px solid ${W.line}`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,P.jsx)(Mn,{size:15,color:W.inkSoft}),(0,P.jsx)(`span`,{style:{fontSize:13},children:e.name||e.id})]}),(0,P.jsx)(`span`,{style:{fontSize:11,color:W.inkSoft},children:e.kind||e.type||`Doc`})]},e.name||e.id))]})]})}function ya(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(!0),[i,a]=(0,h.useState)({}),s=(0,h.useRef)({});(0,h.useEffect)(()=>{(async()=>{let e=await ia();if(!e){r(!1);return}let{data:n}=await o.from(`production_traces`).select(`*`).eq(`customer_id`,e).order(`production_date`,{ascending:!1});t(n||[]),r(!1);let i={};for(let e of n||[]){let t=e.krushos_qr_url||`${window.location.origin}/trace/${e.slug}`;i[e.id]=await Ce.toDataURL(t,{width:240,margin:1})}a(i)})()},[]),(0,h.useEffect)(()=>
133{e.forEach(e=>{let t=s.current[`p-${e.id}`];if(t&&e.product_model)try{(0,ji.default)(t,e.product_model,{format:`CODE128`,width:1.6,height:44,fontSize:11,margin:2})}catch{}(e.raw_material_lots||[]).forEach((t,n)=>{let r=s.current[`l-${e.id}-${n}`];if(r&&t?.lot)try{(0,ji.default)(r,String(t.lot),{format:`CODE128`,width:1.4,height:36,fontSize:10,margin:2})}catch{}})})},[e]);let c=e=>{let t=` 134 <div class="sheet"> 135 <h1>Production Trace</h1> 136 <div class="mono" style="font-size:12px;color:#8A8A8E;margin-bottom:16px">${e.slug}</div> 137 <table> 138 <tr><th>Product</th><td>${e.product_model||`â`}</td></tr> 139 <tr><th>Production date</th><td>${e.production_date||`â`}</td></tr> 140 <tr><th>Notes</th><td>${e.notes||`â`}</td></tr> 141 </table> 142 <h2>Raw material lots</h2> 143 <table> 144 <thead><tr><th>Material</th><th>Lot</th><th>Supplier</th></tr></thead> 145 <tbody> 146 ${(e.raw_material_lots||[]).map(e=>`<tr><td>${e.material||`â`}</td><td class="mono">${e.lot||`â`}</td><td>${e.supplier||`â`}</td></tr>`).join(``)||`<tr><td colspan="3" style="color:#8A8A8E">No lots recorded</td></tr>`} 147 </tbody> 148 </table> 149 <div style="margin-top:20px;text-align:center"><img src="${i[e.id]||``}" style="width:180px;height:180px"/></div> 150 </div>`;Ii(`Trace â ${e.slug}`,t)};return(0,P.jsx)(`div`,{children:(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`QR & Barcode Traceability`}),(0,P.jsx)(`div`,{style:{fontSize:12,color:W.inkSoft,marginBottom:12},children:`Every production run is fingerprinted with a QR code and Code-128 barcodes for the finished product plus every raw-material lot tested in that run. Scan any code to open the full trace.`}),n&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`Loadingâ¦`}),!n&&e.length===0&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`No production traces on file yet.`}),(0,P.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(320px, 1fr))`,gap:14},children:e.map(e=>(0,P.jsxs)(`div`,{style:{border:`1px solid ${W.line}`,borderRadius:6,padding:14,background:`#FDFCF9`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:10},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:700},children:e.product_model||`Product`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:11,color:W.inkSoft},children:e.slug}),(0,P.jsxs)(`div`,{style:{fontSize:11,color:W.inkSoft,marginTop:2},children:[`Run · `,e.production_date||`â`]})]}),i[e.id]&&(0,P.jsx)(`img`,{src:i[e.id],alt:`QR`,style:{width:72,height:72}})]}),(0,P.jsxs)(`div`,{style:{marginBottom:8},children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`,marginBottom:4},children:`Product barcode`}),(0,P.jsx)(`svg`,{ref:t=>{t&&(s.current[`p-${e.id}`]=t)},style:{width:`100%`,maxHeight:60}})]}),(e.raw_material_lots||[]).length>0&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:W.inkSoft,letterSpacing:`0.12em`,textTransform:`uppercase`,marginBottom:4},children:`Raw-material lots tested`}),(e.raw_material_lots||[]).map((t,n)=>(0,P.jsxs)(`div`,{style:{marginBottom:6},children:[(0,P.jsxs)(`div`,{style:{fontSize:11,color:W.ink},children:[t.material||`Material`,` â `,(0,P.jsx)(`span`,{className:`mono`,children:t.lot||`â`})]}),(0,P.jsx)(`svg`,{ref:t=>{t&&(s.current[`l-${e.id}-${n}`]=t)},style:{width:`100%`,maxHeight:48}})]},n))]}),(0,P.jsx)(`div`,{style:{display:`flex`,gap:6,marginTop:10},children:(0,P.jsx)(`button`,{style:ta,onClick:()=>c(e),children:`View / Print`})})]},e.id))})]})})}function ba(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(!0),[i,a]=(0,h.useState)(``),[s,c]=(0,h.useState)(`Buyer`),l=async()=>{let e=await ia();if(!e){r(!1);return}let{data:n}=await o.from(`team_members`).select(`*`).eq(`owner_id`,e).order(`created_at`,{ascending:!1});t(n||[]),r(!1)};(0,h.useEffect)(()=>
150{l()},[]);let u=async()=>{let e=i.trim();if(!e)return;let t=await ia();t&&(await o.from(`team_members`).insert({owner_id:t,email:e,role:s,status:`Invited`}),a(``),l())},d=async e=>{await o.from(`team_members`).delete().eq(`id`,e),l()};return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Invite teammate`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`2fr 1fr auto`,gap:10},children:[(0,P.jsx)(`input`,{style:Qi,type:`email`,placeholder:`[email protected]`,value:i,onChange:e=>a(e.target.value)}),(0,P.jsxs)(`select`,{style:Qi,value:s,onChange:e=>c(e.target.value),children:[(0,P.jsx)(`option`,{children:`Owner`}),(0,P.jsx)(`option`,{children:`Buyer`}),(0,P.jsx)(`option`,{children:`Viewer`})]}),(0,P.jsx)(`button`,{style:ea,onClick:u,children:`Invite`})]}),(0,P.jsx)(`div`,{style:{fontSize:11,color:W.inkSoft,marginTop:8},children:`Owner: full access · Buyer: place orders & approve · Viewer: read-only.`})]}),(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Team members`}),n&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`Loadingâ¦`}),!n&&e.length===0&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`No teammates yet.`}),e.map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`12px 0`,borderBottom:`1px solid ${W.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:e.email}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:W.inkSoft},children:[`added `,(e.created_at||``).slice(0,10)]})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,P.jsx)(`span`,{style:na(W.silver,W.ink),children:e.role}),(0,P.jsx)(`span`,{style:na(e.status===`Active`?W.goodBg:W.warnBg,e.status===`Active`?W.good:W.warn),children:e.status}),(0,P.jsx)(`button`,{style:ta,onClick:()=>d(e.id),children:(0,P.jsx)(rr,{size:13})})]})]},e.id))]})]})}function xa({pallets:e,onBol:t,onPallets:n,onCases:r,onTowers:i,coaDocs:a=[],coaId:o,onCoaChange:s}){let[c,l]=(0,h.useState)(1),[u,d]=(0,h.useState)(1),f={...Qi,width:`auto`,padding:`6px 8px`,fontSize:12};return(0,P.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,alignItems:`center`,marginTop:12},children:[(0,P.jsx)(`button`,{style:ta,onClick:t,children:`BOL`}),(0,P.jsxs)(`button`,{style:ta,onClick:n,children:[`Pallet labels (`,e,`)`]}),(0,P.jsx)(`span`,{style:{width:1,height:22,background:W.line}}),(0,P.jsx)(`span`,{style:{fontSize:10,letterSpacing:`0.12em`,textTransform:`uppercase`,color:W.inkSoft},children:`Pallet`}),(0,P.jsx)(`select`,{style:f,value:c,onChange:e=>l(Number(e.target.value)),children:Array.from({length:e},(e,t)=>t+1).map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))}),(0,P.jsxs)(`button`,{style:ta,onClick:()=>r(c),children:[`Master case labels (`,Ri,`)`]}),(0,P.jsx)(`span`,{style:{fontSize:10,letterSpacing:`0.12em`,textTransform:`uppercase`,color:W.inkSoft},children:`Case`}),(0,P.jsx)(`select`,{style:f,value:u,onChange:e=>d(Number(e.target.value)),children:Array.from({length:Ri},(e,t)=>t+1).map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))}),(0,P.jsxs)(`button`,{style:ta,onClick:()=>i(c,u),children:[`Tower labels (`,zi,`)`]}),(0,P.jsx)(`span`,{style:{width:1,height:22,background:W.line}}),(0,P.jsx)(`span`,{style:{fontSize:10,letterSpacing:`0.12em`,textTransform:`uppercase`,color:W.inkSoft},children:`COA`}),a.length===0?(0,P.jsx)(`span`,{style:{fontSize:11,color:W.inkSoft},children:`No COA on file yet`}):(0,P.jsxs)(`select`,{style:f,value:o||``,onChange:e=>s?.(e.target.value),children:[(0,P.jsx)(`option`,{value:``,children:`No COA on label`}),a.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title||e.name||`COA ${String(e.id).slice(0,6)}`,e.date?` · ${e.date}`:``]},e.id))]})]})}function Sa({refreshKey:e=0,standalone:t=!1}){let[n,r]=(0,h.useState)([]),[i,a]=(0,h.useState)(!0),[s,c]=(0,h.useState)(`all`),[l,u]=(0,h.useState)(``);(0,h.useEffect)(()=>{(async()=>{a(!0);let e=await ia();if(!e){a(!1);return}let{data:t}=await o.from(`label_records`).select(`*`).eq(`customer_id`,e).order(`generated_at`,{ascending:!1}).limit(1e3);r(t||[]),a(!1)})()},[e]);let d=(0,h.useMemo)(()=>{let e=l.trim().toLowerCase();return n.filter(t=>(s===`all`||t.kind===s)&&(!e||[t.code,t.product,t.lot_code].some(t=>String(t||``).toLowerCase().includes(e))))},[n,s,l]),f=(0,h.useMemo)(()=>{let e={bol:0,pallet:0,master_case:0,tower:0};
150return n.forEach(t=>{e[t.kind]!=null&&(e[t.kind]+=1)}),e},[n]),p=async e=>{let t=e.kind===`bol`?null:await Hi(e);if(!t){window.open(e.qr_url||`#`,`_blank`);return}await Ui([{kind:e.kind,code:e.code,product:e.product,lot_code:e.lot_code,sequence:e.sequence,of_total:e.of_total,units:e.units,shipment_id:e.shipment_id,order_id:e.order_id,qr_url:e.qr_url,payload:e.payload||{}}]),Ii(`Reprint â ${e.code}`,t)},m=()=>{let e=[[`code`,`kind`,`product`,`lot`,`pallet`,`case`,`sequence`,`of_total`,`units`,`coa`,`qr_url`,`generated_at`,`last_printed_at`,`reprints`].join(`,`)].concat(d.map(e=>[e.code,e.kind,e.product,e.lot_code,e.payload?.pallet,e.payload?.case,e.sequence,e.of_total,e.units,e.payload?.coa?.reference||e.payload?.coa?.name||``,e.qr_url,e.generated_at,e.last_printed_at,e.reprint_count].map(e=>`"${String(e??``).replace(/"/g,`""`)}"`).join(`,`))),t=URL.createObjectURL(new Blob([e.join(` 151`)],{type:`text/csv`})),n=document.createElement(`a`);n.href=t,n.download=`krush-label-library-${new Date().toISOString().slice(0,10)}.csv`,n.click(),URL.revokeObjectURL(t)},g=[[`all`,`All (${n.length})`],[`tower`,`Tower (${f.tower})`],[`master_case`,`Master case (${f.master_case})`],[`pallet`,`Pallet (${f.pallet})`],[`bol`,`BOL (${f.bol})`]],_=e=>{let t=[];return e.payload?.pallet&&t.push(`P${e.payload.pallet}`),e.payload?.case&&t.push(`C${e.payload.case}`),t.push(`${e.sequence||1}/${e.of_total||1}`),t.join(` · `)};return(0,P.jsxs)(`div`,{style:Xi,children:[(0,P.jsx)(`h2`,{style:Zi,children:`Label library`}),(0,P.jsxs)(`div`,{style:{fontSize:12,color:W.inkSoft,marginBottom:12},children:[`Every tower label, master case label, pallet label and BOL ever generated on this account is archived here â permanently, with its barcode value, lot, pallet/case position, linked COA, QR link, generation date, last print date and reprint count. Nothing can be deleted`,t?` â labels are generated from Shipments â Bill of Lading & Labels.`:`.`]}),(0,P.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,alignItems:`center`,marginBottom:12},children:[g.map(([e,t])=>(0,P.jsx)(`button`,{onClick:()=>c(e),style:{...ta,padding:`7px 11px`,background:s===e?W.silver:`transparent`},children:t},e)),(0,P.jsx)(`input`,{style:{...Qi,width:220},placeholder:`Search code / lot / product`,value:l,onChange:e=>u(e.target.value)}),(0,P.jsx)(`button`,{style:ta,onClick:m,children:`Export CSV`})]}),i&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`Loadingâ¦`}),!i&&d.length===0&&(0,P.jsx)(`div`,{style:{color:W.inkSoft,fontSize:13},children:`No labels on file yet â generate labels from Shipments â Bill of Lading & Labels and every tower, master case, pallet label and BOL will be archived here automatically.`}),!i&&d.length>0&&(0,P.jsxs)(`div`,{style:{overflowX:`auto`},children:[(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`,fontSize:12},children:[(0,P.jsx)(`thead`,{children:(0,P.jsx)(`tr`,{children:[`Code`,`Type`,`Product`,`Lot`,`Position`,`Units`,`COA`,`Generated`,`Last printed`,`Reprints`,``].map(e=>(0,P.jsx)(`th`,{style:{textAlign:`left`,padding:`8px 6px`,borderBottom:`1px solid ${W.line}`,fontSize:10,letterSpacing:`0.12em`,textTransform:`uppercase`,color:W.inkSoft},children:e},e))})}),(0,P.jsx)(`tbody`,{children:d.slice(0,300).map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`mono`,style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`,fontFamily:`ui-monospace, Menlo, monospace`,fontWeight:700},children:e.code}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`},children:(0,P.jsx)(`span`,{style:na(W.silver,W.ink),children:(Vi[e.kind]||{}).label||e.kind})}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`},children:e.product||`â`}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`},children:e.lot_code||`â`}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`},children:_(e)}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`},children:e.units?e.units.toLocaleString():`â`}),(0,P.jsx)(`td`,{className:`mono`,style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`,fontSize:11},children:e.payload?.coa?.reference||e.payload?.coa?.name||`â`}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`},children:String(e.generated_at||``).slice(0,10)}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`},children:String(e.last_printed_at||e.generated_at||``).slice(0,10)}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`},children:e.reprint_count||0}),(0,P.jsx)(`td`,{style:{padding:`8px 6px`,borderBottom:`1px solid ${W.line}`,textAlign:`right`},children:(0,P.jsx)(`button`,{style:{...ta,padding:`6px 10px`},onClick:()=>p(e),children:e.kind===`bol`?`Open trace`:`Reprint`})})]},e.id))})]}),d.length>300&&(0,P.jsxs)(`div`,{style:{fontSize:11,color:W.inkSoft,marginTop:8},children:[`Showing the 300 most recent of `,d.length.toLocaleStr
151ing(),` matching labels â export CSV for the full record.`]})]})]})}var G={card:`#FFFFFF`,ink:`#2E2E30`,inkSoft:`#8A8A8E`,line:`#E9E9E7`,charcoal:`#3A3A3C`,good:`#2F7D4F`,goodBg:`#EAF3ED`,warn:`#A97B1E`,warnBg:`#F7F0DE`,bad:`#B00020`,badBg:`#FBE9EC`},Ca={background:G.card,border:`1px solid ${G.line}`,borderRadius:6,padding:20,marginBottom:16},wa={fontSize:12,letterSpacing:`0.18em`,textTransform:`uppercase`,fontWeight:700,color:G.ink,margin:`0 0 12px`},K={width:`100%`,padding:`9px 11px`,border:`1px solid ${G.line}`,borderRadius:4,background:`#FDFCF9`,fontSize:13,color:G.ink,boxSizing:`border-box`},q={display:`block`,fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`,fontWeight:600,marginBottom:5},Ta={padding:`10px 16px`,background:G.charcoal,color:`#FFF`,border:`none`,borderRadius:4,fontWeight:600,cursor:`pointer`,fontSize:12,letterSpacing:`0.12em`,textTransform:`uppercase`},Ea={...Ta,background:`transparent`,color:G.ink,border:`1px solid ${G.line}`},Da={...Ta,background:`transparent`,color:G.bad,border:`1px solid ${G.line}`},Oa=(e,t)=>({display:`inline-block`,padding:`3px 8px`,borderRadius:3,background:e,color:t,fontSize:10,fontWeight:700,letterSpacing:`0.1em`,textTransform:`uppercase`}),ka=e=>{let t=String(e||``).toLowerCase();return[`approved`,`active`,`verified`].includes(t)?Oa(G.goodBg,G.good):[`rejected`,`declined`,`expired`].includes(t)?Oa(G.badBg,G.bad):Oa(G.warnBg,G.warn)},Aa=e=>`$${((e||0)/100).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;function ja(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)(`cannabis_license`),[s,c]=(0,h.useState)(``),[l,u]=(0,h.useState)(null),[d,f]=(0,h.useState)(!1),[p,m]=(0,h.useState)(null),g=async()=>{let{data:e}=await o.auth.getUser();if(!e.user)return;let[{data:n},{data:i}]=await Promise.all([o.from(`profiles`).select(`cannabis_license_number,license_jurisdiction,license_expiry,compliance_status,compliance_notes,msa_signed_at`).eq(`id`,e.user.id).maybeSingle(),o.from(`license_documents`).select(`*`).eq(`user_id`,e.user.id).order(`created_at`,{ascending:!1})]);r(n),t(i||[])};(0,h.useEffect)(()=>{g()},[]);let _=async e=>{let{data:t}=await o.auth.getUser();await o.from(`profiles`).update(e).eq(`id`,t.user.id),g()},v=async()=>{if(m(null),!l){m(`Choose a file`);return}f(!0);try{let{data:e}=await o.auth.getUser(),t=`${e.user.id}/${Date.now()}_${l.name}`,n=await o.storage.from(`compliance-docs`).upload(t,l,{upsert:!1});if(n.error)throw n.error;let r=await o.from(`license_documents`).insert({user_id:e.user.id,kind:i,file_path:t,file_name:l.name,expiry:s||null,status:`pending`});if(r.error)throw r.error;u(null),c(``),g()}catch(e){m(e.message||String(e))}finally{f(!1)}},y=async e=>{let{data:t}=await o.storage.from(`compliance-docs`).createSignedUrl(e,60);t?.signedUrl&&window.open(t.signedUrl,`_blank`)};return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsxs)(`h2`,{style:wa,children:[(0,P.jsx)(Qn,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` Cannabis license & compliance`]}),(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:12},children:[(0,P.jsx)(`div`,{style:{fontSize:12,color:G.inkSoft},children:`Overall status`}),(0,P.jsx)(`span`,{style:ka(n?.compliance_status),children:n?.compliance_status||`unverified`})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr`,gap:12},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`License number`}),(0,P.jsx)(`input`,{style:K,defaultValue:n?.cannabis_license_number||``,onBlur:e=>_({cannabis_license_number:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Jurisdiction`}),(0,P.jsx)(`input`,{style:K,defaultValue:n?.license_jurisdiction||``,placeholder:`e.g. Health Canada, CA-DCC`,onBlur:e=>_({license_jurisdiction:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Expiry`}),(0,P.jsx)(`input`,{type:`date`,style:K,defaultValue:n?.license_expiry||``,onBlur:e=>_({license_expiry:e.target.value||null})})]})]}),n?.compliance_notes&&(0,P.jsx)(`div`,{style:{marginTop:12,padding:10,background:G.warn
151Bg,color:G.warn,fontSize:12,borderRadius:4},children:n.compliance_notes})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsx)(`h2`,{style:wa,children:`Upload document`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.4fr 1fr 1fr auto`,gap:10,alignItems:`end`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Type`}),(0,P.jsxs)(`select`,{style:K,value:i,onChange:e=>a(e.target.value),children:[(0,P.jsx)(`option`,{value:`cannabis_license`,children:`Cannabis license`}),(0,P.jsx)(`option`,{value:`excise_stamp`,children:`Excise / stamp authorization`}),(0,P.jsx)(`option`,{value:`insurance`,children:`Insurance certificate`}),(0,P.jsx)(`option`,{value:`msa`,children:`MSA / supply agreement`}),(0,P.jsx)(`option`,{value:`other`,children:`Other`})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Expiry (optional)`}),(0,P.jsx)(`input`,{type:`date`,style:K,value:s,onChange:e=>c(e.target.value)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`File (PDF)`}),(0,P.jsx)(`input`,{type:`file`,accept:`.pdf,.png,.jpg,.jpeg`,onChange:e=>u(e.target.files?.[0]||null),style:{fontSize:12}})]}),(0,P.jsx)(`button`,{style:Ta,onClick:v,disabled:d,children:d?`Uploadingâ¦`:`Upload`})]}),p&&(0,P.jsx)(`div`,{style:{marginTop:8,color:G.bad,fontSize:12},children:p})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsx)(`h2`,{style:wa,children:`Submitted documents`}),e.length===0&&(0,P.jsx)(`div`,{style:{color:G.inkSoft,fontSize:13},children:`Nothing submitted yet.`}),e.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.6fr 1fr 0.8fr auto`,gap:10,padding:`12px 0`,borderBottom:`1px solid ${G.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:e.file_name}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:G.inkSoft},children:[e.kind,` · `,new Date(e.created_at).toLocaleDateString(),e.expiry?` · expires ${e.expiry}`:``]}),e.reviewer_notes&&(0,P.jsxs)(`div`,{style:{fontSize:11,color:G.warn,marginTop:4},children:[`Reviewer: `,e.reviewer_notes]})]}),(0,P.jsx)(`div`,{children:e.expiry?(0,P.jsxs)(`span`,{style:{fontSize:12},children:[`Expires `,e.expiry]}):(0,P.jsx)(`span`,{style:{fontSize:12,color:G.inkSoft},children:`No expiry`})}),(0,P.jsx)(`span`,{style:ka(e.status),children:e.status}),(0,P.jsx)(`button`,{style:Ea,onClick:()=>y(e.file_path),children:`Download`})]},e.id))]})]})}function Ma(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)({requested_limit:25e3,monthly_volume:15e3,years:3,trade_ref_1:{company:``,contact:``,email:``},trade_ref_2:{company:``,contact:``,email:``},trade_ref_3:{company:``,contact:``,email:``},bank_ref:{bank:``,contact:``,email:``}}),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),d=async()=>{let{data:e}=await o.auth.getUser();if(!e.user)return;let[{data:n},{data:i}]=await Promise.all([o.from(`profiles`).select(`credit_status,credit_limit_cents,payment_terms`).eq(`id`,e.user.id).maybeSingle(),o.from(`credit_applications`).select(`*`).eq(`user_id`,e.user.id).order(`created_at`,{ascending:!1})]);r(n),t(i||[])};(0,h.useEffect)(()=>{d()},[]);let f=async()=>{u(null),c(!0);try{let{data:e}=await o.auth.getUser(),{error:t}=await o.from(`credit_applications`).insert({user_id:e.user.id,requested_limit_cents:Math.round((+i.requested_limit||0)*100),monthly_volume_cents:Math.round((+i.monthly_volume||0)*100),years_in_business:+i.years||0,trade_ref_1:i.trade_ref_1,trade_ref_2:i.trade_ref_2,trade_ref_3:i.trade_ref_3,bank_ref:i.bank_ref,status:`submitted`});if(t)throw t;d()}catch(e){u(e.message||String(e))}finally{c(!1)}},p=({name:e,label:t})=>(0,P.jsxs)(`div`,{style:{...Ca,marginBottom:0},children:[(0,P.jsx)(`div`,{style:{fontSize:11,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`,marginBottom:8},children:t}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr`,gap:8},children:[(0,P.jsx)(`input`,{style:K,placeholder:`Company / Bank`,value:i[e].company||i[e].bank||``,onChange:t=>a({...i,[e]:{...i[e],[e===`bank_ref`?`bank`:`company`]:t.target.value}})}),(0,P.jsx)(`input`,{style:K,placeholder:`Contact`,value:i[e].contact,onChange:t=>a({...i,[e]:{...i[e],contact:t.target.value}})}),(0,P.jsx)(`input`,{style:K,type:`email`,placeholder:`Email`,value:i[e].email,onChange:t=>a({...i,[e]:{...i[e],email:t.target.value}})})]})]});return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsxs)(`h2`,{style:wa,children:[(0,P.jsx)(cr,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` Payment terms & credit`]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr`,gap:12},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,
151color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`Current terms`}),(0,P.jsx)(`div`,{style:{fontSize:18,fontWeight:700},children:(n?.payment_terms||`prepaid`).toUpperCase()})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`Credit status`}),(0,P.jsx)(`div`,{style:{marginTop:6},children:(0,P.jsx)(`span`,{style:ka(n?.credit_status),children:n?.credit_status||`none`})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`Approved limit`}),(0,P.jsx)(`div`,{style:{fontSize:18,fontWeight:700},children:Aa(n?.credit_limit_cents)})]})]})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsx)(`h2`,{style:wa,children:`Apply for Net-30`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr`,gap:12,marginBottom:12},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Requested limit (USD)`}),(0,P.jsx)(`input`,{style:K,type:`number`,value:i.requested_limit,onChange:e=>a({...i,requested_limit:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Monthly volume (USD)`}),(0,P.jsx)(`input`,{style:K,type:`number`,value:i.monthly_volume,onChange:e=>a({...i,monthly_volume:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Years in business`}),(0,P.jsx)(`input`,{style:K,type:`number`,value:i.years,onChange:e=>a({...i,years:e.target.value})})]})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:10},children:[(0,P.jsx)(p,{name:`trade_ref_1`,label:`Trade reference 1`}),(0,P.jsx)(p,{name:`trade_ref_2`,label:`Trade reference 2`}),(0,P.jsx)(p,{name:`trade_ref_3`,label:`Trade reference 3`}),(0,P.jsx)(p,{name:`bank_ref`,label:`Bank reference`})]}),l&&(0,P.jsx)(`div`,{style:{marginTop:10,color:G.bad,fontSize:12},children:l}),(0,P.jsx)(`div`,{style:{marginTop:14},children:(0,P.jsx)(`button`,{style:Ta,onClick:f,disabled:s,children:s?`Submittingâ¦`:`Submit application`})})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsx)(`h2`,{style:wa,children:`Application history`}),e.length===0&&(0,P.jsx)(`div`,{style:{color:G.inkSoft,fontSize:13},children:`No applications yet.`}),e.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr auto`,gap:10,padding:`12px 0`,borderBottom:`1px solid ${G.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:{fontSize:12,fontWeight:600},children:[`Requested `,Aa(e.requested_limit_cents)]}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:11,color:G.inkSoft},children:new Date(e.created_at).toLocaleDateString()})]}),(0,P.jsxs)(`div`,{style:{fontSize:12},children:[`Approved: `,(0,P.jsx)(`b`,{children:e.approved_limit_cents?Aa(e.approved_limit_cents):`â`})]}),(0,P.jsx)(`div`,{children:e.reviewer_notes&&(0,P.jsx)(`div`,{style:{fontSize:11,color:G.inkSoft},children:e.reviewer_notes})}),(0,P.jsx)(`span`,{style:ka(e.status),children:e.status})]},e.id))]})]})}function Na(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)(0),s=async()=>{let{data:e}=await o.auth.getUser();if(r(e.user?.id||null),!e.user)return;let{data:n}=await o.from(`profiles`).select(`po_approval_threshold_cents`).eq(`id`,e.user.id).maybeSingle();a((n?.po_approval_threshold_cents||0)/100);let{data:i}=await o.from(`order_approvals`).select(`*`).order(`created_at`,{ascending:!1});t(i||[])};(0,h.useEffect)(()=>{s()},[]);let c=async()=>{let{data:e}=await o.auth.getUser();await o.from(`profiles`).update({po_approval_threshold_cents:Math.round((+i||0)*100)}).eq(`id`,e.user.id)},l=async(e,t)=>{let r=prompt(t===`rejected`?`Reason for rejection?`:`Notes (optional)`)||null;await o.from(`order_approvals`).update({status:t,approver_id:n,approver_notes:r,decided_at:new Date().toISOString()}).eq(`id`,e),s()};return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsx)(`h2`,{style:wa,children:`PO approval threshold`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr auto`,gap:10,alignItems:`end`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Orders above this amount (USD) require internal approval`}),(0,P.jsx)(`input`,{style:K,type:`number`,value:i,onChange:e=>a(e.target.value)})]}),(0,P.jsx)(`button`,{style:Ta,onClick:c,children:`Save`})]}),(0,P.jsx)(`div`,{style:{fontSize:11,color:G.inkSoft,marginTop:8},children:`Set to 0 to require approval on every order. Only Owners / Approvers on your account can decide.`})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsx)(`h2`,{style:wa,children:`Approval queue`}),e.length===0&&(0,P.jsx)(`div`,{style:{color:G.inkSoft,fontSize:13},children:`No approvals in queue.`}),e.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.4fr 1fr 1fr auto auto`,gap:10,padding:`12px 0`,borderBottom:`1px solid ${G.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:Aa(e.amount_cents)}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:G.inkSoft},children:[`Req `,new Date(e.created_at).toLocaleDateString()]})]}),(0,P.jsxs)(`div`,{style:{fontSize:12,color:G.inkSoft},children:[`Order `,e.order_id?.slice(0,8)||`â`]}),(0,P.jsx)(`span`,{style:ka(e.status),children:e.status}
151),e.status===`pending`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{style:Ta,onClick:()=>l(e.id,`approved`),children:`Approve`}),(0,P.jsx)(`button`,{style:Da,onClick:()=>l(e.id,`rejected`),children:`Reject`})]}):(0,P.jsx)(P.Fragment,{children:(0,P.jsx)(`div`,{style:{fontSize:11,color:G.inkSoft,gridColumn:`span 2`},children:e.approver_notes||``})})]},e.id))]})]})}function Pa(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)([]),[i,a]=(0,h.useState)([]),[s,c]=(0,h.useState)({domain:``,company_name:``,default_role:`buyer`,sso_enabled:!1,saml_metadata_url:``}),[l,u]=(0,h.useState)(null),d=async()=>{let[e,n,i]=await Promise.all([o.from(`company_domains`).select(`*`).order(`created_at`,{ascending:!1}),o.from(`license_documents`).select(`*`).order(`created_at`,{ascending:!1}).limit(50),o.from(`credit_applications`).select(`*`).order(`created_at`,{ascending:!1}).limit(50)]);t(e.data||[]),r(n.data||[]),a(i.data||[])};(0,h.useEffect)(()=>{d()},[]);let f=async()=>{if(u(null),!s.domain||!s.company_name){u(`Domain and company name required`);return}let{error:e}=await o.from(`company_domains`).insert({domain:s.domain.trim().toLowerCase(),company_name:s.company_name.trim(),default_role:s.default_role,sso_enabled:s.sso_enabled,saml_metadata_url:s.saml_metadata_url||null});if(e){u(e.message);return}c({domain:``,company_name:``,default_role:`buyer`,sso_enabled:!1,saml_metadata_url:``}),d()},p=async e=>{await o.from(`company_domains`).delete().eq(`id`,e),d()},m=async(e,t)=>{let n=t===`rejected`&&prompt(`Reason?`)||``;await o.from(`license_documents`).update({status:t,reviewer_notes:n||null,reviewed_at:new Date().toISOString()}).eq(`id`,e),d()},g=async e=>{let{data:t}=await o.storage.from(`compliance-docs`).createSignedUrl(e,60);t?.signedUrl&&window.open(t.signedUrl,`_blank`)},_=async(e,t)=>{let n=null,r=null;if(t===`approved`){let e=prompt(`Approved limit (USD)`);if(e==null)return;n=Math.round((+e||0)*100),r=prompt(`Notes (optional)`)||null}else r=prompt(`Reason?`)||null;if(await o.from(`credit_applications`).update({status:t,approved_limit_cents:n,reviewer_notes:r,reviewed_at:new Date().toISOString()}).eq(`id`,e),t===`approved`){let t=i.find(t=>t.id===e);t&&await o.from(`profiles`).update({credit_status:`approved`,credit_limit_cents:n,payment_terms:`net_30`}).eq(`id`,t.user_id)}d()};return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsxs)(`h2`,{style:wa,children:[(0,P.jsx)(An,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` Company domains & SSO`]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1.2fr 0.8fr auto auto`,gap:8,alignItems:`end`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Domain`}),(0,P.jsx)(`input`,{style:K,placeholder:`acme.com`,value:s.domain,onChange:e=>c({...s,domain:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Company name`}),(0,P.jsx)(`input`,{style:K,value:s.company_name,onChange:e=>c({...s,company_name:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Default role`}),(0,P.jsx)(`select`,{style:K,value:s.default_role,onChange:e=>c({...s,default_role:e.target.value}),children:[`owner`,`buyer`,`viewer`,`finance`,`compliance`,`approver`].map(e=>(0,P.jsx)(`option`,{children:e},e))})]}),(0,P.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,fontSize:12},children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:s.sso_enabled,onChange:e=>c({...s,sso_enabled:e.target.checked})}),` SSO`]}),(0,P.jsx)(`button`,{style:Ta,onClick:f,children:`Add`})]}),s.sso_enabled&&(0,P.jsxs)(`div`,{style:{marginTop:10},children:[(0,P.jsx)(`label`,{style:q,children:`SAML metadata URL (Okta / Azure AD / OneLogin)`}),(0,P.jsx)(`input`,{style:K,value:s.saml_metadata_url,onChange:e=>c({...s,saml_metadata_url:e.target.value}),placeholder:`https://idp.example.com/app/xxx/sso/saml/metadata`}),(0,P.jsx)(`div`,{style:{fontSize:11,color:G.inkSoft,marginTop:6},children:`Contact Krush to finalize SAML activation for this domain after submitting the metadata URL.`})]}),l&&(0,P.jsx)(`div`,{style:{color:G.bad,fontSize:12,marginTop:8},children:l}),(0,P.jsxs)(`div`,{style:{marginTop:14},children:[e.length===0&&(0,P.jsx)(`div`,{style:{color:G.inkSoft,fontSize:12},children:`No domain rules yet.`}),e.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1.2fr 0.8fr 0.8fr auto`,gap:10,padding:`10px 0`,borderBottom:`1px solid ${G.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:12},children:[`@`,e.domain]}),(0,P.jsx)(`div`,{style:{fontSize:13},children:e.company_name}),(0,P.jsx)(`span`,{style:Oa(`#F3F3F1`,G.ink),children:e.default_role}),(0,P.jsx)(`span`,{style:e.sso_enabled?ka(`active`):Oa(`#F3F3F1`,G.inkSoft),children:e.sso_enabled?`SAML`:`email`}),(0,P.jsx)(`button`,{style:Da,onClick:()=>p(e.id),children:`Remove`})]},e.id))]})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsxs)(`h2`,{style:wa,children:[(0,P.jsx)(Mn,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` License review queue`]}),n.length===0&&(0,P.jsx)(`div`,{style:{color:G.inkSoft,fontSize:13},children:`Nothing to review.`}),n.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.5fr 0.8fr 0.7fr auto auto auto`,gap:10,padding:`10px 0`,borderBottom:`1px solid ${G.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:e.file_name}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:G.inkSoft},children:[e.kind,` · `,e.user_id.slice(0,8)]})]}),(0,P.jsx)(`div`,{style:{fontSize:12},children:e.expiry||`â`}),(0,P.jsx)(`span`,{style:ka(e.status),children:e.status}),(0,P.jsx)(`button`,{style:Ea,onClick:()=>g(e.file_path),children:`View`}),(0,P.jsx)(`button`,{style:Ta,onClick:()=>m(e.id,`approved`),children:`Approve`}),(0,P.jsx)(`button`,{style:Da,onClick:()=>m(e.id,`rejected`),children:`Reject`})]},e.id))]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsxs)(`h2`,{style:wa,children:[(0,P.jsx)(cr,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` Credit applications`]}),i.length===0&&(0,P.jsx)(`div`,{style:{color:G.inkSoft,fontSize:13},children:`No applications.`}),i.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 0.8fr auto auto`,gap:10,padding:`10px 0`,borderBottom:`1px solid ${G.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:{fontSize:13,fontWeight:600},children:[`Req `,Aa(e.requested_limit_cents)]}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:G.inkSoft},children:[e.user_id.slice(0,8),` · vol `,Aa(e.monthly_volume_cents),`/mo · `,e.years_in_business||`?`,`y`]})]}),(0,P.jsxs)(`div`,{style:{fontSize:12},children:[`Approved: `,(0,P.jsx)(`b`,{children:e.approved_limit_cents?Aa(e.approved_limit_cents):`â`})]}),(0,P.jsx)(`span`,{style:ka(e.status),children:e.status}),e.status!==`approved`&&e.status!==`declined`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{style:Ta,onClick:()=>_(e.id,`approved`),children:`Approve`}),(0,P.jsx)(`button`,{style:Da,onClick:()=>_(e.id,`declined`),children:`Decline`})]})]},e.id))]})]})}function Fa({go:e}){let[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)([]),[a,s]=(0,h.useState)([]),[c,l]=(0,h.useState)([]),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(null),[m,g]=(0,h.useState)({legal_name:``,dba:``,business_type:``,tax_id:``,website:``,license_jurisdiction:``,cannabis_license_number:``,license_expiry:``}),_=async()=>{let{data:e}=await o.auth.getUser();if(!e.user)return;let[{data:t},{data:r},{data:a},{data:c}]=await Promise.all([o.from(`profiles`).select(`legal_name,dba,business_type,tax_id,website,license_jurisdiction,cannabis_license_number,license_expiry,compliance_status,compliance_notes,compliance_verified_at,credit_status,credit_limit_cents,payment_terms`).eq(`id`,e.user.id).maybeSingle(),o.from(`license_documents`).select(`id,kind,status,file_name,created_at,expiry`).eq(`user_id`,e.user.id).order(`created_at`,{ascending:!1}),o.from(`credit_applications`).select(`id,status,requested_limit_cents,approved_limit_cents,created_at,reviewer_notes`).eq(`user_id`,e.user.id).order(`created_at`,{ascending:!1}),o.from(`order_approvals`).select(`id,status,amount_cents,created_at`).order(`created_at`,{ascending:!1}).limit(5)]);n(t||null),i(r||[]),s(a||[]),l(c||[]),t&&g(e=>({...e,legal_name:t.legal_name||``,dba:t.dba||``,business_type:t.business_type||``,tax_id:t.tax_id||``,website:t.website||``,license_jurisdiction:t.license_jurisdiction||``,cannabis_license_number:t.cannabis_license_number||``,license_expiry:t.license_expiry||``}))};(0,h.useEffect)(()=>{_()},[]);let v=!!(t?.legal_name&&t?.tax_id&&t?.business_type),y=r.length>0,b=r.some(e=>e.status===`approved`||e.status===`verified`),x=String(t?.compliance_status||(b?`verified`:y?`in_review`:`unverified`)).toLowerCase(),S=[`verified`,`approved`,`active`].includes(x),C=a[0],w=String(t?.credit_status||C?.status||`none`).toLowerCase(),T=[`approved`,`active`].includes(w)||t?.payment_terms===`net_30`,E=[v,y,S,T].filter(
151Boolean).length*25,D=async()=>{p(null),d(!0);try{let{data:e}=await o.auth.getUser();if(!e.user)throw Error(`Not signed in`);let n={legal_name:m.legal_name||null,dba:m.dba||null,business_type:m.business_type||null,tax_id:m.tax_id||null,website:m.website||null,license_jurisdiction:m.license_jurisdiction||null,cannabis_license_number:m.cannabis_license_number||null,license_expiry:m.license_expiry||null};y&&!S?n.compliance_status=`in_review`:t?.compliance_status||(n.compliance_status=`unverified`);let{error:r}=await o.from(`profiles`).update(n).eq(`id`,e.user.id);if(r)throw r;await _()}catch(e){p(e.message||String(e))}finally{d(!1)}},O=({n:e,title:t,subtitle:n,done:r,active:i,cta:a,onCta:o})=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`36px 1fr auto`,gap:14,alignItems:`center`,padding:`16px 0`,borderBottom:`1px solid ${G.line}`},children:[(0,P.jsx)(`div`,{style:{width:32,height:32,borderRadius:16,background:r?G.good:i?G.charcoal:`#F3F3F1`,color:r||i?`#FFF`:G.inkSoft,display:`flex`,alignItems:`center`,justifyContent:`center`,fontWeight:700,fontSize:13},children:r?(0,P.jsx)(wn,{size:16}):e}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:700,color:G.ink},children:t}),(0,P.jsx)(`div`,{style:{fontSize:12,color:G.inkSoft,marginTop:2},children:n})]}),a&&(0,P.jsxs)(`button`,{style:r?Ea:Ta,onClick:o,children:[a,` `,(0,P.jsx)(vn,{size:12,style:{verticalAlign:`-1px`,marginLeft:4}})]})]});return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:{...Ca,background:`linear-gradient(90deg,#FAFAF7,#F3F3F1)`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-end`,marginBottom:10},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h2`,{style:{...wa,margin:0},children:[(0,P.jsx)(Qn,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` Buyer authorization`]}),(0,P.jsx)(`div`,{style:{fontSize:12,color:G.inkSoft,marginTop:4},children:`Complete the four steps to unlock ordering, credit, and PO approvals.`})]}),(0,P.jsxs)(`div`,{style:{textAlign:`right`},children:[(0,P.jsxs)(`div`,{style:{fontSize:22,fontWeight:700,color:G.ink},children:[E,`%`]}),(0,P.jsx)(`div`,{style:{fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`Authorized`})]})]}),(0,P.jsx)(`div`,{style:{height:6,background:`#E6E6E3`,borderRadius:3,overflow:`hidden`},children:(0,P.jsx)(`div`,{style:{width:`${E}%`,height:`100%`,background:E===100?G.good:G.charcoal,transition:`width .3s`}})})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsxs)(`h2`,{style:wa,children:[(0,P.jsx)(Sn,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` 1 · Business profile`]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:12},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Legal name`}),(0,P.jsx)(`input`,{style:K,value:m.legal_name,onChange:e=>g({...m,legal_name:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`DBA (optional)`}),(0,P.jsx)(`input`,{style:K,value:m.dba,onChange:e=>g({...m,dba:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Business type`}
151),(0,P.jsxs)(`select`,{style:K,value:m.business_type,onChange:e=>g({...m,business_type:e.target.value}),children:[(0,P.jsx)(`option`,{value:``,children:`Selectâ¦`}),(0,P.jsx)(`option`,{value:`licensed_producer`,children:`Licensed producer`}),(0,P.jsx)(`option`,{value:`processor`,children:`Processor / packager`}),(0,P.jsx)(`option`,{value:`brand`,children:`Brand (co-pack)`}),(0,P.jsx)(`option`,{value:`distributor`,children:`Distributor`}),(0,P.jsx)(`option`,{value:`retailer`,children:`Retailer`})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Tax ID / Business #`}),(0,P.jsx)(`input`,{style:K,value:m.tax_id,onChange:e=>g({...m,tax_id:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Website`}),(0,P.jsx)(`input`,{style:K,value:m.website,onChange:e=>g({...m,website:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Jurisdiction`}),(0,P.jsx)(`input`,{style:K,value:m.license_jurisdiction,onChange:e=>g({...m,license_jurisdiction:e.target.value}),placeholder:`Health Canada, CA-DCCâ¦`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`Cannabis license #`}),(0,P.jsx)(`input`,{style:K,value:m.cannabis_license_number,onChange:e=>g({...m,cannabis_license_number:e.target.value})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{style:q,children:`License expiry`}),(0,P.jsx)(`input`,{type:`date`,style:K,value:m.license_expiry,onChange:e=>g({...m,license_expiry:e.target.value})})]})]}),f&&(0,P.jsx)(`div`,{style:{marginTop:10,color:G.bad,fontSize:12},children:f}),(0,P.jsxs)(`div`,{style:{marginTop:14,display:`flex`,gap:10,alignItems:`center`},children:[(0,P.jsx)(`button`,{style:Ta,onClick:D,disabled:u,children:u?`Savingâ¦`:x===`in_review`?`Update request`:`Submit for review`}),(0,P.jsxs)(`div`,{style:{fontSize:11,color:G.inkSoft},children:[`Current status: `,(0,P.jsx)(`span`,{style:ka(x),children:x.replace(`_`,` `)})]})]})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsx)(`h2`,{style:wa,children:`Authorization progress`}),(0,P.jsx)(O,{n:1,title:`Business profile`,subtitle:v?`${t.legal_name} · ${t.business_type?.replace(`_`,` `)}`:`Add legal name, business type, and tax ID above.`,done:v,active:!v}),(0,P.jsx)(O,{n:2,title:`Upload license documents`,subtitle:r.length===0?`Upload cannabis license, excise, insurance.`:`${r.length} document${r.length===1?``:`s`} on file · ${r.filter(e=>e.status===`approved`||e.status===`verified`).length} approved`,done:y,active:v&&!y,cta:r.length===0?`Upload`:`Manage`,onCta:()=>e&&e(`compliance`)}),(0,P.jsx)(O,{n:3,title:`Krush compliance review`,subtitle:S?`Verified${t?.compliance_verified_at?` on `+new Date(t.compliance_verified_at).toLocaleDateString():``}.`:x===`in_review`?`In review â typically 1â2 business days after documents are submitted.`:`Awaiting documents. Reviewer will verify jurisdiction, expiry, and stamp authorization.`,done:S,active:y&&!S}),(0,P.jsx)(O,{n:4,title:`Credit terms & Net-30`,subtitle:T?`Approved · limit ${Aa(t?.credit_limit_cents)} · ${(t?.payment_terms||`net_30`).toUpperCase().replace(`_`,`-`)}`:w===`submitted`?`Application under review · requested ${Aa(C?.requested_limit_cents)}`:`Optional. Apply for Net-30 once compliance is verified â prepaid orders can start immediately.`,done:T,active:S&&!T,cta:T||w===`submitted`?`View`:`Apply`,onCta:()=>e&&e(`credit`)})]}),(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsxs)(`h2`,{style:wa,children:[(0,P.jsx)(wn,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` Recent PO approvals`]}),c.length===0&&(0,P.jsxs)(`div`,{style:{fontSize:12,color:G.inkSoft},children:[`No purchase orders have gone through approval yet. Set a threshold in `,(0,P.jsx)(`b`,{children:`PO Approvals`}),` and internal approvers will decide from that queue.`]}),c.map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr auto`,gap:10,padding:`10px 0`,borderBottom:`1px solid ${G.line}`,alignItems:`center`},children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:Aa(e.amount_cents)}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:11,color:G.inkSoft},children:new Date(e.created_at).toLocaleDateString()}),(0,P.jsx)(`span`,{style:ka(e.status),children:e.status})]},e.id)),c.length>0&&(0,P.jsx)(`div`,{style:{marginTop:10},children:(0,P.jsxs)(`button`,{style:Ea,onClick:()=>e&&e(`approvals`),children:[`Open PO approvals `,(0,P.jsx)(vn,{size:12,style:{verticalAlign:`-1px`,marginLeft:4}})]})})]})]})}function Ia(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)({}),[i,a]=(0,h.useState)(`pending`),[s,c]=(0,h.useState)(null),[l,u]=(0,h.useState)(``),[d,f]=(0,h.useState)(!1),[p,m]=(0,h.useState)(null),[g,_]=(0,h.useState)(null),v=async()=>{let{data:e}=await o.auth.getUser();_(e.user?.id||null);let n=o.from(`license_documents`).select(`*`).order(`created_at`,{ascending:!1}),{data:a}=i===`all`?await n:await n.eq(`status`,i);t(a||[]);let s=Array.from(new Set((a||[]).map(e=>e.user_id)));if(s.length){let{data:e}=await o.from(`profiles`).select(`id,email,legal_name,cannabis_license_number,license_jurisdiction,compliance_status`).in(`id`,s),t={};
151(e||[]).forEach(e=>{t[e.id]=e}),r(t)}};(0,h.useEffect)(()=>{v()},[i]);let y=async e=>{c(e),u(e.reviewer_notes||``),m(null);let{data:t}=await o.storage.from(`compliance-docs`).createSignedUrl(e.file_path,600);t?.signedUrl&&m(t.signedUrl)},b=async e=>{if(s){if((e===`rejected`||e===`changes_requested`)&&!l.trim()){alert(`Reviewer notes are required when rejecting or requesting changes.`);return}f(!0);try{let t={status:e,reviewer_id:g,reviewer_notes:l.trim()||null,reviewed_at:new Date().toISOString()},{error:n}=await o.from(`license_documents`).update(t).eq(`id`,s.id);if(n)throw n;e===`approved`?await o.from(`profiles`).update({compliance_status:`verified`,compliance_verified_at:new Date().toISOString(),compliance_notes:null}).eq(`id`,s.user_id):e===`changes_requested`?await o.from(`profiles`).update({compliance_status:`changes_requested`,compliance_notes:l.trim()||null}).eq(`id`,s.user_id):e===`rejected`&&await o.from(`profiles`).update({compliance_status:`rejected`,compliance_notes:l.trim()||null}).eq(`id`,s.user_id),c(null),u(``),m(null),v()}catch(e){alert(e.message||String(e))}finally{f(!1)}}},x=(0,h.useMemo)(()=>{let t={pending:0,in_review:0,changes_requested:0,approved:0,rejected:0};return e.forEach(e=>{t[e.status]=(t[e.status]||0)+1}),t},[e]);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{style:Ca,children:[(0,P.jsxs)(`h2`,{style:wa,children:[(0,P.jsx)(Mn,{size:13,style:{display:`inline`,marginRight:6,verticalAlign:`-2px`}}),` Compliance document review`]}),(0,P.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:[{id:`pending`,label:`Pending`},{id:`changes_requested`,label:`Changes requested`},{id:`approved`,label:`Approved`},{id:`rejected`,label:`Rejected`},{id:`all`,label:`All`}].map(e=>(0,P.jsxs)(`button`,{onClick:()=>a(e.id),style:{...i===e.id?Ta:Ea,padding:`8px 12px`},children:[e.label,x[e.id]!=null&&i!==e.id?` (${x[e.id]||0})`:``]},e.id))})]}),(0,P.jsxs)(`div`,{style:Ca,children:[e.length===0&&(0,P.jsx)(`div`,{style:{color:G.inkSoft,fontSize:13},children:`No documents in this bucket.`}),e.map(e=>{let t=n[e.user_id];return(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.5fr 1.2fr 0.9fr 0.7fr auto`,gap:10,padding:`12px 0`,borderBottom:`1px solid ${G.line}`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:e.file_name}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:G.inkSoft},children:[e.kind,` · uploaded `,new Date(e.created_at).toLocaleDateString()]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:12,fontWeight:600},children:t?.legal_name||t?.email||e.user_id.slice(0,8)}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:G.inkSoft},children:[t?.cannabis_license_number||`â`,` · `,t?.license_jurisdiction||`â`]})]}),(0,P.jsx)(`div`,{style:{fontSize:12},children:e.expiry?`Expires ${e.expiry}`:(0,P.jsx)(`span`,{style:{color:G.inkSoft},children:`No expiry`})}),(0,P.jsx)(`span`,{style:ka(e.status),children:(e.status||``).replace(`_`,` `)}),(0,P.jsx)(`button`,{style:Ta,onClick:()=>y(e),children:`Review`})]},e.id)})]}),s&&(0,P.jsx)(`div`,{onClick:()=>c(null),style:{position:`fixed`,inset:0,background:`rgba(30,30,32,0.55)`,zIndex:60,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:20},children:(0,P.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:{background:`#fff`,borderRadius:6,width:`min(1080px, 100%)`,maxHeight:`92vh`,display:`grid`,gridTemplateColumns:`1.4fr 1fr`,overflow:`hidden`},children:[(0,P.jsx)(`div`,{style:{background:`#1E1E20`,position:`relative`},children:p?/\.(png|jpe?g|gif|webp)$/i.test(s.file_name)?(0,P.jsx)(`img`,{src:p,alt:s.file_name,style:{width:`100%`,height:`100%`,objectFit:`contain`}}):(0,P.jsx)(`iframe`,{title:`doc`,src:p,style:{width:`100%`,height:`100%`,border:`none`,background:`#fff`}}):(0,P.jsx)(`div`,{style:{color:`#fff`,padding:20,fontSize:12},children:`Loading previewâ¦`})}),(0,P.jsxs)(`div`,{style:{padding:20,overflowY:`auto`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:10},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:10,
151color:G.inkSoft,letterSpacing:`0.14em`},children:`Reviewing`}),(0,P.jsx)(`div`,{style:{fontSize:14,fontWeight:700},children:s.file_name})]}),(0,P.jsx)(`button`,{style:Ea,onClick:()=>c(null),children:(0,P.jsx)(Tn,{size:13})})]}),(0,P.jsxs)(`div`,{style:{fontSize:12,color:G.inkSoft,marginBottom:12},children:[s.kind,` · uploaded `,new Date(s.created_at).toLocaleString(),s.reviewed_at&&(0,P.jsxs)(P.Fragment,{children:[` · last reviewed `,new Date(s.reviewed_at).toLocaleString()]})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10,marginBottom:12},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`Buyer`}),(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:n[s.user_id]?.legal_name||n[s.user_id]?.email||s.user_id.slice(0,8)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`Expiry`}),(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600},children:s.expiry||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`License #`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:12},children:n[s.user_id]?.cannabis_license_number||`â`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`Jurisdiction`}),(0,P.jsx)(`div`,{style:{fontSize:12},children:n[s.user_id]?.license_jurisdiction||`â`})]}),(0,P.jsxs)(`div`,{style:{gridColumn:`span 2`},children:[(0,P.jsx)(`div`,{style:{fontSize:10,color:G.inkSoft,letterSpacing:`0.14em`,textTransform:`uppercase`},children:`Current status`}),(0,P.jsx)(`span`,{style:ka(s.status),children:(s.status||``).replace(`_`,` `)})]})]}),(0,P.jsx)(`label`,{style:q,children:`Reviewer notes (required for reject / request changes)`}),(0,P.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:5,style:{...K,resize:`vertical`,fontFamily:`inherit`},placeholder:`e.g. License page 2 is unreadable â please re-upload as a clean PDF.`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:14,flexWrap:`wrap`},children:[(0,P.jsxs)(`button`,{style:Ta,disabled:d,onClick:()=>b(`approved`),children:[(0,P.jsx)(wn,{size:12,style:{verticalAlign:`-1px`,marginRight:4}}),` Approve`]}),(0,P.jsx)(`button`,{style:Ea,disabled:d,onClick:()=>b(`changes_requested`),children:`Request changes`}),(0,P.jsxs)(`button`,{style:Da,disabled:d,onClick:()=>b(`rejected`),children:[(0,P.jsx)(Tn,{size:12,style:{verticalAlign:`-1px`,marginRight:4}}),` Reject`]}),p&&(0,P.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,style:{...Ea,textDecoration:`none`,display:`inline-block`},children:`Open file`})]}),(0,P.jsx)(`div`,{style:{fontSize:11,color:G.inkSoft,marginTop:10},children:`Approving marks the buyer's compliance as verified with a timestamp. Requesting changes surfaces your notes on the buyer's dashboard.`})]})]})})]})}var La=null;function Ra(e){let[t,n]=(0,h.useState)(null);return(0,h.useEffect)(()=>{if(!e){n(null);return}let t=!1,r=new Image;return r.onload=()=>{!t&&r.naturalWidth&&r.naturalHeight&&n(r.naturalWidth/r.naturalHeight)},r.onerror=()=>{t||n(null)},r.src=e,()=>{t=!0}},[e]),t}function za(){return La||=s(()=>import(`./pdf-DyAsWaKN.js`).then(async e=>{let t=(await s(async()=>{let{default:e}=await import(`./pdf.worker-DjB-gKUu.js`);return{default:e}},[])).default;return e.GlobalWorkerOptions.workerSrc=t,e}),void 0),La}async function Ba(e,{scale:t=2,maxPages:n=24}={}){let r=await za(),i=await e.arrayBuffer(),a=new Uint8Array(i.slice(0)),o=await r.getDocument({data:a}).promise,s=Math.min(o.numPages,n),c=[];for(let e=1;e<=s;e++){let n=await o.getPage(e),r=n.getViewport({scale:t}),i=document.createElement(`canvas`);i.width=r.width,i.height=r.height;let a=i.getContext(`2d`);a.fillStyle=`#fff`,a.fillRect(0,0,i.width,i.height),await n.render({canvasContext:a,viewport:r,canvas:i}).promise,c.push(i.toDataURL(`image/png`)),n.cleanup?.()}return await o.destroy?.(),c}var J={bg:`#FAFAF9`,card:`#FFFFFF`,ink:`#2E2E30`,inkSoft:`#8A8A8E`,line:`#E9E9E7`,charc
151oal:`#3A3A3C`,charcoalDark:`#232325`,silver:`#F3F3F1`,rule:`#C63D2F`,good:`#2F7D4F`,goodBg:`#EAF3ED`,warn:`#A97B1E`,warnBg:`#F7F0DE`,bad:`#C63D2F`,badBg:`#F9E9E6`},Va=` 152 @import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@600;700&family=Jost:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap'); 153 * { box-sizing: border-box; } body { margin: 0; } 154 .krush { font-family: 'Jost', sans-serif; color: ${J.ink}; } 155 .script { font-family: 'Dancing Script', cursive; } 156 .caps { text-transform: uppercase; letter-spacing: 0.22em; font-weight: 600; } 157 .mono { font-family: 'IBM Plex Mono', monospace; } 158 .krush ::selection { background: ${J.charcoal}; color: #fff; } 159 button { font-family: inherit; } input, select { font-family: inherit; } 160 input:focus-visible, button:focus-visible { outline: 2px solid ${J.charcoal}; outline-offset: 2px; } 161 .marble { 162 background: 163 radial-gradient(120% 90% at 15% 10%, rgba(190,193,198,0.35), transparent 55%), 164 radial-gradient(90% 120% at 85% 30%, rgba(168,172,178,0.28), transparent 50%), 165 radial-gradient(140% 100% at 50% 95%, rgba(203,206,210,0.30), transparent 60%), 166 linear-gradient(135deg, #FDFDFD 0%, #F2F2F3 45%, #FAFAFA 100%); 167 } 168 @keyframes popIn { from { opacity:0; transform:scale(.85);} to { opacity:1; transform:scale(1);} } 169 .pop { animation: popIn .25s ease-out; } 170 @keyframes spin { to { transform: rotate(360deg); } } 171 .spin { animation: spin .9s linear infinite; } 172 @media (prefers-reduced-motion: reduce) { * { animation:none !important; transition:none !important; } } 173`,Ha=p.url,Ua=m.url;function Wa(){let[e,t]=(0,h.useState)(typeof window<`u`?window.innerWidth:1200);return(0,h.useEffect)(()=>{let e=()=>t(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Ga=[{id:`84-26`,category:`Cones`,name:`84/26 Regular`,drawing:`84/26/11.5/5.5`,tower:900,papers:[`Natural Hemp`,`Refined Wood`,`Natural Wood`],palletUnits:129600,unitPrice:.05},{id:`98-26`,category:`Cones`,name:`98/26 Regular`,drawing:`98/26/11.5/5.5`,tower:800,papers:[`Natural Hemp`,`Refined Wood`,`Natural Wood`],palletUnits:115200,unitPrice:.05},{id:`109-26`,category:`Cones`,name:`109/26 Regular`,drawing:`109/26/12.4/5.5`,tower:800,papers:[`Natural Hemp`,`Refined Wood`,`Natural Wood`],palletUnits:115200,unitPrice:.05},{id:`109-26-hemp`,category:`Hemp blunts`,name:`109/26 Hemp Blunt`,drawing:`109/26/12.4/5.5`,tower:800,papers:[`Hemp â Green`,`Hemp â Brown`],palletUnits:115200,unitPrice:.05}],Ka=24,qa=.01,Ja=14,Ya=1e5,Xa=100,Za=7,Qa=`[email protected]`,$a=.025,eo=10,to=[{id:`s-paid`,label:`Sample purchased`,desc:`$100 CAD · delivered`},{id:`s-tph`,label:`Template emailed to TPH`,desc:`Automated â approved filter artwork sent for print`},{id:`s-print`,label:`Printing`,desc:`Sample run at TPH`},{id:`s-del`,label:`Delivered`,desc:`7-day lead time`}],no=[{id:`f-paid`,label:`Pre-purchase confirmed`,desc:`Filters reserved at $0.025 CAD per unit`},{id:`f-print`,label:`Printing & shipping`,desc:`14-day production of your filter stock`},{id:`f-stock`,label:`Stocked at Krush`,desc:`Held for your future orders â zero added lead time when used`}],ro={"Refined Wood":`#F7F5F0`,"Natural Wood":`#D8BE96`,"Natural Hemp":`#E3DAC3`,"Hemp â Green":`#B9C4A6`,"Hemp â Brown":`#C9A87B`},io=[{id:`received`,label:`Order received`,desc:`Order confirmed and scheduled`},{id:`specs`,label:`Artwork & specs locked`,desc:`Format, paper, and filter artwork confirmed`},{id:`queue`,label:`Production queue`,desc:`Awaiting an automated line slot`},{id:`production`,label:`Cone production`,desc:`Automated no-touch manufacturing`},{id:`qc`,label:`Sanitization & QC`,desc:`UV tunnel, batch testing`},{id:`packing`,label:`Packaging`,desc:`Sorted & counted into towers, cases, pallets`},{id:`ready`,label:`Ready to ship`,desc:`Palletized and staged at dock, carrier booked`},{id:`transit`,label:`In transit`,desc:`With carrier`},{id:`delivered`,label:`Received`,desc:`Delivered â COA follows 5 days after arrival`}],ao=[],oo=[{id:`format`,label:`File format (AI · PDF · EPS · SVG · PNG)`},{id:`res`,label:`Resolution ⥠300 DPI`},{id:`color`,label:`Colour profile (CMYK, FDA food-safe ink set)`},{id:`bleed`,label:`Bleed & filter dieline fit`}];function so(e){let t=e.split(`.`).pop().toLowerCase(),n=[`ai`,`pdf`,`eps`,`svg`].includes(t),r=n||[`png`,`jpg`,`jpeg`].includes(t);return{format:r?{pass:!0,note:t.toUpperCase()+` accepted`}:{pass:!1,note:`Unsupported format`},res:r?n?{pass:!0,note:`Vector â resolution independent`}:{pass:!1,note:`Raster at 72 DPI â will print soft on the filter wrap. Upload vector or 300+ DPI.`}:{pass:!1,note:`Could not read file`},color:r?{pass:!0,note:n?`CMYK verified â mapped to FDA food-safe ink set`:`RGB detected â auto-converted to CMYK`}:{pass:!1,note:`Could not read file`},bleed:r?{pass:!0,note:`Artwork fits 26mm filter wrap dieline with 2mm bleed`}:{pass:!1,note:`Could not read file`}}}var Y=(e,t=2)=>
173`$`+e.toLocaleString(`en-CA`,{minimumFractionDigits:t,maximumFractionDigits:t})+` CAD`,co={"order received":0,received:8,"specs locked":1,queued:2,"in queue":2,"in production":3,qc:4,packing:5,"ready to ship":6,"in transit":7,shipped:7};function lo(e){return co[String(e||``).toLowerCase().trim()]??0}function uo(e,t){return e+`-`+String(t||``).replace(/-/g,``).slice(0,6).toUpperCase()}function fo(e){let t=(e.quantity||0)*(e.unit_price_cents||0)/100;return{uuid:e.id,id:uo(`ORD`,e.id),date:(e.created_at||``).slice(0,10),items:`${(e.quantity??0).toLocaleString()} Ã ${e.product||`cones`}`,total:t,status:e.status||`Pending`,stage:lo(e.status),queueAhead:0,lineStart:null,eta:e.eta||null,lot:e.lot_code||null,pct:0,carrier:e.carrier||null,tracking:e.tracking||null,receivedAt:null,units:e.quantity||0,flow:e.flow||`cone`}}function po(e){return{dbId:e.id,number:e.number,id:e.number||uo(`INV`,e.id),date:(e.created_at||``).slice(0,10),due:e.due_date||`â`,amount:(e.amount_cents||0)/100,status:e.status||`Open`}}var mo={COA:`Compliance`,LOG:`Compliance`,FCS:`Compliance`,ACS:`Compliance`,TDS:`Technical`,SPEC:`Technical`,DWG:`Technical`,TEMPLATE:`Technical`,ART:`Technical`,INV:`Financial`};function ho(e){let t=(e.kind||`DOC`).toUpperCase();return{id:e.id,title:e.name||t,type:t,cat:mo[t]||`Compliance`,date:(e.created_at||``).slice(0,10),expires:null,file_url:e.file_url||null,kind:t,lot:e.name||t,product:(e.notes||``).split(` 174`)[0]||`â`,tested:(e.created_at||``).slice(0,10),micro:`â`,heavy:`â`,structural:`â`,status:e.status===`approved`||e.status===`Pass`?`Pass`:e.status||`Pending`}}function go(){let[e,t]=(0,h.useState)([]),[n,r]=(0,h.useState)(!1),i=e.filter(e=>!e.read_at).length,a=async()=>{let{data:e}=await o.auth.getUser(),n=e?.user?.id;if(!n)return;let{data:r}=await o.from(`notifications`).select(`*`).eq(`user_id`,n).order(`created_at`,{ascending:!1}).limit(20);t(r||[])};return(0,h.useEffect)(()=>{a();let e=setInterval(a,3e4);return()=>clearInterval(e)},[]),(0,P.jsxs)(`div`,{style:{position:`relative`},children:[(0,P.jsxs)(`button`,{onClick:()=>r(e=>!e),"aria-label":`Notifications`,style:{position:`relative`,background:`none`,border:`1px solid ${J.line}`,borderRadius:999,width:36,height:36,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:J.ink},children:[(0,P.jsx)(xn,{size:16}),i>0&&(0,P.jsx)(`span`,{style:{position:`absolute`,top:-4,right:-4,background:`#d33`,color:`#fff`,fontSize:10,fontWeight:700,minWidth:16,height:16,borderRadius:999,padding:`0 4px`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`},children:i>9?`9+`:i})]}),n&&(0,P.jsxs)(`div`,{style:{position:`absolute`,right:0,top:44,width:340,maxHeight:420,overflowY:`auto`,background:`#fff`,border:`1px solid ${J.line}`,borderRadius:12,boxShadow:`0 10px 30px rgba(0,0,0,0.08)`,zIndex:30},children:[(0,P.jsxs)(`div`,{style:{padding:`10px 14px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`,borderBottom:`1px solid ${J.line}`},children:[(0,P.jsx)(`div`,{style:{fontSize:12,fontWeight:700,letterSpacing:`0.12em`,textTransform:`uppercase`},children:`Notifications`}),i>0&&(0,P.jsx)(`button`,{onClick:async()=>{let{data:e}=await o.auth.getUser(),t=e?.user?.id;t&&(await o.from(`notifications`).update({read_at:new Date().toISOString()}).eq(`user_id`,t).is(`read_at`,null),a())},style:{background:`none`,border:`none`,color:J.inkSoft,cursor:`pointer`,fontSize:11,fontWeight:600},children:`Mark all read`})]}),e.length===0?(0,P.jsx)(`div`,{style:{padding:20,textAlign:`center`,color:J.inkSoft,fontSize:12},children:`Youâre all caught up.`}):e.map(e=>(0,P.jsxs)(`div`,{style:{padding:`10px 14px`,borderBottom:`1px solid ${J.line}`,background:e.read_at?`transparent`:`#fafaf6`},children:[(0,P.jsx)(`div`,{style:{fontSize:12.5,fontWeight:600},children:e.title}),e.body&&(0,P.jsx)(`div`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:2},children:e.body}),(0,P.jsx)(`div`,{style:{fontSize:10,color:J.inkSoft,marginTop:4},children:new Date(e.created_at).toLocaleString()})]},e.id))]})]})}function _o({label:e}){let[t,n]={Pass:[J.good,J.goodBg],Paid:[J.good,J.goodBg],Shipped:[J.good,J.goodBg],Approved:[J.good,J.goodBg],Received:[J.good,J.goodBg],"In transit":[J.good,J.goodBg],"Ready to ship":[J.good,J.goodBg],"Order received":[J.good,J.goodBg],Stocked:[J.good,J.goodBg],Pending:[J.warn,J.warnBg],Open:[J.warn,J.warnBg],"In production":[J.
174warn,J.warnBg],"In review":[J.warn,J.warnBg],Queued:[J.warn,J.warnBg],"In print":[J.warn,J.warnBg],"Sample in print":[J.warn,J.warnBg],Overdue:[J.bad,J.badBg],Fail:[J.bad,J.badBg]}[e]||[J.inkSoft,J.silver];return(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10.5,fontWeight:600,color:t,background:n,padding:`3px 8px`,borderRadius:3,whiteSpace:`nowrap`,letterSpacing:`0.04em`},children:e.toUpperCase()})}function vo({code:e}){return(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:11.5,background:J.silver,color:J.charcoal,padding:`2px 7px`,borderRadius:3,border:`1px solid ${J.line}`},children:e})}function X({children:e,style:t}){return(0,P.jsx)(`div`,{style:{background:J.card,border:`1px solid ${J.line}`,borderRadius:6,padding:22,...t},children:e})}function Z({children:e,action:t}){return(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:14,gap:12,flexWrap:`wrap`},children:[(0,P.jsx)(`h2`,{className:`caps`,style:{fontSize:12.5,margin:0,color:J.ink},children:e}),t]})}function Q({children:e,right:t}){return(0,P.jsx)(`th`,{style:{textAlign:t?`right`:`left`,padding:`8px 12px`,fontSize:10.5,fontWeight:600,color:J.inkSoft,textTransform:`uppercase`,letterSpacing:`0.14em`,borderBottom:`2px solid ${J.ink}`},children:e})}function $({children:e,right:t,mono:n}){return(0,P.jsx)(`td`,{className:n?`mono`:``,style:{padding:`11px 12px`,fontSize:13,textAlign:t?`right`:`left`,borderBottom:`1px solid ${J.line}`,verticalAlign:`middle`},children:e})}function yo({children:e,onClick:t,disabled:n,ghost:r,small:i}){return(0,P.jsx)(`button`,{onClick:t,disabled:n,style:{background:n?`#C9C9CB`:r?`transparent`:J.charcoal,color:r?J.charcoal:`#fff`,border:r?`1px solid ${J.charcoal}`:`none`,borderRadius:4,padding:i?`7px 14px`:`11px 20px`,fontSize:i?12:13,fontWeight:600,letterSpacing:`0.08em`,textTransform:`uppercase`,cursor:n?`default`:`pointer`,display:`inline-flex`,alignItems:`center`,gap:8,transition:`background .15s`},onMouseEnter:e=>!n&&!r&&(e.currentTarget.style.background=J.charcoalDark),onMouseLeave:e=>!n&&!r&&(e.currentTarget.style.background=J.charcoal),children:e})}function bo({size:e=30,light:t}){return(0,P.jsx)(`img`,{src:t?Ha:Ua,alt:`Krush â Premium Preroll Cones`,style:{height:e,width:`auto`,display:`inline-block`,verticalAlign:`middle`}})}function xo({light:e,compact:t}){let n=[{icon:Nn,top:`Lab tested`,sub:`COA lab tests`},{icon:bn,top:`100% certified`,sub:`3 tier QC`},{icon:Rn,top:`100% natural`,sub:`All natural`},{icon:nr,top:`No pesticides`,sub:`Pesticide free`}],r=e?`#fff`:J.charcoal,i=e?`rgba(255,255,255,0.65)`:J.inkSoft;return(0,P.jsx)(`div`,{style:{display:`flex`,gap:t?18:28,flexWrap:`wrap`,justifyContent:`center`},children:n.map(e=>(0,P.jsxs)(`div`,{style:{textAlign:`center`,width:t?84:104},children:[(0,P.jsx)(`div`,{style:{width:t?46:56,height:t?46:56,margin:`0 auto`,borderRadius:`50%`,border:`1.6px dotted ${r}`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,P.jsx)(e.icon,{size:t?18:22,color:r,strokeWidth:1.7})}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:t?7.5:8.5,color:r,marginTop:8},children:e.top}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:t?6.5:7.5,color:i,marginTop:2,letterSpacing:`0.18em`},children:e.sub})]},e.top))})}function So({code:e,label:t}){let n=[],r=0;for(let t=0;t<e.length*2;t++){let i=e.charCodeAt(t%e.length)+t*7,a=1+i%3;i%2==0&&n.push({x:r,w:a}),r+=a+1}return(0,P.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,P.jsx)(`svg`,{viewBox:`0 0 ${r} 46`,style:{height:46,maxWidth:`100%`},preserveAspectRatio:`xMidYMid meet`,role:`img`,"aria-label":t,children:n.map((e,t)=>(0,P.jsx)(`rect`,{x:e.x,y:`0`,width:e.w,height:`46`,fill:J.ink},t))}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:10.5,marginTop:4},children:e}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:7.5,color:J.inkSoft,marginTop:3},children:t})]})}function Co({label:e,sub:t}){let n=[];for(let e=0;e<13;e++)for(let t=0;t<13;t++)!(e<4&&t<4||e<4&&t>=9||e>=9&&t<4)&&(e*31+t*17+e*t)%5<2&&n.push([t,e]);let r=(e,t)=>(0,P.jsxs)(`g`,{children:[(0,P.jsx)(`rect`,{x:e,y:t,width:`4`,height:`4`,fill:`none`,stroke:J.ink,strokeWidth:`0.9`}),(0,P.jsx)(`rect`,{x:e+1.3,y:t+1.3,width:`1.4`,height:`1.4`,fill:J.ink})]},e+`-`+t);return(0,P.jsxs)(`div`,{style:{display:`flex`,gap:12,alignItems:`center`}
174,children:[(0,P.jsxs)(`svg`,{viewBox:`-0.5 -0.5 14 14`,style:{width:64,height:64,flexShrink:0},role:`img`,"aria-label":`${e} QR code`,children:[n.map(([e,t],n)=>(0,P.jsx)(`rect`,{x:e,y:t,width:`1`,height:`1`,fill:J.ink},n)),r(0,0),r(9,0),r(0,9)]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:13,letterSpacing:`0.3em`,color:J.inkSoft},children:e}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:8,color:J.inkSoft,marginTop:3},children:t})]})]})}function wo({invoices:e,orders:t,coas:n,docs:r,go:i,modules:a=[],profile:o,bankRows:s=[],artworkCount:c=0}){let l=e.filter(e=>e.status!==`Paid`).reduce((e,t)=>e+t.amount,0),u=e.filter(e=>e.status===`Overdue`).reduce((e,t)=>e+t.amount,0),d=n.filter(e=>e.status===`Pending`).length,f=t.filter(e=>e.stage<8),p=t.filter(e=>e.stage>=2&&e.stage<6).length,m=t.filter(e=>e.stage>=6&&e.stage<8).length,h=t.filter(e=>e.stage>=8).length,g=t.reduce((e,t)=>e+(Number(t.qty)||0),0),_=!!(o?.company_name&&o?.contact_name),v=r.some(e=>(e.kind||``).toLowerCase().includes(`license`)||(e.kind||``).toLowerCase().includes(`compliance`)),y=r.some(e=>(e.kind||``).toLowerCase().includes(`bank`))||!!o?.bank_on_file,b=c>0,x=t.length>0,S=[{done:_,label:`Complete business profile`,dest:`team`},{done:v,label:`Upload compliance / license`,dest:`compliance`},{done:y,label:`Add bank / payment info`,dest:`balance`},{done:b,label:`Upload & approve artwork`,dest:`artwork`},{done:x,label:`Place your first order`,dest:`wizard`}],C=S.filter(e=>e.done).length,w=C===S.length,T=[{id:`customize`,label:`Design a filter`,desc:`Upload artwork, preview on cone`,icon:Wn},{id:`orders`,label:`Place an order`,desc:`Cones or filters, by pallet`,icon:$n},{id:`filter-bank`,label:`Reserve filter bank`,desc:`$0.025 / filter â hold production`,icon:In},{id:`support`,label:`Ask concierge`,desc:`Only sees your orders`,icon:Vn}];return(0,P.jsxs)(`div`,{style:{display:`grid`,gap:18},children:[!w&&(0,P.jsxs)(X,{children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:10},children:[(0,P.jsxs)(Z,{children:[`Get set up · `,C,` of `,S.length]}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:J.inkSoft},children:[Math.round(C/S.length*100),`%`]})]}),(0,P.jsx)(`div`,{style:{height:6,background:J.silver,borderRadius:3,overflow:`hidden`,marginBottom:12},children:(0,P.jsx)(`div`,{style:{width:`${C/S.length*100}%`,height:`100%`,background:J.charcoal}})}),(0,P.jsx)(`div`,{style:{display:`grid`,gap:6},children:S.map(e=>(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(e.dest),style:{display:`flex`,alignItems:`center`,gap:10,padding:`8px 10px`,background:e.done?J.silver:`#fff`,border:`1px solid ${J.line}`,borderRadius:4,cursor:`pointer`,textAlign:`left`},children:[e.done?(0,P.jsx)(wn,{size:16,color:J.charcoal}):(0,P.jsx)(En,{size:16,color:J.inkSoft}),(0,P.jsx)(`span`,{style:{fontSize:13,color:e.done?J.inkSoft:J.ink,textDecoration:e.done?`line-through`:`none`,flex:1},children:e.label}),(0,P.jsx)(yn,{size:13,color:J.inkSoft})]},e.label))})]}),(0,P.jsx)(X,{style:{padding:0,overflow:`hidden`,background:`#0B0B0C`,border:`none`,color:`#fff`},children:(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1.4fr 1fr`,minHeight:220},children:[(0,P.jsxs)(`div`,{style:{padding:`28px 30px`,display:`flex`,flexDirection:`column`,justifyContent:`space-between`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`caps`,style:{fontSize:10,letterSpacing:`0.22em`,color:`#8a8a8a`},children:`Open balance`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:44,fontWeight:600,lineHeight:1.05,marginTop:8,color:`#fff`},children:Y(l)}),(0,P.jsx)(`div`,{style:{fontSize:12.5,marginTop:8,color:u?`#ff6b6b`:`#7dd3a3`},children:u?`${Y(u)} overdue`:`Nothing overdue`})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(`balance`),style:{alignSelf:`flex-start`,background:`#fff`,color:`#0B0B0C`,border:`none`,padding:`10px 16px`,borderRadius:4,fontSize:11.5,fontWeight:700,letterSpacing:`0.12em`,textTransform:`uppercase`,cursor:`pointer`,display:`inline-flex`,alignItems:`center`,gap:8},children:[`View invoices `,(0,P.jsx)(yn,{size:13})]})]}),(0,P.jsx)(`div`,{style:{borderLeft:`1px solid #1e1e1e`,padding:`28px 26px`,display:`grid`,gridTemplateRows:`1fr 1fr 1fr`},children:[{k:`Active orders`,v:f.length,sub:`${p} in production · ${m} in transit`,dest:`orders`,icon:Un},{k:`COAs on file`,v:n.length,sub:d?`${d} pending`:`All results in`,dest:`documents`,icon:Nn}
174,{k:`Cones lifetime`,v:g.toLocaleString(),sub:`${h} orders delivered`,dest:`orders`,icon:ir}].map((e,t)=>(0,P.jsxs)(`div`,{onClick:()=>i(e.dest),role:`button`,tabIndex:0,onKeyDown:t=>t.key===`Enter`&&i(e.dest),style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,cursor:`pointer`,borderTop:t===0?`none`:`1px solid #1e1e1e`,padding:t===0?`0 0 12px`:`12px 0`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`caps`,style:{fontSize:9.5,letterSpacing:`0.18em`,color:`#8a8a8a`},children:e.k}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:22,fontWeight:600,marginTop:4},children:e.v}),(0,P.jsx)(`div`,{style:{fontSize:11,color:`#a3a3a3`,marginTop:2},children:e.sub})]}),(0,P.jsx)(e.icon,{size:18,color:`#8a8a8a`})]},e.k))})]})}),(0,P.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(220px, 1fr))`,gap:12},children:T.map(e=>(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),style:{display:`flex`,alignItems:`flex-start`,gap:14,padding:`18px 18px`,background:`#fff`,border:`1px solid ${J.line}`,borderRadius:6,cursor:`pointer`,textAlign:`left`,transition:`all 140ms ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=J.ink,e.currentTarget.style.transform=`translateY(-1px)`},onMouseLeave:e=>{e.currentTarget.style.borderColor=J.line,e.currentTarget.style.transform=`translateY(0)`},children:[(0,P.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:40,height:40,borderRadius:4,background:J.bg,border:`1px solid ${J.line}`,flexShrink:0},children:(0,P.jsx)(e.icon,{size:18,color:J.ink})}),(0,P.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,gap:4,minWidth:0},children:[(0,P.jsx)(`span`,{style:{fontSize:13.5,fontWeight:600,color:J.ink},children:e.label}),(0,P.jsx)(`span`,{style:{fontSize:11.5,color:J.inkSoft,lineHeight:1.35},children:e.desc})]})]},e.id))}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(340px, 1fr))`,gap:14},children:[(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{action:(0,P.jsxs)(`button`,{onClick:()=>i(`orders`),style:{background:`none`,border:`none`,color:J.charcoal,fontSize:12,fontWeight:600,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:4},children:[`New order `,(0,P.jsx)(yn,{size:13})]}),children:`Recent orders`}),t.length===0&&(0,P.jsx)(`div`,{style:{fontSize:12.5,color:J.inkSoft,padding:`18px 0`},children:`No orders yet â place your first from the Orders module.`}),t.slice(0,4).map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:10,padding:`12px 0`,borderBottom:`1px solid ${J.line}`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:12.5,fontWeight:600},children:e.id}),(0,P.jsxs)(`div`,{style:{fontSize:12,color:J.inkSoft,marginTop:3},children:[e.date,` · `,e.items]})]}),(0,P.jsxs)(`div`,{style:{textAlign:`right`},children:[(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:12.5,fontWeight:600},children:Y(e.total)}),(0,P.jsx)(_o,{label:e.status})]})]},e.id))]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{action:(0,P.jsxs)(`button`,{onClick:()=>i(`documents`),style:{background:`none`,border:`none`,color:J.charcoal,fontSize:12,fontWeight:600,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:4},children:[`All documents `,(0,P.jsx)(yn,{size:13})]}),children:`Latest lot results`}),n.length===0&&(0,P.jsx)(`div`,{style:{fontSize:12.5,color:J.inkSoft,padding:`18px 0`},children:`COAs appear here 5 days after each shipment arrives.`}),n.slice(0,4).map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:10,padding:`12px 0`,borderBottom:`1px solid ${J.line}`},children:[(0,P.jsxs)(`div`,{style:{minWidth:0},children:[(0,P.jsx)(vo,{code:e.lot}),(0,P.jsx)(`div`,{style:{fontSize:12.5,marginTop:5,color:J.inkSoft},children:e.product})]}),(0,P.jsx)(_o,{label:e.status})]},e.lot))]})]}),(0,P.jsx)(xo,{compact:!0})]})}function To({product:e,paperHex:t,artUrl:n,locked:r,filterHex:i,fit:a=`meet`}){let[o,s,c,l]=e.drawing.split(`/`),u=parseFloat(o),d=parseFloat(s),f=parseFloat(c),p=parseFloat(l),m=3.2,h=u*m,g=f*m,_=p*m,v=d*m,y=90+Math.max(g,_)/2+30,b=40+(h-v),x=40+h;y-_/2,y+_/2,y-g/2,y+g/2;let S=y-g/2,C=y+g/2,w=y-_/2,T=y+_/2,E=y+Math.max(g,_)/2+90,D=x+60,O=`#3A3A38`,k={fontFamily:`IBM Plex Mono, ui-monospace, monospace`,fontSize:9,fill:O},ee=Ra(n),A=b+v/2,j={x:w,y:b,w:_,h:v};if(n&&ee&&a!==`none`){let e=_*.92,t=v*.92,n=e,r=n/ee;r>t&&(r=t,n=r*ee),j={x:y-n/2,y:A-r/2,w:n,h:r}}
174return(0,P.jsxs)(`svg`,{viewBox:`0 0 ${E} ${D}`,preserveAspectRatio:`xMidYMid meet`,style:{width:`100%`,height:`100%`,flex:1,display:`block`,margin:`0 auto`,minHeight:420},role:`img`,"aria-label":`Cone technical rendering ${e.drawing} mm`,children:[(0,P.jsxs)(`defs`,{children:[(0,P.jsx)(`clipPath`,{id:`specTip`,children:(0,P.jsx)(`path`,{d:`M ${w} ${b} L ${T} ${b} L ${T} ${x} L ${w} ${x} Z`})}),(0,P.jsxs)(`linearGradient`,{id:`specSh`,x1:`0`,x2:`1`,children:[(0,P.jsx)(`stop`,{offset:`0`,stopColor:`#000`,stopOpacity:`0.09`}),(0,P.jsx)(`stop`,{offset:`0.45`,stopColor:`#000`,stopOpacity:`0`}),(0,P.jsx)(`stop`,{offset:`1`,stopColor:`#000`,stopOpacity:`0.11`})]}),(0,P.jsxs)(`linearGradient`,{id:`filterCyl`,x1:`0`,x2:`1`,children:[(0,P.jsx)(`stop`,{offset:`0`,stopColor:`#000`,stopOpacity:`0.28`}),(0,P.jsx)(`stop`,{offset:`0.15`,stopColor:`#000`,stopOpacity:`0.1`}),(0,P.jsx)(`stop`,{offset:`0.5`,stopColor:`#fff`,stopOpacity:`0.18`}),(0,P.jsx)(`stop`,{offset:`0.85`,stopColor:`#000`,stopOpacity:`0.1`}),(0,P.jsx)(`stop`,{offset:`1`,stopColor:`#000`,stopOpacity:`0.3`})]})]}),(0,P.jsx)(`ellipse`,{cx:y,cy:x+10,rx:_*.9,ry:5,fill:`#000`,opacity:`0.08`}),(0,P.jsx)(`path`,{d:`M ${S} 40 L ${C} 40 L ${T} ${b} L ${w} ${b} Z`,fill:t,stroke:`#00000022`}),(0,P.jsx)(`line`,{x1:y+g/4,y1:44,x2:y+_/4,y2:b-2,stroke:`#0000001a`,strokeDasharray:`2 3`}),(0,P.jsx)(`rect`,{x:w,y:b,width:_,height:v,fill:i||`#fff`,stroke:`#00000022`}),n?(0,P.jsx)(`g`,{clipPath:`url(#specTip)`,children:(0,P.jsx)(`image`,{href:n,x:j.x,y:j.y,width:j.w,height:j.h,preserveAspectRatio:a===`none`?`none`:a===`slice`?`xMidYMid slice`:`xMidYMid meet`})}):(0,P.jsxs)(`g`,{clipPath:`url(#specTip)`,children:[(0,P.jsx)(`rect`,{x:w,y:b,width:_,height:v,fill:J.silver}),(0,P.jsx)(`text`,{x:y,y:b+v/2,textAnchor:`middle`,dominantBaseline:`middle`,fontFamily:`Jost`,fontSize:`4.5`,fill:J.inkSoft,letterSpacing:`1.5`,transform:`rotate(-90 ${y} ${b+v/2})`,children:`YOUR ART`})]}),(0,P.jsx)(`rect`,{x:w,y:b,width:_,height:v,fill:`url(#filterCyl)`,clipPath:`url(#specTip)`,pointerEvents:`none`}),(0,P.jsx)(`line`,{x1:w,y1:b,x2:T,y2:b,stroke:`#0000002a`,strokeWidth:`0.8`}),(0,P.jsx)(`path`,{d:`M ${S} 40 L ${C} 40 L ${T} ${b} L ${w} ${b} Z`,fill:`url(#specSh)`}),(()=>{let e=Math.max(C,T)+22;return(0,P.jsxs)(`g`,{stroke:O,strokeWidth:`0.6`,fill:`none`,children:[(0,P.jsx)(`line`,{x1:C+3,y1:40,x2:e+4,y2:40}),(0,P.jsx)(`line`,{x1:T+3,y1:x,x2:e+4,y2:x}),(0,P.jsx)(`line`,{x1:e,y1:40,x2:e,y2:x,markerStart:`url(#a)`,markerEnd:`url(#a)`}),(0,P.jsxs)(`text`,{x:e+6,y:(40+x)/2+3,...k,stroke:`none`,children:[u,`mm`]})]})})(),(0,P.jsxs)(`g`,{stroke:O,strokeWidth:`0.6`,fill:`none`,children:[(0,P.jsx)(`line`,{x1:S,y1:36,x2:S,y2:22}),(0,P.jsx)(`line`,{x1:C,y1:36,x2:C,y2:22}),(0,P.jsx)(`line`,{x1:S,y1:26,x2:C,y2:26}),(0,P.jsxs)(`text`,{x:y,y:22,textAnchor:`middle`,...k,stroke:`none`,children:[f,`mm`]})]}),(0,P.jsxs)(`g`,{stroke:O,strokeWidth:`0.6`,fill:`none`,children:[(0,P.jsx)(`line`,{x1:w-3,y1:b,x2:w-22,y2:b}),(0,P.jsx)(`line`,{x1:w-3,y1:x,x2:w-22,y2:x}),(0,P.jsx)(`line`,{x1:w-18,y1:b,x2:w-18,y2:x}),(0,P.jsxs)(`text`,{x:w-22,y:(b+x)/2+3,textAnchor:`end`,...k,stroke:`none`,children:[d,`mm`]})]}),(0,P.jsxs)(`g`,{stroke:O,strokeWidth:`0.6`,fill:`none`,children:[(0,P.jsx)(`line`,{x1:w,y1:x+4,x2:w,y2:x+18}),(0,P.jsx)(`line`,{x1:T,y1:x+4,x2:T,y2:x+18}),(0,P.jsx)(`line`,{x1:w,y1:x+14,x2:T,y2:x+14}),(0,P.jsxs)(`text`,{x:y,y:x+28,textAnchor:`middle`,...k,stroke:`none`,children:[p,`mm Ã`]})]}),(0,P.jsx)(`text`,{x:50,y:52,...k,stroke:`none`,children:`MOUTH`}),(0,P.jsx)(`text`,{x:50,y:b+4,...k,stroke:`none`,children:`FILTER`}),(0,P.jsxs)(`text`,{x:E-6,y:D-6,textAnchor:`end`,fontFamily:`IBM Plex Mono`,fontSize:`7.5`,fill:J.inkSoft,children:[e.drawing,` · 2024 Q2 REV`]}),r&&(0,P.jsxs)(`g`,{children:[(0,P.jsx)(`rect`,{x:y-70,y:4,width:140,height:22,rx:3,fill:J.goodBg,stroke:J.good}),(0,P.jsx)(`text`,{x:y,y:19,textAnchor:`middle`,fontFamily:`IBM Plex Mono`,fontSize:`10`,fontWeight:`600`,fill:J.good,children:`PROOF APPROVED`})]})]})}function Eo({onOrderSample:e,sampleInfo:t,onUploaded:n}){let[r,i]=(0,h.useState)(Ga[1]),[a,s]=(0,h.useState)(Ga[1].papers[1]),[c,l]=(0,h.useState)(`Refined`),[u,d]=(0,h.useState)([]),[f,p]=(0,h.useState)(null),[m,g]=(0,h.useState)(null),[_,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(``),[C,w]=(0,h.useState)(!1),[T,E]=(0,h.useState)(``),[D,O]=(0,h.useState)(!1),[k,ee]=(0,h.useState)(`meet`),[A,j]=(0,h.useState)(1),[te,ne]=(0,h.useState)({x:0,y:0}),re=(0,h.useRef)(null),M=u.find(e=>e.n===f)||null,ie=M&&(M.pages?.[M.activeIdx??0]||M.url)||null,ae=M&&Object.values(M.plan).every(e=>
174e.pass),N=!!_,oe=ro[a]||`#F0EEE8`,se={Refined:`#F7F5F0`,Natural:`#E3DAC3`},ce=se[c],le=async e=>{let t=e&&e[0];if(!t||N)return;E(``),O(!0);let i=u.length+1,s=so(t.name),l=/\.(png|jpe?g|svg)$/i.test(t.name),f=/\.pdf$/i.test(t.name)||t.type===`application/pdf`;try{let e=[];if(l)e=[await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(Error(`Could not read image file.`)),r.readAsDataURL(t)})];else if(f){if(e=await Ba(t),!e.length)throw Error(`PDF appears to be empty.`)}else e=[];let u=null;try{let{data:e}=await o.auth.getUser(),i=e?.user?.id;if(i){let e=t.name.replace(/[^\w.\-]+/g,`_`);u=`${i}/filter-templates/${Date.now()}-${e}`;let s=await o.storage.from(`compliance-docs`).upload(u,t,{contentType:t.type||`application/octet-stream`,upsert:!1});if(s.error)throw s.error;let{error:l}=await o.from(`documents`).insert({customer_id:i,kind:`TEMPLATE`,name:`Filter template â ${t.name}`,file_url:u,status:`active`,notes:`${r.name} · ${a} · Filter ${c}\nUploaded from Customize studio`});if(l)throw l;n?.()}}catch(e){console.warn(`[Customize] template persist failed:`,e),E(`Preview ready, but saving to your library failed: ${e?.message||e}`)}d(n=>[...n,{n:i,name:t.name,pages:e,activeIdx:0,url:e[0]||null,plan:s,storagePath:u}]),p(i);let m={};oo.forEach(e=>m[e.id]=`pending`),g({...m}),oo.forEach((e,t)=>setTimeout(()=>{g(t=>t&&{...t,[e.id]:s[e.id].pass?`pass`:`fail`}),t===oo.length-1&&setTimeout(()=>g(null),350)},450+t*520))}catch(e){console.error(`[Customize] upload failed:`,e),E(e?.message||`Could not process that file.`)}finally{O(!1)}},ue=e=>{d(t=>t.map(t=>t.n===f?{...t,activeIdx:e,url:t.pages?.[e]||t.url}:t))},de=M?.pages?.length||0,fe=M?.activeIdx??0;return(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:Wa()<1024?`1fr`:`240px 5fr 280px`,gap:16,alignItems:`stretch`},children:[(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Format & paper`}),(0,P.jsx)(`div`,{style:{display:`grid`,gap:12,marginBottom:16},children:Array.from(new Set(Ga.map(e=>e.category||`Cones`))).map(e=>(0,P.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,color:J.inkSoft,letterSpacing:1},children:e}),Ga.filter(t=>(t.category||`Cones`)===e).map(e=>(0,P.jsxs)(`button`,{disabled:N,onClick:()=>{i(e),s(e.papers[0])},style:{textAlign:`left`,padding:`11px 13px`,borderRadius:4,cursor:N?`default`:`pointer`,border:`1px solid ${r.id===e.id?J.charcoal:J.line}`,background:r.id===e.id?J.silver:`#fff`,opacity:N?.55:1},children:[(0,P.jsx)(`div`,{style:{fontSize:13.5,fontWeight:600},children:e.name}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10.5,color:J.inkSoft,marginTop:2},children:[e.drawing,` · folded filter · straight gum line`]})]},e.id))]},e))}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:10,marginBottom:8},children:`Paper type`}),(0,P.jsx)(`div`,{style:{display:`grid`,gap:7},children:r.papers.map(e=>(0,P.jsxs)(`button`,{disabled:N,onClick:()=>s(e),style:{display:`flex`,alignItems:`center`,gap:10,padding:`9px 12px`,borderRadius:4,cursor:N?`default`:`pointer`,border:`1px solid ${a===e?J.charcoal:J.line}`,background:a===e?J.silver:`#fff`,fontSize:13,opacity:N?.55:1},children:[(0,P.jsx)(`span`,{style:{width:15,height:15,borderRadius:`50%`,background:ro[e],border:`1px solid #00000022`}}),e]},e))}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:10,marginTop:14,marginBottom:8},children:`Filter paper`}),(0,P.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:7},children:[`Refined`,`Natural`].map(e=>(0,P.jsxs)(`button`,{disabled:N,onClick:()=>l(e),style:{display:`flex`,alignItems:`center`,gap:8,padding:`9px 10px`,borderRadius:4,cursor:N?`default`:`pointer`,border:`1px solid ${c===e?J.charcoal:J.line}`,background:c===e?J.silver:`#fff`,fontSize:12.5,opacity:N?.55:1},children:[(0,P.jsx)(`span`,{style:{width:14,height:14,borderRadius:`50%`,background:se[e],border:`1px solid #00000022`}}),e]},e))}),(0,P.jsx)(`div`,{style:{marginTop:16,fontSize:11.5,color:J.inkSoft,borderTop:`1px solid ${J.line}`,paddingTop:12},children:`Full-colour filter printing uses FDA-standard food-safe inks. Cones are UV-sanitized in a cleanroom and compatible with knock boxes, rocket boxes, and automated filling.`})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:14,minHeight:`100%`},children:[(0,P.jsxs)(X,{style:{padding:20,flex:1,display:`flex`,flexDirection:`column`,minHeight:520},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`center`,gap:6,marginBottom:8},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,color:J.inkSoft,letterSpacing:1,alignSelf:`center`,marginRight:4},children:`Render`}),[{id:`meet`,label:`Fit (aspect)`},{id:`slice`,label:`Fill (crop)`},{id:`none`,label:`Wrap (stretch)`}].map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>ee(e.id),style:{border:`1px solid ${k===e.id?J.charcoal:J.line}`,background:k===e.id?J.silver:`#fff`,padding:`4px 10px`,borderRadius:4,cursor:`pointer`,fontSize:11},children:e.label},e.id))]}),(0,P.jsx)(`div`,{style:{flex:1,display:`flex`,alignItems:`stretch`,justifyContent:`center`,minHeight:0},children:(0,P.jsx)(To,{product:r,paperHex:oe,artUrl:ie,locked:N,filterHex:ce,fit:k})}),(0,P.jsxs)(`div`,{className:`caps`,style:{textAlign:`center`,fontSize:9.5,color:J.inkSoft,marginTop:12,letterSpacing:1},children:[r.name,` · `,a,` · `,c,` filter paper · full-colour print`]}),M&&!ie&&(0,P.jsxs)(`div`,{className:`mono`,style:{textAlign:`center`,fontSize:10.5,color:J.inkSoft,marginTop:6},children:[(0,P.jsx)(Mn,{size:11,style:{verticalAlign:`-2px`}}),` `,M.name,` â vector placed; proof render generated at prepress`]})]}),ie&&(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Uploaded artwork`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[(0,P.jsxs)(`div`,{ref:re,onMouseDown:e=>{if(A<=1)return;let t=e.clientX,n=e.clientY,r={...te},i=e=>ne({x:r.x+(e.clientX-t),y:r.y+(e.clientY-n)}),a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},style:{position:`relative`,border:`1px solid ${J.line}`,borderRadius:4,overflow:`hidden`,background:`#fff`,height:640,cursor:A>1?`grab`:`zoom-in`},onDoubleClick:()=>{j(e=>e>=3?1:e+1),ne({x:0,y:0})},title:A>1?`Drag to pan · double-click to reset`:`Double-click or use + to zoom in`,children:[(0,P.jsx)(`img`,{src:ie,alt:M?.name||`Uploaded filter artwork`,draggable:!1,style:{display:`block`,width:`100%`,height:`100%`,objectFit:`contain`,objectPosition:`center`,background:`#fff`,padding:8,transform:`translate(${te.x}px, ${te.y}px) scale(${A})`,transformOrigin:`center center`,transition:re.current?`none`:`transform .15s`,userSelect:`none`,pointerEvents:`none`}}),(0,P.jsxs)(`div`,{style:{position:`absolute`,right:8,bottom:8,display:`flex`,gap:4,background:`rgba(255,255,255,0.95)`,border:`1px solid ${J.line}`,borderRadius:4,padding:3},children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>{j(e=>Math.max(1,+(e-.5).toFixed(2))),A-.5<=1&&ne({x:0,y:0})},style:{width:26,height:26,border:`1px solid ${J.line}
174`,background:`#fff`,cursor:`pointer`,borderRadius:3,display:`grid`,placeItems:`center`},"aria-label":`Zoom out`,children:(0,P.jsx)(Hn,{size:12})}),(0,P.jsxs)(`div`,{className:`mono`,style:{minWidth:42,textAlign:`center`,fontSize:11,lineHeight:`26px`,color:J.inkSoft},children:[Math.round(A*100),`%`]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>j(e=>Math.min(4,+(e+.5).toFixed(2))),style:{width:26,height:26,border:`1px solid ${J.line}`,background:`#fff`,cursor:`pointer`,borderRadius:3,display:`grid`,placeItems:`center`},"aria-label":`Zoom in`,children:(0,P.jsx)(qn,{size:12})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{j(1),ne({x:0,y:0})},style:{height:26,padding:`0 8px`,border:`1px solid ${J.line}`,background:`#fff`,cursor:`pointer`,borderRadius:3,fontSize:11},children:`Reset`}),(0,P.jsx)(`a`,{href:ie,target:`_blank`,rel:`noopener noreferrer`,style:{height:26,padding:`0 8px`,border:`1px solid ${J.line}`,background:`#fff`,borderRadius:3,fontSize:11,lineHeight:`24px`,textDecoration:`none`,color:J.ink},children:`Open`})]})]}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10.5,color:J.inkSoft,wordBreak:`break-all`},children:[M?.name,de>1?` · design ${fe+1} / ${de}`:``]}),de>1&&(0,P.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:M.pages.map((e,t)=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>ue(t),style:{padding:0,border:`2px solid ${t===fe?J.charcoal:J.line}`,background:`#fff`,borderRadius:3,cursor:`pointer`,width:40,height:40,overflow:`hidden`},children:(0,P.jsx)(`img`,{src:e,alt:`Design ${t+1}`,style:{width:`100%`,height:`100%`,objectFit:`contain`,display:`block`,background:`#fff`}})},t))})]})]}),!N&&(0,P.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),w(!0)},onDragLeave:()=>w(!1),onDrop:e=>{e.preventDefault(),w(!1),le(e.dataTransfer.files)},style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:6,border:`1px dashed ${C?J.charcoal:`#C9C9C6`}`,background:C?J.silver:`#fff`,borderRadius:6,padding:`24px 16px`,cursor:`pointer`,transition:`all .15s`},children:[(0,P.jsx)(Dn,{size:22,color:J.charcoal}),(0,P.jsx)(`span`,{style:{fontSize:13,fontWeight:600},children:D?`Rendering artworkâ¦`:u.length?`Upload a new filter artwork version`:`Upload your filter artwork`}),(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10,color:J.inkSoft},children:`AI · PDF (multi-page) · EPS · SVG · PNG â preflight runs instantly`}),T&&(0,P.jsx)(`span`,{style:{fontSize:11,color:`#B33A3A`,marginTop:4,textAlign:`center`},children:T}),(0,P.jsx)(`input`,{type:`file`,style:{display:`none`},accept:`.ai,.pdf,.eps,.svg,.png,.jpg,.jpeg`,onChange:e=>{le(e.target.files),e.target.value=``}})]}),N&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(X,{style:{background:J.goodBg,border:`1px solid ${J.good}33`,display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:10,flexWrap:`wrap`},children:[(0,P.jsxs)(`span`,{style:{fontSize:12.5,color:J.good,fontWeight:600,display:`flex`,gap:8,alignItems:`center`},children:[(0,P.jsx)(wn,{size:15}),` Approved by `,_.name,` · `,new Date(_.at).toLocaleString(),` â signature, timestamp & IP recorded.`]}),(0,P.jsxs)(yo,{ghost:!0,small:!0,onClick:()=>{v(null),d([]),p(null)},children:[(0,P.jsx)(Fn,{size:13}),` New project`]})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Printed filter sample`}),t?(0,P.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,P.jsxs)(`div`,{style:{fontSize:12.5,color:J.good,fontWeight:600,display:`flex`,gap:8,alignItems:`center`},children:[(0,P.jsx)(wn,{size:15}),` Sample purchased â template dispatched automatically.`]}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:J.inkSoft},children:[t.artwork,` EMAILED TO `,Qa,` · `,t.at]}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:J.inkSoft},children:[`DELIVERY BY `,t.eta,` · TRACK IT UNDER ORDERS`]})]}):(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,P.jsxs)(`p`,{style:{fontSize:12,color:J.inkSoft,margin:0,maxWidth:460},children:[`See your approved artwork on a physical filter before committing to a run. On purchase, the portal automatically emails your filter template to TPH for printing â `,Y(Xa),` including delivery, `,Za,`-day lead time.`]}),(0,P.jsxs)(yo,{small:!0,onClick:()=>e(`v${M?.n} · ${M?.name}`),children:[`Order sample â `,Y(Xa)]})]})]})]})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:14},children:[(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Artwork preflight`}),!M&&!m&&(0,P.jsx)(`p`,{style:{fontSize:12,color:J.inkSoft,margin:0},children:`Upload filter artwork and we verify format, resolution, colour profile, and dieline fit automatically â before prepress ever sees it.`}),(m||M)&&oo.map(e=>{let t=m?m[e.id]:M.plan[e.id].pass?`pass`:`fail`,n=M?.plan[e.id]?.note;return(0,P.jsxs)(`div`,{style:{display:`flex`,gap:9,padding:`8px 0`,borderBottom:`1px solid ${J.line}`,alignItems:`flex-start`},children:[(0,P.jsxs)(`span`,{style:{flexShrink:0,marginTop:1},children:[t===`pending`&&(0,P.jsx)(zn,{size:14,className:`spin`,color:J.inkSoft}),t===`pass`&&(0,P.jsx)(`span`,{className:`pop`,style:{display:`inline-flex`},children:(0,P.jsx)(wn,{size:14,color:J.good})}),t===`fail`&&(0,P.jsx)(`span`,{className:`pop`,style:{display:`inline-flex`},children:(0,P.jsx)(Tn,{size:14,color:J.bad})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:12,fontWeight:600},children:e.label}),!m&&n&&(0,P.jsx)(`div`,{style:{fontSize:11,color:t===`fail`?J.bad:J.inkSoft,marginTop:2},children:n})]})]},e.id)}),M&&!m&&!ae&&(0,P.jsxs)(`div`,{style:{marginTop:12,background:J.warnBg,borderRadius:4,padding:`10px 12px`,fontSize:11.5,color:J.warn,display:`flex`,gap:8},children:[(0,P.jsx)(ar,{size:13,style:{flexShrink:0,marginTop:1}}
174),` Fix and re-upload, or send to prepress for a hand-fix (adds ~1 business day).`]}),ae&&!N&&!m&&(0,P.jsx)(`div`,{style:{marginTop:14},children:(0,P.jsxs)(yo,{onClick:()=>b(!0),children:[(0,P.jsx)(Gn,{size:14}),` Approve proof`]})})]}),u.length>0&&(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Versions`}),[...u].reverse().map(e=>{let t=Object.values(e.plan).every(e=>e.pass);return(0,P.jsxs)(`button`,{disabled:N,onClick:()=>p(e.n),style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,gap:8,padding:`9px 10px`,borderRadius:4,marginBottom:6,cursor:N?`default`:`pointer`,border:`1px solid ${e.n===f?J.charcoal:J.line}`,background:e.n===f?J.silver:`#fff`},children:[(0,P.jsxs)(`span`,{className:`mono`,style:{fontSize:11.5,fontWeight:600},children:[`v`,e.n]}),(0,P.jsx)(`span`,{style:{fontSize:11,color:J.inkSoft,flex:1,textAlign:`left`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name}),(0,P.jsx)(_o,{label:t?`Pass`:`Fail`})]},e.n)})]})]}),y&&(0,P.jsx)(`div`,{style:{position:`fixed`,inset:0,background:`rgba(30,30,32,0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:20,zIndex:50},children:(0,P.jsxs)(`div`,{style:{background:`#fff`,borderRadius:8,width:`100%`,maxWidth:430,padding:26,position:`relative`},children:[(0,P.jsx)(`button`,{onClick:()=>b(!1),"aria-label":`Close`,style:{position:`absolute`,top:14,right:14,background:`none`,border:`none`,cursor:`pointer`,color:J.inkSoft},children:(0,P.jsx)(lr,{size:17})}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:13},children:`Digital proof approval`}),(0,P.jsxs)(`p`,{style:{fontSize:12.5,color:J.inkSoft},children:[`You're approving `,(0,P.jsxs)(`span`,{className:`mono`,style:{color:J.ink,fontWeight:600},children:[`v`,M?.n,` · `,M?.name]}),` on `,r.name,`, `,a,`. This releases artwork to production and locks the configuration. On-screen colour is a guide; production matches your file's CMYK values in the food-safe ink set.`]}),(0,P.jsx)(`label`,{className:`caps`,style:{fontSize:10,display:`block`,marginBottom:6},children:`Type your full name to sign`}),(0,P.jsx)(`input`,{value:x,onChange:e=>S(e.target.value),placeholder:`Full name`,style:{width:`100%`,padding:`11px 12px`,borderRadius:4,fontSize:14,border:`1px solid ${J.line}`,marginBottom:16,background:J.bg}}),(0,P.jsxs)(yo,{disabled:x.trim().length<3,onClick:()=>{v({name:x.trim(),at:new Date().toISOString()}),b(!1)},children:[(0,P.jsx)(Gn,{size:14}),` Sign & approve`]})]})})]})}function Do({coas:e,docs:t}){let[n,r]=(0,h.useState)(``),[i,a]=(0,h.useState)(`All`),[s,c]=(0,h.useState)(null),l=[`All`,`Compliance`,`Technical`,`Financial`],u=(Array.isArray(t)?t:[]).filter(e=>(i===`All`||e.cat===i)&&(e.title+e.type).toLowerCase().includes(n.toLowerCase())),d=e=>e.expires&&(new Date(e.expires)-new Date)/864e5<90,f=async e=>{if(!e)return null;if(/^https?:\/\//.test(e))return e;let{data:t,error:n}=await o.storage.from(`coa-docs`).createSignedUrl(e,3600);return n?(alert(n.message),null):t?.signedUrl||null},p=async e=>{let t=await f(e);t&&window.open(t,`_blank`,`noopener`)},m=async(e,t)=>{let n=await f(e);if(!n)return;let r=(n.split(`?`)[0]||``).toLowerCase(),i=/\.(png|jpe?g|gif|webp|svg)$/.test(r)?`image`:/\.pdf$/.test(r)||r.includes(`pdf`)?`pdf`:`other`;c({url:n,name:t||`Document`,kind:i})};return(0,P.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{action:(0,P.jsxs)(`div`,{style:{position:`relative`},children:[(0,P.jsx)(Xn,{size:13,style:{position:`absolute`,left:10,top:9,color:J.inkSoft}}),(0,P.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Search lot, doc, or type`,style:{padding:`7px 10px 7px 30px`,borderRadius:4,border:`1px solid ${J.line}`,fontSize:12.5,background:J.bg,width:230}})]}),children:`Certificates of Analysis`}),(0,P.jsx)(`p`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:0},children:`Every batch is tested for microbial contamination, heavy metals, and structural integrity. COAs are available 5 days after product arrival. Each tower and case carries a QR code linking to its COA and technical specification.`}),(0,P.jsx)(`div`,{style:{overflowX:`auto`}
174,children:(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(Q,{children:`Lot`}),(0,P.jsx)(Q,{children:`Product`}),(0,P.jsx)(Q,{children:`Tested`}),(0,P.jsx)(Q,{children:`Microbial`}),(0,P.jsx)(Q,{children:`Heavy metals`}),(0,P.jsx)(Q,{children:`Structural`}),(0,P.jsx)(Q,{children:`Result`}),(0,P.jsx)(Q,{right:!0,children:`PDF`})]})}),(0,P.jsx)(`tbody`,{children:e.filter(e=>(e.lot+e.product).toLowerCase().includes(n.toLowerCase())).map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)($,{children:(0,P.jsx)(vo,{code:e.lot})}),(0,P.jsx)($,{children:e.product}),(0,P.jsx)($,{mono:!0,children:e.tested}),(0,P.jsx)($,{mono:!0,children:e.micro}),(0,P.jsx)($,{mono:!0,children:e.heavy}),(0,P.jsx)($,{mono:!0,children:e.structural}),(0,P.jsx)($,{children:(0,P.jsx)(_o,{label:e.status})}),(0,P.jsx)($,{right:!0,children:(0,P.jsxs)(`div`,{style:{display:`inline-flex`,gap:4,justifyContent:`flex-end`},children:[(0,P.jsx)(`button`,{disabled:e.status===`Pending`||!e.file_url,onClick:()=>m(e.file_url,`COA ${e.lot}`),"aria-label":`Preview COA ${e.lot}`,style:{background:`none`,border:`none`,cursor:e.status===`Pending`||!e.file_url?`default`:`pointer`,color:e.status===`Pending`||!e.file_url?`#C6C6C8`:J.charcoal,padding:4},children:(0,P.jsx)(jn,{size:15})}),(0,P.jsx)(`button`,{disabled:e.status===`Pending`||!e.file_url,onClick:()=>p(e.file_url),"aria-label":`Download COA ${e.lot}`,style:{background:`none`,border:`none`,cursor:e.status===`Pending`||!e.file_url?`default`:`pointer`,color:e.status===`Pending`||!e.file_url?`#C6C6C8`:J.charcoal,padding:4},children:(0,P.jsx)(kn,{size:15})})]})})]},e.lot))})]})})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{action:(0,P.jsx)(`div`,{style:{display:`flex`,gap:6},children:l.map(e=>(0,P.jsx)(`button`,{onClick:()=>a(e),style:{padding:`6px 12px`,borderRadius:4,fontSize:11.5,fontWeight:600,cursor:`pointer`,border:`1px solid ${i===e?J.charcoal:J.line}`,background:i===e?J.charcoal:`#fff`,color:i===e?`#fff`:J.ink},children:e},e))}),children:`Document library`}),(0,P.jsx)(`p`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:0},children:`Your permanent archive â every document Krush issues to your account lives here: Letter of Guarantee, food contact & allergen statements, technical data sheets, material specs, technical drawings, and invoices.`}),u.map((e,t)=>(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`11px 0`,borderBottom:`1px solid ${J.line}`},children:[(0,P.jsx)(Mn,{size:16,color:J.inkSoft,style:{flexShrink:0}}),(0,P.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:500,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.title}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10.5,color:J.inkSoft,marginTop:2},children:[e.type,` · `,e.cat.toUpperCase(),` · ISSUED `,e.date,e.expires?` · EXPIRES ${e.expires}`:``]})]}),d(e)&&(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10,fontWeight:600,color:J.warn,background:J.warnBg,padding:`3px 7px`,borderRadius:3},children:`RENEWS SOON`}),(0,P.jsx)(`button`,{"aria-label":`Preview ${e.title}`,onClick:()=>m(e.file_url,e.title),disabled:!e.file_url,style:{background:`none`,border:`none`,cursor:e.file_url?`pointer`:`default`,color:e.file_url?J.charcoal:`#C6C6C8`,padding:4},children:(0,P.jsx)(jn,{size:15})}),(0,P.jsx)(`button`,{"aria-label":`Download ${e.title}`,onClick:()=>p(e.file_url),disabled:!e.file_url,style:{background:`none`,border:`none`,cursor:e.file_url?`pointer`:`default`,color:e.file_url?J.charcoal:`#C6C6C8`,padding:4},children:(0,P.jsx)(kn,{size:15})})]},t)),u.length===0&&(0,P.jsx)(`p`,{style:{fontSize:12.5,color:J.inkSoft},children:`No documents match. Documents appear here as Krush issues them to your account.`}),(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14,fontSize:11.5,color:J.inkSoft},children:[(0,P.jsx)(Jn,{size:14}),` Tip: scan the QR on any tower or master case to open its COA and technical spec directly.`]})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Material tracking & QR code data`}),(0,P.jsx)(`p`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:0},children:`Every raw material and production run carries a traceability barcode. The top code identifies the product and production date; the codes below it identify the raw materials used in that run â so any case in your warehouse traces back to its inputs.`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(240px, 1fr))`,gap:20,alignItems:`end`,padding:`8px 0 4px`},children:[(0,P.jsx)(So,{code:`NATURAL-98-26-9.2-20-05-26`,label:`Product · size · production date`}),(0,P.jsx)(So,{code:`122A00006V-20-01-26`,label:`Raw material · paper lot`}),(0,P.jsx)(So,{code:`32133479101221-27-03-26`,label:`Raw material · entry date`})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:34,flexWrap:`wrap`,marginTop:18,paddingTop:16,borderTop:`1px solid ${J.line}`},children:[(0,P.jsx)(Co,{label:`C O A`,sub:`Certificate of Analysis`}),(0,P.jsx)(Co,{label:`T E C H`,sub:`Technical drawing`}),(0,P.jsx)(`p`,{style:{fontSize:11.5,color:J.inkSoft,margin:0,flex:`1 1 220px`,alignSelf:`center`},children:`Product data is printed on every tower for your QA team â from Certificates of Analysis to technical drawings, at your operations team's fingertips.`})]})]}),s&&(0,P.jsx)(`div`,{onClick:()=>c(null),style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.72)`,zIndex:1e3,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:24},children:(0,P.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:{background:`#fff`,width:`min(1100px, 100%)`,height:`min(900px, 100%)`,borderRadius:6,display:`flex`,flexDirection:`column`,overflow:`hidden`,boxShadow:`0 20px 60px rgba(0,0,0,0.4)`}
174,children:[(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,padding:`10px 14px`,borderBottom:`1px solid ${J.line}`,background:J.bg},children:[(0,P.jsx)(Mn,{size:15,color:J.inkSoft}),(0,P.jsx)(`div`,{style:{fontSize:13,fontWeight:600,flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:s.name}),(0,P.jsxs)(`a`,{href:s.url,target:`_blank`,rel:`noopener`,download:!0,style:{display:`inline-flex`,alignItems:`center`,gap:6,fontSize:11.5,fontWeight:600,color:J.charcoal,textDecoration:`none`,border:`1px solid ${J.line}`,padding:`5px 10px`,borderRadius:4},children:[(0,P.jsx)(kn,{size:13}),` Download`]}),(0,P.jsx)(`button`,{onClick:()=>c(null),"aria-label":`Close preview`,style:{background:`none`,border:`none`,cursor:`pointer`,color:J.ink,padding:4},children:(0,P.jsx)(lr,{size:18})})]}),(0,P.jsx)(`div`,{style:{flex:1,background:`#1c1c1e`,overflow:`auto`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:s.kind===`image`?(0,P.jsx)(`img`,{src:s.url,alt:s.name,style:{maxWidth:`100%`,maxHeight:`100%`,objectFit:`contain`}}):(s.kind,(0,P.jsx)(`iframe`,{src:s.url,title:s.name,style:{width:`100%`,height:`100%`,border:`none`,background:`#fff`}}))})]})})]})}function Oo({invoices:e,onPay:t}){let n=e.filter(e=>e.status!==`Paid`).reduce((e,t)=>e+t.amount,0),r=e.filter(e=>e.status===`Overdue`).reduce((e,t)=>e+t.amount,0);return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(200px, 1fr))`,gap:14,marginBottom:16},children:[[`Total outstanding`,Y(n),J.ink],[`Overdue`,Y(r),r?J.bad:J.ink],[`Terms`,`NET 30`,J.ink]].map(([e,t,n])=>(0,P.jsxs)(X,{style:{padding:18},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,color:J.inkSoft},children:e}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:25,fontWeight:600,marginTop:8,color:n},children:t})]},e))}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{action:(0,P.jsx)(dr,{rows:e,filename:`invoices.csv`}),children:`Invoices`}),(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(Q,{children:`Invoice`}),(0,P.jsx)(Q,{children:`Issued`}),(0,P.jsx)(Q,{children:`Due`}),(0,P.jsx)(Q,{right:!0,children:`Amount`}),(0,P.jsx)(Q,{children:`Status`}),(0,P.jsx)(Q,{right:!0,children:`Pay`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)($,{mono:!0,children:e.id}),(0,P.jsx)($,{mono:!0,children:e.date}),(0,P.jsx)($,{mono:!0,children:e.due}),(0,P.jsx)($,{right:!0,mono:!0,children:Y(e.amount)}),(0,P.jsx)($,{children:(0,P.jsx)(_o,{label:e.status})}),(0,P.jsx)($,{right:!0,children:e.status!==`Paid`&&(0,P.jsx)(yo,{ghost:!0,small:!0,onClick:()=>t(e),children:`Pay now`})})]},e.id))})]})})]})]})}function ko({order:e,onReceive:t,coa:n,onDownloadCoa:r}){let i=(e,t)=>{let n=new Date(e);return n.setDate(n.getDate()+t),n.toISOString().slice(0,10)},a=e.flow||`cone`,o=a===`sample`?to:a===`filters`?no:io;return(0,P.jsxs)(X,{style:{borderTop:`2px solid ${J.charcoal}`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:12,flexWrap:`wrap`,marginBottom:6},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`caps`,style:{fontSize:12.5},children:[`Track & trace â `,(0,P.jsx)(`span`,{className:`mono`,style:{letterSpacing:0},children:e.id})]}),(0,P.jsxs)(`div`,{style:{fontSize:12.5,color:J.inkSoft,marginTop:4},children:[e.items,` · placed `,e.date]}),e.lot&&(0,P.jsx)(`div`,{style:{marginTop:6},children:(0,P.jsx)(vo,{code:e.lot})})]}),(0,P.jsxs)(`div`,{style:{textAlign:`right`},children:[(0,P.jsx)(_o,{label:e.status}),e.eta&&!e.receivedAt&&(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:J.inkSoft,marginTop:6},children:[`EST. DELIVERY `,e.eta]}),n&&(0,P.jsx)(`div`,{style:{marginTop:8},children:(0,P.jsxs)(yo,{small:!0,onClick:()=>r?.(n),children:[(0,P.jsx)(kn,{size:13}),` Download COA`]})})]})]}),a===`cone`&&e.stage===2&&(0,P.jsxs)(`div`,{style:{display:`flex`,gap:10,alignItems:`flex-start`,background:J.warnBg,borderRadius:4,padding:`12px 14px`,margin:`10px 0 4px`},children:[(0,P.jsx)(Un,{size:15,color:J.warn,style:{flexShrink:0,marginTop:1}}),(0,P.jsxs)(`div`,{style:{fontSize:12.5,color:J.warn},children:[(0,P.jsxs)(`span`,{className:`mono`,style:{fontWeight:600},children:[e.queueAhead,` production run`,e.queueAhead===1?``:`s`]}),` ahead of yours on the automated line.`,e.lineStart&&(0,P.jsxs)(P.Fragment,{children:[` Estimated line start: `,(0,P.jsx)(`span`,{className:`mono`,style:{fontWeight:600},children:e.lineStart}),`.`]}),` Position updates as runs complete.`]})]}),(0,P.jsx)(`div`,{style:{marginTop:12},children:o.map((a,s)=>{let c=s<e.stage,l=s===e.stage;return(0,P.jsxs)(`div`,{style:{display:`flex`,gap:12},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`},children:[(0,P.jsx)(`span`,{style:{width:14,height:14,borderRadius:`50%`,flexShrink:0,marginTop:2,background:c?J.charcoal:`#fff`,border:`2px solid ${c||l?J.charcoal:J.line}`,boxShadow:l?`0 0 0 3px ${J.silver}`:`none`}}),s<o.length-1&&(0,P.jsx)(`span`,{style:{width:2,flex:1,minHeight:18,background:c?J.charcoal:J.line}})]}),(0,P.jsxs)(`div`,{style:{paddingBottom:s<o.length-1?14:0,opacity:c||l?1:.45},children:[(0,P.jsxs)(`div`,{style:{fontSize:13,fontWeight:l?700:600,display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`},children:[a.label,l&&(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:9.5,fontWeight:600,color:J.charcoal,background:J.silver,padding:`2px 6px`,borderRadius:3,letterSpacing:`0.08em`},children:`CURRENT`})]}),(0,P.jsx)(`div`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:2},children:a.desc}),a.id===`s-tph`&&e.tphAt&&(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10.5,color:J.good,marginTop:4},children:[`SENT TO `,Qa,` · `,e.tphAt,e.artwork?` · ${e.artwork}`:``]}),l&&a.id===`production`&&(0,P.jsxs)(`div`,{style:{marginTop:8,maxWidth:320},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:10.5,marginBottom:4},children:[(0,P.jsx)(`span`,{className:`mono`,style:{color:J.inkSoft},children:`RUN PROGRESS`}),(0,P.jsxs)(`span`,{className:`mono`,style:{fontWeight:600},children:[e.pct,`%`]})]}),(0,P.jsx)(`div`,{style:{height:6,background:J.silver,borderRadius:3,overflow:`hidden`},children:(0,P.jsx)(`div`,{style:{width:`${e.pct}
174%`,height:`100%`,background:J.charcoal,transition:`width .3s`}})})]}),l&&a.id===`transit`&&e.carrier&&(0,P.jsxs)(`div`,{style:{marginTop:8,display:`flex`,flexDirection:`column`,gap:8,alignItems:`flex-start`},children:[(0,P.jsxs)(`span`,{className:`mono`,style:{fontSize:11.5},children:[e.carrier,` · `,(0,P.jsx)(`span`,{style:{fontWeight:600},children:e.tracking})]}),(0,P.jsxs)(yo,{small:!0,onClick:()=>t(e.id),children:[(0,P.jsx)(wn,{size:13}),` Confirm receipt`]}),(0,P.jsx)(`span`,{style:{fontSize:10.5,color:J.inkSoft},children:`Confirming receipt starts your COA clock â results are issued 5 days after arrival.`})]}),l&&a.id===`delivered`&&e.receivedAt&&(0,P.jsxs)(`div`,{style:{marginTop:8,background:J.goodBg,borderRadius:4,padding:`10px 12px`,fontSize:11.5,color:J.good,maxWidth:420},children:[`Received `,e.receivedAt,`. COA for lot `,e.lot?(0,P.jsx)(`span`,{className:`mono`,style:{fontWeight:600},children:e.lot}):`(assigned at production)`,` expected by`,` `,(0,P.jsx)(`span`,{className:`mono`,style:{fontWeight:600},children:i(e.receivedAt,5)}),` â it will appear in COAs & Documents automatically.`]}),l&&a.id===`delivered`&&e.receivedAt&&(0,P.jsx)(Ao,{receivedAt:e.receivedAt,coa:n,onDownloadCoa:r,addDays:i})]})]},a.id)})})]})}function Ao({receivedAt:e,coa:t,onDownloadCoa:n,addDays:r}){let i=new Date().toISOString().slice(0,10),a=Math.max(0,Math.floor((new Date(i)-new Date(e))/864e5)),o=(t?.status||``).toLowerCase(),s=!!t?.file_url,c=0;a>=1&&(c=1),(s||o===`ready`||o===`issued`||o===`sent`)&&(c=2),o===`sent`&&(c=3);let l=[{id:`requested`,label:`Requested`,desc:`COA request opened on arrival.`,date:e},{id:`generating`,label:`Generating`,desc:`Lab preparing certificate of analysis.`,date:r(e,1)},{id:`ready`,label:`Ready`,desc:`COA issued and available to download.`,date:t?.issued_at?.slice(0,10)||r(e,4)},{id:`sent`,label:`Sent`,desc:`Delivered to your COAs & Documents.`,date:r(e,5)}];return(0,P.jsxs)(`div`,{style:{marginTop:10,border:`1px solid ${J.line}`,borderRadius:4,padding:`12px 14px`,maxWidth:460},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`,marginBottom:10},children:[(0,P.jsx)(`span`,{className:`caps`,style:{fontSize:10.5,letterSpacing:`0.1em`,color:J.charcoal},children:`COA STATUS · 5-DAY WINDOW`}),(0,P.jsxs)(`span`,{className:`mono`,style:{fontSize:10,color:J.inkSoft},children:[`DAY `,Math.min(a,5),` / 5`]})]}),(0,P.jsx)(`div`,{style:{display:`flex`,gap:4,marginBottom:10},children:[0,1,2,3].map(e=>(0,P.jsx)(`div`,{style:{flex:1,height:4,borderRadius:2,background:e<=c?J.charcoal:J.line}},e))}),l.map((e,t)=>{let n=t<c,r=t===c;return(0,P.jsxs)(`div`,{style:{display:`flex`,gap:10,alignItems:`flex-start`,padding:`4px 0`,opacity:n||r?1:.5},children:[(0,P.jsx)(`span`,{style:{width:10,height:10,borderRadius:`50%`,flexShrink:0,marginTop:4,background:n?J.charcoal:`#fff`,border:`2px solid ${n||r?J.charcoal:J.line}`}}),(0,P.jsxs)(`div`,{style:{flex:1},children:[(0,P.jsxs)(`div`,{style:{fontSize:12,fontWeight:r?700:600,display:`flex`,justifyContent:`space-between`,gap:8},children:[(0,P.jsxs)(`span`,{children:[e.label,r&&(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:9,fontWeight:600,color:J.charcoal,background:J.silver,padding:`1px 5px`,borderRadius:3,letterSpacing:`0.08em`,marginLeft:6},children:`CURRENT`})]}),(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10.5,color:J.inkSoft,fontWeight:400},children:e.date})]}),(0,P.jsx)(`div`,{style:{fontSize:11,color:J.inkSoft,marginTop:1},children:e.desc})]})]},e.id)}),c>=2&&t&&(0,P.jsx)(`div`,{style:{marginTop:10},children:(0,P.jsxs)(yo,{small:!0,onClick:()=>n?.(t),children:[(0,P.jsx)(kn,{size:13}),` Download COA`]})})]})}function jo({cart:e,setCart:t,orders:n,onCheckout:r,onReceive:i,filterBank:a,onPrepayFilters:s,initialPrintFilters:c,coas:l=[]}){let[u,d]=(0,h.useState)(n.find(e=>e.stage<8)?.id||null),[f,p]=(0,h.useState)(!!c),[m,g]=(0,h.useState)(1),_=n.find(e=>e.id===u),v=e=>e&&l.find(t=>t.file_url&&t.status!==`Pending`&&(e.lot&&t.lot===e.lot||e.id&&(t.notes||``).includes(e.id)))||null,y=async e=>{if(!e?.file_url)return;let t=e.file_url;if(!/^https?:\/\//.test(t)){let{data:e,error:n}
174=await o.storage.from(`coa-docs`).createSignedUrl(t,3600);if(n){alert(n.message);return}t=e?.signedUrl}t&&window.open(t,`_blank`,`noopener`)},b=Ga.flatMap(e=>e.papers.map(t=>({key:e.id+`|`+t,p:e,paper:t}))),x=Object.entries(e).reduce((e,[t,n])=>{let r=b.find(e=>e.key===t);return e+(r?r.p.palletUnits*n:0)},0),S=Object.entries(e).reduce((e,[t,n])=>{let r=b.find(e=>e.key===t);return e+(r?r.p.palletUnits*r.p.unitPrice*n:0)},0),C=f?Math.min(a,x):0,w=f?x-C:0,T=w*qa,E=f&&w>0?Ja:0,D=S+T,O=Object.values(e).reduce((e,t)=>e+t,0),k=(e,n)=>t(t=>{let r={...t,[e]:Math.max(0,(t[e]||0)+n)};return r[e]||delete r[e],r});return(0,P.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Place a new order`}),(0,P.jsx)(`p`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:0},children:`Ordered by the pallet â 24 cases · 144 towers per pallet. Minimum order: 1 full pallet. Priced at $0.05 CAD/cone blank, $0.06 CAD/cone custom printed. 12-month subscription: 10% off.`}),(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(Q,{children:`Format`}),(0,P.jsx)(Q,{children:`Paper`}),(0,P.jsx)(Q,{children:`Per pallet`}),(0,P.jsx)(Q,{right:!0,children:`Per cone`}),(0,P.jsx)(Q,{right:!0,children:`Pallet price (CAD)`}),(0,P.jsx)(Q,{right:!0,children:`Pallets`})]})}),(0,P.jsx)(`tbody`,{children:b.map(t=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)($,{children:[(0,P.jsx)(`span`,{style:{fontWeight:600},children:t.p.name}),` `,(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10.5,color:J.inkSoft},children:t.p.drawing})]}),(0,P.jsx)($,{children:(0,P.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:7},children:[(0,P.jsx)(`span`,{style:{width:13,height:13,borderRadius:`50%`,background:ro[t.paper],border:`1px solid #00000022`}}),t.paper]})}),(0,P.jsxs)($,{mono:!0,children:[t.p.palletUnits.toLocaleString(),` cones · 24 cases`]}),(0,P.jsx)($,{right:!0,mono:!0,children:Y(t.p.unitPrice)}),(0,P.jsx)($,{right:!0,mono:!0,children:Y(t.p.palletUnits*t.p.unitPrice)}),(0,P.jsx)($,{right:!0,children:(0,P.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:8},children:[(0,P.jsx)(`button`,{onClick:()=>k(t.key,-1),"aria-label":`Decrease`,style:{width:25,height:25,borderRadius:4,border:`1px solid ${J.line}`,background:`#fff`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,P.jsx)(Hn,{size:12})}),(0,P.jsx)(`span`,{className:`mono`,style:{width:26,textAlign:`center`,fontSize:13},children:e[t.key]||0}),(0,P.jsx)(`button`,{onClick:()=>k(t.key,1),"aria-label":`Increase`,style:{width:25,height:25,borderRadius:4,border:`1px solid ${J.line}`,background:`#fff`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,P.jsx)(qn,{size:12})})]})})]},t.key))})]})}),(0,P.jsxs)(`div`,{style:{marginTop:16,border:`1px solid ${J.line}`,borderRadius:4,padding:14,background:J.bg},children:[(0,P.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,cursor:`pointer`},children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked),style:{marginTop:3}}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{style:{fontSize:13,fontWeight:600},children:`Add custom printed filters`}),(0,P.jsxs)(`span`,{className:`mono`,style:{fontSize:11,color:J.inkSoft,marginLeft:8},children:[`+$0.01/cone · +`,Ja,` days printing & shipping`]}),(0,P.jsx)(`span`,{style:{display:`block`,fontSize:11.5,color:J.inkSoft,marginTop:3},children:`Your approved filter artwork, printed with FDA food-safe inks â included at no additional cost. Pre-purchased filter stock is applied first and removes the added lead time.`})]})]}),f&&x>0&&(0,P.jsxs)(`div`,{style:{marginTop:10,paddingTop:10,borderTop:`1px solid ${J.line}`,display:`grid`,gap:4},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:12},children:[(0,P.jsx)(`span`,{style:{color:J.inkSoft},children:`Cones in this order`}
174),(0,P.jsx)(`span`,{className:`mono`,children:x.toLocaleString()})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:12},children:[(0,P.jsx)(`span`,{style:{color:J.inkSoft},children:`Covered by your filter bank`}),(0,P.jsx)(`span`,{className:`mono`,style:{color:C>0?J.good:J.inkSoft},children:C.toLocaleString()})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:12},children:[(0,P.jsx)(`span`,{style:{color:J.inkSoft},children:`To be printed for this order`}),(0,P.jsxs)(`span`,{className:`mono`,children:[w.toLocaleString(),` · `,(0,P.jsx)(`b`,{children:`included`})]})]}),(0,P.jsx)(`div`,{style:{marginTop:6,borderRadius:4,padding:`8px 10px`,fontSize:11.5,fontWeight:600,background:E?J.warnBg:J.goodBg,color:E?J.warn:J.good},children:E?`Lead time: +${Ja} days for filter printing & shipping before cone production.`:`Fully covered by pre-purchased filters â no added lead time.`})]})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,alignItems:`center`,gap:16,marginTop:16,flexWrap:`wrap`},children:[(0,P.jsxs)(`div`,{style:{fontSize:12.5,color:J.inkSoft},children:[O,` pallet`,O===1?``:`s`,O>0&&(0,P.jsxs)(`span`,{className:`mono`,style:{marginLeft:8,fontSize:10.5,color:J.inkSoft,background:J.silver,padding:`2px 7px`,borderRadius:3},children:[(O*Ka).toLocaleString(),` CASES`]}),f&&w>0&&(0,P.jsx)(`span`,{className:`mono`,style:{marginLeft:8,fontSize:10.5,color:J.good,background:J.goodBg,padding:`2px 7px`,borderRadius:3},children:`PRINTED FILTERS INCL.`}),(0,P.jsx)(`span`,{className:`mono`,style:{fontWeight:600,color:J.ink,marginLeft:10},children:Y(D)})]}),(0,P.jsxs)(yo,{disabled:!O,onClick:()=>r(D,{printFilters:f,conesTotal:x,covered:C,toPrint:w,addedDays:E}),children:[(0,P.jsx)($n,{size:15}),` Review & pay`]})]})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{action:(0,P.jsxs)(`span`,{className:`mono`,style:{fontSize:11,color:a>0?J.good:J.inkSoft,background:a>0?J.goodBg:J.silver,padding:`4px 9px`,borderRadius:3,fontWeight:600},children:[`BANK BALANCE `,a.toLocaleString(),` FILTERS`]}),children:`Filter bank â pre-purchase printed filters`}),(0,P.jsxs)(`p`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:0},children:[`Buy printed filters ahead at the same `,Y(qa),`/unit cost. They're produced once (`,Ja,`-day print & ship), then stocked at Krush â orders that draw on your bank skip the printing lead time entirely.`]}),(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:14,flexWrap:`wrap`},children:[(0,P.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:8},children:[(0,P.jsx)(`button`,{onClick:()=>g(e=>Math.max(1,e-1)),"aria-label":`Decrease filter quantity`,style:{width:25,height:25,borderRadius:4,border:`1px solid ${J.line}`,background:`#fff`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,P.jsx)(Hn,{size:12})}),(0,P.jsx)(`span`,{className:`mono`,style:{minWidth:90,textAlign:`center`,fontSize:13},children:(m*Ya).toLocaleString()}),(0,P.jsx)(`button`,{onClick:()=>g(e=>e+1),"aria-label":`Increase filter quantity`,style:{width:25,height:25,borderRadius:4,border:`1px solid ${J.line}`,background:`#fff`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,P.jsx)(qn,{size:12})})]}),(0,P.jsxs)(`span`,{className:`mono`,style:{fontSize:12.5,fontWeight:600},children:[`= `,Y(m*Ya*qa)]}),(0,P.jsx)(yo,{ghost:!0,small:!0,onClick:()=>s(m*Ya),children:`Pre-purchase filters`})]})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{action:(0,P.jsx)(dr,{rows:n,filename:`orders.csv`}),children:`Order history`}),(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(Q,{children:`Order`}),(0,P.jsx)(Q,{children:`Date`}),(0,P.jsx)(Q,{children:`Items`}),(0,P.jsx)(Q,{right:!0,children:`Total`}),(0,P.jsx)(Q,{children:`Status`}),(0,P.jsx)(Q,{right:!0,children:`COA`}),(0,P.jsx)(Q,{right:!0,children:`Track`})]})}),(0,P.jsx)(`tbody`,{children:n.map(e=>{let t=v(e);return(0,P.jsxs)(`tr`,{style:{background:e.id===u?J.silver:`transparent`},children:[(0,P.jsx)($,{mono:!0,children:e.id}),(0,P.jsx)($,{mono:!0,children:e.date}),(0,P.jsx)($,{children:e.items}),(0,P.jsx)($,{right:!0,mono:!0,children:Y(e.total)}),(0,P.jsx)($,{children:(0,P.jsx)(_o,{label:e.status})}),(0,P.jsx)($,{right:!0,children:t?(0,P.jsxs)(yo,{ghost:!0,small:!0,onClick:()=>y(t),children:[(0,P.jsx)(kn,{size:13}),` COA`]}):(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10.5,color:J.inkSoft},children:e.receivedAt?`PENDING`:`â`})}),(0,P.jsx)($,{right:!0,children:(0,P.jsx)(yo,{ghost:!0,small:!0,onClick:()=>d(e.id===u?null:e.id),children:e.id===u?`Hide`:`Track`})})]},e.id)})})]})})]}),_&&(0,P.jsx)(ko,{order:_,onReceive:i,coa:v(_),onDownloadCoa:y})]})}function Mo({orders:e,filterBank:t}){let[n,r]=(0,h.useState)(18e4),[i,a]=(0,h.useState)(6e4),[o,s]=(0,h.useState)(!0),c=new Date,l=e=>{let t=new Date(c);return t.setDate(t.getDate()+e),t.toISOString().slice(0,10)},u=e.filter(e=>(e.flow||`cone`)===`cone`&&e.units),d=u.filter(e=>e.stage<8&&e.eta).map(e=>({...e,week:Math.min(16,Math.max(1,Math.ceil((new Date(e.eta)-c)/6048e5)))})),f=Array(17).fill(0);
174d.forEach(e=>{f[e.week]+=e.units});let p=[n],m=null;for(let e=1;e<=16;e++){let t=p[e-1]+f[e]-i;t<=0&&m===null&&(m=e),p.push(Math.max(0,t))}let g=o&&t<115200?Ja:0,_=21+g,v=Math.ceil(_/7)*i,y=m?l(m*7):null,b=m?l(Math.max(0,m*7-_)):null,x=m&&m*7-_<=7,S=u.filter(e=>e.stage<=5&&e.stage>=0&&!e.receivedAt).reduce((e,t)=>e+t.units,0),C=u.filter(e=>e.stage===6||e.stage===7).reduce((e,t)=>e+t.units,0),w=e=>e>=1e3?Math.round(e/1e3).toLocaleString()+`k`:e.toLocaleString(),T=Math.max(...p,v,i)*1.15||1,E=e=>50+e/16*654,D=e=>216-e/T*200,O=p.map((e,t)=>`${t?`L`:`M`}${E(t).toFixed(1)} ${D(e).toFixed(1)}`).join(` `),k=O+` L${E(16).toFixed(1)} ${D(0)} L${E(0).toFixed(1)} ${D(0)} Z`,ee=(e,t)=>(0,P.jsx)(`input`,{type:`number`,min:`0`,step:`10000`,value:e,className:`mono`,onChange:e=>t(Math.max(0,Number(e.target.value)||0)),style:{width:120,padding:`9px 10px`,borderRadius:4,border:`1px solid ${J.line}`,fontSize:13,background:J.bg}}),A=[{icon:In,label:`Filter bank`,value:t,note:`printed & stocked`},{icon:Un,label:`In production`,value:S,note:`on the line at Krush`},{icon:or,label:`In transit`,value:C,note:`with carrier`},{icon:Ln,label:`Your stock`,value:n,note:`on hand at your facility`},{icon:ir,label:`Consumption`,value:i,note:`cones per week`,perWeek:!0}];return(0,P.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(200px, 1fr))`,gap:14},children:[(0,P.jsxs)(X,{style:{padding:18},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,color:J.inkSoft},children:`Weeks of cover`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:24,fontWeight:600,marginTop:8},children:m||`16+`}),(0,P.jsx)(`div`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:2},children:`incl. incoming orders`})]}),(0,P.jsxs)(X,{style:{padding:18},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,color:J.inkSoft},children:`Projected run-out`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:24,fontWeight:600,marginTop:8,color:m?J.bad:J.good},children:y||`Covered`}),(0,P.jsx)(`div`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:2},children:m?`at current burn rate`:`beyond the 16-week horizon`})]}),(0,P.jsxs)(X,{style:{padding:18},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,color:J.inkSoft},children:`Order by`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:24,fontWeight:600,marginTop:8,color:x?J.bad:J.ink},children:b||`â`}),(0,P.jsx)(`div`,{style:{fontSize:11.5,color:x?J.bad:J.inkSoft,marginTop:2},children:b?`${_}-day lead time${g?` incl. filter printing`:``}`:`no reorder needed yet`})]}),(0,P.jsxs)(X,{style:{padding:18},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,color:J.inkSoft},children:`Incoming supply`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:24,fontWeight:600,marginTop:8},children:w(d.reduce((e,t)=>e+t.units,0))}),(0,P.jsxs)(`div`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:2},children:[d.length,` order`,d.length===1?``:`s`,` en route`]})]})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Your consumption profile`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:24,flexWrap:`wrap`,alignItems:`flex-end`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`caps`,style:{fontSize:10,display:`block`,marginBottom:6},children:`Cones on hand`}),ee(n,r)]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`caps`,style:{fontSize:10,display:`block`,marginBottom:6},children:`Weekly consumption`}),ee(i,a)]}),(0,P.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12.5,paddingBottom:10,cursor:`pointer`},children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`My orders use custom printed filters`]}),o&&(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:10.5,paddingBottom:12,color:g?J.warn:J.good},children:g?`FILTER BANK LOW â +${Ja} DAYS ADDED TO LEAD TIME`:`FILTER BANK COVERS REORDER â NO ADDED LEAD TIME`})]})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Flowthrough â where your cones are right now`}),(0,P.jsx)(`div`,{style:{display:`flex`,alignItems:`stretch`,gap:8,flexWrap:`wrap`},children:A.map((e,t)=>(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flex:`1 1 150px`},children:[(0,P.jsxs)(`div`,{style:{flex:1,border:`1px solid ${J.line}`,borderRadius:4,padding:`12px 12px`,background:t===A.length-1?J.silver:`#fff`,minWidth:130},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7},children:[(0,P.jsx)(e.icon,{size:14,color:J.inkSoft}),(0,P.jsx)(`span`,{className:`caps`,style:{fontSize:8.5,color:J.inkSoft},children:e.label})]}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:19,fontWeight:600,marginTop:6}
174,children:[w(e.value),e.perWeek&&(0,P.jsx)(`span`,{style:{fontSize:11,color:J.inkSoft},children:`/wk`})]}),(0,P.jsx)(`div`,{style:{fontSize:10.5,color:J.inkSoft,marginTop:2},children:e.note})]}),t<A.length-1&&(0,P.jsx)(vn,{size:15,color:J.inkSoft,style:{flexShrink:0}})]},e.label))})]}),(0,P.jsxs)(X,{children:[(0,P.jsxs)(Z,{action:(0,P.jsxs)(`div`,{style:{display:`flex`,gap:14,fontSize:10.5,color:J.inkSoft,alignItems:`center`,flexWrap:`wrap`},children:[(0,P.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:5},children:[(0,P.jsx)(`span`,{style:{width:16,height:2,background:J.charcoal,display:`inline-block`}}),` projected stock`]}),(0,P.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:5},children:[(0,P.jsx)(`span`,{style:{width:16,height:0,borderTop:`2px dashed ${J.warn}`,display:`inline-block`}}),` reorder point`]}),(0,P.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:5},children:[(0,P.jsx)(`span`,{style:{width:0,height:0,borderLeft:`5px solid transparent`,borderRight:`5px solid transparent`,borderBottom:`7px solid ${J.good}`,display:`inline-block`}}),` delivery`]})]}),children:[16,`-week stock projection`]}),(0,P.jsxs)(`svg`,{viewBox:`0 0 720 250`,style:{width:`100%`,display:`block`},role:`img`,"aria-label":`Stock projection chart`,children:[[.25,.5,.75,1].map(e=>(0,P.jsxs)(`g`,{children:[(0,P.jsx)(`line`,{x1:50,x2:704,y1:D(T*e),y2:D(T*e),stroke:J.line,strokeWidth:`1`}),(0,P.jsx)(`text`,{x:44,y:D(T*e)+3,textAnchor:`end`,fontFamily:`IBM Plex Mono`,fontSize:`9`,fill:J.inkSoft,children:w(Math.round(T*e))})]},e)),(0,P.jsx)(`line`,{x1:50,x2:704,y1:D(0),y2:D(0),stroke:J.ink,strokeWidth:`1.5`}),[0,4,8,12,16].map(e=>(0,P.jsx)(`text`,{x:E(e),y:236,textAnchor:`middle`,fontFamily:`IBM Plex Mono`,fontSize:`9`,fill:J.inkSoft,children:l(e*7).slice(5)},e)),(0,P.jsx)(`line`,{x1:50,x2:704,y1:D(v),y2:D(v),stroke:J.warn,strokeWidth:`1.5`,strokeDasharray:`6 4`}),(0,P.jsxs)(`text`,{x:704,y:D(v)-5,textAnchor:`end`,fontFamily:`IBM Plex Mono`,fontSize:`9`,fill:J.warn,children:[`REORDER AT `,w(v)]}),(0,P.jsx)(`path`,{d:k,fill:J.silver,opacity:`0.7`}),(0,P.jsx)(`path`,{d:O,fill:`none`,stroke:J.charcoal,strokeWidth:`2`}),d.map(e=>(0,P.jsxs)(`g`,{children:[(0,P.jsx)(`path`,{d:`M${E(e.week)-5} ${D(0)+12} L${E(e.week)+5} ${D(0)+12} L${E(e.week)} ${D(0)+4} Z`,fill:J.good}),(0,P.jsxs)(`title`,{children:[e.id,` · `,w(e.units),` cones · ETA `,e.eta]})]},e.id)),m&&(0,P.jsxs)(`g`,{children:[(0,P.jsx)(`line`,{x1:E(m),x2:E(m),y1:16,y2:D(0),stroke:J.bad,strokeWidth:`1.5`,strokeDasharray:`3 3`}),(0,P.jsxs)(`text`,{x:E(m)+4,y:26,fontFamily:`IBM Plex Mono`,fontSize:`9`,fill:J.bad,children:[`RUN-OUT `,y]})]})]}),(0,P.jsx)(`div`,{style:{marginTop:12,borderRadius:4,padding:`10px 14px`,fontSize:12.5,fontWeight:600,background:m?x?J.badBg:J.warnBg:J.goodBg,color:m?x?J.bad:J.warn:J.good},children:m?`At ${w(i)}/week you run out around ${y}. With a ${_}-day lead time, place your next order by ${b}${x?` â that's inside the next week.`:`.`}`:`Incoming orders keep you stocked past the 16-week horizon at ${w(i)}/week. No action needed.`})]})]})}function No({company:e,orders:t,invoices:n,filterBank:r}){let[i,a]=(0,h.useState)([{role:`assistant`,content:`Hi ${e||`there`} â I'm Kai, your Krush account concierge. I can see your live orders, COA timelines, filter bank, and balance, and I know our cones inside out. What can I help with today?`}]),[o,s]=(0,h.useState)(``),[c,l]=(0,h.useState)(!1),[u,d]=(0,h.useState)(!1),f=(0,h.useRef)(null);(0,h.useEffect)(()=>{f.current?.scrollIntoView({behavior:`smooth`})},[i,c]);let p=JSON.stringify({client:e,today:new Date().toISOString().slice(0,10),filterBankBalance:r,orders:t.map(e=>({id:e.id,type:e.flow||`cone`,placed:e.date,items:e.items,totalCAD:e.total,status:e.status,stageIndex:e.stage,stageName:((e.flow===`sample`?to:e.flow===`filters`?no:io)[e.stage]||{}).label,productionRunsAhead:e.stage===2?e.queueAhead:void 0,estLineStart:e.lineStart||void 0,eta:e.eta,lot:e.lot||void 0,runProgressPct:e.stage===3?e.pct:void 0,carrier:e.carrier||void 0,tracking:e.tracking||void 0,receivedAt:e.receivedAt||void 0})),invoices:n.map(e=>({id:e.id,issued:e.date,due:e.due,amountCAD:e.amount,status:e.status}))}),m=async e=>{let t=(e??o).trim();if(!t||c)return;s(``),d(!1);let n=[...i,{role:`user`,content:t}];a(n),l(!0);try{let{reply:e}=await g({data:{accountContext:p,messages:n.slice(-14).map(e=>({role:e.role,content:e.content}))}});a(t=>[...t,{role:`assistant`,content:e||`I hit a snag generating that â mind rephrasing?`}])}catch{d(!0),a(e=>[...e,{role:`assistant`,content:`I couldn't reach the assistant service just now. Try again in a moment â or email [email protected]
174a / call 1-800-420-9650 and a human will jump in.`}])}l(!1)};return(0,P.jsxs)(`div`,{style:{display:`grid`,gap:14},children:[(0,P.jsxs)(X,{style:{padding:0,display:`flex`,flexDirection:`column`,height:`min(72vh, 640px)`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`14px 18px`,borderBottom:`1px solid ${J.line}`},children:[(0,P.jsx)(`div`,{className:`marble`,style:{width:36,height:36,borderRadius:`50%`,border:`1px solid ${J.line}`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,P.jsx)(`span`,{className:`script`,style:{fontSize:17,fontWeight:700,color:J.charcoal},children:`K`})}),(0,P.jsxs)(`div`,{style:{flex:1},children:[(0,P.jsx)(`div`,{style:{fontSize:13.5,fontWeight:600},children:`Kai â your Krush concierge`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:10,color:c?J.warn:J.good},children:c?`TYPINGâ¦`:`ONLINE · KNOWS YOUR LIVE ACCOUNT`})]}),(0,P.jsxs)(`a`,{href:`tel:18004209650`,style:{display:`flex`,alignItems:`center`,gap:6,fontSize:11.5,color:J.inkSoft,textDecoration:`none`},children:[(0,P.jsx)(Kn,{size:13}),` 1-800-420-9650`]})]}),(0,P.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:18,dis
174play:`flex`,flexDirection:`column`,gap:12},children:[i.map((e,t)=>(0,P.jsx)(`div`,{style:{alignSelf:e.role===`user`?`flex-end`:`flex-start`,maxWidth:`78%`},children:(0,P.jsx)(`div`,{style:{padding:`10px 14px`,borderRadius:8,fontSize:13.5,lineHeight:1.55,whiteSpace:`pre-wrap`,background:e.role===`user`?J.charcoal:J.silver,color:e.role===`user`?`#fff`:J.ink,border:e.role===`user`?`none`:`1px solid ${J.line}`},children:e.content})},t)),c&&(0,P.jsx)(`div`,{style:{alignSelf:`flex-start`,padding:`10px 14px`,borderRadius:8,background:J.silver,border:`1px solid ${J.line}`},children:(0,P.jsx)(zn,{size:15,className:`spin`,color:J.inkSoft})}),(0,P.jsx)(`div`,{ref:f})]}),i.length<=1&&(0,P.jsx)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,padding:`0 18px 12px`},children:[`Where is my order right now?`,`When will my COA be ready?`,`Refined vs natural paper â what's the difference?`,`How do printed filters and the filter bank work?`].map(e=>(0,P.jsx)(`button`,{onClick:()=>m(e),style:{fontSize:11.5,padding:`7px 12px`,borderRadius:20,border:`1px solid ${J.line}`,background:`#fff`,cursor:`pointer`,color:J.ink},children:e},e))}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:10,padding:`12px 16px`,borderTop:`1px solid ${J.line}`},children:[(0,P.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&m(),placeholder:`Ask about your orders, COAs, specs, pricing, lead timesâ¦`,style:{flex:1,padding:`11px 13px`,borderRadius:4,border:`1px solid ${J.line}`,fontSize:13.5,background:J.bg}}),(0,P.jsxs)(yo,{small:!0,disabled:c||!o.trim(),onClick:()=>m(),children:[(0,P.jsx)(Zn,{size:13}),` Send`]})]})]}),(0,P.jsxs)(`div`,{style:{fontSize:11,color:J.inkSoft,display:`flex`,gap:6,alignItems:`flex-start`},children:[(0,P.jsx)(ar,{size:12,style:{flexShrink:0,marginTop:1}}),`Kai answers from Krush's published specs and your live account data`,u?` â the assistant service is currently unreachable`:``,`. For quotes, credit changes, or anything unresolved, your account team is at [email protected].`]})]})}function Po({coas:e,skus:t,onReorder:n,go:r}){let i=Array.isArray(t)&&t.length?t:ao,a=Wa(),[o,s]=(0,h.useState)(i[0]?.id||null);if(!i.length)return(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Your SKUs`}),(0,P.jsx)(`p`,{style:{fontSize:12.5,color:J.inkSoft,marginTop:0},children:`No SKUs on file yet. A SKU is created automatically the first time you approve artwork on a new cone configuration.`}),(0,P.jsxs)(yo,{onClick:()=>r?.(`customize`),children:[(0,P.jsx)(Wn,{size:13}),` Start in Customize`]})]});let c=i.find(e=>e.id===o)||i[0],l=Ga.find(e=>e.id===c.productId)||Ga[0],[u,d,f,p]=l.drawing.split(`/`),m=(l.unit_price_cad??l.unitPrice)+(c.printedFilter?qa:0),g=l.palletUnits*m,_=(e||[]).filter(e=>e.lot.startsWith(c.barcode.split(`-`)[0])&&e.product.includes(l.name.split(` `)[0])),v=({k:e,v:t})=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,padding:`7px 0`,borderBottom:`1px solid ${J.line}`,fontSize:12.5},children:[(0,P.jsx)(`span`,{style:{color:J.inkSoft},children:e}),(0,P.jsx)(`span`,{className:`mono`,style:{textAlign:`right`},children:t})]});return(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:a<900?`1fr`:`290px 1fr`,gap:16,alignItems:`start`},children:[(0,P.jsxs)(X,{style:{padding:14},children:[(0,P.jsx)(Z,{children:`Your SKUs`}),i.map(e=>(0,P.jsxs)(`button`,{onClick:()=>s(e.id),style:{display:`block`,width:`100%`,textAlign:`left`,padding:`11px 12px`,borderRadius:4,marginBottom:7,cursor:`pointer`,border:`1px solid ${e.id===o?J.charcoal:J.line}`,background:e.id===o?J.silver:`#fff`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:8},children:[(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:11.5,fontWeight:600},children:e.id}),e.printedFilter&&(0,P.jsx)(`span`,{className:`mono`,style:{fontSize:9,fontWeight:600,color:J.charcoal,background:J.silver,border:`1px solid ${J.line}`,padding:`2px 6px`,borderRadius:3},children:`PRINTED`})]}),(0,P.jsx)(`div`,{style:{fontSize:12.5,marginTop:4},children:e.name}
174),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10,color:J.inkSoft,marginTop:3},children:[`LAST ORDERED `,e.lastOrdered]})]},e.id)),(0,P.jsx)(`p`,{style:{fontSize:10.5,color:J.inkSoft,margin:`10px 2px 0`},children:`New SKUs are created automatically when you approve artwork on a new configuration.`})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:14},children:[(0,P.jsx)(X,{children:(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:12,flexWrap:`wrap`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:13},children:c.name}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:11,color:J.inkSoft,marginTop:5},children:[c.id,` · YOUR CODE `,c.clientCode]}),c.notes&&(0,P.jsx)(`div`,{style:{fontSize:12,color:J.inkSoft,marginTop:8,maxWidth:480},children:c.notes})]}),(0,P.jsxs)(`div`,{style:{textAlign:`right`},children:[(0,P.jsxs)(yo,{small:!0,onClick:()=>n(`${l.id}|${c.paper}`,c.defaultPallets,c.printedFilter),children:[(0,P.jsx)($n,{size:13}),` Reorder `,c.defaultPallets,` pallet`,c.defaultPallets>1?`s`:``]}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10.5,color:J.inkSoft,marginTop:8},children:[Y(g),` / PALLET`,c.printedFilter?` INCL. PRINT`:``]})]})]})}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(280px, 1fr))`,gap:14},children:[(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Specification`}),(0,P.jsx)(v,{k:`Format`,v:l.name}),(0,P.jsx)(v,{k:`Technical drawing`,v:l.drawing}),(0,P.jsx)(v,{k:`Length / diameter`,v:`${u}mm / ${f}mm`}),(0,P.jsx)(v,{k:`Filter`,v:`Folded · ${d}mm à ${p}mm`}),(0,P.jsx)(v,{k:`Gum line`,v:`Straight`}),(0,P.jsx)(v,{k:`Paper`,v:c.paper}),(0,P.jsx)(v,{k:`Basis weight`,v:`14.1 g/m²`}),(0,P.jsx)(v,{k:`Fillers / burn additives`,v:`None`}),(0,P.jsx)(v,{k:`Storage`,v:`16â24°C, stable humidity`})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Print & artwork`}),c.printedFilter?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(v,{k:`Printed filter`,v:`Yes â full colour`}),(0,P.jsx)(v,{k:`Inks`,v:`FDA food-safe`}),(0,P.jsx)(v,{k:`Approved artwork`,v:c.artwork}),(0,P.jsx)(v,{k:`Approved by`,v:c.approvedBy}),(0,P.jsx)(v,{k:`Approved on`,v:c.approvedOn}),(0,P.jsx)(v,{k:`Print upcharge`,v:`+${Y(qa)}/cone`}),(0,P.jsx)(`p`,{style:{fontSize:11,color:J.inkSoft,marginTop:10,marginBottom:0},children:`Artwork is locked to this SKU. To change it, approve a new version in Customize â a new SKU revision is created so past lots stay traceable.`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(v,{k:`Printed filter`,v:`No â standard folded`}),(0,P.jsxs)(`p`,{style:{fontSize:11.5,color:J.inkSoft,marginTop:10},children:[`Add your brand to this SKU: upload filter artwork in Customize â custom printing is +$0.01/cone (blank $0.05 â custom $0.06 CAD). Pre-purchased filter stock removes the `,Ja,`-day print lead.`]})]})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Packaging & pricing`}),(0,P.jsx)(v,{k:`Per tower`,v:`${l.tower} cones`}),(0,P.jsx)(v,{k:`Per case`,v:`${(l.tower*6).toLocaleString()} cones · 6 towers`}),(0,P.jsx)(v,{k:`Per pallet`,v:`${l.palletUnits.toLocaleString()} cones · 24 cases`}),(0,P.jsx)(v,{k:`Unit price`,v:`${Y(m)} /cone`}),(0,P.jsx)(v,{k:`Pallet price`,v:Y(g)}),(0,P.jsx)(v,{k:`Minimum order`,v:`1 full pallet`})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Traceability`}),(0,P.jsx)(So,{code:c.barcode,label:`Product · size · paper weight`}),(0,P.jsxs)(`div`,{style:{marginTop:14},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:8.5,color:J.inkSoft,marginBottom:8},children:`Recent lots on this SKU`}),_.length?_.map(e=>(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:8,padding:`7px 0`,borderBottom:`1px solid ${J.line}`},children:[(0,P.jsx)(vo,{code:e.lot}),(0,P.jsx)(_o,{label:e.status})]},e.lot)):(0,P.jsx)(`p`,{style:{fontSize:11.5,color:J.inkSoft,margin:0},children:`Lots appear here as production runs complete.`})]})]})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Activity`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:30,flexWrap:`wrap`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:8.5,color:J.inkSoft},children:`Lifetime units`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:20,fontWeight:600,marginTop:4}
174,children:c.lifetimeUnits.toLocaleString()})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:8.5,color:J.inkSoft},children:`Last ordered`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:20,fontWeight:600,marginTop:4},children:c.lastOrdered})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:8.5,color:J.inkSoft},children:`Usual order`}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:20,fontWeight:600,marginTop:4},children:[c.defaultPallets,` pallet`,c.defaultPallets>1?`s`:``]})]})]})]})]})]})}function Fo({ctx:e,onClose:t,onConfirm:n}){let[r,i]=(0,h.useState)(`card`),[a,o]=(0,h.useState)(!1);return(0,P.jsx)(`div`,{style:{position:`fixed`,inset:0,background:`rgba(30,30,32,0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:20,zIndex:50},children:(0,P.jsxs)(`div`,{style:{background:`#fff`,borderRadius:8,width:`100%`,maxWidth:430,padding:26,position:`relative`},children:[(0,P.jsx)(`button`,{onClick:t,"aria-label":`Close`,style:{position:`absolute`,top:14,right:14,background:`none`,border:`none`,cursor:`pointer`,color:J.inkSoft},children:(0,P.jsx)(lr,{size:17})}),a?(0,P.jsxs)(`div`,{style:{textAlign:`center`,padding:`24px 0`},children:[(0,P.jsx)(wn,{size:40,color:J.good}),(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:13,marginTop:12},children:`Payment received`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:14,color:J.inkSoft,marginTop:6},children:Y(e.amount)})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:13},children:e.type===`invoice`?`Pay ${e.label}`:`Checkout`}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:25,fontWeight:600,margin:`10px 0 18px`},children:Y(e.amount)}),(0,P.jsx)(`div`,{style:{display:`grid`,gap:9,marginBottom:18},children:[{id:`card`,label:`Credit / debit card`,icon:On},{id:`ach`,label:`Bank transfer (EFT / ACH)`,icon:Sn}].map(e=>(0,P.jsxs)(`button`,{onClick:()=>i(e.id),style:{display:`flex`,alignItems:`center`,gap:10,padding:`12px 14px`,borderRadius:4,cursor:`pointer`,fontSize:13.5,fontWeight:500,border:`1px solid ${r===e.id?J.charcoal:J.line}`,background:r===e.id?J.silver:`#fff`,textAlign:`left`},children:[(0,P.jsx)(e.icon,{size:16,color:r===e.id?J.charcoal:J.inkSoft}),` `,e.label]},e.id))}),r===`card`&&(0,P.jsxs)(`div`,{style:{display:`grid`,gap:9,marginBottom:18},children:[(0,P.jsx)(`input`,{"aria-label":`Card number`,placeholder:`Card number`,className:`mono`,style:{padding:`11px 12px`,borderRadius:4,border:`1px solid ${J.line}`,fontSize:13.5,background:J.bg}}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:9},children:[(0,P.jsx)(`input`,{"aria-label":`Card expiry (MM / YY)`,placeholder:`MM / YY`,className:`mono`,style:{padding:`11px 12px`,borderRadius:4,border:`1px solid ${J.line}`,fontSize:13.5,background:J.bg}}),(0,P.jsx)(`input`,{"aria-label":`Card CVC`,placeholder:`CVC`,className:`mono`,style:{padding:`11px 12px`,borderRadius:4,border:`1px solid ${J.line}`,fontSize:13.5,background:J.bg}})]})]}),r===`ach`&&(0,P.jsx)(`p`,{style:{fontSize:12.5,color:J.inkSoft,background:J.bg,padding:12,borderRadius:4,marginTop:0},children:`You'll be redirected to securely link your bank account. EFT/ACH settles in 1â3 business days.`}),(0,P.jsxs)(yo,{onClick:()=>{o(!0),setTimeout(n,1100)},children:[`Confirm `,Y(e.amount)]}),(0,P.jsx)(`div`,{style:{fontSize:10.5,color:J.inkSoft,marginTop:12}})]})]})})}function Io({reserved:e,held:t,onReserve:n,onRequestProduction:r}){let[i,a]=(0,h.useState)(Ga[0].id),o=(Ga.find(e=>e.id===i)||Ga[0]).palletUnits,[s,c]=(0,h.useState)(1),l=s*o,[u,d]=(0,h.useState)(``),[f,p]=(0,h.useState)(0),m=e-t.reduce((e,t)=>e+t.units,0),g=l*$a,_=t.reduce((e,t)=>e+t.units,0),v=Array.from(new Set(t.map(e=>e.sku))),y=e=>t.filter(t=>t.sku===e).reduce((e,t)=>e+t.units,0),b=Math.max(0,e-_),x=b>0?Math.round(b/(90/7)):0,S=x>0?Math.floor(_/x):null,C=e>0&&_/e<.2,w={padding:`8px 10px`,border:`1px solid ${J.line}`,borderRadius:4,fontSize:14,background:`#fff`},T={fontSize:11,color:J.inkSoft,letterSpacing:`0.08em`,textTransform:`uppercase`,fontWeight:600};return(0,P.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,P.jsxs)(X,{children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,gap:16,flexWrap:`wrap`,marginBottom:14},children:[(0,P.jsxs)(`div`,{style:{flex:`1 1 320px`,minWidth:0},children:[(0,P.jsx)(Z,{children:`Filter Bank`}),(0,P.jsxs)(`p`,{style:{fontSize:13,color:J.inkSoft,lineHeight:1.55,margin:0},children:[`Reserve production line time at `,(0,P.jsxs)(`b`,{style:{color:J.ink},children:[Y($a,3),`/cone`]}),`. We produce against your reservation, hold your cones at Krush, and ship on-demand with a `,eo,`-day lead time.`]})]}),(0,P.jsxs)(`div`,{className:`mono`,style:{textAlign:`right`,fontSize:11,color:J.inkSoft,letterSpacing:`0.12em`},children:[(0,P.jsx)(`div`,{children:`PALLETS · 84/26 129,600`}),(0,P.jsx)(`div`,{children:`98/26 · 109/26 115,200`})]})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(3, minmax(0,1fr))`,gap:10},children:[(0,P.jsx)(Lo,{label:`Reserved`,value:`${e.toLocaleStr
174ing()}`,note:`filters pre-paid`}),(0,P.jsx)(Lo,{label:`Held at Krush`,value:`${_.toLocaleString()}`,note:`ready to release`}),(0,P.jsx)(Lo,{label:`Available`,value:`${Math.max(0,m).toLocaleString()}`,note:`unassigned`})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(2, minmax(0,1fr))`,gap:10,marginTop:10},children:[(0,P.jsx)(Lo,{label:`Burn rate`,value:x?`${x.toLocaleString()}/wk`:`â`,note:`trailing 90-day avg`}),(0,P.jsx)(Lo,{label:`Runway`,value:S==null?`â`:`${S} wk`,note:C?`Low â reserve more`:`at current burn`})]}),C&&(0,P.jsx)(`div`,{style:{marginTop:10,padding:`10px 12px`,background:`#FFF3F1`,border:`1px solid #F2C6BF`,borderRadius:6,fontSize:12.5,color:`#8A2E1E`},children:`Filter Bank is below 20% of your reservation. New pulls will run out soon â reserve another pallet to avoid stock-outs.`})]}),(0,P.jsxs)(X,{children:[(0,P.jsx)(Z,{children:`Reserve pallets`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:14},children:[(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0,1.4fr) minmax(0,1fr)`,gap:14},children:[(0,P.jsxs)(`div`,{style:{minWidth:0},children:[(0,P.jsx)(`div`,{style:T,children:`SKU`}),(0,P.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),style:{...w,width:`100%`,height:40,marginTop:6},children:Ga.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.name,` â `,e.palletUnits.toLocaleString(),`/pallet`]},e.id))})]}),(0,P.jsxs)(`div`,{style:{minWidth:0},children:[(0,P.jsx)(`div`,{style:T,children:`Pallets`}),(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`stretch`,marginTop:6,border:`1px solid ${J.line}`,borderRadius:4,overflow:`hidden`,background:`#fff`,height:40},children:[(0,P.jsx)(`button`,{type:`button`,"aria-label":`Decrease pallets`,onClick:()=>c(Math.max(1,s-1)),style:{background:J.silver,border:`none`,borderRight:`1px solid ${J.line}`,width:40,cursor:`pointer`,fontSize:18,lineHeight:1,flexShrink:0},children:`â`}),(0,P.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,value:s,onChange:e=>{let t=parseInt((e.target.value||``).replace(/\D/g,``),10);c(Number.isFinite(t)&&t>0?t:1)},className:`mono`,style:{border:`none`,outline:`none`,minWidth:0,width:`100%`,height:`100%`,textAlign:`center`,fontSize:16,fontWeight:600,background:`#fff`}}),(0,P.jsx)(`button`,{type:`button`,"aria-label":`Increase pallets`,onClick:()=>c(s+1),style:{background:J.silver,border:`none`,borderLeft:`1px solid ${J.line}`,width:40,cursor:`pointer`,fontSize:18,lineHeight:1,flexShrink:0},children:`+`})]})]})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(2, minmax(0,1fr))`,gap:14},children:[(0,P.jsxs)(`div`,{style:{minWidth:0},children:[(0,P.jsx)(`div`,{style:T,children:`Cones`}),(0,P.jsx)(`div`,{className:`mono`,style:{marginTop:6,height:40,display:`flex`,alignItems:`center`,padding:`0 12px`,border:`1px solid ${J.line}`,borderRadius:4,background:J.bg,fontSize:15,color:J.ink},children:l.toLocaleString()})]}),(0,P.jsxs)(`div`,{style:{minWidth:0},children:[(0,P.jsx)(`div`,{style:T,children:`Total`}),(0,P.jsxs)(`div`,{className:`mono`,style:{marginTop:6,height:40,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,padding:`0 12px`,border:`1px solid ${J.line}`,borderRadius:4,background:J.bg,fontSize:17,color:J.ink,fontWeight:700},children:[Y(g),` CAD`]})]})]})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:16,paddingTop:14,borderTop:`1px solid ${J.line}`,gap:12,flexWrap:`wrap`},children:[(0,P.jsx)(`div`,{style:{fontSize:11.5,color:J.inkSoft},children:`Minimum 1 pallet · non-refundable · never expires`}),(0,P.jsxs)(yo,{onClick:()=>n(l,g),disabled:s<1,children:[`Reserve `,s,` pallet`,s===1?``:`s`,` â `,Y(g)]})]})]}),(0,P.jsx)(X,{children:(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:t.length>0?`1.4fr 1fr`:`1fr`,gap:20},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(Z,{children:`Held at Krush`}),t.length===0?(0,P.jsx)(`p`,{style:{fontSize:13,color:J.inkSoft,margin:0},children:`No cones held yet. Once a reservation runs, finished cones sit here until you request release.`}):(0,P.jsxs)(`table`,{style:{width:`100%`,borderCollapse:`collapse`},children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(Q,{children:`SKU`}),(0,P.jsx)(Q,{right:!0,children:`Units`}),(0,P.jsx)(Q,{children:`Produced`}),(0,P.jsx)(Q,{right:!0,children:`Value`})]})}),(0,P.jsx)(`tbody`,{children:t.map((e,t)=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)($,{mono:!0,children:e.sku}
174),(0,P.jsx)($,{right:!0,mono:!0,children:e.units.toLocaleString()}),(0,P.jsx)($,{children:e.producedAt}),(0,P.jsx)($,{right:!0,mono:!0,children:Y(e.units*$a)})]},t))})]})]}),t.length>0&&(0,P.jsxs)(`div`,{style:{background:J.bg,border:`1px solid ${J.line}`,borderRadius:6,padding:14},children:[(0,P.jsx)(Z,{children:`Request release`}),(0,P.jsxs)(`p`,{style:{fontSize:12,color:J.inkSoft,margin:`0 0 12px`},children:[`We finish, pack, and ship in `,eo,` days.`]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:10},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:T,children:`SKU`}),(0,P.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),style:{...w,width:`100%`,marginTop:6},children:[(0,P.jsx)(`option`,{value:``,children:`Selectâ¦`}),v.map(e=>(0,P.jsxs)(`option`,{value:e,children:[e,` (`,y(e).toLocaleString(),` held)`]},e))]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:T,children:`Units`}),(0,P.jsx)(`input`,{type:`number`,value:f,min:0,max:u?y(u):0,onChange:e=>p(parseInt(e.target.value||`0`,10)),className:`mono`,style:{...w,width:`100%`,marginTop:6}})]}),(0,P.jsx)(yo,{onClick:()=>{r(u,f),p(0)},disabled:!u||f<=0||f>y(u),children:`Request release`})]})]})]})})]})}function Lo({label:e,value:t,note:n}){return(0,P.jsxs)(`div`,{style:{background:J.bg,border:`1px solid ${J.line}`,borderRadius:6,padding:14},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:10.5,color:J.inkSoft,letterSpacing:`0.14em`},children:e}),(0,P.jsx)(`div`,{className:`mono`,style:{fontSize:22,color:J.ink,margin:`6px 0 2px`},children:t}),(0,P.jsx)(`div`,{style:{fontSize:11,color:J.inkSoft},children:n})]})}function Ro(){let[e,t]=(0,h.useState)(null);(0,h.useEffect)(()=>{o.auth.getUser().then(({data:e})=>t(e.user?.email||e.user?.id||null));let{data:e}=o.auth.onAuthStateChange((e,n)=>t(n?.user?.email||n?.user?.id||null));return()=>e.subscription.unsubscribe()},[]);let n=async()=>{try{localStorage.removeItem(`krush_pending_profile`),sessionStorage.clear()}catch{}await o.auth.signOut({scope:`global`}),t(null),window.location.replace(`/auth`)},[r,i]=(0,h.useState)(`dashboard`),[a,s]=(0,h.useState)([]),[c,l]=(0,h.useState)([]),[u,d]=(0,h.useState)([]),[f,p]=(0,h.useState)(null),[m,g]=(0,h.useState)({}),[_,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),[C,w]=(0,h.useState)(!1),[T,E]=(0,h.useState)([]),[D,ee]=(0,h.useState)(0),A=Wa(),[j,te]=(0,h.useState)(!1),[ne,re]=(0,h.useState)([]),M=(0,h.useMemo)(()=>T.reduce((e,t)=>e+(t.units||0),0),[T]),ie=(0,h.useMemo)(()=>T.filter(e=>(e.units_remaining||0)>0).map(e=>({id:e.id,sku:e.notes||`UNALLOCATED`,units:e.units_remaining,producedAt:e.release_date||(e.created_at||``).slice(0,10)})),[T]),ae=M-ie.reduce((e,t)=>e+t.units,0)<0?M:ie.reduce((e,t)=>e+t.units,0);(0,h.useEffect)(()=>{let e=!1;return Promise.all([O().catch(()=>({isAdmin:!1})),k().catch(()=>({roles:[]}))]).then(([t,n])=>{e||(te(!!t?.isAdmin),re(Array.isArray(n?.roles)?n.roles:[]))}),()=>{e=!0}},[]),(0,h.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{let{data:e}=await o.auth.getUser(),n=e?.user?.id;if(!n)return;let[{data:r},{data:i},{data:a},{data:c},{data:u},{count:f}]=await Promise.all([o.from(`profiles`).select(`*`).eq(`id`,n).maybeSingle(),o.from(`orders`).select(`*`).eq(`customer_id`,n).order(`created_at`,{ascending:!1}),o.from(`invoices`).select(`*`).eq(`customer_id`,n).order(`created_at`,{ascending:!1}),o.from(`documents`).select(`*`).eq(`customer_id`,n).order(`created_at`,{ascending:!1}),o.from(`filter_bank_reservations`).select(`*`).eq(`customer_id`,n).order(`created_at`,{ascending:!1}),o.from(`artwork_items`).select(`id`,{count:`exact`,head:!0}).eq(`customer_id`,n)]);t||(p(r||null),l((i||[]).map(fo)),s((a||[]).map(po)),d((c||[]).map(ho)),E(u||[]),ee(f||0))};return n(),N.current=n,()=>{t=!0}},[e]);let N=(0,h.useRef)(async()=>{}),oe=()=>N.current?.(),se=(...e)=>e.some(e=>ne.includes(e)),ce=j||se(`compliance`),le=j||se(`buyer`,`finance`,`approver`,`owner`),ue=j||se(`approver`,`owner`,`finance`),de=j||se(`owner`),fe=[{id:`dashboard`,label:`Dashboard`,icon:Ln},{id:`customize`,label:`Customize`,icon:Wn},{id:`skus`,label:`My SKUs`,icon:In},{id:`wizard`,label:`Place Order`,icon:$n},{id:`orders`,label:`Orders`,icon:$n},{id:`tracker`,label:`Track Orders`,icon:or},{id:`reorder`,label:`Reorder & Subs`,icon:Yn},{id:`forecast`,label:`Forecast`,icon:ir},{id:`bank`,label:`Filter Bank`,icon:Un},{id:`artwork`,label:`Artwork & Approvals`,icon:Wn},{id:`shipments`,label:`Shipments`,icon:or},{id:`labels`,label:`Label Library`,icon:In},{id:`traceability`,label:`QR & Barcodes`,icon:Jn}
174,{id:`concierge`,label:`Support / Concierge`,icon:Vn},{id:`team`,label:`Team & Roles`,icon:sr},{id:`documents`,label:`COAs & Documents`,icon:Pn},{id:`vault`,label:`Compliance Vault`,icon:Qn},{id:`subscriptions`,label:`Subscriptions`,icon:Yn},{id:`referrals`,label:`Referrals`,icon:bn},{id:`samples`,label:`Sample Kit`,icon:Un},{id:`annual`,label:`Annual Review`,icon:ir},{id:`balance`,label:`Invoices & Payments`,icon:cr}],pe=le?[{id:`authorization`,label:`Buyer Authorization`,icon:bn},{id:`compliance`,label:`Licenses & Compliance`,icon:Qn},{id:`credit`,label:`Credit & Net-30`,icon:cr}]:[],me=ue?[{id:`approvals`,label:`PO Approvals`,icon:wn}]:[],he=[...j?[{id:`admin`,label:`Admin`,icon:Qn}]:[],...ce?[{id:`review`,label:`Compliance Review`,icon:Mn}]:[],...de?[{id:`enterprise`,label:`Enterprise Admin`,icon:Sn}]:[]],ge=[...fe,...pe,...me,...he],_e=(0,h.useMemo)(()=>new Set(ge.map(e=>e.id)),[ge]);(0,h.useEffect)(()=>{_e.has(r)||i(`dashboard`)},[_e,r]);let ve=(0,h.useMemo)(()=>e?e.split(`@`)[0].replace(/[._-]/g,` `):``,[e]),ye=(e,t=new Date)=>{let n=new Date(t);return n.setDate(n.getDate()+e),n.toISOString().slice(0,10)},be=async()=>{if(!_)return;new Date().toISOString().slice(0,10);let{data:e}=await o.auth.getUser(),t=e?.user?.id;if(!t){v(null);return}if(_.type===`invoice`)await o.from(`invoices`).update({status:`Paid`}).eq(`number`,_.label).eq(`customer_id`,t),oe();else if(_.type===`filters`){let e=_.units;await o.from(`orders`).insert({customer_id:t,product:`Printed filter pre-purchase`,quantity:e,unit_price_cents:Math.round(_.amount/Math.max(e,1)*100),status:`In print`,flow:`filters`,printed_filters:!0,eta:ye(Ja),metadata:{note:`filter bank pre-purchase`}}),oe()}else if(_.type===`bank`){let e=_.units;await o.from(`filter_bank_reservations`).insert({customer_id:t,units:e,units_remaining:e,price_per_cone_cents:Math.round($a*1e3)/10,release_date:ye(eo),status:`Reserved`,notes:`UNALLOCATED`}),await o.from(`orders`).insert({customer_id:t,product:`Filter Bank reservation`,quantity:e,unit_price_cents:Math.round($a*100),status:`Reserved â production scheduled`,flow:`bank`,eta:ye(eo),metadata:{rate_per_cone:$a}}),oe()}else if(_.type===`sample`){let e=new Date().toLocaleString();b({artwork:_.artwork,at:e,eta:ye(Za)}),await o.from(`orders`).insert({customer_id:t,product:`Printed filter sample`,quantity:1,unit_price_cents:Math.round(_.amount*100),status:`Sample in print`,flow:`sample`,eta:ye(Za),metadata:{artwork:_.artwork,tph_at:e}}),oe()}else{let e=_.meta||{},n=Object.values(m).reduce((e,t)=>e+t,0),r=c.filter(e=>(e.flow||`cone`)===`cone`&&e.stage<=3&&!e.receivedAt).length+2,i=r*3+14+(e.addedDays||0),a=e.conesTotal||Ka*1e3*n;if(await o.from(`orders`).insert({customer_id:t,product:`${n} pallet cone order${e.printFilters?` · printed filters`:``}`,quantity:a||n,unit_price_cents:Math.round(_.amount/Math.max(a||n,1)*100),status:`Order received`,flow:`cone`,pallets:n,printed_filters:!!e.printFilters,eta:ye(i),metadata:{queueAhead:r,addedDays:e.addedDays||0,covered_from_bank:e.covered||0}}),e.printFilters&&e.covered>0){let t=e.covered;for(let e of T){if(t<=0)break;let n=Math.min(t,e.units_remaining||0);n>0&&(await o.from(`filter_bank_reservations`).update({units_remaining:(e.units_remaining||0)-n}).eq(`id`,e.id),t-=n)}}g({}),oe()}v(null)},xe=async e=>{let t=c.find(t=>t.id===e);t?.uuid&&await o.from(`orders`).update({status:`Received`}).eq(`id`,t.uuid),l(t=>t.map(t=>t.id===e?{...t,stage:8,status:`Received`,receivedAt:new Date().toISOString().slice(0,10)}:t))};if(!e)return null;let Se=A,Ce=Se<640,we=Se>=640&&Se<1024,Te=[`dashboard`,`skus`,`orders`,`documents`,`concierge`],Ee=Te.map(e=>ge.find(t=>t.id===e)),De=ge.filter(e=>!Te.includes(e.id)),F={dashboard:`Home`,skus:`SKUs`,orders:`Orders`,documents:`Docs`,concierge:`Kai`};return(0,P.jsxs)(`div`,{className:`krush`,style:{minHeight:`100vh`,background:J.bg,display:`flex`,flexDirection:Ce?`column`:`row`},children:[(0,P.jsx)(`style`,{children:Va}),Ce&&(0,P.jsxs)(`div`,{style:{position:`sticky`,top:0,zIndex:30,background:`#fff`,borderBottom:`1px solid ${J.line}`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px 16px`},children:[(0,P.jsx)(bo,{size:26}),(0,P.jsx)(`button`,{onClick:()=>w(!0),className:`caps`,style:{fontSize:10,background:`none`,border:`1px solid ${J.line}`,borderRadius:4,padding:`7px 12px`,cursor:`pointer`,color:J.ink},children:`More`})]}),!Ce&&(0,P.jsxs)(`aside`,{style:{width:we?64:230,background:`#fff`,borderRight:`1px solid ${J.line}
174`,display:`flex`,flexDirection:`column`,flexShrink:0},children:[(0,P.jsxs)(`div`,{className:`marble`,style:{padding:we?`18px 8px 14px`:`26px 20px 20px`,borderBottom:`1px solid ${J.line}`,textAlign:`center`},children:[(0,P.jsx)(bo,{size:we?22:34}),!we&&(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9,color:J.inkSoft,marginTop:6},children:`Preroll Cones · Production Portal`})]}),(0,P.jsx)(`nav`,{style:{padding:we?`12px 8px`:`14px 10px`,flex:1},children:ge.map(e=>(0,P.jsxs)(`button`,{onClick:()=>i(e.id),title:e.label,"aria-label":e.label,style:{display:`flex`,alignItems:`center`,justifyContent:we?`center`:`flex-start`,gap:10,width:`100%`,padding:we?`12px 0`:`10px 12px`,borderRadius:4,border:`none`,cursor:`pointer`,fontSize:13,fontWeight:600,marginBottom:2,textAlign:`left`,background:r===e.id?J.silver:`transparent`,color:r===e.id?J.ink:J.inkSoft,borderLeft:`2px solid ${r===e.id?J.charcoal:`transparent`}`,transition:`background .12s`},children:[(0,P.jsx)(e.icon,{size:we?18:15}),` `,!we&&e.label]},e.id))}),(0,P.jsxs)(`div`,{style:{padding:we?`12px 8px`:`14px 20px`,borderTop:`1px solid ${J.line}`,textAlign:we?`center`:`left`},children:[!we&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{style:{fontSize:12.5,fontWeight:600,textTransform:`capitalize`},children:ve}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10.5,color:J.inkSoft,marginBottom:10},children:[f?.company_name?f.company_name.toUpperCase():`ACCOUNT`,` · `,String(f?.payment_terms||`prepaid`).toUpperCase()]})]}),(0,P.jsxs)(`button`,{onClick:n,title:`Sign out`,"aria-label":`Sign out`,style:{display:`inline-flex`,alignItems:`center`,gap:7,background:`none`,border:`none`,color:J.inkSoft,cursor:`pointer`,fontSize:12.5,fontWeight:600,padding:0},children:[(0,P.jsx)(Bn,{size:13}),` `,!we&&`Sign out`]})]})]}),(0,P.jsxs)(`main`,{style:{flex:1,padding:Ce?`16px 14px 88px`:we?`22px 20px`:`26px 30px`,minWidth:0},children:[(0,P.jsxs)(`header`,{style:{marginBottom:Ce?14:20,display:`flex`,justifyContent:`space-between`,alignItems:`flex-end`,flexWrap:`wrap`,gap:8},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:9.5,color:J.inkSoft},children:new Date().toLocaleDateString(`en-US`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}),(0,P.jsx)(`h1`,{className:`caps`,style:{fontSize:Ce?14:17,margin:`4px 0 0`,letterSpacing:`0.18em`},children:ge.find(e=>e.id===r)?.label})]}),(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:14},children:[!Ce&&(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:8.5,color:`#B9B9BC`,letterSpacing:`0.3em`},children:`Always with quality`}),(0,P.jsx)(gr,{}),(0,P.jsx)(go,{})]})]}),r===`dashboard`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(pr,{onResume:()=>i(`wizard`)}),(0,P.jsx)(mr,{orders:c,onReorder:e=>{g({[e.key]:1}),i(`orders`)}}),(0,P.jsx)(wo,{invoices:a,orders:c,coas:u.filter(e=>e.kind===`COA`),docs:u,go:i,modules:ge.filter(e=>e.id!==`dashboard`),profile:f,bankRows:T,artworkCount:D})]}),r===`customize`&&(0,P.jsx)(Eo,{onOrderSample:e=>v({type:`sample`,label:`Printed filter sample`,amount:Xa,artwork:e}),sampleInfo:y,onUploaded:oe}),r===`skus`&&(0,P.jsx)(Po,{coas:u.filter(e=>e.kind===`COA`),skus:ao,go:i,onReorder:(e,t,n)=>{g({[e]:t}),S(!!n),i(`orders`)}}),r===`orders`&&(0,P.jsx)(jo,{cart:m,setCart:g,orders:c,onCheckout:(e,t)=>v({type:`order`,label:`New order`,amount:e,meta:t}),onReceive:xe,filterBank:ae,onPrepayFilters:e=>v({type:`filters`,label:`Filter pre-purchase`,amount:e*qa,units:e}),initialPrintFilters:x,coas:u.filter(e=>e.kind===`COA`)}),r===`wizard`&&(0,P.jsx)(da,{onSubmitted:()=>{oe(),i(`tracker`)}}),r===`tracker`&&(0,P.jsx)(ma,{orders:c}),r===`reorder`&&(0,P.jsx)(ha,{orders:c,onReorder:()=>i(`wizard`)}),r===`artwork`&&(0,P.jsx)(_a,{}),r===`shipments`&&(0,P.jsx)(va,{orders:c,docs:u}),r===`labels`&&(0,P.jsx)(Sa,{standalone:!0}),r===`traceability`&&(0,P.jsx)(ya,{}),r===`team`&&(0,P.jsx)(ba,{}),r===`forecast`&&(0,P.jsx)(Mo,{orders:c,filterBank:ae}),r===`bank`&&(0,P.jsx)(Io,{reserved:M,held:ie,onReserve:(e,t)=>v({type:`bank`,label:`Filter Bank reservation`,amount:t,units:e}),onRequestProduction:async(e,t)=>{let{data:n}=await o.auth.getUser(),r=n?.user?.id;if(!r)return;let i=t;for(let t of T){if(i<=0)break;if((t.notes||`UNALLOCATED`)!==e)continue;let n=Math.min(i,t.units_remaining||0);n>0&&(await o.from(`filter_bank_reservations`).update({units_remaining:(t.units_remaining||0)-n}).eq(`id`,t.id),i-=n)}await o.from(`orders`).insert({customer_id:r,product:`Release from Filter Bank · ${e}`,quantity:t,unit_price_cents:0,status:`Production requested`,flow:`bank`,eta:ye(eo),metadata:{source:`filter_bank_release`,sku:e}}),oe()}}
174),r===`concierge`&&(0,P.jsx)(No,{company:ve,orders:c,invoices:a,filterBank:ae}),r===`documents`&&(0,P.jsx)(Do,{coas:u.filter(e=>e.kind===`COA`),docs:u}),r===`vault`&&(0,P.jsx)(Dr,{}),r===`subscriptions`&&(0,P.jsx)(wr,{}),r===`referrals`&&(0,P.jsx)(Tr,{}),r===`samples`&&(0,P.jsx)(Er,{}),r===`annual`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Or,{orders:c,invoices:a}),(0,P.jsx)(kr,{})]}),r===`balance`&&(0,P.jsx)(Oo,{invoices:a,onPay:e=>v({type:`invoice`,label:e.id,amount:e.amount,dbId:e.dbId,number:e.number||e.id})}),r===`admin`&&j&&(0,P.jsx)(Oe,{}),r===`authorization`&&le&&(0,P.jsx)(Fa,{go:i}),r===`compliance`&&le&&(0,P.jsx)(ja,{}),r===`credit`&&le&&(0,P.jsx)(Ma,{}),r===`approvals`&&ue&&(0,P.jsx)(Na,{}),r===`enterprise`&&de&&(0,P.jsx)(Pa,{}),r===`review`&&ce&&(0,P.jsx)(Ia,{})]}),Ce&&(0,P.jsx)(`nav`,{style:{position:`fixed`,bottom:0,left:0,right:0,zIndex:30,background:`#fff`,borderTop:`1px solid ${J.line}`,display:`flex`,paddingBottom:`env(safe-area-inset-bottom)`},"aria-label":`Primary`,children:Ee.map(e=>(0,P.jsxs)(`button`,{onClick:()=>{i(e.id),w(!1)},"aria-label":e.label,style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:3,padding:`9px 0 10px`,background:`none`,border:`none`,borderTop:`2px solid ${r===e.id?J.charcoal:`transparent`}`,cursor:`pointer`,color:r===e.id?J.ink:J.inkSoft},children:[(0,P.jsx)(e.icon,{size:19}),(0,P.jsx)(`span`,{className:`caps`,style:{fontSize:7.5},children:F[e.id]})]},e.id))}),Ce&&C&&(0,P.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:40,background:`rgba(30,30,32,0.5)`},onClick:()=>w(!1),children:(0,P.jsxs)(`div`,{onClick:e=>e.stopPropagation(),style:{position:`absolute`,bottom:0,left:0,right:0,background:`#fff`,borderRadius:`12px 12px 0 0`,padding:`18px 18px calc(18px + env(safe-area-inset-bottom))`},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:10,color:J.inkSoft,marginBottom:12},children:`More`}),De.map(e=>(0,P.jsxs)(`button`,{onClick:()=>{i(e.id),w(!1)},style:{display:`flex`,alignItems:`center`,gap:12,width:`100%`,padding:`13px 10px`,borderRadius:6,border:`none`,background:r===e.id?J.silver:`transparent`,cursor:`pointer`,fontSize:14,fontWeight:600,color:J.ink,textAlign:`left`},children:[(0,P.jsx)(e.icon,{size:17}),` `,e.label]},e.id)),(0,P.jsxs)(`div`,{style:{borderTop:`1px solid ${J.line}`,marginTop:10,paddingTop:12,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontSize:12.5,fontWeight:600,textTransform:`capitalize`},children:ve}),(0,P.jsxs)(`div`,{className:`mono`,style:{fontSize:10,color:J.inkSoft},children:[f?.company_name?f.company_name.toUpperCase():`ACCOUNT`,` · `,String(f?.payment_terms||`prepaid`).toUpperCase()]})]}),(0,P.jsxs)(`button`,{onClick:n,style:{display:`flex`,alignItems:`center`,gap:6,background:`none`,border:`1px solid ${J.line}`,borderRadius:4,padding:`8px 12px`,color:J.inkSoft,cursor:`pointer`,fontSize:12,fontWeight:600},children:[(0,P.jsx)(Bn,{size:13}),` Sign out`]})]})]})}),_&&_.type===`invoice`&&_.dbId?(0,P.jsx)(un,{invoiceId:_.dbId,invoiceNumber:_.number||_.label,amount:_.amount,onClose:()=>{v(null),oe()}}):_?(0,P.jsx)(Fo,{ctx:_,onClose:()=>v(null),onConfirm:be}):null,(0,P.jsx)(hr,{nav:ge,orders:c,invoices:a,onGo:i}),(0,P.jsx)(jr,{})]})}function zo(){let[e,t]=(0,h.useState)(!0),[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)(``);return(0,h.useEffect)(()=>{let e=async()=>{try{let e=localStorage.getItem(`krush_pending_profile`);if(!e)return;let t=JSON.parse(e),{data:n}=await o.auth.getUser();if(!n.user||n.user.id!==t.user_id)return;let{user_id:r,...i}=t;await o.from(`profiles`).update(i).eq(`id`,r),localStorage.removeItem(`krush_pending_profile`)}catch{}};e();let n=async()=>{try{let{data:e}=await o.auth.getUser(),t=e.user;if(!t)return;a(t.email??``);let[{data:n},{data:i}]=await Promise.all([o.from(`user_roles`).select(`role`).eq(`user_id`,t.id),o.from(`profiles`).select(`access_status, access_notes`).eq(`id`,t.id).maybeSingle()]);if((n??[]).some(e=>[`admin`,`owner`,`staff`,`finance`,`compliance`].includes(e.role))){r({status:`approved`});return}r({status:i?.access_status??`pending`,notes:i?.access_notes??null})}catch{r({status:`approved`})}};n();let{data:i}=o.auth.onAuthStateChange((r,i)=>{if(r===`SIGNED_IN`&&(e(),n()),r===`SIGNED_OUT`||!i){t(!1);let e=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=e&&e!==`/auth`?`/auth?redirect=${encodeURIComponent(e)}`:`/auth`;window.location.replace(n)}});return()=>i.subscription.unsubscribe()},[]),!e||!n?null:n.status===`approved`?(0,P.jsx)(Ro,{}):(0,P.jsx)(Bo,{status:n.status,notes:n.notes,email:i})}function Bo({status:e,notes:t,email:n}){let r=e===`rejected`;return(0,P.jsx)(`div`,{style:{minHeight:`100vh`,background:`#FFFFFF`,color:`#1B1B1B`,fontFamily:`'Inter', -apple-system, sans-serif`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`40px 20px`},children:(0,P.jsxs)(`div`,{style:{maxWidth:520,textAlign:`center`},children:[(0,P.jsx)(`div`,{className:`caps`,style:{fontSize:11,letterSpacing:`0.18em`,color:`#7A7A7C`,marginBottom:14},children:`Krush Cones Inc. · Production Portal`}),(0,P.jsx)(`h1`,{style:{fontSize:26,fontWeight:600,margin:`0 0 14px`},children:r?`Account not approved`:`Account pending approval`}),(0,P.jsx)(`p`,{style:{fontSize:14,lineHeight:1.65,color:`#5A5A5C`},children:r?`Your access request was declined. If you believe this is an error, reply to our team and we will review it again.`:`Thanks for registering. Our team reviews every business profile before granting portal access â you will receive an email as soon as your account is approved.`}),t&&(0,P.jsx)(`p`,{style:{fontSize:13,marginTop:14,padding:12,background:`#F7F7F5`,borderRadius:6,color:`#4A4A4C`},children:t}),(0,P.jsxs)(`p`,{style:{fontSize:12,color:`#9A9A9C`,marginTop:22},children:[`Signed in as `,n||`your account`,` · Questions? [email protected]
174a`]}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:10,justifyContent:`center`,marginTop:22},children:[(0,P.jsx)(`button`,{onClick:()=>window.location.reload(),style:{padding:`10px 16px`,fontSize:12,fontWeight:600,cursor:`pointer`,border:`1px solid #1E1E20`,background:`#1E1E20`,color:`#fff`,borderRadius:4},children:`Check again`}),(0,P.jsx)(`button`,{onClick:async()=>{await o.auth.signOut(),window.location.replace(`/auth`)},style:{padding:`10px 16px`,fontSize:12,fontWeight:600,cursor:`pointer`,border:`1px solid #D6D6D4`,background:`#fff`,color:`#1E1E20`,borderRadius:4},children:`Sign out`})]})]})})}export{zo as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.