PageSourceSearch

https://thalio.ai/assets/mode-e-review-JBHfdRgA.js

js thalio.ai collected 2026-10-04 17:56:04 UTC 31,623 bytes, 1 lines download raw bytes

1import{s as Oe,w as Ee,n as M,u as Ue,b as De,r as S,k as K,j as r,B as W,t as I}from"./index-B6paN9hX.js";import{I as J}from"./input-BZd0Y6Li.js";import{L as D}from"./label-BWzqZyYA.js";import{T as Be}from"./textarea-BDOxSvSd.js";import{R as ke,a as fe}from"./radio-group-Bw1T8cnk.js";import{T as ze,a as $e,b as pe,c as re,d as Qe,e as ne}from"./table-_bM_dYa0.js";import{B as oe}from"./badge-8GFq6V0p.js";import"./index-BiUYA0AJ.js";const Q="https://thalio-pipeline.benson-tracy06.workers.dev",ae="IGe5FxkVTn+BDWXXhOGtzBJ+mFObl4xd0PvLHq2PBGU=",ye=["succeeded","failed","gated"];async function H(i){if(!i.ok){let o="";try{o=await i.text()}catch{}throw new Error(`pipeline ${i.status}: ${o||i.statusText}`)}return i.json()}const he=()=>({"Content-Type":"application/json","X-Api-Key":ae});async function ge(i){const o=new FormData;if(i.reference)o.append("reference",i.reference);else if(i.reference_url)o.append("reference_url",i.reference_url);else throw new Error("decompose requires either reference (File) or reference_url");o.append("brand_id",i.brand_id),o.append("user_id",i.user_id),i.duration_seconds!==void 0&&o.append("duration_seconds",String(i.duration_seconds)),i.phone_number&&o.append("phone_number",i.phone_number),i.idea_id&&o.append("idea_id",i.idea_id);const a=await fetch(`${Q}/render-mode-e/decompose`,{method:"POST",headers:{"X-Api-Key":ae},body:o});return H(a)}async function He(i){const o=new FormData;o.append("render_id",i.render_id),o.append("shot_index",String(i.shot_index)),o.append("file",i.file);const a=await fetch(`${Q}/render-mode-e/upload`,{method:"POST",headers:{"X-Api-Key":ae},body:o});return H(a)}async function Ge(i){const o=await fetch(`${Q}/render-mode-e/assemble`,{method:"POST",headers:he(),body:JSON.stringify({render_id:i})});return H(o)}async function Ve(i){const o=await fetch(`${Q}/render-mode-e/${i}`,{method:"GET",headers:{"X-Api-Key":ae}});return H(o)}async function Ye(i){const o=await fetch(`${Q}/render-mode-e/send-briefing`,{method:"POST",headers:he(),body:JSON.stringify({render_id:i.render_id,force:i.force})});return H(o)}async function Xe(i,o){const a=await fetch(`${Q}/render-mode-e/${i}/verdict`,{method:"POST",headers:he(),body:JSON.stringify(o)});return H(a)}async function Ke(i){const{data:o,error:a}=await Oe.from("mode_e_renders").select("id, status, output_url, created_at, updated_at").eq("user_id",i).order("created_at",{ascending:!1}).limit(20);return a?(console.warn("[mode-e] listMyRenders fell back to empty:",a.message),[]):o??[]}function We(i){return Ee({queryKey:["mode-e-render",i],queryFn:()=>Ve(i),enabled:!!i,staleTime:0,refetchInterval:o=>{const a=o.state.data?.status;return a&&ye.includes(a)?!1:3500}})}var Je=Object.defineProperty,ie=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,xe=(i,o,a)=>o in i?Je(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a,ce=(i,o)=>{for(var a in o||(o={}))be.call(o,a)&&xe(i,a,o[a]);if(ie)for(var a of ie(o))Ne.call(o,a)&&xe(i,a,o[a]);return i},ue=(i,o)=>{var a={};for(var h in i)be.call(i,h)&&o.indexOf(h)<0&&(a[h]=i[h]);if(i!=null&&ie)for(var h of ie(i))o.indexOf(h)<0&&Ne.call(i,h)&&(a[h]=i[h]);return a};var z;(i=>{const o=class v{constructor(e,s,t,n){if(this.version=e,this.errorCorrectionLevel=s,this.modules=[],this.isFunction=[],e<v.MIN_VERSION||e>v.MAX_VERSION)throw new RangeError("Version value out of range");if(n<-1||n>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let l=[];for(let d=0;d<this.size;d++)l.push(!1);for(let d=0;d<this.size;d++)this.modules.push(l.slice()),this.isFunction.push(l.slice());this.drawFunctionPatterns();const f=this.addEccAndInterleave(t);if(this.drawCodewords(f),n==-1){let d=1e9;for(let g=0;g<8;g++){this.applyMask(g),this.drawFormatBits(g);const u=this.getPenaltyScore();u<d&&(n=g,d=u),this.applyMask(g)}}x(0<=n&&n<=7),this.mask=n,this.applyMask(n),this.drawFormatBits(n),this.isFunction=[]}static encodeText(e,s){const t=i.QrSegment.makeSegments(e);return v.encodeSegments(t,s)}static encodeBinary(e,s){const t=i.QrSegment.makeBytes(e);return v.encodeSegments([t],s)}static encodeSegments(e,s,t=1,n=40,l=-1,f=!0){if(!(v.MIN_VERSION<=t&&t<=n&&n<=v.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let d,g;for(d=t;;d++){const p=v.getNumDataCodewords(d,s)*8,N=b.getTotalBits(e,d);if(N<=p){g=N;break}if(d>=n)throw new RangeError("Data too long")}for(const p of[v.Ecc.MEDIUM,v.Ecc.QUARTILE,v.Ecc.HIGH])f&&g<=v.getNumDataCodewords(d,p)*8&&(s=p);let u=[];for(const p of e){a(p.mode.modeBits,4,u),a(p.numChars,p.mode.numCharCountBits(d),u);for(const N of p.getData())u.push(N)}x(u.length==g);const P=v.getNumDataCodewords(d,s)*8;x(u.length<=P),a(0,Math.min(4,P-u.length),u),a(0,(8-u.length%8)%8,u),x(u.length%8==0);for(let p=236;u.length<P;p^=253)a(p,8,u);let w=[];for(;w.length*8<u.length;)w.push(0);return u.forEach((p,N)=>w[N>>>3]|=p<<7-(N&7)),new v(d,s,w,l)}getModule(e,s){return 0<=e&&e<this.size&&0<=s&&s<this.size&&this.modules[s][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),s=e.length;for(let t=0;t<s;t++)for(let n=0;n<s;n++)t==0&&n==0||t==0&&n==s-1||t==s-1&&n==0||this.drawAlignmentPattern(e[t],e[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const s=this.errorCorrectionLevel.formatBits<<3|e;let t=s;for(let l=0;l<10;l++)t=t<<1^(t>>>9)*1335;const n=(s<<10|t)^21522;x(n>>>15==0);for(let l=0;l<=5;l++)this.setFunctionModule(8,l,h(n,l));this.setFunctionModule(8,7,h(n,6)),this.setFunctionModule(8,8,h(n,7)),this.setFunctionModule(7,8,h(n,8));for(let l=9;l<15;l++)this.setFunctionModule(14-l,8,h(n,l));for(let l=0;l<8;l++)this.setFunctionModule(this.size-1-l,8,h(n,l));for(let l=8;l<15;l++)this.setFunctionModule(8,this.size-15+l,h(n,l));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const s=this.version<<12|e;x(s>>>18==0);for(let t=0;t<18;t++){const n=h(s,t),l=this.size-11+t%3,f=Math.floor(t/3);this.setFunctionModule(l,f,n),this.setFunctionModule(f,l,n)}}
1drawFinderPattern(e,s){for(let t=-4;t<=4;t++)for(let n=-4;n<=4;n++){const l=Math.max(Math.abs(n),Math.abs(t)),f=e+n,d=s+t;0<=f&&f<this.size&&0<=d&&d<this.size&&this.setFunctionModule(f,d,l!=2&&l!=4)}}drawAlignmentPattern(e,s){for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)this.setFunctionModule(e+n,s+t,Math.max(Math.abs(n),Math.abs(t))!=1)}setFunctionModule(e,s,t){this.modules[s][e]=t,this.isFunction[s][e]=!0}addEccAndInterleave(e){const s=this.version,t=this.errorCorrectionLevel;if(e.length!=v.getNumDataCodewords(s,t))throw new RangeError("Invalid argument");const n=v.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][s],l=v.ECC_CODEWORDS_PER_BLOCK[t.ordinal][s],f=Math.floor(v.getNumRawDataModules(s)/8),d=n-f%n,g=Math.floor(f/n);let u=[];const P=v.reedSolomonComputeDivisor(l);for(let p=0,N=0;p<n;p++){let R=e.slice(N,N+g-l+(p<d?0:1));N+=R.length;const T=v.reedSolomonComputeRemainder(R,P);p<d&&R.push(0),u.push(R.concat(T))}let w=[];for(let p=0;p<u[0].length;p++)u.forEach((N,R)=>{(p!=g-l||R>=d)&&w.push(N[p])});return x(w.length==f),w}drawCodewords(e){if(e.length!=Math.floor(v.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let s=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let n=0;n<this.size;n++)for(let l=0;l<2;l++){const f=t-l,g=(t+1&2)==0?this.size-1-n:n;!this.isFunction[g][f]&&s<e.length*8&&(this.modules[g][f]=h(e[s>>>3],7-(s&7)),s++)}}x(s==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let s=0;s<this.size;s++)for(let t=0;t<this.size;t++){let n;switch(e){case 0:n=(t+s)%2==0;break;case 1:n=s%2==0;break;case 2:n=t%3==0;break;case 3:n=(t+s)%3==0;break;case 4:n=(Math.floor(t/3)+Math.floor(s/2))%2==0;break;case 5:n=t*s%2+t*s%3==0;break;case 6:n=(t*s%2+t*s%3)%2==0;break;case 7:n=((t+s)%2+t*s%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[s][t]&&n&&(this.modules[s][t]=!this.modules[s][t])}}getPenaltyScore(){let e=0;for(let l=0;l<this.size;l++){let f=!1,d=0,g=[0,0,0,0,0,0,0];for(let u=0;u<this.size;u++)this.modules[l][u]==f?(d++,d==5?e+=v.PENALTY_N1:d>5&&e++):(this.finderPenaltyAddHistory(d,g),f||(e+=this.finderPenaltyCountPatterns(g)*v.PENALTY_N3),f=this.modules[l][u],d=1);e+=this.finderPenaltyTerminateAndCount(f,d,g)*v.PENALTY_N3}for(let l=0;l<this.size;l++){let f=!1,d=0,g=[0,0,0,0,0,0,0];for(let u=0;u<this.size;u++)this.modules[u][l]==f?(d++,d==5?e+=v.PENALTY_N1:d>5&&e++):(this.finderPenaltyAddHistory(d,g),f||(e+=this.finderPenaltyCountPatterns(g)*v.PENALTY_N3),f=this.modules[u][l],d=1);e+=this.finderPenaltyTerminateAndCount(f,d,g)*v.PENALTY_N3}for(let l=0;l<this.size-1;l++)for(let f=0;f<this.size-1;f++){const d=this.modules[l][f];d==this.modules[l][f+1]&&d==this.modules[l+1][f]&&d==this.modules[l+1][f+1]&&(e+=v.PENALTY_N2)}let s=0;for(const l of this.modules)s=l.reduce((f,d)=>f+(d?1:0),s);const t=this.size*this.size,n=Math.ceil(Math.abs(s*20-t*10)/t)-1;return x(0<=n&&n<=9),e+=n*v.PENALTY_N4,x(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,s=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let n=this.size-7;t.length<e;n-=s)t.splice(1,0,n);return t}}static getNumRawDataModules(e){if(e<v.MIN_VERSION||e>v.MAX_VERSION)throw new RangeError("Version number out of range");let s=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;s-=(25*t-10)*t-55,e>=7&&(s-=36)}return x(208<=s&&s<=29648),s}static getNumDataCodewords(e,s){return Math.floor(v.getNumRawDataModules(e)/8)-v.ECC_CODEWORDS_PER_BLOCK[s.ordinal][e]*v.NUM_ERROR_CORRECTION_BLOCKS[s.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let s=[];for(let n=0;n<e-1;n++)s.push(0);s.push(1);let t=1;for(let n=0;n<e;n++){for(let l=0;l<s.length;l++)s[l]=v.reedSolomonMultiply(s[l],t),l+1<s.length&&(s[l]^=s[l+1]);t=v.reedSolomonMultiply(t,2)}return s}static reedSolomonComputeRemainder(e,s){let t=s.map(n=>0);for(const n of e){const l=n^t.shift();t.push(0),s.forEach((f,d)=>t[d]^=v.reedSolomonMultiply(f,l))}return t}static reedSolomonMultiply(e,s){if(e>>>8||s>>>8)throw new RangeError("Byte out of range");let t=0;for(let n=7;n>=0;n--)t=t<<1^(t>>>7)*285,t^=(s>>>n&1)*e;return x(t>>>8==0),t}finderPenaltyCountPatterns(e){const s=e[1];x(s<=this.size*3);const t=s>0&&e[2]==s&&e[3]==s*3&&e[4]==s&&e[5]==s;return(t&&e[0]>=s*4&&e[6]>=s?1:0)+(t&&e[6]>=s*4&&e[0]>=s?1:0)}finderPenaltyTerminateAndCount(e,s,t){return e&&(this.finderPenaltyAddHistory(s,t),s=0),s+=this.size,this.finderPenaltyAddHistory(s,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,s){s[0]==0&&(e+=this.size),s.pop(),s.unshift(e)}};o.MIN_VERSION=1,o.MAX_VERSION=40,o.PENALTY_N1=3,o.PENALTY_N2=3,o.PENALTY_N3=40,o.PENALTY_N4=10,o.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],o.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],i.QrCode=o;function a(y,e,s){if(e<0||e>31||y>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)s.push(y>>>t&1)}function h(y,e){return(y>>>e&1)!=0}function x(y){if(!y)throw new Error("Assertion error")}const m=class C{constructor(e,s,t){if(this.mode=e,this.numChars=s,this.bitData=t,s<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let s=[];for(const t of e)a(t,8,s);return new C(C.Mode.BYTE,e.length,s)}static makeNumeric(e){if(!C.isNumeric(e))throw new RangeError("String contains 
1non-numeric characters");let s=[];for(let t=0;t<e.length;){const n=Math.min(e.length-t,3);a(parseInt(e.substring(t,t+n),10),n*3+1,s),t+=n}return new C(C.Mode.NUMERIC,e.length,s)}static makeAlphanumeric(e){if(!C.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let s=[],t;for(t=0;t+2<=e.length;t+=2){let n=C.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;n+=C.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),a(n,11,s)}return t<e.length&&a(C.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,s),new C(C.Mode.ALPHANUMERIC,e.length,s)}static makeSegments(e){return e==""?[]:C.isNumeric(e)?[C.makeNumeric(e)]:C.isAlphanumeric(e)?[C.makeAlphanumeric(e)]:[C.makeBytes(C.toUtf8ByteArray(e))]}static makeEci(e){let s=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)a(e,8,s);else if(e<16384)a(2,2,s),a(e,14,s);else if(e<1e6)a(6,3,s),a(e,21,s);else throw new RangeError("ECI assignment value out of range");return new C(C.Mode.ECI,0,s)}static isNumeric(e){return C.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return C.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,s){let t=0;for(const n of e){const l=n.mode.numCharCountBits(s);if(n.numChars>=1<<l)return 1/0;t+=4+l+n.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let s=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?s.push(e.charCodeAt(t)):(s.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return s}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let b=m;i.QrSegment=m})(z||(z={}));(i=>{(o=>{const a=class{constructor(x,m){this.ordinal=x,this.formatBits=m}};a.LOW=new a(0,1),a.MEDIUM=new a(1,0),a.QUARTILE=new a(2,3),a.HIGH=new a(3,2),o.Ecc=a})(i.QrCode||(i.QrCode={}))})(z||(z={}));(i=>{(o=>{const a=class{constructor(x,m){this.modeBits=x,this.numBitsCharCount=m}numCharCountBits(x){return this.numBitsCharCount[Math.floor((x+7)/17)]}};a.NUMERIC=new a(1,[10,12,14]),a.ALPHANUMERIC=new a(2,[9,11,13]),a.BYTE=new a(4,[8,16,16]),a.KANJI=new a(8,[8,10,12]),a.ECI=new a(7,[0,0,0]),o.Mode=a})(i.QrSegment||(i.QrSegment={}))})(z||(z={}));var $=z;var Ze={L:$.QrCode.Ecc.LOW,M:$.QrCode.Ecc.MEDIUM,Q:$.QrCode.Ecc.QUARTILE,H:$.QrCode.Ecc.HIGH},we=128,Ce="L",Me="#FFFFFF",Re="#000000",je=!1,Se=1,qe=4,et=0,tt=.1;function Pe(i,o=0){const a=[];return i.forEach(function(h,x){let m=null;h.forEach(function(b,y){if(!b&&m!==null){a.push(`M${m+o} ${x+o}h${y-m}v1H${m+o}z`),m=null;return}if(y===h.length-1){if(!b)return;m===null?a.push(`M${y+o},${x+o} h1v1H${y+o}z`):a.push(`M${m+o},${x+o} h${y+1-m}v1H${m+o}z`);return}b&&m===null&&(m=y)})}),a.join("")}function _e(i,o){return i.slice().map((a,h)=>h<o.y||h>=o.y+o.h?a:a.map((x,m)=>m<o.x||m>=o.x+o.w?x:!1))}function st(i,o,a,h){if(h==null)return null;const x=i.length+a*2,m=Math.floor(o*tt),b=x/o,y=(h.width||m)*b,e=(h.height||m)*b,s=h.x==null?i.length/2-y/2:h.x*b,t=h.y==null?i.length/2-e/2:h.y*b,n=h.opacity==null?1:h.opacity;let l=null;if(h.excavate){let d=Math.floor(s),g=Math.floor(t),u=Math.ceil(y+s-d),P=Math.ceil(e+t-g);l={x:d,y:g,w:u,h:P}}const f=h.crossOrigin;return{x:s,y:t,h:e,w:y,excavation:l,opacity:n,crossOrigin:f}}function rt(i,o){return o!=null?Math.max(Math.floor(o),0):i?qe:et}function Ae({value:i,level:o,minVersion:a,includeMargin:h,marginSize:x,imageSettings:m,size:b,boostLevel:y}){let e=M.useMemo(()=>{const d=(Array.isArray(i)?i:[i]).reduce((g,u)=>(g.push(...$.QrSegment.makeSegments(u)),g),[]);return $.QrCode.encodeSegments(d,Ze[o],a,void 0,void 0,y)},[i,o,a,y]);const{cells:s,margin:t,numCells:n,calculatedImageSettings:l}=M.useMemo(()=>{let f=e.getModules();const d=rt(h,x),g=f.length+d*2,u=st(f,b,d,m);return{cells:f,margin:d,numCells:g,calculatedImageSettings:u}},[e,b,m,h,x]);return{qrcode:e,margin:t,cells:s,numCells:n,calculatedImageSettings:l}}var nt=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ot=M.forwardRef(function(o,a){const h=o,{value:x,size:m=we,level:b=Ce,bgColor:y=Me,fgColor:e=Re,includeMargin:s=je,minVersion:t=Se,boostLevel:n,marginSize:l,imageSettings:f}=h,g=ue(h,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:u}=g,P=ue(g,["style"]),w=f?.src,p=M.useRef(null),N=M.useRef(null),R=M.useCallback(O=>{p.current=O,typeof a=="function"?a(O):a&&(a.current=O)},[a]),[T,Z]=M.useState(!1),{margin:B,cells:j,numCells:F,calculatedImageSettings:_}=Ae({value:x,level:b,minVersion:t,boostLevel:n,includeMargin:s,marginSize:l,imageSettings:f,size:m});M.useEffect(()=>{if(p.current!=null){const O=p.current,A=O.getContext("2d");if(!A)return;let q=j;const k=N.current,U=_!=null&&k!==null&&k.complete&&k.naturalHeight!==0&&k.naturalWi
1dth!==0;U&&_.excavation!=null&&(q=_e(j,_.excavation));const ee=window.devicePixelRatio||1;O.height=O.width=m*ee;const Y=m/F*ee;A.scale(Y,Y),A.fillStyle=y,A.fillRect(0,0,F,F),A.fillStyle=e,nt?A.fill(new Path2D(Pe(q,B))):j.forEach(function(le,te){le.forEach(function(se,X){se&&A.fillRect(X+B,te+B,1,1)})}),_&&(A.globalAlpha=_.opacity),U&&A.drawImage(k,_.x+B,_.y+B,_.w,_.h)}}),M.useEffect(()=>{Z(!1)},[w]);const G=ce({height:m,width:m},u);let V=null;return w!=null&&(V=M.createElement("img",{src:w,key:w,style:{display:"none"},onLoad:()=>{Z(!0)},ref:N,crossOrigin:_?.crossOrigin})),M.createElement(M.Fragment,null,M.createElement("canvas",ce({style:G,height:m,width:m,ref:R,role:"img"},P)),V)});ot.displayName="QRCodeCanvas";var Ie=M.forwardRef(function(o,a){const h=o,{value:x,size:m=we,level:b=Ce,bgColor:y=Me,fgColor:e=Re,includeMargin:s=je,minVersion:t=Se,boostLevel:n,title:l,marginSize:f,imageSettings:d}=h,g=ue(h,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:u,cells:P,numCells:w,calculatedImageSettings:p}=Ae({value:x,level:b,minVersion:t,boostLevel:n,includeMargin:s,marginSize:f,imageSettings:d,size:m});let N=P,R=null;d!=null&&p!=null&&(p.excavation!=null&&(N=_e(P,p.excavation)),R=M.createElement("image",{href:d.src,height:p.h,width:p.w,x:p.x+u,y:p.y+u,preserveAspectRatio:"none",opacity:p.opacity,crossOrigin:p.crossOrigin}));const T=Pe(N,u);return M.createElement("svg",ce({height:m,width:m,viewBox:`0 0 ${w} ${w}`,ref:a,role:"img"},g),!!l&&M.createElement("title",null,l),M.createElement("path",{fill:y,d:`M0,0 h${w}v${w}H0z`,shapeRendering:"crispEdges"}),M.createElement("path",{fill:e,d:T,shapeRendering:"crispEdges"}),R)});Ie.displayName="QRCodeSVG";function it({referenceUrl:i,startSec:o,durationSec:a}){const h=S.useRef(null),x=o+a;S.useEffect(()=>{const b=h.current;if(!b)return;const y=()=>{try{b.currentTime=o}catch{}};return b.readyState>=1?y():b.addEventListener("loadedmetadata",y,{once:!0}),()=>{b.removeEventListener("loadedmetadata",y)}},[o]);const m=()=>{const b=h.current;b&&b.currentTime>=x&&(b.pause(),b.currentTime=o)};return r.jsxs("div",{className:"space-y-1",children:[r.jsx("video",{ref:h,src:i,muted:!0,playsInline:!0,controls:!0,onTimeUpdate:m,className:"aspect-[9/16] w-full rounded-md bg-black"}),r.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Plays ",o.toFixed(1),"s – ",x.toFixed(1),"s of the reference"]})]})}function ve(i){return i?i==="succeeded"?r.jsx(oe,{className:"bg-green-600 hover:bg-green-600",children:i}):i==="failed"||i==="gated"?r.jsx(oe,{variant:"destructive",children:i}):r.jsx(oe,{variant:"secondary",children:i}):r.jsx(oe,{variant:"secondary",children:"—"})}function xt(){const{user:i}=Ue(),{brand:o}=De(),a=i?.id??"",[h,x]=S.useState(""),[m,b]=S.useState(null),[y,e]=S.useState(null),[s,t]=S.useState(null),[n,l]=S.useState(""),[f,d]=S.useState(""),g=n.trim()||o?.id||"",[u,P]=S.useState(null);S.useEffect(()=>{if(!m){e(null),t(null);return}const c=URL.createObjectURL(m);e(c);const E=document.createElement("video");E.preload="metadata",E.muted=!0,E.src=c;const L=()=>{Number.isFinite(E.duration)&&E.duration>0&&t(E.duration)};return E.addEventListener("loadedmetadata",L,{once:!0}),()=>{E.removeEventListener("loadedmetadata",L),URL.revokeObjectURL(c)}},[m]);const w=(()=>{const c=f.trim();if(!c)return;if(c.startsWith("+"))return c;const E=c.replace(/\D/g,"");return E.length===10?`+1${E}`:E.length===11&&E.startsWith("1")?`+${E}`:c})(),p=K({mutationFn:()=>{const c=h.trim();if(c)return ge({reference_url:c,brand_id:g,user_id:a,phone_number:w});if(!m)throw new Error("Provide a reel URL or upload an mp4 file");return ge({reference:m,brand_id:g,user_id:a,duration_seconds:s??8,phone_number:w})},onSuccess:c=>{P(c),T({}),I.success(`Shot list ready (${c.shot_list.shots.length} shots)`),w&&N.mutate(c.render_id)},onError:c=>I.error(`Decompose failed: ${c.message}`)}),N=K({mutationFn:c=>Ye({render_id:c}),onSuccess:c=>I.success(`Briefing SMS queued (sid ${c.sid.slice(0,12)}…)`),onError:c=>{/30034/.test(c.message)?I.message("SMS skipped — A2P 10DLC pending; use the QR instead."):I.error(`SMS failed: ${c.message}`)}}),[R,T]=S.useState({}),Z=K({mutationFn:({shot_index:c,file:E})=>He({render_id:u.render_id,shot_index:c,file:E}),onMutate:({shot_index:c})=>{T(E=>({...E,[c]:"uploading"}))},onSuccess:(c,{shot_index:E})=>{T(L=>({...L,[E]:"uploaded"}))},onError:(c,{shot_index:E})=>{T(L=>({...L,[E]:"failed"})),I.error(`Upload shot ${E} failed: ${c.message}`)}}),B=u?.render_id??null,{data:j}=We(B),F=j?.status??"",_=!!F&&ye.includes(F),G=u?.shot_list.shots.length??0,V=S.useMemo(()=>Object.values(R).filter(c=>c==="uploaded").length,[R]),O=G>0&&V>=G,A=K({mutationFn:()=>Ge(u.render_id),onSuccess:()=>I.success("Assembly started"),onError:c=>I.error(`Assemble failed: ${c.message}`)}),q=!!F&&F!=="pending"&&!_,k=!u||!O||A.isPending||q,[U,ee]=S.useState(null),[Y,le]=S.useState(""),[te,se]=S.useState(!1),X=K({mutationFn:()=>Xe(u.render_id,{passed:U==="yes",notes:Y.trim()}),onMutate:()=>{se(!0)},onSuccess:()=>I.success("Verdict recorded"),onError:c=>{se(!1),I.error(`Verdict failed: ${c.message}`)}}),de=Ee({queryKey:["mode-e-past",a],queryFn:()=>Ke(a),enabled:!!a,staleTime:3e4}),Le=(!!h.trim()||!!m)&&!!g&&!!a&&!p.isPending;return r.jsxs("div",{className:"container mx-auto max-w-5xl space-y-10 py-8",children:[r.jsxs("header",{children:[r.jsx("h1",{className:"text-2xl font-semibold",children:"Mode E Review"}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:"Decompose a reference reel, upload your matching shots, assemble, and submit a round-1 verdict."})]}),r.jsxs("section",{className:"space-y-4 rounded-lg border p-6",children:[r.jsx("h2",{className:"text-lg font-medium",children:"1. Reference video"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Paste a public Instagram reel URL. The worker scrapes it via Apify and re-hosts the mp4 on R2. Or upload an mp4 directly as a fallback."}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(D,{htmlFor:"ref-url",children:"Instagram reel URL"}),r.jsx(J,{id:"ref-url",placeholder:"https://www.instagram.com/reel/...",value:h,onChange:c=>x(c.target.value),disabled:!!m}),h.trim()&&r.jsx("div",{className:"text-xs text-muted-foreground",children:"URL path — duration + metadata sourced from Apify."})]}),r.jsxs("details",{className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[r.jsx("summary",{className:"cursor-pointer select-none text-muted-foreground",children:"…or upload an mp4 manually (fallback)"}),r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsx(D,{htmlFor:"ref-file",children:"Reference mp4"}),r.jsx(J,{id:"ref-file",type:"file",accept:"video/mp4",disabled:!!h.trim(),onChange:c=>{const E=c.target.files?.[0]??null;b(E)}}),m&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.name," —"," ",(m.size/1024/1024).toFixed(1)," MB",s!=null?` · ${s.toFixed(1)}s`:" · probing…"]}
1),y&&r.jsx("video",{src:y,controls:!0,muted:!0,playsInline:!0,className:"aspect-[9/16] w-full max-w-xs rounded-md bg-black"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(D,{htmlFor:"brand-id",children:["Brand ID"," ",r.jsxs("span",{className:"text-muted-foreground",children:["(defaults to your active brand",o?.id?` ${o.id}`:"",")"]})]}),r.jsx(J,{id:"brand-id",placeholder:o?.id??"brand UUID",value:n,onChange:c=>l(c.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(D,{htmlFor:"phone-number",children:["Phone (optional —"," ",r.jsx("span",{className:"text-muted-foreground",children:"also fires SMS briefing once A2P is approved"}),")"]}),r.jsx(J,{id:"phone-number",type:"tel",placeholder:"+15551234567",value:f,onChange:c=>d(c.target.value)})]}),r.jsx(W,{onClick:()=>p.mutate(),disabled:!Le,children:p.isPending?"Decomposing…":"Decompose reference"})]}),u?.magic_link&&r.jsxs("section",{className:"space-y-4 rounded-lg border p-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-medium",children:"Open on your phone"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Scan this QR with your phone camera to open the upload page there. SMS delivery is queued for after A2P 10DLC clears (issue thalio-v2#71); for now this QR is the fastest way to jump from desktop to phone."})]}),r.jsxs("div",{className:"flex flex-col items-start gap-4 sm:flex-row sm:items-center",children:[r.jsx("div",{className:"rounded-md bg-white p-3",children:r.jsx(Ie,{value:u.magic_link,size:196,marginSize:0})}),r.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[r.jsx("a",{href:u.magic_link,target:"_blank",rel:"noreferrer",className:"block break-all rounded-md border bg-muted/30 p-2 font-mono text-xs text-primary underline",children:u.magic_link}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(W,{variant:"secondary",size:"sm",onClick:()=>{navigator.clipboard.writeText(u.magic_link).then(()=>I.success("Magic-link copied")).catch(()=>I.error("Copy failed"))},children:"Copy link"}),w&&r.jsx(W,{variant:"secondary",size:"sm",disabled:N.isPending,onClick:()=>N.mutate(u.render_id),children:N.isPending?"Sending…":"Re-send SMS"})]}),N.data?.sid&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Last SMS sid: ",N.data.sid]})]})]})]}),u&&r.jsxs("section",{className:"space-y-4 rounded-lg border p-6",children:[r.jsxs("h2",{className:"text-lg font-medium",children:["2. Upload your shots (",V,"/",G,")"]}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Hit play on each example to see exactly what to film, then upload your version."}),r.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:u.shot_list.shots.map((c,E)=>{const L=R[E]??"idle",Te=c.start_sec??0;return r.jsxs("div",{className:"flex flex-col gap-3 rounded-md border p-3",children:[r.jsxs("div",{className:"text-sm font-medium",children:["Shot ",E+1," · ",c.duration_sec,"s · ",c.framing," ·"," ",c.camera_motion]}),r.jsx(it,{referenceUrl:u.reference_url,startSec:Te,durationSec:c.duration_sec}),r.jsx("div",{className:"text-xs text-muted-foreground",children:c.content_cue}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(D,{htmlFor:`upload-shot-${E}`,className:"text-xs font-medium",children:"Upload your version"}),r.jsx(J,{id:`upload-shot-${E}`,type:"file",accept:"video/*",disabled:L==="uploading",onChange:Fe=>{const me=Fe.target.files?.[0];me&&Z.mutate({shot_index:E,file:me})}})]}),r.jsxs("div",{className:"text-xs",children:["State:"," ",r.jsx("span",{className:L==="uploaded"?"text-green-700":L==="failed"?"text-red-700":"text-muted-foreground",children:L})]})]},E)})})]}),u&&r.jsxs("section",{className:"space-y-4 rounded-lg border p-6",children:[r.jsx("h2",{className:"text-lg font-medium",children:"3. Assemble & status"}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(W,{onClick:()=>A.mutate(),disabled:k,children:A.isPending?"Triggering…":"Assemble"}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{children:"Status:"})," ",ve(F||void 0)]}),j&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["clips ",j.clips_uploaded,"/",j.clips_required]})]}),j?.error_message&&r.jsxs("p",{className:"text-sm text-red-700",children:["Error: ",j.error_message]})]}),j?.output_url&&r.jsxs("section",{className:"space-y-4 rounded-lg border p-6",children:[r.jsx("h2",{className:"text-lg font-medium",children:"4. Side-by-side review"}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[j.reference_url?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium",children:"Reference"}),r.jsx("video",{controls:!0,src:j.reference_url,className:"aspect-[9/16] w-full rounded-md bg-black"})]}):r.jsx("div",{className:"text-sm text-muted-foreground",children:"No reference URL recorded."}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium",children:"Output"}),r.jsx("video",{controls:!0,src:j.output_url,className:"aspect-[9/16] w-full rounded-md bg-black"})]})]})]}),j?.output_url&&!te&&r.jsxs("section",{className:"space-y-4 rounded-lg border p-6",children:[r.jsx("h2",{className:"text-lg font-medium",children:"5. Round-1 verdict"}),r.jsxs(ke,{value:U??"",onValueChange:c=>ee(c),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fe,{id:"verdict-yes",value:"yes"}),r.jsx(D,{htmlFor:"verdict-yes",children:"Yes — I would post this"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fe,{id:"verdict-no",value:"no"}),r.jsx(D,{htmlFor:"verdict-no",children:"No — I would not post"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(D,{htmlFor:"verdict-notes",children:"Notes"}),r.jsx(Be,{id:"verdict-notes",value:Y,onChange:c=>le(c.target.value),placeholder:"What did/didn't land?",rows:4})]}),r.jsx(W,{onClick:()=>
1X.mutate(),disabled:!U||X.isPending,children:X.isPending?"Submitting…":"Submit verdict"})]}),te&&r.jsx("section",{className:"rounded-lg border bg-muted/30 p-6",children:r.jsxs("p",{className:"text-sm",children:["Verdict submitted",U?` — ${U}`:"",". Thanks."]})}),r.jsxs("section",{className:"space-y-4 rounded-lg border p-6",children:[r.jsx("h2",{className:"text-lg font-medium",children:"6. Past renders"}),de.isPending?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):(de.data??[]).length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No past renders yet."}):r.jsxs(ze,{children:[r.jsx($e,{children:r.jsxs(pe,{children:[r.jsx(re,{children:"ID"}),r.jsx(re,{children:"Status"}),r.jsx(re,{children:"Output"}),r.jsx(re,{children:"Updated"})]})}),r.jsx(Qe,{children:(de.data??[]).map(c=>r.jsxs(pe,{children:[r.jsxs(ne,{className:"font-mono text-xs",children:[c.id.slice(0,8),"…"]}),r.jsx(ne,{children:ve(c.status)}),r.jsx(ne,{children:c.output_url?r.jsx("a",{href:c.output_url,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"view"}):r.jsx("span",{className:"text-muted-foreground",children:"—"})}),r.jsx(ne,{className:"text-xs text-muted-foreground",children:new Date(c.updated_at).toLocaleString()})]},c.id))})]})]})]})}export{xt as default};

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.