PageSourceSearch

https://www.withmarble.ai/_next/static/chunks/pages/paths/archive/gym_math_rooms-ff60fa3851338803.js

js withmarble.ai collected 2026-10-05 14:50:59 UTC 18,504 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8507,5697],{35945:function(e,r,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/paths/archive/gym_math_rooms",function(){return n(59834)}])},59834:function(e,r,n){"use strict";n.r(r);var t=n(47568),a=n(29815),o=n(97582),s=n(85893),c=n(67294),l=n(67642),i=n(41352),u=n(12048),d=n.n(u),h=n(87617);var m=function(e){var r=e.content,n=(0,c.useState)(!1),t=n[0],a=(n[1],function(e){try{var r=RegExp("<BlockMath>\\{'(.*?)'\\}<\\/BlockMath>","gs"),n=RegExp("<InlineMath>\\{'(.*?)'\\}<\\/InlineMath>","gs"),t=Array.from(e.matchAll(r)),a=Array.from(e.matchAll(n));return{blocks:t.map((function(e){return e[1].replace(/\\\\/g,"\\")})),inlines:a.map((function(e){return e[1].replace(/\\\\/g,"\\")}))}}catch(o){return console.error("Error extracting expressions:",o),{blocks:[],inlines:[]}}}(r));return t?(0,s.jsxs)("div",{className:"bg-red-900/30 p-4 rounded",children:[(0,s.jsx)("h3",{className:"text-xl font-bold mb-2",children:"Error Rendering LaTeX"}),(0,s.jsx)("p",{children:"There was an error rendering the LaTeX content."}),(0,s.jsx)("pre",{className:"mt-4 bg-gray-900 p-3 rounded text-sm overflow-auto",children:r})]}):(0,s.jsxs)("div",{children:[function(e){try{var r=RegExp("<h3>(.*?)<\\/h3>","gs");return Array.from(e.matchAll(r)).map((function(e,r){return(0,s.jsx)("h3",{className:"text-xl font-bold mb-4",children:e[1]},r)}))}catch(n){return(0,s.jsx)("h3",{className:"text-xl font-bold mb-4",children:"Transcription Result"})}}(r),function(e){try{var r=RegExp("<p>(.*?)<\\/p>","gs");return Array.from(e.matchAll(r)).map((function(e,r){return e[1].includes("<InlineMath>")?null:(0,s.jsx)("p",{children:e[1]},r)})).filter((function(e){return null!==e}))}catch(n){return(0,s.jsx)("p",{children:"Error rendering text content"})}}(r),a.blocks.length>0&&(0,s.jsx)("div",{className:"space-y-6 mt-4",children:a.blocks.map((function(e,r){return(0,s.jsx)("div",{className:"py-2",children:"\\"!==e&&(0,s.jsx)(h.BlockMath,{children:e})},r)}))}),0===a.inlines.length&&0===a.blocks.length&&(0,s.jsxs)("div",{className:"bg-yellow-900/30 p-4 rounded",children:[(0,s.jsx)("p",{children:"No LaTeX expressions found in the content."}),(0,s.jsx)("pre",{className:"mt-4 bg-gray-900 p-3 rounded text-sm overflow-auto",children:r})]})]})},p=function(e){var r=e.onImagesChanged,n=e.latexContent,i=Math.floor(1e4*Math.random()),u=(0,c.useState)("".concat(i)),p=u[0],f=u[1],g=(0,c.useState)(!1),x=g[0],b=g[1],y=(0,c.useState)(null),v=y[0],j=y[1],N=function(e){var r=(0,c.useState)([]),n=r[0],s=r[1],i=(0,c.useState)(!1),u=i[0],d=i[1],h=(0,c.useState)(null),m=h[0],p=h[1],f=(0,c.useState)(!0),g=f[0],x=f[1],b=(0,c.useRef)(null),y=!1;return(0,c.useEffect)((function(){return b.current||(0,t.Z)((function(){var r;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,fetch("/api/paths/ai/socket_image_rooms")];case 1:n.sent(),n.label=2;case 2:return b.current=(0,l.ZP)({reconnection:!0,reconnectionAttempts:5,reconnectionDelay:1e3}),b.current.on("connect",(function(){console.log("Connected to rooms server. Joining room:",e),d(!0),p(null),x(!1),e&&b.current.emit("join-room",e)})),b.current.on("connect_error",(function(e){console.error("Connection error:",e),p("Failed to connect. Please refresh."),d(!1),x(!1)})),b.current.on("new-room-message",(function(e){var r;(null===(r=e.content)||void 0===r?void 0:r.image)&&s((function(r){return(0,a.Z)(r).concat([e])}))})),b.current.on("disconnect",(function(e){console.log("Disconnected from server. Reason:",e),d(!1),x(!1)})),[3,4];case 3:return r=n.sent(),console.error("Error setting up socket:",r),p("Could not set up socket. Try refreshing."),x(!1),[3,4];case 4:return[2]}}
1))}))(),function(){b.current&&(b.current.disconnect(),b.current=null)}}),[e,y]),{connected:u,loading:g,error:m,images:n,setError:p}}(p),w=N.connected,k=N.loading,T=N.error,E=N.images,M=N.setError,_=(0,c.useState)("\n    <h3>Sample LaTeX Equations</h3>\n    <p>This is an inline equation: <InlineMath>{'\\\\frac{1}{2} + \\\\frac{1}{3} = \\\\frac{5}{6}'}</InlineMath></p>\n    <p>This is a block equation:</p>\n    <BlockMath>{'\\\\int_{a}^{b} f(x) \\\\, dx = F(b) - F(a)'}</BlockMath>\n    <p>Another complex equation:</p>\n    <BlockMath>{'\\\\sum_{i=1}^{n} i = \\\\frac{n(n+1)}{2}'}</BlockMath>\n  "),C=_[0],S=_[1],I=function(e){try{var r=RegExp("BlockMath>\\{'(.*?)'\\}<\\/BlockMath","gs"),n=RegExp("InlineMath>\\{'(.*?)'\\}<\\/InlineMath","gs"),t=Array.from(e.matchAll(r)),a=Array.from(e.matchAll(n));if(!t.length&&!a.length)return"No LaTeX content found";var o="";return t.length&&(o+="/* Block Equations */\n\n",t.forEach((function(e,r){if(e[1]){var n=e[1].replace(/\\\\/g,"\\");o+=n+"\n\n"}}))),a.length&&(o+="\n/* Inline Equations */\n\n",a.forEach((function(e,r){if(e[1]){var n=e[1].replace(/\\\\/g,"\\");o+=n+"\n"}}))),o.trim()}catch(T){return console.error("Error extracting LaTeX:",T),"Error extracting LaTeX content. Please check console for details."}};(0,c.useEffect)((function(){n&&(S(n),b(!1),j(null))}),[n]),(0,c.useEffect)((function(){r&&"function"===typeof r&&r(E)}),[E,r]);var A=function(e){e.target.onerror=null,e.target.style.display="none";var r=document.createElement("div");r.textContent="Image failed to load",r.className="text-red-500 text-sm mt-1",e.target.parentNode.appendChild(r)};return(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)("h2",{className:"text-2xl font-bold mb-2",children:"Gym Math Rooms"}),(0,s.jsxs)("div",{className:"mb-4 flex items-center space-x-4",children:[(0,s.jsx)("label",{className:"text-white",htmlFor:"roomId",children:"Room ID:"}),(0,s.jsx)("input",{id:"roomId",className:"bg-gray-800 text-white px-2 py-1 rounded",value:p,onChange:function(e){return f(e.target.value)},placeholder:"Room ID"}),(0,s.jsx)("span",{className:"px-2 py-1 rounded text-xs ".concat(w?"bg-green-700":"bg-red-700"),children:w?"\u2713 Connected":"\u2717 Disconnected"})]}),T&&(0,s.jsxs)("div",{className:"mb-4 p-3 bg-red-900/50 text-white rounded-lg",children:[(0,s.jsx)("p",{children:T}),(0,s.jsx)("button",{onClick:function(){return M(null)},className:"text-sm underline mt-1",children:"Dismiss"})]}),(0,s.jsxs)("div",{className:"flex space-x-4",children:[(0,s.jsx)("div",{className:"flex-1",children:k?(0,s.jsx)("div",{className:"py-6 text-center text-gray-400",children:(0,s.jsx)("p",{children:"Connecting to room server..."})}):0===E.length?(0,s.jsxs)("div",{className:"py-6 text-center text-gray-400",children:[(0,s.jsx)("p",{children:"No images yet in this room."}),(0,s.jsxs)("p",{children:["Scan an image from ",(0,s.jsx)("strong",{children:"math_scan_socket_rooms"})," in the same room."]})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:E.map((function(e,r){var n=e.id,t=e.timestamp,a=e.content,o=new Date(t).toLocaleString();return(0,s.jsxs)("div",{className:"bg-gray-800 rounded-lg overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-2 bg-gray-700 text-xs",children:[o," (Room: ",p,")"]}),(0,s.jsx)("div",{className:"p-2",children:(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)("img",{src:a.image,alt:"Math note ".concat(r+1),className:"max-w-full rounded border border-gray-600 max-h-[30vh]",onError:A,loading:"lazy"})})})]},n||r)}))})}),(0,s.jsxs)("div",{className:"flex-1 bg-gray-800 rounded-lg p-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-4 border-b border-gray-700 pb-2",children:[(0,s.jsx)("h3",{className:"text-xl font-bold",children:"LaTeX Rendering"}),(0,s.jsxs)("div",{className:"flex space-x-2",children:[(0,s.jsx)("button",{onClick:function(){return b(!x)},className:"bg-gray-700 hover:bg-gray-600 px-3 py-1 text-sm rounded",children:x?"Show Rendered":"Show Raw LaTeX"}),x&&(0,s.jsx)("button",{onClick:function(){return e=I(C),void navigator.clipboard.writeText(e).then((function(){alert("LaTeX copied to clipboard!")})).catch((function(e){console.error("Failed to copy: ",e)}));var e},className:"bg-blue-700 hover:bg-blue-600 px-3 py-1 text-sm rounded",children:"Copy LaTeX"})]})]}),(0,s.jsxs)("div",{className:"latex-content",children:[(0,s.jsx)("link",{rel:"stylesheet",href:"https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"}),x?(0,s.jsx)("div",{className:"bg-gray-900 p-4 rounded overflow-auto max-h-[60vh]",children:(0,s.jsx)("pre",{className:"text-gray-300 whitespace-pre-wrap",children:I(C)})}):v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"bg-yellow-900/30 p-3 rounded mb-4",children:[(0,s.jsx)("p",{className:"text-sm",children:"JSX Parser encountered an error. Using fallback renderer."}),(0,s.jsx)("button",{onClick:function(){return j(null)},className:"text-xs underline mt-1 text-yellow-400",children:"Try JSX Parser again"})]}),(0,s.jsx)(m,{content:C})]}):(0,s.jsx)(d(),{components:{BlockMath:h.BlockMath,InlineMath:h.InlineMath}
1,jsx:C,onError:function(e){console.log("JsxParser Error:\n",e),j(e)}})]})]})]})]})};r.default=function(){var e=(0,c.useState)(""),r=e[0],n=e[1],l=(0,c.useState)([]),u=l[0],d=l[1],h=(0,c.useState)(""),m=h[0],f=h[1],g=(0,c.useState)(!1),x=g[0],b=g[1],y=(0,c.useState)([{text:"Can you help me solve this math problem?",isUser:!1},{text:"I shared an image in the room. Can you check it?",isUser:!0}]),v=y[0],j=y[1],N=function(){r.trim()&&(j((0,a.Z)(v).concat([{text:r,isUser:!0}])),n(""))},w=function(){var e=(0,t.Z)((function(){var e,r,n,t,a,s,c,l,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(0===u.length)return console.log("No images available to transcribe"),f("\n        <h3>No Images to Transcribe</h3>\n        <p>Please add images to the room before transcribing.</p>\n      "),[2];o.label=1;case 1:return o.trys.push([1,6,7,8]),b(!0),console.log("Attempting to transcribe images..."),f("\n        <h3>Transcribing...</h3>\n        <p>Please wait while we analyze the mathematical content in your images.</p>\n        <p>This may take a moment depending on the complexity of the equations.</p>\n      "),e=u.map((function(e){return e.content.image})),[4,fetch("/api/paths/ai/transcribe-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({images:e})})];case 2:return(r=o.sent()).ok?[3,4]:[4,r.json()];case 3:throw n=o.sent(),new Error("API error: ".concat(n.error||"Unknown error"));case 4:return[4,r.json()];case 5:if(t=o.sent(),console.log("Transcription result:",t),a=function(e){if(!e)return"";var r=e.replace(/\n/g," ");return r=(r=r.replace(/\\/g,"\\\\")).replace(/'/g,"\\'")},t.expressions&&Array.isArray(t.expressions)&&t.expressions.length>0)s="<h3>Transcribed LaTeX</h3>",t.expressions.forEach((function(e,r){var n=a(e.latex);s+='\n            <div class="expression-container mb-6 pb-4 '.concat(r<t.expressions.length-1?"border-b border-gray-700":"",'">\n              ').concat(e.description?'<p class="text-gray-300 mb-2">'.concat(e.description,"</p>"):"","\n              <BlockMath>{'").concat(n,"'}</BlockMath>\n            </div>\n          ")})),f(s);else{if(!t.latex)throw new Error("Unexpected response format from API");c=a(t.latex),l="\n          <h3>Transcribed LaTeX</h3>\n          <p>The following was transcribed from your image(s):</p>\n          <BlockMath>{'".concat(c,"'}</BlockMath>\n        "),f(l)}return[3,8];case 6:return i=o.sent(),console.error("Failed to transcribe images:",i),f("\n        <h3>Transcription Error</h3>\n        <p>There was an error transcribing your images:</p>\n        <p>".concat(i.message,"</p>\n      ")),[3,8];case 7:return b(!1),[7];case 8:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}();return(0,s.jsxs)("div",{className:"flex h-screen bg-gray-900 text-white",children:[(0,s.jsxs)("div",{className:"flex-1 flex flex-col border-r border-gray-700",children:[(0,s.jsxs)("div",{className:"flex items-center p-4 border-b border-gray-700",children:[(0,s.jsx)(i.Z,{className:"w-5 h-5 text-gray-400"}),(0,s.jsxs)("div",{className:"mx-2 h-2 w-72 bg-gray-700 rounded relative",children:[(0,s.jsx)("div",{className:"absolute top-0 left-0 h-full w-full bg-gray-700 rounded"}),(0,s.jsx)("div",{className:"absolute top-0 left-0 h-full w-1/2 bg-blue-500 rounded"})]})]}),(0,s.jsx)("div",{className:"flex-1 p-6 overflow-y-auto",children:(0,s.jsx)(p,{onImagesChanged:function(e){d(e)},latexContent:m})})]}),(0,s.jsxs)("div",{className:"w-96 flex flex-col",children:[(0,s.jsxs)("div",{className:"p-2 space-y-2 bg-gray-800 border-b border-gray-700",children:[(0,s.jsx)("button",{onClick:function(){u.length>0?console.log("Image data from socket connection:",u):console.log("No images available in the math board")},className:"bg-gray-700 hover:bg-gray-600 p-2 text-white w-full rounded",children:"Test Dev Button"}),(0,s.jsx)("button",{onClick:w,disabled:x||0===u.length,className:"flex justify-center items-center p-3 text-white w-full rounded font-bold \n              ".concat(x?"bg-purple-900 cursor-not-allowed":0===u.length?"bg-gray-700 cursor-not-allowed":"bg-purple-700 hover:bg-purple-600"),children:x?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Transcribing..."]}):"Transcribe Math Images"})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:v.map((function(e,r){return e.isUser?(0,s.jsx)("div",{className:"p-3 bg-gray-800 rounded-lg",children:e.text},r):(0,s.jsx)("div",{className:"mb-4",children:e.text},r)}))}),(0,s.jsx)("div",{className:"p-4 border-t border-gray-700",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("textarea",{value:r,onChange:function(e){return n(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),N())},placeholder:"I",className:"w-full bg-gray-800 rounded-lg p-4 pr-20 resize-none focus:outline-none",rows:"3"}),(0,s.jsxs)("div",{className:"absolute bottom-3 right-3 flex items-center",children:[(0,s.jsxs)("div",{className:"flex items-center text-gray-400 mr-2",children:["balanced ",(0,s.jsx)("span",{className:"ml-1",children:"\u25be"})]}),(0,s.jsx)("button",{onClick:N,className:"bg-gray-600 hover:bg-gray-500 px-3 py-1 rounded",children:"Send \u21b5"})]})]})})]})]})}},92703:function(e,r,n){"use strict";var t=n(50414);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,r,n,a,o,s){if(s!==t){var c=new 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 c.name="Invariant Violation",c}}function r(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:r,element:e,elementType:e,instanceOf:r,node:e,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},45697:function(e,r,n){e.exports=n(92703)()},50414:function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},87617:function(e,r,n){var t,a,o,s;s=function(e,r,n,t){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function o(e){if("function"!==typeof WeakMap)return null;var r=new WeakMap,n=new WeakMap;return(o=function(e){return e?n:r})(e)}function s(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!==typeof e&&"function"!==typeof e)return{default:e};var n=o(r);if(n&&n.has(e))return n.get(e);var t={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var c=a?Object.getOwnPropertyDescriptor(e,s):null;c&&(c.get||c.set)?Object.defineProperty(t,s,c):t[s]=e[s]}return t.default=e,n&&n.set(e,t),t}
1Object.defineProperty(e,"__esModule",{value:!0}),function(e,r){for(var n in r)Object.defineProperty(e,n,{enumerable:!0,get:r[n]})}(e,{BlockMath:()=>d,InlineMath:()=>h}),r=s(r),n=a(n),t=a(t);const c=(e,{displayMode:a})=>{const o=({children:n,errorColor:o,math:s,renderError:c})=>{const l=null!==s&&void 0!==s?s:n,{html:i,error:u}=(0,r.useMemo)((()=>{try{return{html:t.default.renderToString(l,{displayMode:a,errorColor:o,throwOnError:!!c}),error:void 0}}catch(u){if(u instanceof t.default.ParseError||u instanceof TypeError)return{error:u};throw u}}),[l,o,c]);return u?c?c(u):r.default.createElement(e,{html:`${u.message}`}):r.default.createElement(e,{html:i})};return o.propTypes={children:n.default.string,errorColor:n.default.string,math:n.default.string,renderError:n.default.func},o},l={html:n.default.string.isRequired},i=({html:e})=>r.default.createElement("div",{"data-testid":"react-katex",dangerouslySetInnerHTML:{__html:e}});i.propTypes=l;const u=({html:e})=>r.default.createElement("span",{"data-testid":"react-katex",dangerouslySetInnerHTML:{__html:e}});u.propTypes=l;const d=c(i,{displayMode:!0}),h=c(u,{displayMode:!1})},"object"===typeof e.exports?s(r,n(67294),n(45697),n(20527)):(a=[r,n(67294),n(45697),n(20527)],void 0===(o="function"===typeof(t=s)?t.apply(r,a):t)||(e.exports=o))},20943:function(e,r,n){"use strict";function t(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}n.d(r,{Z:function(){return t}})},13375:function(e,r,n){"use strict";function t(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}n.d(r,{Z:function(){return t}})},29815:function(e,r,n){"use strict";n.d(r,{Z:function(){return s}});var t=n(20943);var a=n(13375);var o=n(91566);function s(e){return function(e){if(Array.isArray(e))return(0,t.Z)(e)}(e)||(0,a.Z)(e)||(0,o.Z)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},91566:function(e,r,n){"use strict";n.d(r,{Z:function(){return a}});var t=n(20943);function a(e,r){if(e){if("string"===typeof e)return(0,t.Z)(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?(0,t.Z)(e,r):void 0}}}},function(e){e.O(0,[8889,573,7642,9774,2888,179],(function(){return r=35945,e(e.s=r);var r}));var r=e.O();_N_E=r}]);

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.