@pineui/react 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pineui.es.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import Q, { useState as w, useEffect as W, Component as se } from "react";
2
2
  import ie from "react-dom";
3
- var J = {}, G = ie;
4
- J.createRoot = G.createRoot, J.hydrateRoot = G.hydrateRoot;
5
- var X = { exports: {} }, H = {};
3
+ var q = {}, G = ie;
4
+ q.createRoot = G.createRoot, q.hydrateRoot = G.hydrateRoot;
5
+ var X = { exports: {} }, P = {};
6
6
  /**
7
7
  * @license React
8
8
  * react-jsx-runtime.production.min.js
@@ -20,10 +20,10 @@ function ee(e, n, r) {
20
20
  if (e && e.defaultProps) for (t in n = e.defaultProps, n) s[t] === void 0 && (s[t] = n[t]);
21
21
  return { $$typeof: ae, type: e, key: o, ref: a, props: s, _owner: ue.current };
22
22
  }
23
- H.Fragment = le;
24
- H.jsx = ee;
25
- H.jsxs = ee;
26
- X.exports = H;
23
+ P.Fragment = le;
24
+ P.jsx = ee;
25
+ P.jsxs = ee;
26
+ X.exports = P;
27
27
  var i = X.exports;
28
28
  function T(e, n) {
29
29
  if (typeof e == "string")
@@ -336,9 +336,9 @@ const ge = ({
336
336
  };
337
337
  return /* @__PURE__ */ i.jsx("span", { className: "pineui-icon", style: s, children: o[e] || e });
338
338
  };
339
- function U(e, n) {
340
- return e === "{{response}}" ? n : typeof e != "object" || e === null ? e : Array.isArray(e) ? e.map((r) => U(r, n)) : Object.fromEntries(
341
- Object.entries(e).map(([r, t]) => [r, U(t, n)])
339
+ function J(e, n) {
340
+ return e === "{{response}}" ? n : typeof e != "object" || e === null ? e : Array.isArray(e) ? e.map((r) => J(r, n)) : Object.fromEntries(
341
+ Object.entries(e).map(([r, t]) => [r, J(t, n)])
342
342
  );
343
343
  }
344
344
  const _e = ({
@@ -372,10 +372,10 @@ const _e = ({
372
372
  try {
373
373
  if (k ? S(!0) : E(!0), N(null), s.type === "action.http") {
374
374
  let u = s.url;
375
- u.includes("{{state.") && (u = u.replace(/\{\{state\.([^}]+)\}\}/g, (M, P) => {
376
- const z = P.split(".");
375
+ u.includes("{{state.") && (u = u.replace(/\{\{state\.([^}]+)\}\}/g, (M, H) => {
376
+ const V = H.split(".");
377
377
  let F = m.state;
378
- for (const re of z) {
378
+ for (const re of V) {
379
379
  if (F == null) return "";
380
380
  F = F[re];
381
381
  }
@@ -384,7 +384,7 @@ const _e = ({
384
384
  const x = await (await fetch(u)).json(), I = x.data || x;
385
385
  if (j((M) => k ? [...M, ...I] : I), s.onSuccess && m) {
386
386
  console.log(`[Collection] onSuccess called with ${I.length} items`);
387
- const M = U(s.onSuccess, I);
387
+ const M = J(s.onSuccess, I);
388
388
  await m.executeAction(M), console.log("[Collection] onSuccess done");
389
389
  }
390
390
  x.pagination ? (O(x.pagination.hasMore), f(x.pagination.cursor)) : O(!1);
@@ -510,7 +510,7 @@ const _e = ({
510
510
  },
511
511
  a
512
512
  )) });
513
- }, V = ({
513
+ }, z = ({
514
514
  type: e,
515
515
  id: n,
516
516
  label: r,
@@ -769,11 +769,11 @@ const _e = ({
769
769
  icon: we,
770
770
  collection: _e,
771
771
  "collection.map": Ne,
772
- "input.text": V,
773
- "input.email": V,
774
- "input.password": V,
775
- "input.number": V,
776
- "input.search": V,
772
+ "input.text": z,
773
+ "input.email": z,
774
+ "input.password": z,
775
+ "input.number": z,
776
+ "input.search": z,
777
777
  divider: Ae,
778
778
  conditionalRender: Te,
779
779
  "conditional.render": Ee,
@@ -807,7 +807,7 @@ const _e = ({
807
807
  renderer: R
808
808
  }
809
809
  ) : (console.warn(`Unknown component type: ${o.type}`), null);
810
- }, Le = ({ messages: e, onDismiss: n }) => /* @__PURE__ */ i.jsx("div", { className: "pineui-snackbar-container", children: e.map((r) => /* @__PURE__ */ i.jsx(Ve, { message: r, onDismiss: n }, r.id)) }), Ve = ({
810
+ }, Le = ({ messages: e, onDismiss: n }) => /* @__PURE__ */ i.jsx("div", { className: "pineui-snackbar-container", children: e.map((r) => /* @__PURE__ */ i.jsx(ze, { message: r, onDismiss: n }, r.id)) }), ze = ({
811
811
  message: e,
812
812
  onDismiss: n
813
813
  }) => {
@@ -822,7 +822,7 @@ const _e = ({
822
822
  /* @__PURE__ */ i.jsx("span", { className: "pineui-snackbar__message", children: e.message }),
823
823
  e.action && /* @__PURE__ */ i.jsx("button", { className: "pineui-snackbar__action", onClick: e.action.onPress, children: e.action.label })
824
824
  ] });
825
- }, ze = ({
825
+ }, Ve = ({
826
826
  presentation: e = "modal",
827
827
  dismissible: n = !0,
828
828
  child: r,
@@ -848,7 +848,7 @@ const _e = ({
848
848
  renderer: t
849
849
  }) => /* @__PURE__ */ i.jsx(i.Fragment, { children: Object.entries(e).map(
850
850
  ([s, { visible: o, config: a }]) => o ? /* @__PURE__ */ i.jsx(
851
- ze,
851
+ Ve,
852
852
  {
853
853
  id: s,
854
854
  ...a,
@@ -859,7 +859,7 @@ const _e = ({
859
859
  s
860
860
  ) : null
861
861
  ) });
862
- function q(e, n) {
862
+ function U(e, n) {
863
863
  if (n.startsWith("http://") || n.startsWith("https://"))
864
864
  return n;
865
865
  try {
@@ -876,18 +876,18 @@ async function Z(e, n) {
876
876
  if (e.imports.components)
877
877
  for (const t of e.imports.components)
878
878
  try {
879
- const s = q(n, t), a = await (await fetch(s)).json();
879
+ const s = U(n, t), a = await (await fetch(s)).json();
880
880
  r.components = {
881
881
  ...r.components,
882
882
  ...a
883
883
  };
884
884
  } catch (s) {
885
- console.error(`❌ Failed to load component from ${t}:`, s), console.error(` Resolved URL: ${q(n, t)}`);
885
+ console.error(`❌ Failed to load component from ${t}:`, s), console.error(` Resolved URL: ${U(n, t)}`);
886
886
  }
887
887
  if (e.imports.views)
888
888
  for (const t of e.imports.views)
889
889
  try {
890
- const s = q(n, t), a = await (await fetch(s)).json();
890
+ const s = U(n, t), a = await (await fetch(s)).json();
891
891
  r.views = {
892
892
  ...r.views,
893
893
  ...a
@@ -897,7 +897,7 @@ async function Z(e, n) {
897
897
  }
898
898
  return r;
899
899
  }
900
- class He extends se {
900
+ class Pe extends se {
901
901
  constructor(n) {
902
902
  super(n), this.state = { hasError: !1, error: null };
903
903
  }
@@ -933,7 +933,7 @@ class He extends se {
933
933
  ] }) : this.props.children;
934
934
  }
935
935
  }
936
- function Pe(e, n) {
936
+ function He(e, n) {
937
937
  const r = n.split(".");
938
938
  let t = e;
939
939
  for (const s of r) {
@@ -942,7 +942,7 @@ function Pe(e, n) {
942
942
  }
943
943
  return t;
944
944
  }
945
- const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
945
+ const Ue = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
946
946
  const [t, s] = w(null), [o, a] = w(!0), [d, c] = w(null), [p, m] = w([]), [y, g] = w({}), j = (e == null ? void 0 : e.state) || {
947
947
  currentUser: {
948
948
  id: "user_current",
@@ -1016,7 +1016,7 @@ const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
1016
1016
  const u = l.value;
1017
1017
  console.log(`[patch] ${l.path} =`, typeof u == "object" && u !== null ? Array.isArray(u) ? `Array(${u.length})` : `{id: ${u == null ? void 0 : u.id}, title: ${u == null ? void 0 : u.title}}` : u), E((v) => {
1018
1018
  const x = { ...v };
1019
- return Je(x, l.path, l.value), x;
1019
+ return qe(x, l.path, l.value), x;
1020
1020
  });
1021
1021
  break;
1022
1022
  }
@@ -1043,8 +1043,8 @@ const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
1043
1043
  const u = typeof l.message == "string" && l.message.includes("{{") ? l.message.replace(/\{\{(.+?)\}\}/g, (x, I) => {
1044
1044
  const M = I.trim();
1045
1045
  if (M.startsWith("state.")) {
1046
- const P = M.substring(6), z = Pe(b, P);
1047
- return z != null ? String(z) : "";
1046
+ const H = M.substring(6), V = He(b, H);
1047
+ return V != null ? String(V) : "";
1048
1048
  }
1049
1049
  return "";
1050
1050
  }) : l.message, v = {
@@ -1137,28 +1137,28 @@ const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
1137
1137
  [f]: { ...h[f], visible: !1 }
1138
1138
  }));
1139
1139
  };
1140
- return /* @__PURE__ */ i.jsx(He, { children: /* @__PURE__ */ i.jsxs("div", { className: "pineui-root", children: [
1140
+ return /* @__PURE__ */ i.jsx(Pe, { children: /* @__PURE__ */ i.jsxs("div", { className: "pineui-root", children: [
1141
1141
  /* @__PURE__ */ i.jsx(R, { node: t.screen, context: C }),
1142
1142
  /* @__PURE__ */ i.jsx(Le, { messages: p, onDismiss: O }),
1143
1143
  /* @__PURE__ */ i.jsx(Re, { overlays: y, onClose: B, context: C, renderer: R })
1144
1144
  ] }) });
1145
1145
  };
1146
- function Je(e, n, r) {
1146
+ function qe(e, n, r) {
1147
1147
  const t = n.split(".");
1148
1148
  let s = e;
1149
1149
  for (let o = 0; o < t.length - 1; o++)
1150
1150
  s[t[o]] || (s[t[o]] = {}), s = s[t[o]];
1151
1151
  s[t[t.length - 1]] = r;
1152
1152
  }
1153
- function Ue(e) {
1153
+ function Je(e) {
1154
1154
  var t, s;
1155
1155
  const n = typeof e.target == "string" ? document.querySelector(e.target) : e.target;
1156
1156
  if (!n) {
1157
1157
  console.error("PineUI: Target element not found"), (t = e.onError) == null || t.call(e, new Error("Target element not found"));
1158
1158
  return;
1159
1159
  }
1160
- J.createRoot(n).render(
1161
- Q.createElement(qe, {
1160
+ q.createRoot(n).render(
1161
+ Q.createElement(Ue, {
1162
1162
  schema: e.schema,
1163
1163
  schemaUrl: e.schemaUrl,
1164
1164
  baseUrl: e.baseUrl
@@ -1166,9 +1166,10 @@ function Ue(e) {
1166
1166
  ), (s = e.onReady) == null || s.call(e);
1167
1167
  }
1168
1168
  typeof window < "u" && (window.PineUI = {
1169
- render: Ue
1169
+ render: Je
1170
1170
  });
1171
+ console.log("%c🍍 PineUI v0.1.5%c — Server-Driven UI for AI-Native Apps", "color:#6750A4;font-weight:700;font-size:14px", "color:#79747E;font-size:12px");
1171
1172
  export {
1172
- qe as PineUI,
1173
- Ue as render
1173
+ Ue as PineUI,
1174
+ Je as render
1174
1175
  };
@@ -8374,6 +8374,7 @@
8374
8374
  render
8375
8375
  };
8376
8376
  }
8377
+ console.log("%c🍍 PineUI v0.1.5%c — Server-Driven UI for AI-Native Apps", "color:#6750A4;font-weight:700;font-size:14px", "color:#79747E;font-size:12px");
8377
8378
  exports2.PineUI = PineUI;
8378
8379
  exports2.render = render;
8379
8380
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
@@ -1,4 +1,4 @@
1
- (function(E,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],m):(E=typeof globalThis<"u"?globalThis:E||self,m(E.PineUI={},E.React,E.ReactDOM))})(this,function(E,m,re){"use strict";var U={},K=re;U.createRoot=K.createRoot,U.hydrateRoot=K.hydrateRoot;var Y={exports:{}},P={};/**
1
+ (function(E,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],m):(E=typeof globalThis<"u"?globalThis:E||self,m(E.PineUI={},E.React,E.ReactDOM))})(this,function(E,m,re){"use strict";var H={},K=re;H.createRoot=K.createRoot,H.hydrateRoot=K.hydrateRoot;var Y={exports:{}},R={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,9 +6,9 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ie=m,oe=Symbol.for("react.element"),ae=Symbol.for("react.fragment"),le=Object.prototype.hasOwnProperty,ce=ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ue={key:!0,ref:!0,__self:!0,__source:!0};function Z(e,n,s){var t,r={},o=null,a=null;s!==void 0&&(o=""+s),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(a=n.ref);for(t in n)le.call(n,t)&&!ue.hasOwnProperty(t)&&(r[t]=n[t]);if(e&&e.defaultProps)for(t in n=e.defaultProps,n)r[t]===void 0&&(r[t]=n[t]);return{$$typeof:oe,type:e,key:o,ref:a,props:r,_owner:ce.current}}P.Fragment=ae,P.jsx=Z,P.jsxs=Z,Y.exports=P;var i=Y.exports;function T(e,n){if(typeof e=="string")return de(e,n);if(Array.isArray(e))return e.map(s=>T(s,n));if(e&&typeof e=="object"){const s={};for(const t in e)s[t]=T(e[t],n);return s}return e}function de(e,n){const s=e.indexOf("}}");if(e.startsWith("{{")&&e.endsWith("}}")&&s===e.length-2){const r=e.slice(2,-2).trim();return(r==="item"||r.startsWith("item."))&&(!("item"in n)||n.item===void 0)||(r==="props"||r.startsWith("props."))&&(!("props"in n)||n.props===void 0)||(r==="response"||r.startsWith("response."))&&!("response"in n)?e:Q(r,n)}return e.replace(/\{\{(.+?)\}\}/g,(r,o)=>{const a=Q(o.trim(),n);return a!=null?String(a):""})}function Q(e,n){try{if(/^[\w.]+$/.test(e))return X(n,e);if(e.includes("|")&&!e.includes("||"))return pe(e,n);const s=Object.keys(n).filter(o=>/^[a-zA-Z_$][\w$]*$/.test(o)),t=s.map(o=>n[o]);return new Function(...s,`"use strict"; try { return (${e}); } catch(e) { return undefined; }`)(...t)}catch(s){console.warn(`Failed to evaluate expression: ${e}`,s);return}}function X(e,n){const s=n.split(".");let t=e;for(const r of s){if(t==null)return;t=t[r]}return t}function pe(e,n){const[s,t]=e.split("|").map(o=>o.trim()),r=X(n,s);return t==="timeAgo"?fe(r):r}function fe(e){if(!e)return"";const n=new Date(e);if(isNaN(n.getTime()))return e;const t=Math.floor((new Date().getTime()-n.getTime())/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:t<2592e3?`${Math.floor(t/86400)}d`:t<31536e3?`${Math.floor(t/2592e3)}mo`:`${Math.floor(t/31536e3)}y`}function q(e){var n,s,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(n=0;n<r;n++)e[n]&&(s=q(e[n]))&&(t&&(t+=" "),t+=s)}else for(s in e)e[s]&&(t&&(t+=" "),t+=s);return t}function D(){for(var e,n,s=0,t="",r=arguments.length;s<r;s++)(e=arguments[s])&&(n=q(e))&&(t&&(t+=" "),t+=n);return t}const me=({content:e,style:n="bodyMedium",color:s,fontWeight:t,maxLines:r})=>{const o=D("pineui-text",`pineui-text--${n}`,{"pineui-text--bold":t==="bold"}),a={color:s?`var(--md-sys-color-${s}, ${s})`:void 0,WebkitLineClamp:r??void 0,display:r?"-webkit-box":void 0,WebkitBoxOrient:r?"vertical":void 0,overflow:r?"hidden":void 0};return i.jsx("p",{className:o,style:a,children:e||"(empty)"})},L=({type:e,label:n,icon:s,enabled:t=!0,loading:r=!1,onPress:o,context:a,size:d="medium",color:c})=>{const p=async()=>{if(!t||r||!o||!a)return;const b=T(o,a);await a.executeAction(b)},h=D("pineui-button",`pineui-button--${e.split(".")[1]}`,{"pineui-button--disabled":!t,"pineui-button--loading":r,[`pineui-button--${d}`]:d}),v={color:c?`var(--md-sys-color-${c}, ${c})`:void 0};return i.jsxs("button",{className:h,onClick:p,disabled:!t||r,style:v,children:[r?i.jsx("span",{className:"pineui-button__spinner",children:"⏳"}):s?i.jsx("span",{className:"pineui-button__icon",children:s}):null,n&&i.jsx("span",{className:"pineui-button__label",children:n})]})},ee=({type:e,children:n=[],spacing:s=0,padding:t=0,mainAxisAlignment:r="start",crossAxisAlignment:o="start",flex:a,width:d,height:c,maxWidth:p,overflow:h,backgroundColor:v,border:b,borderRadius:w,elevation:j,borderRight:I,borderLeft:C,borderTop:M,borderBottom:_,onPress:N,context:S,renderer:B})=>{if(!B||!S)return null;const F=async()=>{if(N&&S){const A=T(N,S);await S.executeAction(A)}},f=e==="layout.column",y=D("pineui-layout",{"pineui-layout--column":f,"pineui-layout--row":!f}),l={display:"flex",flexDirection:f?"column":"row",gap:`${s}px`,padding:`${t}px`,justifyContent:he(r),alignItems:ye(o),flex:a,width:d!==void 0?typeof d=="number"?`${d}px`:d:void 0,height:c!==void 0?typeof c=="number"?`${c}px`:c:void 0,maxWidth:p!==void 0?typeof p=="number"?`${p}px`:p:void 0,overflow:h,backgroundColor:v,border:b,borderRadius:w!==void 0?`${w}px`:void 0,boxShadow:j?ve(j):void 0,borderRight:I,borderLeft:C,borderTop:M,borderBottom:_,minWidth:0,cursor:N?"pointer":void 0};return i.jsx("div",{className:y,style:l,onClick:N?F:void 0,children:n.map((A,k)=>i.jsx(B,{node:A,context:S},k))})};function he(e){return{start:"flex-start",center:"center",end:"flex-end",spaceBetween:"space-between",spaceAround:"space-around"}[e]||"flex-start"}function ye(e){return{start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"}[e]||"flex-start"}function ve(e){const n={1:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",2:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",3:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",4:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",5:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"};return n[e]||n[1]}const xe=({child:e,children:n,elevation:s=1,padding:t=16,variant:r,onPress:o,context:a,renderer:d})=>{if(!d||!a)return null;const c=async()=>{if(o&&a){const w=T(o,a);await a.executeAction(w)}},h=D("pineui-card",`pineui-card--elevation-${r==="outlined"||r==="filled"?0:s}`,{"pineui-card--clickable":!!o,"pineui-card--outlined":r==="outlined","pineui-card--filled":r==="filled"}),v={padding:`${t}px`,...r==="outlined"?{border:"1px solid var(--md-sys-color-outline)"}:{},...r==="filled"?{background:"var(--md-sys-color-surfaceVariant)"}:{}},b=e?i.jsx(d,{node:e,context:a}):n?i.jsx(i.Fragment,{children:n.map((w,j)=>i.jsx(d,{node:w,context:a},j))}):null;return i.jsx("div",{className:h,style:v,onClick:o?c:void 0,children:b})},ge=({src:e,alt:n="",aspectRatio:s,borderRadius:t=0,loading:r="lazy",onPress:o,context:a})=>{const d=async()=>{o&&a&&await a.executeAction(o)},c={width:"100%",aspectRatio:s,borderRadius:`${t}px`,objectFit:"cover",cursor:o?"pointer":void 0};return i.jsx("img",{className:"pineui-image",src:e,alt:n,loading:r,style:c,onClick:o?d:void 0})},be=({src:e,size:n=40,onPress:s,context:t})=>{const r=async()=>{s&&t&&await t.executeAction(s)},o={width:`${n}px`,height:`${n}px`,borderRadius:"50%",objectFit:"cover",cursor:s?"pointer":void 0};return i.jsx("img",{className:"pineui-avatar",src:e,alt:"Avatar",style:o,onClick:s?r:void 0})},je=({name:e,size:n=24,color:s,visible:t=!0})=>{if(!t)return null;const r={fontSize:`${n}px`,color:s?`var(--md-sys-color-${s}, ${s})`:void 0},o={verified:"✓",favorite:"❤️",favoriteBorder:"🤍",chatBubbleOutline:"💬",repeat:"🔁",bookmark:"🔖",bookmarkBorder:"🔖",iosShare:"↗️",moreVert:"⋮"};return i.jsx("span",{className:"pineui-icon",style:r,children:o[e]||e})};function $(e,n){return e==="{{response}}"?n:typeof e!="object"||e===null?e:Array.isArray(e)?e.map(s=>$(s,n)):Object.fromEntries(Object.entries(e).map(([s,t])=>[s,$(t,n)]))}const we=({id:e,layout:n="list",columns:s=3,spacing:t=16,data:r,itemTemplate:o,loadingState:a,emptyState:d,errorState:c,refreshable:p=!1,context:h,renderer:v})=>{const[b,w]=m.useState([]),[j,I]=m.useState(!0),[C,M]=m.useState(!1),[_,N]=m.useState(null),[S,B]=m.useState(!0),[F,f]=m.useState(null),y=r.type==="action.http"&&h?r.url.replace(/\{\{state\.([^}]+)\}\}/g,(k,u)=>{const x=u.split(".");let g=h.state;for(const O of x){if(g==null)return"";g=g[O]}return g!=null?String(g):""}):"";m.useEffect(()=>{l()},[y]);const l=async(k=!1)=>{if(h)try{if(k?M(!0):I(!0),N(null),r.type==="action.http"){let u=r.url;u.includes("{{state.")&&(u=u.replace(/\{\{state\.([^}]+)\}\}/g,(W,G)=>{const H=G.split(".");let V=h.state;for(const We of H){if(V==null)return"";V=V[We]}return V!=null?String(V):""})),k&&F&&(u+=`${u.includes("?")?"&":"?"}after=${F}`);const g=await(await fetch(u)).json(),O=g.data||g;if(w(W=>k?[...W,...O]:O),r.onSuccess&&h){console.log(`[Collection] onSuccess called with ${O.length} items`);const W=$(r.onSuccess,O);await h.executeAction(W),console.log("[Collection] onSuccess done")}g.pagination?(B(g.pagination.hasMore),f(g.pagination.cursor)):B(!1)}}catch(u){N(u)}finally{I(!1),M(!1)}},A=()=>{!C&&S&&l(!0)};return!v||!h?null:j&&a?i.jsx(v,{node:a,context:h}):_&&c?i.jsx(v,{node:c,context:h}):b.length===0&&d?i.jsx(v,{node:d,context:h}):i.jsxs("div",{className:"pineui-collection","data-collection-id":e,children:[p&&i.jsx("div",{className:"pineui-collection__refresh",children:i.jsx("button",{onClick:()=>l(!1),children:"Refresh"})}),i.jsx("div",{className:`pineui-collection__${n}`,style:n==="grid"?{display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gap:`${t}px`}:void 0,children:b.map((k,u)=>{const x={...h,item:k,index:u};return i.jsx("div",{className:`pineui-collection__item ${n==="grid"?"pineui-collection__item--grid":""}`,children:i.jsx(v,{node:o,context:x})},k.id||u)})}),S&&!j&&i.jsx("div",{className:"pineui-collection__load-more",style:{padding:"16px",textAlign:"center"},children:i.jsx("button",{onClick:A,disabled:C,style:{padding:"12px 24px",fontSize:"14px",fontWeight:500,cursor:C?"not-allowed":"pointer",opacity:C?.6:1},children:C?"Carregando...":"Carregar mais"})})]})},_e=({data:e,template:n,itemTemplate:s,layout:t="list",columns:r=3,spacing:o=16,context:a,renderer:d})=>{if(!d||!a)return null;const c=n||s;if(!c)return null;const p=typeof e=="string"?T(e,a):e,h=Array.isArray(p)?p:[];if(h.length===0)return null;const v=t==="grid"?{display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gap:`${o}px`}:{display:"flex",flexDirection:"column",gap:`${o}px`};return i.jsx("div",{style:v,children:h.map((b,w)=>{const j={...a,item:b,index:w};return i.jsx(d,{node:c,context:j},b.id??w)})})},Ne=({appBar:e,body:n,floatingActionButton:s,bottomNavigationBar:t,context:r,renderer:o})=>!o||!r?null:i.jsxs("div",{className:"pineui-scaffold",children:[e&&i.jsx("header",{className:"pineui-scaffold__appbar",children:i.jsx(o,{node:e,context:r})}),i.jsx("main",{className:"pineui-scaffold__body",children:i.jsx(o,{node:n,context:r})}),s&&i.jsx("div",{className:"pineui-scaffold__fab",children:i.jsx(o,{node:s,context:r})}),t&&i.jsx("footer",{className:"pineui-scaffold__bottomnav",children:i.jsx(o,{node:t,context:r})})]}),ke=({title:e,leading:n,actions:s=[],context:t,renderer:r})=>!r||!t?null:i.jsxs("div",{className:"pineui-appbar",children:[n&&i.jsx("div",{className:"pineui-appbar__leading",children:i.jsx(r,{node:n,context:t})}),e&&i.jsx("div",{className:"pineui-appbar__title",children:i.jsx(r,{node:e,context:t})}),s.length>0&&i.jsx("div",{className:"pineui-appbar__actions",children:s.map((o,a)=>i.jsx(r,{node:o,context:t},a))})]}),Ce=({items:e,currentIndex:n,onItemTap:s,context:t})=>{const r=async o=>{if(!t)return;const a=JSON.parse(JSON.stringify(s).replace(/\{\{item\.(\w+)\}\}/g,(d,c)=>{const p=o[c];return p!=null?String(p):""}));await t.executeAction(a)};return i.jsx("nav",{className:"pineui-bottomnav",children:e.map((o,a)=>i.jsxs("button",{className:`pineui-bottomnav__item ${a===n?"pineui-bottomnav__item--active":""}`,onClick:()=>r(o),children:[i.jsxs("div",{className:"pineui-bottomnav__icon-container",children:[i.jsx("span",{className:"pineui-bottomnav__icon",children:o.icon}),o.badge&&o.badge>0&&i.jsx("span",{className:"pineui-bottomnav__badge",children:o.badge})]}),i.jsx("span",{className:"pineui-bottomnav__label",children:o.label})]},a))})},R=({type:e,id:n,label:s,placeholder:t="",value:r="",error:o,multiline:a=!1,maxLines:d=1,maxLength:c,autofocus:p=!1,onChanged:h,onChange:v,context:b})=>{const w=v||h,j=async _=>{!w||!b||await b.executeAction(w,{event:{value:_.target.value},value:_.target.value})},C={"input.email":"email","input.password":"password","input.number":"number","input.search":"search","input.text":"text"}[e]||"text",M={id:n,placeholder:t,defaultValue:r,maxLength:c,autoFocus:p,onChange:j,className:`pineui-input${o?" pineui-input--error":""}`};return i.jsxs("div",{className:"pineui-input-wrapper",style:{width:"100%"},children:[s&&i.jsx("label",{htmlFor:n,style:{display:"block",fontSize:"12px",fontWeight:500,color:o?"var(--md-sys-color-error)":"var(--md-sys-color-onSurfaceVariant)",marginBottom:"4px"},children:s}),a?i.jsx("textarea",{...M,rows:d,style:{resize:"none",minHeight:`${d*24}px`}}):i.jsx("input",{...M,type:C}),o&&i.jsx("p",{style:{fontSize:"12px",color:"var(--md-sys-color-error)",marginTop:"4px"},children:o})]})},Se={text:me,"button.filled":L,"button.text":L,"button.outlined":L,"button.icon":L,"button.fab":L,"layout.column":ee,"layout.row":ee,"layout.scaffold":Ne,"layout.appBar":ke,"layout.bottomNav":Ce,card:xe,image:ge,avatar:be,icon:je,collection:we,"collection.map":_e,"input.text":R,"input.email":R,"input.password":R,"input.number":R,"input.search":R,divider:({thickness:e=1,color:n="surfaceVariant"})=>{const s={height:`${e}px`,backgroundColor:`var(--md-sys-color-${n}, #e0e0e0)`,border:"none",margin:0};return i.jsx("hr",{className:"pineui-divider",style:s})},conditionalRender:({conditions:e,context:n,renderer:s})=>{if(!s||!n)return null;for(const t of e){const r=T({when:t.when},n);if(r.when===!0||r.when==="true")return i.jsx(s,{node:t.render,context:n})}return null},"conditional.render":({condition:e,children:n,child:s,context:t,renderer:r})=>{if(!r||!t)return null;const o=T({condition:e},t);return o.condition===!0||o.condition==="true"||o.condition===1?s?i.jsx(r,{node:s,context:t}):n?i.jsx(i.Fragment,{children:n.map((d,c)=>i.jsx(r,{node:d,context:t},c))}):null:null},tabs:({tabs:e,defaultTab:n,context:s,renderer:t})=>{var d;const[r,o]=m.useState(n||((d=e[0])==null?void 0:d.id));if(!t||!s)return null;const a=e.find(c=>c.id===r);return i.jsxs("div",{className:"pineui-tabs",children:[i.jsx("div",{className:"pineui-tabs__header",children:e.map(c=>i.jsxs("button",{className:`pineui-tabs__tab ${r===c.id?"pineui-tabs__tab--active":""}`,onClick:()=>o(c.id),children:[c.icon&&i.jsx("span",{className:"pineui-tabs__icon",children:c.icon}),i.jsx("span",{className:"pineui-tabs__label",children:c.label}),c.badge!==void 0&&c.badge>0&&i.jsx("span",{className:"pineui-tabs__badge",children:c.badge})]},c.id))}),i.jsx("div",{className:"pineui-tabs__content",children:a&&i.jsx(t,{node:a.content,context:s})})]})},badge:({label:e,variant:n="default",size:s="medium"})=>{const t=D("pineui-badge",`pineui-badge--${n}`,`pineui-badge--${s}`);return i.jsx("span",{className:t,children:e})},chip:({label:e,icon:n,selected:s=!1,onPress:t,context:r})=>{const o=async()=>{t&&r&&await r.executeAction(t)},a=D("pineui-chip",{"pineui-chip--selected":s});return i.jsxs("button",{className:a,onClick:o,children:[n&&i.jsx("span",{className:"pineui-chip__icon",children:n}),i.jsx("span",{className:"pineui-chip__label",children:e})]})},grid:({children:e,columns:n=3,spacing:s=16,context:t,renderer:r})=>{if(!r||!t)return null;const o={display:"grid",gridTemplateColumns:`repeat(${n}, 1fr)`,gap:`${s}px`};return i.jsx("div",{className:"pineui-grid",style:o,children:e.map((a,d)=>i.jsx(r,{node:a,context:t},d))})},progress:({value:e,label:n,showPercentage:s=!1,color:t="primary"})=>{const r=Math.min(100,Math.max(0,e));return i.jsxs("div",{className:"pineui-progress",children:[(n||s)&&i.jsxs("div",{className:"pineui-progress__header",children:[n&&i.jsx("span",{className:"pineui-progress__label",children:n}),s&&i.jsxs("span",{className:"pineui-progress__percentage",children:[r,"%"]})]}),i.jsx("div",{className:"pineui-progress__track",children:i.jsx("div",{className:`pineui-progress__fill pineui-progress__fill--${t}`,style:{width:`${r}%`}})})]})},table:({columns:e,data:n,context:s,renderer:t})=>{const[r,o]=m.useState([]),[a,d]=m.useState(!0);m.useEffect(()=>{c()},[]);const c=async()=>{if(s){if(Array.isArray(n)){o(n),d(!1);return}if(n.type==="action.http")try{const p=n,v=await(await fetch(p.url,{method:p.method||"GET",headers:{"Content-Type":"application/json"},body:p.body?JSON.stringify(p.body):void 0})).json();o(v.data||v),d(!1)}catch(p){console.error("Table data fetch error:",p),d(!1)}}};return!t||!s?null:a?i.jsx("div",{className:"pineui-table",children:i.jsx("p",{style:{padding:"16px",textAlign:"center"},children:"Loading..."})}):i.jsx("div",{className:"pineui-table",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsx("tr",{children:e.map(p=>i.jsx("th",{style:{width:p.width},className:"pineui-table__header",children:p.label},p.key))})}),i.jsx("tbody",{children:r.map((p,h)=>i.jsx("tr",{className:"pineui-table__row",children:e.map(v=>i.jsx("td",{className:"pineui-table__cell",children:v.template?i.jsx(t,{node:v.template,context:s,parentData:p}):i.jsx("span",{children:p[v.key]})},v.key))},h))})]})})},view:({name:e,context:n,renderer:s,flex:t,width:r,height:o})=>{var c;const a=(c=n==null?void 0:n.views)==null?void 0:c[e];if(!a)return console.warn(`View not found: ${e}`),null;const d={};return t&&(d.flex=t),r&&(d.width=r),o&&(d.height=o),i.jsx("div",{className:"pineui-view",style:d,children:i.jsx(s,{node:a.screen,context:n})})}},z=({node:e,context:n,parentData:s})=>{if(!e||!e.type)return null;const t=s!==void 0?Object.assign({},n,{item:s}):n,o=e.type!=="collection"&&e.type!=="collection.map"?T(e,t):e;if(o.type.startsWith("component.")){const d=o.type,c=n.components[d];if(!c)return console.warn(`Component not found: ${d}`),null;const p={...t,props:o.props};return i.jsx(z,{node:c.definition,context:p,parentData:s})}const a=Se[o.type];return a?i.jsx(a,{...o,context:n,renderer:z}):(console.warn(`Unknown component type: ${o.type}`),null)},Te=({messages:e,onDismiss:n})=>i.jsx("div",{className:"pineui-snackbar-container",children:e.map(s=>i.jsx(Ae,{message:s,onDismiss:n},s.id))}),Ae=({message:e,onDismiss:n})=>{const[s,t]=m.useState(!1);return m.useEffect(()=>{setTimeout(()=>t(!0),10);const r=setTimeout(()=>{t(!1),setTimeout(()=>n(e.id),300)},e.duration||3e3);return()=>clearTimeout(r)},[e,n]),i.jsxs("div",{className:`pineui-snackbar ${s?"pineui-snackbar--visible":""}`,children:[i.jsx("span",{className:"pineui-snackbar__message",children:e.message}),e.action&&i.jsx("button",{className:"pineui-snackbar__action",onClick:e.action.onPress,children:e.action.label})]})},Ee=({presentation:e="modal",dismissible:n=!0,child:s,onClose:t,context:r,renderer:o})=>{if(m.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),!o||!r)return null;const a=p=>{n&&p.target===p.currentTarget&&t()},d=p=>{n&&p.key==="Escape"&&t()};m.useEffect(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[n]);const c=e==="bottomSheet"?"pineui-modal-backdrop pineui-modal-backdrop--bottomSheet":"pineui-modal-backdrop";return i.jsx("div",{className:c,onClick:a,children:i.jsx("div",{className:`pineui-modal pineui-modal--${e}`,children:i.jsx(o,{node:s,context:r})})})},Ie=({overlays:e,onClose:n,context:s,renderer:t})=>i.jsx(i.Fragment,{children:Object.entries(e).map(([r,{visible:o,config:a}])=>o?i.jsx(Ee,{id:r,...a,onClose:()=>n(r),context:s,renderer:t},r):null)});function J(e,n){if(n.startsWith("http://")||n.startsWith("https://"))return n;try{const s=new URL(e,window.location.href);return new URL(n,s).href}catch{const s=n.replace(/^\.\//,"");return`${e.endsWith("/")?e.slice(0,-1):e}/${s}`}}async function te(e,n){if(!e.imports)return e;const s={...e};if(e.imports.components)for(const t of e.imports.components)try{const r=J(n,t),a=await(await fetch(r)).json();s.components={...s.components,...a}}catch(r){console.error(`❌ Failed to load component from ${t}:`,r),console.error(` Resolved URL: ${J(n,t)}`)}if(e.imports.views)for(const t of e.imports.views)try{const r=J(n,t),a=await(await fetch(r)).json();s.views={...s.views,...a}}catch(r){console.error(`Failed to load view from ${t}:`,r)}return s}class Me extends m.Component{constructor(n){super(n),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,s){console.error("🚨 PineUI Error:",n),console.error("Component Stack:",s.componentStack)}render(){var n;return this.state.hasError?this.props.fallback?this.props.fallback:i.jsxs("div",{className:"pineui-error",style:{padding:"24px",textAlign:"center"},children:[i.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"⚠️"}),i.jsx("h3",{style:{marginBottom:"8px",fontSize:"18px",fontWeight:600},children:"Something went wrong"}),i.jsx("p",{style:{color:"#79747E",fontSize:"14px",marginBottom:"16px"},children:((n=this.state.error)==null?void 0:n.message)||"An unexpected error occurred"}),i.jsx("button",{onClick:()=>window.location.reload(),style:{padding:"10px 20px",background:"#6750A4",color:"white",border:"none",borderRadius:"20px",cursor:"pointer",fontSize:"14px",fontWeight:500},children:"Reload Page"})]}):this.props.children}}function Oe(e,n){const s=n.split(".");let t=e;for(const r of s){if(t==null)return;t=t[r]}return t}const ne=({schema:e,schemaUrl:n,baseUrl:s=""})=>{const[t,r]=m.useState(null),[o,a]=m.useState(!0),[d,c]=m.useState(null),[p,h]=m.useState([]),[v,b]=m.useState({}),w=(e==null?void 0:e.state)||{currentUser:{id:"user_current",username:"currentuser",displayName:"Current User",avatar:"https://i.pravatar.cc/150?img=1"},composer:{text:"",media:null,posting:!1},testInput:""},[j,I]=m.useState(w);m.useEffect(()=>{n&&!e?M():e&&C()},[n,e,s]);const C=async()=>{try{a(!0);let f=e;f.imports&&s&&(console.log("Loading imports for initial schema...",f.imports),f=await te(f,s),console.log("Imports loaded! Components:",Object.keys(f.components||{}))),r(f),f.state&&I(y=>({...y,...f.state}))}catch(f){c(f)}finally{a(!1)}},M=async()=>{try{a(!0);let y=await(await fetch(n)).json();y.imports&&s&&(y=await te(y,s)),r(y),y.state&&I(l=>({...l,...y.state}))}catch(f){c(f)}finally{a(!1)}},_=async(f,y)=>{var A,k;(f.type==="action.sequence"||f.intent&&f.intent.startsWith("course"))&&console.log(`[executeAction] type=${f.intent||f.type}, courseList.length=${((A=j.courseList)==null?void 0:A.length)??"N/A"}, selectedCourseIndex=${j.selectedCourseIndex}`);const l=T(f,{state:j,...y});if(l.intent){const u=l.intent,x={...y,...l};return delete x.intent,N(u,x)}if(l.type==="intent"&&l.name){const u={...y,...l};return delete u.type,delete u.name,N(l.name,u)}if(l.type&&l.type.startsWith("intent.")){const u=l.type.substring(7),x={...y,...l};return delete x.type,N(u,x)}switch(l.type){case"action.http":{try{const u=l.url.startsWith("http")?l.url:`${s}${l.url}`,g=await(await fetch(u,{method:l.method||"GET",headers:{"Content-Type":"application/json"},body:l.body?JSON.stringify(l.body):void 0})).json();console.log("HTTP action result:",g)}catch(u){console.error("HTTP action error:",u)}break}case"action.state.patch":{const u=l.value;console.log(`[patch] ${l.path} =`,typeof u=="object"&&u!==null?Array.isArray(u)?`Array(${u.length})`:`{id: ${u==null?void 0:u.id}, title: ${u==null?void 0:u.title}}`:u),I(x=>{const g={...x};return Be(g,l.path,l.value),g});break}case"action.overlay.open":{const u=(k=t==null?void 0:t.overlays)==null?void 0:k[l.overlayId];u?b(x=>({...x,[l.overlayId]:{visible:!0,config:u}})):console.warn("Overlay not found:",l.overlayId);break}case"action.overlay.close":{b(u=>({...u,[l.overlayId]:{...u[l.overlayId],visible:!1}}));break}case"action.collection.refresh":{console.log("Refresh collection:",l.collectionId);break}case"action.snackbar.show":{const u=typeof l.message=="string"&&l.message.includes("{{")?l.message.replace(/\{\{(.+?)\}\}/g,(g,O)=>{const W=O.trim();if(W.startsWith("state.")){const G=W.substring(6),H=Oe(j,G);return H!=null?String(H):""}return""}):l.message,x={id:`snackbar-${Date.now()}`,message:u,duration:l.duration||3e3,action:l.action?{label:l.action.label,onPress:()=>_(l.action.onPress)}:void 0};h(g=>[...g,x]);break}case"action.delay":{const u=l.duration||1e3;await new Promise(x=>setTimeout(x,u));break}case"action.sequence":{for(const u of l.actions??[])await _(u,y);break}default:console.warn("Unknown action type:",l.type)}},N=async(f,y)=>{if(console.log("Executing intent:",f,y),!(t!=null&&t.intents))return;const l=t.intents[f];if(!l){console.warn("Intent not found:",f);return}if(Array.isArray(l.handler))for(const A of l.handler)await _(A,y);else await _(l.handler,y)},S={state:j,data:{},components:(t==null?void 0:t.components)||{},views:(t==null?void 0:t.views)||{},intents:(t==null?void 0:t.intents)||{},schema:t,executeAction:_,executeIntent:N};if(o)return i.jsxs("div",{className:"pineui-loading",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"400px",gap:"16px",color:"#79747E"},children:[i.jsx("div",{style:{width:"40px",height:"40px",border:"4px solid #E7E0EC",borderTop:"4px solid #6750A4",borderRadius:"50%",animation:"pineui-spin 1s linear infinite"}}),i.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:500},children:"Loading application..."}),i.jsx("style",{dangerouslySetInnerHTML:{__html:`
9
+ */var ie=m,oe=Symbol.for("react.element"),ae=Symbol.for("react.fragment"),le=Object.prototype.hasOwnProperty,ce=ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ue={key:!0,ref:!0,__self:!0,__source:!0};function Z(e,n,s){var t,r={},o=null,a=null;s!==void 0&&(o=""+s),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(a=n.ref);for(t in n)le.call(n,t)&&!ue.hasOwnProperty(t)&&(r[t]=n[t]);if(e&&e.defaultProps)for(t in n=e.defaultProps,n)r[t]===void 0&&(r[t]=n[t]);return{$$typeof:oe,type:e,key:o,ref:a,props:r,_owner:ce.current}}R.Fragment=ae,R.jsx=Z,R.jsxs=Z,Y.exports=R;var i=Y.exports;function A(e,n){if(typeof e=="string")return de(e,n);if(Array.isArray(e))return e.map(s=>A(s,n));if(e&&typeof e=="object"){const s={};for(const t in e)s[t]=A(e[t],n);return s}return e}function de(e,n){const s=e.indexOf("}}");if(e.startsWith("{{")&&e.endsWith("}}")&&s===e.length-2){const r=e.slice(2,-2).trim();return(r==="item"||r.startsWith("item."))&&(!("item"in n)||n.item===void 0)||(r==="props"||r.startsWith("props."))&&(!("props"in n)||n.props===void 0)||(r==="response"||r.startsWith("response."))&&!("response"in n)?e:Q(r,n)}return e.replace(/\{\{(.+?)\}\}/g,(r,o)=>{const a=Q(o.trim(),n);return a!=null?String(a):""})}function Q(e,n){try{if(/^[\w.]+$/.test(e))return X(n,e);if(e.includes("|")&&!e.includes("||"))return pe(e,n);const s=Object.keys(n).filter(o=>/^[a-zA-Z_$][\w$]*$/.test(o)),t=s.map(o=>n[o]);return new Function(...s,`"use strict"; try { return (${e}); } catch(e) { return undefined; }`)(...t)}catch(s){console.warn(`Failed to evaluate expression: ${e}`,s);return}}function X(e,n){const s=n.split(".");let t=e;for(const r of s){if(t==null)return;t=t[r]}return t}function pe(e,n){const[s,t]=e.split("|").map(o=>o.trim()),r=X(n,s);return t==="timeAgo"?fe(r):r}function fe(e){if(!e)return"";const n=new Date(e);if(isNaN(n.getTime()))return e;const t=Math.floor((new Date().getTime()-n.getTime())/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:t<2592e3?`${Math.floor(t/86400)}d`:t<31536e3?`${Math.floor(t/2592e3)}mo`:`${Math.floor(t/31536e3)}y`}function q(e){var n,s,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(n=0;n<r;n++)e[n]&&(s=q(e[n]))&&(t&&(t+=" "),t+=s)}else for(s in e)e[s]&&(t&&(t+=" "),t+=s);return t}function W(){for(var e,n,s=0,t="",r=arguments.length;s<r;s++)(e=arguments[s])&&(n=q(e))&&(t&&(t+=" "),t+=n);return t}const me=({content:e,style:n="bodyMedium",color:s,fontWeight:t,maxLines:r})=>{const o=W("pineui-text",`pineui-text--${n}`,{"pineui-text--bold":t==="bold"}),a={color:s?`var(--md-sys-color-${s}, ${s})`:void 0,WebkitLineClamp:r??void 0,display:r?"-webkit-box":void 0,WebkitBoxOrient:r?"vertical":void 0,overflow:r?"hidden":void 0};return i.jsx("p",{className:o,style:a,children:e||"(empty)"})},L=({type:e,label:n,icon:s,enabled:t=!0,loading:r=!1,onPress:o,context:a,size:d="medium",color:c})=>{const p=async()=>{if(!t||r||!o||!a)return;const b=A(o,a);await a.executeAction(b)},h=W("pineui-button",`pineui-button--${e.split(".")[1]}`,{"pineui-button--disabled":!t,"pineui-button--loading":r,[`pineui-button--${d}`]:d}),v={color:c?`var(--md-sys-color-${c}, ${c})`:void 0};return i.jsxs("button",{className:h,onClick:p,disabled:!t||r,style:v,children:[r?i.jsx("span",{className:"pineui-button__spinner",children:"⏳"}):s?i.jsx("span",{className:"pineui-button__icon",children:s}):null,n&&i.jsx("span",{className:"pineui-button__label",children:n})]})},ee=({type:e,children:n=[],spacing:s=0,padding:t=0,mainAxisAlignment:r="start",crossAxisAlignment:o="start",flex:a,width:d,height:c,maxWidth:p,overflow:h,backgroundColor:v,border:b,borderRadius:w,elevation:j,borderRight:I,borderLeft:C,borderTop:M,borderBottom:_,onPress:N,context:S,renderer:B})=>{if(!B||!S)return null;const F=async()=>{if(N&&S){const T=A(N,S);await S.executeAction(T)}},f=e==="layout.column",y=W("pineui-layout",{"pineui-layout--column":f,"pineui-layout--row":!f}),l={display:"flex",flexDirection:f?"column":"row",gap:`${s}px`,padding:`${t}px`,justifyContent:he(r),alignItems:ye(o),flex:a,width:d!==void 0?typeof d=="number"?`${d}px`:d:void 0,height:c!==void 0?typeof c=="number"?`${c}px`:c:void 0,maxWidth:p!==void 0?typeof p=="number"?`${p}px`:p:void 0,overflow:h,backgroundColor:v,border:b,borderRadius:w!==void 0?`${w}px`:void 0,boxShadow:j?ve(j):void 0,borderRight:I,borderLeft:C,borderTop:M,borderBottom:_,minWidth:0,cursor:N?"pointer":void 0};return i.jsx("div",{className:y,style:l,onClick:N?F:void 0,children:n.map((T,k)=>i.jsx(B,{node:T,context:S},k))})};function he(e){return{start:"flex-start",center:"center",end:"flex-end",spaceBetween:"space-between",spaceAround:"space-around"}[e]||"flex-start"}function ye(e){return{start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"}[e]||"flex-start"}function ve(e){const n={1:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",2:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",3:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",4:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",5:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"};return n[e]||n[1]}const xe=({child:e,children:n,elevation:s=1,padding:t=16,variant:r,onPress:o,context:a,renderer:d})=>{if(!d||!a)return null;const c=async()=>{if(o&&a){const w=A(o,a);await a.executeAction(w)}},h=W("pineui-card",`pineui-card--elevation-${r==="outlined"||r==="filled"?0:s}`,{"pineui-card--clickable":!!o,"pineui-card--outlined":r==="outlined","pineui-card--filled":r==="filled"}),v={padding:`${t}px`,...r==="outlined"?{border:"1px solid var(--md-sys-color-outline)"}:{},...r==="filled"?{background:"var(--md-sys-color-surfaceVariant)"}:{}},b=e?i.jsx(d,{node:e,context:a}):n?i.jsx(i.Fragment,{children:n.map((w,j)=>i.jsx(d,{node:w,context:a},j))}):null;return i.jsx("div",{className:h,style:v,onClick:o?c:void 0,children:b})},ge=({src:e,alt:n="",aspectRatio:s,borderRadius:t=0,loading:r="lazy",onPress:o,context:a})=>{const d=async()=>{o&&a&&await a.executeAction(o)},c={width:"100%",aspectRatio:s,borderRadius:`${t}px`,objectFit:"cover",cursor:o?"pointer":void 0};return i.jsx("img",{className:"pineui-image",src:e,alt:n,loading:r,style:c,onClick:o?d:void 0})},be=({src:e,size:n=40,onPress:s,context:t})=>{const r=async()=>{s&&t&&await t.executeAction(s)},o={width:`${n}px`,height:`${n}px`,borderRadius:"50%",objectFit:"cover",cursor:s?"pointer":void 0};return i.jsx("img",{className:"pineui-avatar",src:e,alt:"Avatar",style:o,onClick:s?r:void 0})},je=({name:e,size:n=24,color:s,visible:t=!0})=>{if(!t)return null;const r={fontSize:`${n}px`,color:s?`var(--md-sys-color-${s}, ${s})`:void 0},o={verified:"✓",favorite:"❤️",favoriteBorder:"🤍",chatBubbleOutline:"💬",repeat:"🔁",bookmark:"🔖",bookmarkBorder:"🔖",iosShare:"↗️",moreVert:"⋮"};return i.jsx("span",{className:"pineui-icon",style:r,children:o[e]||e})};function $(e,n){return e==="{{response}}"?n:typeof e!="object"||e===null?e:Array.isArray(e)?e.map(s=>$(s,n)):Object.fromEntries(Object.entries(e).map(([s,t])=>[s,$(t,n)]))}const we=({id:e,layout:n="list",columns:s=3,spacing:t=16,data:r,itemTemplate:o,loadingState:a,emptyState:d,errorState:c,refreshable:p=!1,context:h,renderer:v})=>{const[b,w]=m.useState([]),[j,I]=m.useState(!0),[C,M]=m.useState(!1),[_,N]=m.useState(null),[S,B]=m.useState(!0),[F,f]=m.useState(null),y=r.type==="action.http"&&h?r.url.replace(/\{\{state\.([^}]+)\}\}/g,(k,u)=>{const x=u.split(".");let g=h.state;for(const O of x){if(g==null)return"";g=g[O]}return g!=null?String(g):""}):"";m.useEffect(()=>{l()},[y]);const l=async(k=!1)=>{if(h)try{if(k?M(!0):I(!0),N(null),r.type==="action.http"){let u=r.url;u.includes("{{state.")&&(u=u.replace(/\{\{state\.([^}]+)\}\}/g,(D,G)=>{const U=G.split(".");let P=h.state;for(const De of U){if(P==null)return"";P=P[De]}return P!=null?String(P):""})),k&&F&&(u+=`${u.includes("?")?"&":"?"}after=${F}`);const g=await(await fetch(u)).json(),O=g.data||g;if(w(D=>k?[...D,...O]:O),r.onSuccess&&h){console.log(`[Collection] onSuccess called with ${O.length} items`);const D=$(r.onSuccess,O);await h.executeAction(D),console.log("[Collection] onSuccess done")}g.pagination?(B(g.pagination.hasMore),f(g.pagination.cursor)):B(!1)}}catch(u){N(u)}finally{I(!1),M(!1)}},T=()=>{!C&&S&&l(!0)};return!v||!h?null:j&&a?i.jsx(v,{node:a,context:h}):_&&c?i.jsx(v,{node:c,context:h}):b.length===0&&d?i.jsx(v,{node:d,context:h}):i.jsxs("div",{className:"pineui-collection","data-collection-id":e,children:[p&&i.jsx("div",{className:"pineui-collection__refresh",children:i.jsx("button",{onClick:()=>l(!1),children:"Refresh"})}),i.jsx("div",{className:`pineui-collection__${n}`,style:n==="grid"?{display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gap:`${t}px`}:void 0,children:b.map((k,u)=>{const x={...h,item:k,index:u};return i.jsx("div",{className:`pineui-collection__item ${n==="grid"?"pineui-collection__item--grid":""}`,children:i.jsx(v,{node:o,context:x})},k.id||u)})}),S&&!j&&i.jsx("div",{className:"pineui-collection__load-more",style:{padding:"16px",textAlign:"center"},children:i.jsx("button",{onClick:T,disabled:C,style:{padding:"12px 24px",fontSize:"14px",fontWeight:500,cursor:C?"not-allowed":"pointer",opacity:C?.6:1},children:C?"Carregando...":"Carregar mais"})})]})},_e=({data:e,template:n,itemTemplate:s,layout:t="list",columns:r=3,spacing:o=16,context:a,renderer:d})=>{if(!d||!a)return null;const c=n||s;if(!c)return null;const p=typeof e=="string"?A(e,a):e,h=Array.isArray(p)?p:[];if(h.length===0)return null;const v=t==="grid"?{display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gap:`${o}px`}:{display:"flex",flexDirection:"column",gap:`${o}px`};return i.jsx("div",{style:v,children:h.map((b,w)=>{const j={...a,item:b,index:w};return i.jsx(d,{node:c,context:j},b.id??w)})})},Ne=({appBar:e,body:n,floatingActionButton:s,bottomNavigationBar:t,context:r,renderer:o})=>!o||!r?null:i.jsxs("div",{className:"pineui-scaffold",children:[e&&i.jsx("header",{className:"pineui-scaffold__appbar",children:i.jsx(o,{node:e,context:r})}),i.jsx("main",{className:"pineui-scaffold__body",children:i.jsx(o,{node:n,context:r})}),s&&i.jsx("div",{className:"pineui-scaffold__fab",children:i.jsx(o,{node:s,context:r})}),t&&i.jsx("footer",{className:"pineui-scaffold__bottomnav",children:i.jsx(o,{node:t,context:r})})]}),ke=({title:e,leading:n,actions:s=[],context:t,renderer:r})=>!r||!t?null:i.jsxs("div",{className:"pineui-appbar",children:[n&&i.jsx("div",{className:"pineui-appbar__leading",children:i.jsx(r,{node:n,context:t})}),e&&i.jsx("div",{className:"pineui-appbar__title",children:i.jsx(r,{node:e,context:t})}),s.length>0&&i.jsx("div",{className:"pineui-appbar__actions",children:s.map((o,a)=>i.jsx(r,{node:o,context:t},a))})]}),Ce=({items:e,currentIndex:n,onItemTap:s,context:t})=>{const r=async o=>{if(!t)return;const a=JSON.parse(JSON.stringify(s).replace(/\{\{item\.(\w+)\}\}/g,(d,c)=>{const p=o[c];return p!=null?String(p):""}));await t.executeAction(a)};return i.jsx("nav",{className:"pineui-bottomnav",children:e.map((o,a)=>i.jsxs("button",{className:`pineui-bottomnav__item ${a===n?"pineui-bottomnav__item--active":""}`,onClick:()=>r(o),children:[i.jsxs("div",{className:"pineui-bottomnav__icon-container",children:[i.jsx("span",{className:"pineui-bottomnav__icon",children:o.icon}),o.badge&&o.badge>0&&i.jsx("span",{className:"pineui-bottomnav__badge",children:o.badge})]}),i.jsx("span",{className:"pineui-bottomnav__label",children:o.label})]},a))})},z=({type:e,id:n,label:s,placeholder:t="",value:r="",error:o,multiline:a=!1,maxLines:d=1,maxLength:c,autofocus:p=!1,onChanged:h,onChange:v,context:b})=>{const w=v||h,j=async _=>{!w||!b||await b.executeAction(w,{event:{value:_.target.value},value:_.target.value})},C={"input.email":"email","input.password":"password","input.number":"number","input.search":"search","input.text":"text"}[e]||"text",M={id:n,placeholder:t,defaultValue:r,maxLength:c,autoFocus:p,onChange:j,className:`pineui-input${o?" pineui-input--error":""}`};return i.jsxs("div",{className:"pineui-input-wrapper",style:{width:"100%"},children:[s&&i.jsx("label",{htmlFor:n,style:{display:"block",fontSize:"12px",fontWeight:500,color:o?"var(--md-sys-color-error)":"var(--md-sys-color-onSurfaceVariant)",marginBottom:"4px"},children:s}),a?i.jsx("textarea",{...M,rows:d,style:{resize:"none",minHeight:`${d*24}px`}}):i.jsx("input",{...M,type:C}),o&&i.jsx("p",{style:{fontSize:"12px",color:"var(--md-sys-color-error)",marginTop:"4px"},children:o})]})},Se={text:me,"button.filled":L,"button.text":L,"button.outlined":L,"button.icon":L,"button.fab":L,"layout.column":ee,"layout.row":ee,"layout.scaffold":Ne,"layout.appBar":ke,"layout.bottomNav":Ce,card:xe,image:ge,avatar:be,icon:je,collection:we,"collection.map":_e,"input.text":z,"input.email":z,"input.password":z,"input.number":z,"input.search":z,divider:({thickness:e=1,color:n="surfaceVariant"})=>{const s={height:`${e}px`,backgroundColor:`var(--md-sys-color-${n}, #e0e0e0)`,border:"none",margin:0};return i.jsx("hr",{className:"pineui-divider",style:s})},conditionalRender:({conditions:e,context:n,renderer:s})=>{if(!s||!n)return null;for(const t of e){const r=A({when:t.when},n);if(r.when===!0||r.when==="true")return i.jsx(s,{node:t.render,context:n})}return null},"conditional.render":({condition:e,children:n,child:s,context:t,renderer:r})=>{if(!r||!t)return null;const o=A({condition:e},t);return o.condition===!0||o.condition==="true"||o.condition===1?s?i.jsx(r,{node:s,context:t}):n?i.jsx(i.Fragment,{children:n.map((d,c)=>i.jsx(r,{node:d,context:t},c))}):null:null},tabs:({tabs:e,defaultTab:n,context:s,renderer:t})=>{var d;const[r,o]=m.useState(n||((d=e[0])==null?void 0:d.id));if(!t||!s)return null;const a=e.find(c=>c.id===r);return i.jsxs("div",{className:"pineui-tabs",children:[i.jsx("div",{className:"pineui-tabs__header",children:e.map(c=>i.jsxs("button",{className:`pineui-tabs__tab ${r===c.id?"pineui-tabs__tab--active":""}`,onClick:()=>o(c.id),children:[c.icon&&i.jsx("span",{className:"pineui-tabs__icon",children:c.icon}),i.jsx("span",{className:"pineui-tabs__label",children:c.label}),c.badge!==void 0&&c.badge>0&&i.jsx("span",{className:"pineui-tabs__badge",children:c.badge})]},c.id))}),i.jsx("div",{className:"pineui-tabs__content",children:a&&i.jsx(t,{node:a.content,context:s})})]})},badge:({label:e,variant:n="default",size:s="medium"})=>{const t=W("pineui-badge",`pineui-badge--${n}`,`pineui-badge--${s}`);return i.jsx("span",{className:t,children:e})},chip:({label:e,icon:n,selected:s=!1,onPress:t,context:r})=>{const o=async()=>{t&&r&&await r.executeAction(t)},a=W("pineui-chip",{"pineui-chip--selected":s});return i.jsxs("button",{className:a,onClick:o,children:[n&&i.jsx("span",{className:"pineui-chip__icon",children:n}),i.jsx("span",{className:"pineui-chip__label",children:e})]})},grid:({children:e,columns:n=3,spacing:s=16,context:t,renderer:r})=>{if(!r||!t)return null;const o={display:"grid",gridTemplateColumns:`repeat(${n}, 1fr)`,gap:`${s}px`};return i.jsx("div",{className:"pineui-grid",style:o,children:e.map((a,d)=>i.jsx(r,{node:a,context:t},d))})},progress:({value:e,label:n,showPercentage:s=!1,color:t="primary"})=>{const r=Math.min(100,Math.max(0,e));return i.jsxs("div",{className:"pineui-progress",children:[(n||s)&&i.jsxs("div",{className:"pineui-progress__header",children:[n&&i.jsx("span",{className:"pineui-progress__label",children:n}),s&&i.jsxs("span",{className:"pineui-progress__percentage",children:[r,"%"]})]}),i.jsx("div",{className:"pineui-progress__track",children:i.jsx("div",{className:`pineui-progress__fill pineui-progress__fill--${t}`,style:{width:`${r}%`}})})]})},table:({columns:e,data:n,context:s,renderer:t})=>{const[r,o]=m.useState([]),[a,d]=m.useState(!0);m.useEffect(()=>{c()},[]);const c=async()=>{if(s){if(Array.isArray(n)){o(n),d(!1);return}if(n.type==="action.http")try{const p=n,v=await(await fetch(p.url,{method:p.method||"GET",headers:{"Content-Type":"application/json"},body:p.body?JSON.stringify(p.body):void 0})).json();o(v.data||v),d(!1)}catch(p){console.error("Table data fetch error:",p),d(!1)}}};return!t||!s?null:a?i.jsx("div",{className:"pineui-table",children:i.jsx("p",{style:{padding:"16px",textAlign:"center"},children:"Loading..."})}):i.jsx("div",{className:"pineui-table",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsx("tr",{children:e.map(p=>i.jsx("th",{style:{width:p.width},className:"pineui-table__header",children:p.label},p.key))})}),i.jsx("tbody",{children:r.map((p,h)=>i.jsx("tr",{className:"pineui-table__row",children:e.map(v=>i.jsx("td",{className:"pineui-table__cell",children:v.template?i.jsx(t,{node:v.template,context:s,parentData:p}):i.jsx("span",{children:p[v.key]})},v.key))},h))})]})})},view:({name:e,context:n,renderer:s,flex:t,width:r,height:o})=>{var c;const a=(c=n==null?void 0:n.views)==null?void 0:c[e];if(!a)return console.warn(`View not found: ${e}`),null;const d={};return t&&(d.flex=t),r&&(d.width=r),o&&(d.height=o),i.jsx("div",{className:"pineui-view",style:d,children:i.jsx(s,{node:a.screen,context:n})})}},V=({node:e,context:n,parentData:s})=>{if(!e||!e.type)return null;const t=s!==void 0?Object.assign({},n,{item:s}):n,o=e.type!=="collection"&&e.type!=="collection.map"?A(e,t):e;if(o.type.startsWith("component.")){const d=o.type,c=n.components[d];if(!c)return console.warn(`Component not found: ${d}`),null;const p={...t,props:o.props};return i.jsx(V,{node:c.definition,context:p,parentData:s})}const a=Se[o.type];return a?i.jsx(a,{...o,context:n,renderer:V}):(console.warn(`Unknown component type: ${o.type}`),null)},Ae=({messages:e,onDismiss:n})=>i.jsx("div",{className:"pineui-snackbar-container",children:e.map(s=>i.jsx(Te,{message:s,onDismiss:n},s.id))}),Te=({message:e,onDismiss:n})=>{const[s,t]=m.useState(!1);return m.useEffect(()=>{setTimeout(()=>t(!0),10);const r=setTimeout(()=>{t(!1),setTimeout(()=>n(e.id),300)},e.duration||3e3);return()=>clearTimeout(r)},[e,n]),i.jsxs("div",{className:`pineui-snackbar ${s?"pineui-snackbar--visible":""}`,children:[i.jsx("span",{className:"pineui-snackbar__message",children:e.message}),e.action&&i.jsx("button",{className:"pineui-snackbar__action",onClick:e.action.onPress,children:e.action.label})]})},Ee=({presentation:e="modal",dismissible:n=!0,child:s,onClose:t,context:r,renderer:o})=>{if(m.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),!o||!r)return null;const a=p=>{n&&p.target===p.currentTarget&&t()},d=p=>{n&&p.key==="Escape"&&t()};m.useEffect(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[n]);const c=e==="bottomSheet"?"pineui-modal-backdrop pineui-modal-backdrop--bottomSheet":"pineui-modal-backdrop";return i.jsx("div",{className:c,onClick:a,children:i.jsx("div",{className:`pineui-modal pineui-modal--${e}`,children:i.jsx(o,{node:s,context:r})})})},Ie=({overlays:e,onClose:n,context:s,renderer:t})=>i.jsx(i.Fragment,{children:Object.entries(e).map(([r,{visible:o,config:a}])=>o?i.jsx(Ee,{id:r,...a,onClose:()=>n(r),context:s,renderer:t},r):null)});function J(e,n){if(n.startsWith("http://")||n.startsWith("https://"))return n;try{const s=new URL(e,window.location.href);return new URL(n,s).href}catch{const s=n.replace(/^\.\//,"");return`${e.endsWith("/")?e.slice(0,-1):e}/${s}`}}async function te(e,n){if(!e.imports)return e;const s={...e};if(e.imports.components)for(const t of e.imports.components)try{const r=J(n,t),a=await(await fetch(r)).json();s.components={...s.components,...a}}catch(r){console.error(`❌ Failed to load component from ${t}:`,r),console.error(` Resolved URL: ${J(n,t)}`)}if(e.imports.views)for(const t of e.imports.views)try{const r=J(n,t),a=await(await fetch(r)).json();s.views={...s.views,...a}}catch(r){console.error(`Failed to load view from ${t}:`,r)}return s}class Me extends m.Component{constructor(n){super(n),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,s){console.error("🚨 PineUI Error:",n),console.error("Component Stack:",s.componentStack)}render(){var n;return this.state.hasError?this.props.fallback?this.props.fallback:i.jsxs("div",{className:"pineui-error",style:{padding:"24px",textAlign:"center"},children:[i.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"⚠️"}),i.jsx("h3",{style:{marginBottom:"8px",fontSize:"18px",fontWeight:600},children:"Something went wrong"}),i.jsx("p",{style:{color:"#79747E",fontSize:"14px",marginBottom:"16px"},children:((n=this.state.error)==null?void 0:n.message)||"An unexpected error occurred"}),i.jsx("button",{onClick:()=>window.location.reload(),style:{padding:"10px 20px",background:"#6750A4",color:"white",border:"none",borderRadius:"20px",cursor:"pointer",fontSize:"14px",fontWeight:500},children:"Reload Page"})]}):this.props.children}}function Oe(e,n){const s=n.split(".");let t=e;for(const r of s){if(t==null)return;t=t[r]}return t}const ne=({schema:e,schemaUrl:n,baseUrl:s=""})=>{const[t,r]=m.useState(null),[o,a]=m.useState(!0),[d,c]=m.useState(null),[p,h]=m.useState([]),[v,b]=m.useState({}),w=(e==null?void 0:e.state)||{currentUser:{id:"user_current",username:"currentuser",displayName:"Current User",avatar:"https://i.pravatar.cc/150?img=1"},composer:{text:"",media:null,posting:!1},testInput:""},[j,I]=m.useState(w);m.useEffect(()=>{n&&!e?M():e&&C()},[n,e,s]);const C=async()=>{try{a(!0);let f=e;f.imports&&s&&(console.log("Loading imports for initial schema...",f.imports),f=await te(f,s),console.log("Imports loaded! Components:",Object.keys(f.components||{}))),r(f),f.state&&I(y=>({...y,...f.state}))}catch(f){c(f)}finally{a(!1)}},M=async()=>{try{a(!0);let y=await(await fetch(n)).json();y.imports&&s&&(y=await te(y,s)),r(y),y.state&&I(l=>({...l,...y.state}))}catch(f){c(f)}finally{a(!1)}},_=async(f,y)=>{var T,k;(f.type==="action.sequence"||f.intent&&f.intent.startsWith("course"))&&console.log(`[executeAction] type=${f.intent||f.type}, courseList.length=${((T=j.courseList)==null?void 0:T.length)??"N/A"}, selectedCourseIndex=${j.selectedCourseIndex}`);const l=A(f,{state:j,...y});if(l.intent){const u=l.intent,x={...y,...l};return delete x.intent,N(u,x)}if(l.type==="intent"&&l.name){const u={...y,...l};return delete u.type,delete u.name,N(l.name,u)}if(l.type&&l.type.startsWith("intent.")){const u=l.type.substring(7),x={...y,...l};return delete x.type,N(u,x)}switch(l.type){case"action.http":{try{const u=l.url.startsWith("http")?l.url:`${s}${l.url}`,g=await(await fetch(u,{method:l.method||"GET",headers:{"Content-Type":"application/json"},body:l.body?JSON.stringify(l.body):void 0})).json();console.log("HTTP action result:",g)}catch(u){console.error("HTTP action error:",u)}break}case"action.state.patch":{const u=l.value;console.log(`[patch] ${l.path} =`,typeof u=="object"&&u!==null?Array.isArray(u)?`Array(${u.length})`:`{id: ${u==null?void 0:u.id}, title: ${u==null?void 0:u.title}}`:u),I(x=>{const g={...x};return Be(g,l.path,l.value),g});break}case"action.overlay.open":{const u=(k=t==null?void 0:t.overlays)==null?void 0:k[l.overlayId];u?b(x=>({...x,[l.overlayId]:{visible:!0,config:u}})):console.warn("Overlay not found:",l.overlayId);break}case"action.overlay.close":{b(u=>({...u,[l.overlayId]:{...u[l.overlayId],visible:!1}}));break}case"action.collection.refresh":{console.log("Refresh collection:",l.collectionId);break}case"action.snackbar.show":{const u=typeof l.message=="string"&&l.message.includes("{{")?l.message.replace(/\{\{(.+?)\}\}/g,(g,O)=>{const D=O.trim();if(D.startsWith("state.")){const G=D.substring(6),U=Oe(j,G);return U!=null?String(U):""}return""}):l.message,x={id:`snackbar-${Date.now()}`,message:u,duration:l.duration||3e3,action:l.action?{label:l.action.label,onPress:()=>_(l.action.onPress)}:void 0};h(g=>[...g,x]);break}case"action.delay":{const u=l.duration||1e3;await new Promise(x=>setTimeout(x,u));break}case"action.sequence":{for(const u of l.actions??[])await _(u,y);break}default:console.warn("Unknown action type:",l.type)}},N=async(f,y)=>{if(console.log("Executing intent:",f,y),!(t!=null&&t.intents))return;const l=t.intents[f];if(!l){console.warn("Intent not found:",f);return}if(Array.isArray(l.handler))for(const T of l.handler)await _(T,y);else await _(l.handler,y)},S={state:j,data:{},components:(t==null?void 0:t.components)||{},views:(t==null?void 0:t.views)||{},intents:(t==null?void 0:t.intents)||{},schema:t,executeAction:_,executeIntent:N};if(o)return i.jsxs("div",{className:"pineui-loading",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"400px",gap:"16px",color:"#79747E"},children:[i.jsx("div",{style:{width:"40px",height:"40px",border:"4px solid #E7E0EC",borderTop:"4px solid #6750A4",borderRadius:"50%",animation:"pineui-spin 1s linear infinite"}}),i.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:500},children:"Loading application..."}),i.jsx("style",{dangerouslySetInnerHTML:{__html:`
10
10
  @keyframes pineui-spin {
11
11
  0% { transform: rotate(0deg); }
12
12
  100% { transform: rotate(360deg); }
13
13
  }
14
- `}})]});if(d)return i.jsx("div",{className:"pineui-error",children:i.jsxs("p",{children:["Error loading schema: ",d.message]})});if(!t)return i.jsx("div",{className:"pineui-error",children:i.jsx("p",{children:"No schema provided"})});const B=f=>{h(y=>y.filter(l=>l.id!==f))},F=f=>{b(y=>({...y,[f]:{...y[f],visible:!1}}))};return i.jsx(Me,{children:i.jsxs("div",{className:"pineui-root",children:[i.jsx(z,{node:t.screen,context:S}),i.jsx(Te,{messages:p,onDismiss:B}),i.jsx(Ie,{overlays:v,onClose:F,context:S,renderer:z})]})})};function Be(e,n,s){const t=n.split(".");let r=e;for(let o=0;o<t.length-1;o++)r[t[o]]||(r[t[o]]={}),r=r[t[o]];r[t[t.length-1]]=s}function se(e){var t,r;const n=typeof e.target=="string"?document.querySelector(e.target):e.target;if(!n){console.error("PineUI: Target element not found"),(t=e.onError)==null||t.call(e,new Error("Target element not found"));return}U.createRoot(n).render(m.createElement(ne,{schema:e.schema,schemaUrl:e.schemaUrl,baseUrl:e.baseUrl})),(r=e.onReady)==null||r.call(e)}typeof window<"u"&&(window.PineUI={render:se}),E.PineUI=ne,E.render=se,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
14
+ `}})]});if(d)return i.jsx("div",{className:"pineui-error",children:i.jsxs("p",{children:["Error loading schema: ",d.message]})});if(!t)return i.jsx("div",{className:"pineui-error",children:i.jsx("p",{children:"No schema provided"})});const B=f=>{h(y=>y.filter(l=>l.id!==f))},F=f=>{b(y=>({...y,[f]:{...y[f],visible:!1}}))};return i.jsx(Me,{children:i.jsxs("div",{className:"pineui-root",children:[i.jsx(V,{node:t.screen,context:S}),i.jsx(Ae,{messages:p,onDismiss:B}),i.jsx(Ie,{overlays:v,onClose:F,context:S,renderer:V})]})})};function Be(e,n,s){const t=n.split(".");let r=e;for(let o=0;o<t.length-1;o++)r[t[o]]||(r[t[o]]={}),r=r[t[o]];r[t[t.length-1]]=s}function se(e){var t,r;const n=typeof e.target=="string"?document.querySelector(e.target):e.target;if(!n){console.error("PineUI: Target element not found"),(t=e.onError)==null||t.call(e,new Error("Target element not found"));return}H.createRoot(n).render(m.createElement(ne,{schema:e.schema,schemaUrl:e.schemaUrl,baseUrl:e.baseUrl})),(r=e.onReady)==null||r.call(e)}typeof window<"u"&&(window.PineUI={render:se}),console.log("%c🍍 PineUI v0.1.5%c — Server-Driven UI for AI-Native Apps","color:#6750A4;font-weight:700;font-size:14px","color:#79747E;font-size:12px"),E.PineUI=ne,E.render=se,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pineui/react",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Server-Driven UI framework for AI-native applications. Build dynamic, multi-platform interfaces from JSON schemas.",
5
5
  "keywords": [
6
6
  "server-driven-ui",