@e-llm-studio/instant-learning 1.3.31 → 1.3.32

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.
@@ -12,7 +12,7 @@ function ConditionSectionField(props) {
12
12
  var _a, _b, _c, _d, _e, _f;
13
13
  const isWta = ((_a = props.schema) == null ? void 0 : _a.data_key) === "whenToApply";
14
14
  const keyPrefix = ((_b = props.schema) == null ? void 0 : _b.data_key) || "condition";
15
- const valueStr = typeof props.value === "string" ? props.value : "";
15
+ const valueStr = conditionText.normalizeConditionValue(props.value);
16
16
  const committedItems = React.useMemo(() => conditionText.splitConditions(valueStr, keyPrefix), [valueStr, keyPrefix]);
17
17
  const [draftRows, setDraftRows] = React.useState([]);
18
18
  const [rhsEditRequestId, setRhsEditRequestId] = React.useState(0);
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionSectionField.js","sources":["../../../../src/schema-driven/components/ConditionSectionField.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef, useMemo } from 'react';\nimport { ConditionSection } from '../../features/IL-OTJ/_components/organisms/ConditionSection';\nimport { splitConditions } from '../utils/conditionText';\nimport { getSchemaFieldAliases, useRhsEditOwner } from '../hooks/RhsEditRegistry';\n\nexport default function ConditionSectionField(props: any) {\n const isWta = props.schema?.data_key === 'whenToApply';\n const keyPrefix = props.schema?.data_key || 'condition';\n\n const valueStr = typeof props.value === 'string' ? props.value : '';\n const committedItems = useMemo(() => splitConditions(valueStr, keyPrefix), [valueStr, keyPrefix]);\n\n // Transient empty rows being typed; cleared once the AI writes the string back.\n const [draftRows, setDraftRows] = useState<Array<{ id: string; text: string }>>([]);\n const [rhsEditRequestId, setRhsEditRequestId] = useState(0);\n const prevValueRef = useRef(valueStr);\n useEffect(() => {\n if (prevValueRef.current !== valueStr) {\n setDraftRows([]);\n prevValueRef.current = valueStr;\n }\n }, [valueStr]);\n\n const items = [...committedItems, ...draftRows];\n const handleAdd = () => setDraftRows((prev) => [...prev, { id: `new-${Date.now()}-${prev.length}`, text: '' }]);\n // ConditionList only calls onRemove for brand-new empty rows it is cancelling.\n const handleRemove = (_tk: string, _idx: number, id: any) => setDraftRows((prev) => prev.filter((r) => r.id !== id));\n\n // New UI: a parent section/group/variant owns one draft, so this field drops\n // its per-item chat-message lifecycle and edits that parent draft instead.\n // Variant sessions supply structured `conditions` callbacks; section/group\n // sessions supply the generic `value`/`onChange` contract. Support both so\n // every owner can make a highlighted condition field genuinely editable.\n const hasParentDraft = props.hideEditControls === true;\n const parentConditions = Array.isArray(props.conditions) ? props.conditions : items;\n const serializeConditions = (rows: Array<{ id: string | number; text: string }>) =>\n rows.map((row) => row.text).filter((text) => text.trim() !== '').join('\\n');\n const handleParentAdd = props.onAdd || handleAdd;\n const handleParentRemove = props.onRemove || ((_tier: string, _index: number, id: string | number) => {\n const next = parentConditions.filter((row: any) => row.id !== id);\n setDraftRows((current) => current.filter((row) => row.id !== id));\n props.onChange?.(serializeConditions(next));\n });\n const handleParentEdit = props.onEdit || ((_tier: string, _index: number, id: string | number, text: string) => {\n const next = parentConditions.map((row: any) => row.id === id ? { ...row, text } : row);\n props.onChange?.(serializeConditions(next));\n });\n\n // Standalone condition lists own a per-row edit session. The child list\n // receives a monotonic request token and opens its first/empty row using its\n // existing edit logic; parent variants/sections remain the registered owner\n // whenever they supplied a shared draft.\n useRhsEditOwner(\n !hasParentDraft && !props.readOnly\n ? {\n ownerId: `conditions-${props.id || keyPrefix}`,\n fieldIds: getSchemaFieldAliases(props.id, props.schema),\n requestEdit: () => {\n const activeEditId = props.uiState?.activeEditId;\n if (activeEditId) {\n props.uiState?.setPendingEditId?.(activeEditId);\n return 'blocked';\n }\n setRhsEditRequestId((current) => current + 1);\n return 'opened';\n },\n }\n : null,\n );\n\n return (\n <ConditionSection\n {...props}\n citations={props.state?.citations}\n conditions={hasParentDraft ? parentConditions : items}\n onAdd={hasParentDraft ? handleParentAdd : handleAdd}\n onRemove={hasParentDraft ? handleParentRemove : handleRemove}\n onEdit={hasParentDraft ? handleParentEdit : undefined}\n bordered={true}\n idPrefix={`condition-${props.schema?.data_key}`}\n rhsEditRequestId={rhsEditRequestId}\n addLabel={isWta\n ? (props.uiState?.addWhenToApplyBtnLabel || 'Add When to apply')\n : (props.uiState?.addWhenNotToApplyBtnLabel || 'Add When NOT to apply')}\n />\n );\n}\n"],"names":["useMemo","splitConditions","useState","useRef","useEffect","_a","useRhsEditOwner","getSchemaFieldAliases","_b","_c","jsx","ConditionSection"],"mappings":";;;;;;;;;;AAKA,SAAwB,sBAAsB,KAAY,EAAA;AAL1D,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAME,EAAA,MAAM,KAAQ,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,MAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAc,QAAa,MAAA,aAAA,CAAA;AACzC,EAAA,MAAM,SAAY,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,MAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAc,QAAY,KAAA,WAAA,CAAA;AAE5C,EAAA,MAAM,WAAW,OAAO,KAAA,CAAM,KAAU,KAAA,QAAA,GAAW,MAAM,KAAQ,GAAA,EAAA,CAAA;AACjE,EAAM,MAAA,cAAA,GAAiBA,aAAQ,CAAA,MAAMC,6BAAgB,CAAA,QAAA,EAAU,SAAS,CAAG,EAAA,CAAC,QAAU,EAAA,SAAS,CAAC,CAAA,CAAA;AAGhG,EAAA,MAAM,CAAC,SAAW,EAAA,YAAY,CAAI,GAAAC,cAAA,CAA8C,EAAE,CAAA,CAAA;AAClF,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAIA,eAAS,CAAC,CAAA,CAAA;AAC1D,EAAM,MAAA,YAAA,GAAeC,aAAO,QAAQ,CAAA,CAAA;AACpC,EAAAC,eAAA,CAAU,MAAM;AACd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,GAAA,KAAA,CAAM,OAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAe,yBAA6B,KAAA,uBAAA;AAAA,KAAA;AAAA,GACnD,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ConditionSectionField.js","sources":["../../../../src/schema-driven/components/ConditionSectionField.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef, useMemo } from 'react';\nimport { ConditionSection } from '../../features/IL-OTJ/_components/organisms/ConditionSection';\nimport { normalizeConditionValue, splitConditions } from '../utils/conditionText';\nimport { getSchemaFieldAliases, useRhsEditOwner } from '../hooks/RhsEditRegistry';\n\nexport default function ConditionSectionField(props: any) {\n const isWta = props.schema?.data_key === 'whenToApply';\n const keyPrefix = props.schema?.data_key || 'condition';\n\n const valueStr = normalizeConditionValue(props.value);\n const committedItems = useMemo(() => splitConditions(valueStr, keyPrefix), [valueStr, keyPrefix]);\n\n // Transient empty rows being typed; cleared once the AI writes the string back.\n const [draftRows, setDraftRows] = useState<Array<{ id: string; text: string }>>([]);\n const [rhsEditRequestId, setRhsEditRequestId] = useState(0);\n const prevValueRef = useRef(valueStr);\n useEffect(() => {\n if (prevValueRef.current !== valueStr) {\n setDraftRows([]);\n prevValueRef.current = valueStr;\n }\n }, [valueStr]);\n\n const items = [...committedItems, ...draftRows];\n const handleAdd = () => setDraftRows((prev) => [...prev, { id: `new-${Date.now()}-${prev.length}`, text: '' }]);\n // ConditionList only calls onRemove for brand-new empty rows it is cancelling.\n const handleRemove = (_tk: string, _idx: number, id: any) => setDraftRows((prev) => prev.filter((r) => r.id !== id));\n\n // New UI: a parent section/group/variant owns one draft, so this field drops\n // its per-item chat-message lifecycle and edits that parent draft instead.\n // Variant sessions supply structured `conditions` callbacks; section/group\n // sessions supply the generic `value`/`onChange` contract. Support both so\n // every owner can make a highlighted condition field genuinely editable.\n const hasParentDraft = props.hideEditControls === true;\n const parentConditions = Array.isArray(props.conditions) ? props.conditions : items;\n const serializeConditions = (rows: Array<{ id: string | number; text: string }>) =>\n rows.map((row) => row.text).filter((text) => text.trim() !== '').join('\\n');\n const handleParentAdd = props.onAdd || handleAdd;\n const handleParentRemove = props.onRemove || ((_tier: string, _index: number, id: string | number) => {\n const next = parentConditions.filter((row: any) => row.id !== id);\n setDraftRows((current) => current.filter((row) => row.id !== id));\n props.onChange?.(serializeConditions(next));\n });\n const handleParentEdit = props.onEdit || ((_tier: string, _index: number, id: string | number, text: string) => {\n const next = parentConditions.map((row: any) => row.id === id ? { ...row, text } : row);\n props.onChange?.(serializeConditions(next));\n });\n\n // Standalone condition lists own a per-row edit session. The child list\n // receives a monotonic request token and opens its first/empty row using its\n // existing edit logic; parent variants/sections remain the registered owner\n // whenever they supplied a shared draft.\n useRhsEditOwner(\n !hasParentDraft && !props.readOnly\n ? {\n ownerId: `conditions-${props.id || keyPrefix}`,\n fieldIds: getSchemaFieldAliases(props.id, props.schema),\n requestEdit: () => {\n const activeEditId = props.uiState?.activeEditId;\n if (activeEditId) {\n props.uiState?.setPendingEditId?.(activeEditId);\n return 'blocked';\n }\n setRhsEditRequestId((current) => current + 1);\n return 'opened';\n },\n }\n : null,\n );\n\n return (\n <ConditionSection\n {...props}\n citations={props.state?.citations}\n conditions={hasParentDraft ? parentConditions : items}\n onAdd={hasParentDraft ? handleParentAdd : handleAdd}\n onRemove={hasParentDraft ? handleParentRemove : handleRemove}\n onEdit={hasParentDraft ? handleParentEdit : undefined}\n bordered={true}\n idPrefix={`condition-${props.schema?.data_key}`}\n rhsEditRequestId={rhsEditRequestId}\n addLabel={isWta\n ? (props.uiState?.addWhenToApplyBtnLabel || 'Add When to apply')\n : (props.uiState?.addWhenNotToApplyBtnLabel || 'Add When NOT to apply')}\n />\n );\n}\n"],"names":["normalizeConditionValue","useMemo","splitConditions","useState","useRef","useEffect","_a","useRhsEditOwner","getSchemaFieldAliases","_b","_c","jsx","ConditionSection"],"mappings":";;;;;;;;;;AAKA,SAAwB,sBAAsB,KAAY,EAAA;AAL1D,EAAA,IAA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,GAAU,CAAC,CAAA,CAAA;AAC5C,QAAO,OAAA,QAAA,CAAA;AAAA,OACT;AAAA,KAEA,GAAA,IAAA;AAAA,GACN,CAAA;AAEA,EACE,uBAAAE,cAAA;AAAA,IAACC,iCAAA;AAAA,IAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,SAAA,EAAA,CAAW,EAAM,GAAA,KAAA,CAAA,KAAA,KAAN,IAAa,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,SAAA;AAAA,MACxB,UAAA,EAAY,iBAAiB,gBAAmB,GAAA,KAAA;AAAA,MAChD,KAAA,EAAO,iBAAiB,eAAkB,GAAA,SAAA;AAAA,MAC1C,QAAA,EAAU,iBAAiB,kBAAqB,GAAA,YAAA;AAAA,MAChD,MAAA,EAAQ,iBAAiB,gBAAmB,GAAA,KAAA,CAAA;AAAA,MAC5C,QAAU,EAAA,IAAA;AAAA,MACV,QAAU,EAAA,CAAA,UAAA,EAAA,CAAa,EAAM,GAAA,KAAA,CAAA,MAAA,KAAN,mBAAc,QAAQ,CAAA,CAAA;AAAA,MAC7C,gBAAA;AAAA,MACA,QAAA,EAAU,KACL,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,OAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAe,2BAA0B,mBACzC,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,OAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAe,yBAA6B,KAAA,uBAAA;AAAA,KAAA;AAAA,GACnD,CAAA;AAEJ;;;;"}
@@ -5,6 +5,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const AI_REASONING = /<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/;
6
6
  const AI_REASONING_G = /<ai_reasoning>[\s\S]*?<\/ai_reasoning>/g;
7
7
  const CONDITION = /(?:<ai_reasoning>[\s\S]*?<\/ai_reasoning>|[^\r\n])+/g;
8
+ const normalizeConditionValue = (value) => {
9
+ const unwrap = (item) => item && typeof item === "object" && !Array.isArray(item) && "value" in item ? item.value : item;
10
+ const normalized = unwrap(value);
11
+ if (Array.isArray(normalized)) {
12
+ return normalized.map((item) => {
13
+ const candidate = unwrap(item);
14
+ return typeof candidate === "string" ? candidate : candidate && typeof candidate === "object" && "text" in candidate ? candidate.text : "";
15
+ }).filter((item) => typeof item === "string" && item.trim().length > 0).join("\n");
16
+ }
17
+ return typeof normalized === "string" ? normalized : "";
18
+ };
8
19
  const splitConditions = (raw, keyPrefix) => {
9
20
  var _a;
10
21
  return (
@@ -19,5 +30,6 @@ const splitConditions = (raw, keyPrefix) => {
19
30
  );
20
31
  };
21
32
 
33
+ exports.normalizeConditionValue = normalizeConditionValue;
22
34
  exports.splitConditions = splitConditions;
23
35
  //# sourceMappingURL=conditionText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditionText.js","sources":["../../../../src/schema-driven/utils/conditionText.ts"],"sourcesContent":["// src/schema-driven/utils/conditionText.ts\nconst AI_REASONING = /<ai_reasoning>([\\s\\S]*?)<\\/ai_reasoning>/;\nconst AI_REASONING_G = /<ai_reasoning>[\\s\\S]*?<\\/ai_reasoning>/g;\n\n// One condition = everything up to the next line break, EXCEPT that a whole\n// <ai_reasoning> block counts as a single unit. That one exception is the whole\n// point: a reasoning block carries its own bullet list (\"...initial query.\\n- Since\n// no entity references...\"), and those line breaks belong to the block, not to the\n// condition list. Matching conditions (rather than splitting on line breaks) keeps\n// each block intact, so its bullets render as separate points inside ONE condition\n// row — instead of tearing the block in two, leaving row 1 with an unclosed tag\n// (no cognitive icon) and row 2 with a stray `</ai_reasoning>` shown as plain text.\nconst CONDITION = /(?:<ai_reasoning>[\\s\\S]*?<\\/ai_reasoning>|[^\\r\\n])+/g;\n\nexport interface ConditionItem {\n id: string;\n text: string;\n reasoning?: string;\n}\n\n// A field counts as filled in only when it carries a letter or a digit — spaces and\n// punctuation alone don't qualify.\nexport const hasMeaningfulText = (text?: string | null) => !!text && /[a-z0-9À-￿]/i.test(text);\n\n// wta/wnta are stored as ONE `\\n`-separated string, but list UIs work on an array\n// of items — this is the string↔items bridge. Each condition may carry its own\n// inline <ai_reasoning>; we split it off into `reasoning` so the row shows the\n// cognitive-decisioning icon.\nexport const splitConditions = (raw: string, keyPrefix: string): ConditionItem[] =>\n // The AI sometimes leaves its line breaks escaped as a literal `\\n`; normalise\n // them first so CONDITION only has one kind of break to deal with.\n (String(raw ?? '').replace(/\\\\+n/g, '\\n').match(CONDITION) ?? [])\n .map((line) => {\n const reasoning = line.match(AI_REASONING)?.[1];\n const text = line.replace(AI_REASONING_G, '').trim().replace(/^-\\s*/, '');\n return { text, reasoning };\n })\n .filter((c) => c.text)\n .map((c, i) => ({ id: `${keyPrefix}-${i}`, text: c.text, reasoning: c.reasoning }));\n"],"names":["_a"],"mappings":";;;;AACA,MAAM,YAAe,GAAA,0CAAA,CAAA;AACrB,MAAM,cAAiB,GAAA,yCAAA,CAAA;AAUvB,MAAM,SAAY,GAAA,sDAAA,CAAA;AAgBL,MAAA,eAAA,GAAkB,CAAC,GAAA,EAAa,SAAoC,KAAA;AA5BjF,EAAA,IAAA,EAAA,CAAA;AA+BG,EAAA;AAAA;AAAA;AAAA,IAAA,CAAA,CAAA,EAAA,GAAA,MAAA,CAAO,GAAO,IAAA,IAAA,GAAA,GAAA,GAAA,EAAE,CAAE,CAAA,OAAA,CAAQ,SAAS,IAAI,CAAA,CAAE,KAAM,CAAA,SAAS,MAAxD,IAA6D,GAAA,EAAA,GAAA,EAC3D,EAAA,GAAA,CAAI,CAAC,IAAS,KAAA;AAhCnB,MAAAA,IAAAA,GAAAA,CAAAA;AAiCM,MAAA,MAAM,aAAYA,GAAA,GAAA,IAAA,CAAK,MAAM,YAAY,CAAA,KAAvB,gBAAAA,GAA2B,CAAA,CAAA,CAAA,CAAA;AAC7C,MAAM,MAAA,IAAA,GAAO,IAAK,CAAA,OAAA,CAAQ,cAAgB,EAAA,EAAE,EAAE,IAAK,EAAA,CAAE,OAAQ,CAAA,OAAA,EAAS,EAAE,CAAA,CAAA;AACxE,MAAO,OAAA,EAAE,MAAM,SAAU,EAAA,CAAA;AAAA,KAC1B,CACA,CAAA,MAAA,CAAO,CAAC,CAAA,KAAM,EAAE,IAAI,CAAA,CACpB,GAAI,CAAA,CAAC,CAAG,EAAA,CAAA,MAAO,EAAE,EAAI,EAAA,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,IAAM,EAAA,CAAA,CAAE,IAAM,EAAA,SAAA,EAAW,CAAE,CAAA,SAAA,EAAY,CAAA,CAAA;AAAA,IAAA;AAAA;;;;"}
1
+ {"version":3,"file":"conditionText.js","sources":["../../../../src/schema-driven/utils/conditionText.ts"],"sourcesContent":["// src/schema-driven/utils/conditionText.ts\nconst AI_REASONING = /<ai_reasoning>([\\s\\S]*?)<\\/ai_reasoning>/;\nconst AI_REASONING_G = /<ai_reasoning>[\\s\\S]*?<\\/ai_reasoning>/g;\n\n// One condition = everything up to the next line break, EXCEPT that a whole\n// <ai_reasoning> block counts as a single unit. That one exception is the whole\n// point: a reasoning block carries its own bullet list (\"...initial query.\\n- Since\n// no entity references...\"), and those line breaks belong to the block, not to the\n// condition list. Matching conditions (rather than splitting on line breaks) keeps\n// each block intact, so its bullets render as separate points inside ONE condition\n// row — instead of tearing the block in two, leaving row 1 with an unclosed tag\n// (no cognitive icon) and row 2 with a stray `</ai_reasoning>` shown as plain text.\nconst CONDITION = /(?:<ai_reasoning>[\\s\\S]*?<\\/ai_reasoning>|[^\\r\\n])+/g;\n\nexport interface ConditionItem {\n id: string;\n text: string;\n reasoning?: string;\n}\n\n/** Normalize host/API condition values to the string shape used by the form store. */\nexport const normalizeConditionValue = (value: unknown): string => {\n const unwrap = (item: any): unknown =>\n item && typeof item === 'object' && !Array.isArray(item) && 'value' in item\n ? item.value\n : item;\n const normalized = unwrap(value);\n if (Array.isArray(normalized)) {\n return normalized\n .map((item) => {\n const candidate = unwrap(item);\n return typeof candidate === 'string' ? candidate : candidate && typeof candidate === 'object' && 'text' in candidate ? candidate.text : '';\n })\n .filter((item): item is string => typeof item === 'string' && item.trim().length > 0)\n .join('\\n');\n }\n return typeof normalized === 'string' ? normalized : '';\n};\n\n// A field counts as filled in only when it carries a letter or a digit — spaces and\n// punctuation alone don't qualify.\nexport const hasMeaningfulText = (text?: string | null) => !!text && /[a-z0-9À-￿]/i.test(text);\n\n// wta/wnta are stored as ONE `\\n`-separated string, but list UIs work on an array\n// of items — this is the string↔items bridge. Each condition may carry its own\n// inline <ai_reasoning>; we split it off into `reasoning` so the row shows the\n// cognitive-decisioning icon.\nexport const splitConditions = (raw: string, keyPrefix: string): ConditionItem[] =>\n // The AI sometimes leaves its line breaks escaped as a literal `\\n`; normalise\n // them first so CONDITION only has one kind of break to deal with.\n (String(raw ?? '').replace(/\\\\+n/g, '\\n').match(CONDITION) ?? [])\n .map((line) => {\n const reasoning = line.match(AI_REASONING)?.[1];\n const text = line.replace(AI_REASONING_G, '').trim().replace(/^-\\s*/, '');\n return { text, reasoning };\n })\n .filter((c) => c.text)\n .map((c, i) => ({ id: `${keyPrefix}-${i}`, text: c.text, reasoning: c.reasoning }));\n"],"names":["_a"],"mappings":";;;;AACA,MAAM,YAAe,GAAA,0CAAA,CAAA;AACrB,MAAM,cAAiB,GAAA,yCAAA,CAAA;AAUvB,MAAM,SAAY,GAAA,sDAAA,CAAA;AASL,MAAA,uBAAA,GAA0B,CAAC,KAA2B,KAAA;AACjE,EAAA,MAAM,MAAS,GAAA,CAAC,IACd,KAAA,IAAA,IAAQ,OAAO,IAAS,KAAA,QAAA,IAAY,CAAC,KAAA,CAAM,QAAQ,IAAI,CAAA,IAAK,OAAW,IAAA,IAAA,GACnE,KAAK,KACL,GAAA,IAAA,CAAA;AACN,EAAM,MAAA,UAAA,GAAa,OAAO,KAAK,CAAA,CAAA;AAC/B,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,UAAU,CAAG,EAAA;AAC7B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CAAA,MAAA,CAAO,CAAC,CAAA,KAAM,EAAE,IAAI,CAAA,CACpB,GAAI,CAAA,CAAC,CAAG,EAAA,CAAA,MAAO,EAAE,EAAI,EAAA,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,IAAM,EAAA,CAAA,CAAE,IAAM,EAAA,SAAA,EAAW,CAAE,CAAA,SAAA,EAAY,CAAA,CAAA;AAAA,IAAA;AAAA;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { useMemo, useState, useRef, useEffect } from 'react';
3
- import { splitConditions } from '../utils/conditionText.js';
3
+ import { normalizeConditionValue, splitConditions } from '../utils/conditionText.js';
4
4
  import { useRhsEditOwner, getSchemaFieldAliases } from '../hooks/RhsEditRegistry.js';
5
5
  import { ConditionSection } from '../../features/IL-OTJ/_components/organisms/ConditionSection/ConditionSection.js';
6
6
 
@@ -8,7 +8,7 @@ function ConditionSectionField(props) {
8
8
  var _a, _b, _c, _d, _e, _f;
9
9
  const isWta = ((_a = props.schema) == null ? void 0 : _a.data_key) === "whenToApply";
10
10
  const keyPrefix = ((_b = props.schema) == null ? void 0 : _b.data_key) || "condition";
11
- const valueStr = typeof props.value === "string" ? props.value : "";
11
+ const valueStr = normalizeConditionValue(props.value);
12
12
  const committedItems = useMemo(() => splitConditions(valueStr, keyPrefix), [valueStr, keyPrefix]);
13
13
  const [draftRows, setDraftRows] = useState([]);
14
14
  const [rhsEditRequestId, setRhsEditRequestId] = useState(0);
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionSectionField.js","sources":["../../../src/schema-driven/components/ConditionSectionField.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef, useMemo } from 'react';\nimport { ConditionSection } from '../../features/IL-OTJ/_components/organisms/ConditionSection';\nimport { splitConditions } from '../utils/conditionText';\nimport { getSchemaFieldAliases, useRhsEditOwner } from '../hooks/RhsEditRegistry';\n\nexport default function ConditionSectionField(props: any) {\n const isWta = props.schema?.data_key === 'whenToApply';\n const keyPrefix = props.schema?.data_key || 'condition';\n\n const valueStr = typeof props.value === 'string' ? props.value : '';\n const committedItems = useMemo(() => splitConditions(valueStr, keyPrefix), [valueStr, keyPrefix]);\n\n // Transient empty rows being typed; cleared once the AI writes the string back.\n const [draftRows, setDraftRows] = useState<Array<{ id: string; text: string }>>([]);\n const [rhsEditRequestId, setRhsEditRequestId] = useState(0);\n const prevValueRef = useRef(valueStr);\n useEffect(() => {\n if (prevValueRef.current !== valueStr) {\n setDraftRows([]);\n prevValueRef.current = valueStr;\n }\n }, [valueStr]);\n\n const items = [...committedItems, ...draftRows];\n const handleAdd = () => setDraftRows((prev) => [...prev, { id: `new-${Date.now()}-${prev.length}`, text: '' }]);\n // ConditionList only calls onRemove for brand-new empty rows it is cancelling.\n const handleRemove = (_tk: string, _idx: number, id: any) => setDraftRows((prev) => prev.filter((r) => r.id !== id));\n\n // New UI: a parent section/group/variant owns one draft, so this field drops\n // its per-item chat-message lifecycle and edits that parent draft instead.\n // Variant sessions supply structured `conditions` callbacks; section/group\n // sessions supply the generic `value`/`onChange` contract. Support both so\n // every owner can make a highlighted condition field genuinely editable.\n const hasParentDraft = props.hideEditControls === true;\n const parentConditions = Array.isArray(props.conditions) ? props.conditions : items;\n const serializeConditions = (rows: Array<{ id: string | number; text: string }>) =>\n rows.map((row) => row.text).filter((text) => text.trim() !== '').join('\\n');\n const handleParentAdd = props.onAdd || handleAdd;\n const handleParentRemove = props.onRemove || ((_tier: string, _index: number, id: string | number) => {\n const next = parentConditions.filter((row: any) => row.id !== id);\n setDraftRows((current) => current.filter((row) => row.id !== id));\n props.onChange?.(serializeConditions(next));\n });\n const handleParentEdit = props.onEdit || ((_tier: string, _index: number, id: string | number, text: string) => {\n const next = parentConditions.map((row: any) => row.id === id ? { ...row, text } : row);\n props.onChange?.(serializeConditions(next));\n });\n\n // Standalone condition lists own a per-row edit session. The child list\n // receives a monotonic request token and opens its first/empty row using its\n // existing edit logic; parent variants/sections remain the registered owner\n // whenever they supplied a shared draft.\n useRhsEditOwner(\n !hasParentDraft && !props.readOnly\n ? {\n ownerId: `conditions-${props.id || keyPrefix}`,\n fieldIds: getSchemaFieldAliases(props.id, props.schema),\n requestEdit: () => {\n const activeEditId = props.uiState?.activeEditId;\n if (activeEditId) {\n props.uiState?.setPendingEditId?.(activeEditId);\n return 'blocked';\n }\n setRhsEditRequestId((current) => current + 1);\n return 'opened';\n },\n }\n : null,\n );\n\n return (\n <ConditionSection\n {...props}\n citations={props.state?.citations}\n conditions={hasParentDraft ? parentConditions : items}\n onAdd={hasParentDraft ? handleParentAdd : handleAdd}\n onRemove={hasParentDraft ? handleParentRemove : handleRemove}\n onEdit={hasParentDraft ? handleParentEdit : undefined}\n bordered={true}\n idPrefix={`condition-${props.schema?.data_key}`}\n rhsEditRequestId={rhsEditRequestId}\n addLabel={isWta\n ? (props.uiState?.addWhenToApplyBtnLabel || 'Add When to apply')\n : (props.uiState?.addWhenNotToApplyBtnLabel || 'Add When NOT to apply')}\n />\n );\n}\n"],"names":["_a","_b","_c"],"mappings":";;;;;;AAKA,SAAwB,sBAAsB,KAAY,EAAA;AAL1D,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAME,EAAA,MAAM,KAAQ,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,MAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAc,QAAa,MAAA,aAAA,CAAA;AACzC,EAAA,MAAM,SAAY,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,MAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAc,QAAY,KAAA,WAAA,CAAA;AAE5C,EAAA,MAAM,WAAW,OAAO,KAAA,CAAM,KAAU,KAAA,QAAA,GAAW,MAAM,KAAQ,GAAA,EAAA,CAAA;AACjE,EAAM,MAAA,cAAA,GAAiB,OAAQ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iB,gBAAmB,GAAA,KAAA,CAAA;AAAA,MAC5C,QAAU,EAAA,IAAA;AAAA,MACV,QAAU,EAAA,CAAA,UAAA,EAAA,CAAa,EAAM,GAAA,KAAA,CAAA,MAAA,KAAN,mBAAc,QAAQ,CAAA,CAAA;AAAA,MAC7C,gBAAA;AAAA,MACA,QAAA,EAAU,KACL,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,OAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAe,2BAA0B,mBACzC,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,OAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAe,yBAA6B,KAAA,uBAAA;AAAA,KAAA;AAAA,GACnD,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ConditionSectionField.js","sources":["../../../src/schema-driven/components/ConditionSectionField.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef, useMemo } from 'react';\nimport { ConditionSection } from '../../features/IL-OTJ/_components/organisms/ConditionSection';\nimport { normalizeConditionValue, splitConditions } from '../utils/conditionText';\nimport { getSchemaFieldAliases, useRhsEditOwner } from '../hooks/RhsEditRegistry';\n\nexport default function ConditionSectionField(props: any) {\n const isWta = props.schema?.data_key === 'whenToApply';\n const keyPrefix = props.schema?.data_key || 'condition';\n\n const valueStr = normalizeConditionValue(props.value);\n const committedItems = useMemo(() => splitConditions(valueStr, keyPrefix), [valueStr, keyPrefix]);\n\n // Transient empty rows being typed; cleared once the AI writes the string back.\n const [draftRows, setDraftRows] = useState<Array<{ id: string; text: string }>>([]);\n const [rhsEditRequestId, setRhsEditRequestId] = useState(0);\n const prevValueRef = useRef(valueStr);\n useEffect(() => {\n if (prevValueRef.current !== valueStr) {\n setDraftRows([]);\n prevValueRef.current = valueStr;\n }\n }, [valueStr]);\n\n const items = [...committedItems, ...draftRows];\n const handleAdd = () => setDraftRows((prev) => [...prev, { id: `new-${Date.now()}-${prev.length}`, text: '' }]);\n // ConditionList only calls onRemove for brand-new empty rows it is cancelling.\n const handleRemove = (_tk: string, _idx: number, id: any) => setDraftRows((prev) => prev.filter((r) => r.id !== id));\n\n // New UI: a parent section/group/variant owns one draft, so this field drops\n // its per-item chat-message lifecycle and edits that parent draft instead.\n // Variant sessions supply structured `conditions` callbacks; section/group\n // sessions supply the generic `value`/`onChange` contract. Support both so\n // every owner can make a highlighted condition field genuinely editable.\n const hasParentDraft = props.hideEditControls === true;\n const parentConditions = Array.isArray(props.conditions) ? props.conditions : items;\n const serializeConditions = (rows: Array<{ id: string | number; text: string }>) =>\n rows.map((row) => row.text).filter((text) => text.trim() !== '').join('\\n');\n const handleParentAdd = props.onAdd || handleAdd;\n const handleParentRemove = props.onRemove || ((_tier: string, _index: number, id: string | number) => {\n const next = parentConditions.filter((row: any) => row.id !== id);\n setDraftRows((current) => current.filter((row) => row.id !== id));\n props.onChange?.(serializeConditions(next));\n });\n const handleParentEdit = props.onEdit || ((_tier: string, _index: number, id: string | number, text: string) => {\n const next = parentConditions.map((row: any) => row.id === id ? { ...row, text } : row);\n props.onChange?.(serializeConditions(next));\n });\n\n // Standalone condition lists own a per-row edit session. The child list\n // receives a monotonic request token and opens its first/empty row using its\n // existing edit logic; parent variants/sections remain the registered owner\n // whenever they supplied a shared draft.\n useRhsEditOwner(\n !hasParentDraft && !props.readOnly\n ? {\n ownerId: `conditions-${props.id || keyPrefix}`,\n fieldIds: getSchemaFieldAliases(props.id, props.schema),\n requestEdit: () => {\n const activeEditId = props.uiState?.activeEditId;\n if (activeEditId) {\n props.uiState?.setPendingEditId?.(activeEditId);\n return 'blocked';\n }\n setRhsEditRequestId((current) => current + 1);\n return 'opened';\n },\n }\n : null,\n );\n\n return (\n <ConditionSection\n {...props}\n citations={props.state?.citations}\n conditions={hasParentDraft ? parentConditions : items}\n onAdd={hasParentDraft ? handleParentAdd : handleAdd}\n onRemove={hasParentDraft ? handleParentRemove : handleRemove}\n onEdit={hasParentDraft ? handleParentEdit : undefined}\n bordered={true}\n idPrefix={`condition-${props.schema?.data_key}`}\n rhsEditRequestId={rhsEditRequestId}\n addLabel={isWta\n ? (props.uiState?.addWhenToApplyBtnLabel || 'Add When to apply')\n : (props.uiState?.addWhenNotToApplyBtnLabel || 'Add When NOT to apply')}\n />\n );\n}\n"],"names":["_a","_b","_c"],"mappings":";;;;;;AAKA,SAAwB,sBAAsB,KAAY,EAAA;AAL1D,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAME,EAAA,MAAM,KAAQ,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,MAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAc,QAAa,MAAA,aAAA,CAAA;AACzC,EAAA,MAAM,SAAY,GAAA,CAAA,CAAA,EAAA,GAAA,KAAA,CAAM,MAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAc,QAAY,KAAA,WAAA,CAAA;AAE5C,EAAM,MAAA,QAAA,GAAW,uBAAwB,CAAA,KAAA,CAAM,KAAK,CAAA,CAAA;AACpD,EAAM,MAAA,cAAA,GAAiB,OAAQ,CAAA,MAAM,eAAgB,CAAA,QAAA,EAAU,SAAS,CAAG,EAAA,CAAC,QAAU,EAAA,SAAS,CAAC,CAAA,CAAA;AAGhG,EAAA,MAAM,CAAC,SAAW,EAAA,YAAY,CAAI,GAAA,QAAA,CAA8C,EAAE,CAAA,CAAA;AAClF,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAS,CAAC,CAAA,CAAA;AAC1D,EAAM,MAAA,YAAA,GAAe,OAAO,QAAQ,CAAA,CAAA;AACpC,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,YAAA,CAAa,YAAY,QAAU,EAAA;AACrC,MAAA,YAAA,CAAa,EAAE,CAAA,CAAA;AACf,MAAA,YAAA,CAAa,OAAU,GAAA,QAAA,CA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;"}
@@ -1,6 +1,17 @@
1
1
  const AI_REASONING = /<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/;
2
2
  const AI_REASONING_G = /<ai_reasoning>[\s\S]*?<\/ai_reasoning>/g;
3
3
  const CONDITION = /(?:<ai_reasoning>[\s\S]*?<\/ai_reasoning>|[^\r\n])+/g;
4
+ const normalizeConditionValue = (value) => {
5
+ const unwrap = (item) => item && typeof item === "object" && !Array.isArray(item) && "value" in item ? item.value : item;
6
+ const normalized = unwrap(value);
7
+ if (Array.isArray(normalized)) {
8
+ return normalized.map((item) => {
9
+ const candidate = unwrap(item);
10
+ return typeof candidate === "string" ? candidate : candidate && typeof candidate === "object" && "text" in candidate ? candidate.text : "";
11
+ }).filter((item) => typeof item === "string" && item.trim().length > 0).join("\n");
12
+ }
13
+ return typeof normalized === "string" ? normalized : "";
14
+ };
4
15
  const splitConditions = (raw, keyPrefix) => {
5
16
  var _a;
6
17
  return (
@@ -15,5 +26,5 @@ const splitConditions = (raw, keyPrefix) => {
15
26
  );
16
27
  };
17
28
 
18
- export { splitConditions };
29
+ export { normalizeConditionValue, splitConditions };
19
30
  //# sourceMappingURL=conditionText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditionText.js","sources":["../../../src/schema-driven/utils/conditionText.ts"],"sourcesContent":["// src/schema-driven/utils/conditionText.ts\nconst AI_REASONING = /<ai_reasoning>([\\s\\S]*?)<\\/ai_reasoning>/;\nconst AI_REASONING_G = /<ai_reasoning>[\\s\\S]*?<\\/ai_reasoning>/g;\n\n// One condition = everything up to the next line break, EXCEPT that a whole\n// <ai_reasoning> block counts as a single unit. That one exception is the whole\n// point: a reasoning block carries its own bullet list (\"...initial query.\\n- Since\n// no entity references...\"), and those line breaks belong to the block, not to the\n// condition list. Matching conditions (rather than splitting on line breaks) keeps\n// each block intact, so its bullets render as separate points inside ONE condition\n// row — instead of tearing the block in two, leaving row 1 with an unclosed tag\n// (no cognitive icon) and row 2 with a stray `</ai_reasoning>` shown as plain text.\nconst CONDITION = /(?:<ai_reasoning>[\\s\\S]*?<\\/ai_reasoning>|[^\\r\\n])+/g;\n\nexport interface ConditionItem {\n id: string;\n text: string;\n reasoning?: string;\n}\n\n// A field counts as filled in only when it carries a letter or a digit — spaces and\n// punctuation alone don't qualify.\nexport const hasMeaningfulText = (text?: string | null) => !!text && /[a-z0-9À-￿]/i.test(text);\n\n// wta/wnta are stored as ONE `\\n`-separated string, but list UIs work on an array\n// of items — this is the string↔items bridge. Each condition may carry its own\n// inline <ai_reasoning>; we split it off into `reasoning` so the row shows the\n// cognitive-decisioning icon.\nexport const splitConditions = (raw: string, keyPrefix: string): ConditionItem[] =>\n // The AI sometimes leaves its line breaks escaped as a literal `\\n`; normalise\n // them first so CONDITION only has one kind of break to deal with.\n (String(raw ?? '').replace(/\\\\+n/g, '\\n').match(CONDITION) ?? [])\n .map((line) => {\n const reasoning = line.match(AI_REASONING)?.[1];\n const text = line.replace(AI_REASONING_G, '').trim().replace(/^-\\s*/, '');\n return { text, reasoning };\n })\n .filter((c) => c.text)\n .map((c, i) => ({ id: `${keyPrefix}-${i}`, text: c.text, reasoning: c.reasoning }));\n"],"names":["_a"],"mappings":"AACA,MAAM,YAAe,GAAA,0CAAA,CAAA;AACrB,MAAM,cAAiB,GAAA,yCAAA,CAAA;AAUvB,MAAM,SAAY,GAAA,sDAAA,CAAA;AAgBL,MAAA,eAAA,GAAkB,CAAC,GAAA,EAAa,SAAoC,KAAA;AA5BjF,EAAA,IAAA,EAAA,CAAA;AA+BG,EAAA;AAAA;AAAA;AAAA,IAAA,CAAA,CAAA,EAAA,GAAA,MAAA,CAAO,GAAO,IAAA,IAAA,GAAA,GAAA,GAAA,EAAE,CAAE,CAAA,OAAA,CAAQ,SAAS,IAAI,CAAA,CAAE,KAAM,CAAA,SAAS,MAAxD,IAA6D,GAAA,EAAA,GAAA,EAC3D,EAAA,GAAA,CAAI,CAAC,IAAS,KAAA;AAhCnB,MAAAA,IAAAA,GAAAA,CAAAA;AAiCM,MAAA,MAAM,aAAYA,GAAA,GAAA,IAAA,CAAK,MAAM,YAAY,CAAA,KAAvB,gBAAAA,GAA2B,CAAA,CAAA,CAAA,CAAA;AAC7C,MAAM,MAAA,IAAA,GAAO,IAAK,CAAA,OAAA,CAAQ,cAAgB,EAAA,EAAE,EAAE,IAAK,EAAA,CAAE,OAAQ,CAAA,OAAA,EAAS,EAAE,CAAA,CAAA;AACxE,MAAO,OAAA,EAAE,MAAM,SAAU,EAAA,CAAA;AAAA,KAC1B,CACA,CAAA,MAAA,CAAO,CAAC,CAAA,KAAM,EAAE,IAAI,CAAA,CACpB,GAAI,CAAA,CAAC,CAAG,EAAA,CAAA,MAAO,EAAE,EAAI,EAAA,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,IAAM,EAAA,CAAA,CAAE,IAAM,EAAA,SAAA,EAAW,CAAE,CAAA,SAAA,EAAY,CAAA,CAAA;AAAA,IAAA;AAAA;;;;"}
1
+ {"version":3,"file":"conditionText.js","sources":["../../../src/schema-driven/utils/conditionText.ts"],"sourcesContent":["// src/schema-driven/utils/conditionText.ts\nconst AI_REASONING = /<ai_reasoning>([\\s\\S]*?)<\\/ai_reasoning>/;\nconst AI_REASONING_G = /<ai_reasoning>[\\s\\S]*?<\\/ai_reasoning>/g;\n\n// One condition = everything up to the next line break, EXCEPT that a whole\n// <ai_reasoning> block counts as a single unit. That one exception is the whole\n// point: a reasoning block carries its own bullet list (\"...initial query.\\n- Since\n// no entity references...\"), and those line breaks belong to the block, not to the\n// condition list. Matching conditions (rather than splitting on line breaks) keeps\n// each block intact, so its bullets render as separate points inside ONE condition\n// row — instead of tearing the block in two, leaving row 1 with an unclosed tag\n// (no cognitive icon) and row 2 with a stray `</ai_reasoning>` shown as plain text.\nconst CONDITION = /(?:<ai_reasoning>[\\s\\S]*?<\\/ai_reasoning>|[^\\r\\n])+/g;\n\nexport interface ConditionItem {\n id: string;\n text: string;\n reasoning?: string;\n}\n\n/** Normalize host/API condition values to the string shape used by the form store. */\nexport const normalizeConditionValue = (value: unknown): string => {\n const unwrap = (item: any): unknown =>\n item && typeof item === 'object' && !Array.isArray(item) && 'value' in item\n ? item.value\n : item;\n const normalized = unwrap(value);\n if (Array.isArray(normalized)) {\n return normalized\n .map((item) => {\n const candidate = unwrap(item);\n return typeof candidate === 'string' ? candidate : candidate && typeof candidate === 'object' && 'text' in candidate ? candidate.text : '';\n })\n .filter((item): item is string => typeof item === 'string' && item.trim().length > 0)\n .join('\\n');\n }\n return typeof normalized === 'string' ? normalized : '';\n};\n\n// A field counts as filled in only when it carries a letter or a digit — spaces and\n// punctuation alone don't qualify.\nexport const hasMeaningfulText = (text?: string | null) => !!text && /[a-z0-9À-￿]/i.test(text);\n\n// wta/wnta are stored as ONE `\\n`-separated string, but list UIs work on an array\n// of items — this is the string↔items bridge. Each condition may carry its own\n// inline <ai_reasoning>; we split it off into `reasoning` so the row shows the\n// cognitive-decisioning icon.\nexport const splitConditions = (raw: string, keyPrefix: string): ConditionItem[] =>\n // The AI sometimes leaves its line breaks escaped as a literal `\\n`; normalise\n // them first so CONDITION only has one kind of break to deal with.\n (String(raw ?? '').replace(/\\\\+n/g, '\\n').match(CONDITION) ?? [])\n .map((line) => {\n const reasoning = line.match(AI_REASONING)?.[1];\n const text = line.replace(AI_REASONING_G, '').trim().replace(/^-\\s*/, '');\n return { text, reasoning };\n })\n .filter((c) => c.text)\n .map((c, i) => ({ id: `${keyPrefix}-${i}`, text: c.text, reasoning: c.reasoning }));\n"],"names":["_a"],"mappings":"AACA,MAAM,YAAe,GAAA,0CAAA,CAAA;AACrB,MAAM,cAAiB,GAAA,yCAAA,CAAA;AAUvB,MAAM,SAAY,GAAA,sDAAA,CAAA;AASL,MAAA,uBAAA,GAA0B,CAAC,KAA2B,KAAA;AACjE,EAAA,MAAM,MAAS,GAAA,CAAC,IACd,KAAA,IAAA,IAAQ,OAAO,IAAS,KAAA,QAAA,IAAY,CAAC,KAAA,CAAM,QA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,MAAA,IAAA,GAAO,IAAK,CAAA,OAAA,CAAQ,cAAgB,EAAA,EAAE,EAAE,IAAK,EAAA,CAAE,OAAQ,CAAA,OAAA,EAAS,EAAE,CAAA,CAAA;AACxE,MAAO,OAAA,EAAE,MAAM,SAAU,EAAA,CAAA;AAAA,KAC1B,CACA,CAAA,MAAA,CAAO,CAAC,CAAA,KAAM,EAAE,IAAI,CAAA,CACpB,GAAI,CAAA,CAAC,CAAG,EAAA,CAAA,MAAO,EAAE,EAAI,EAAA,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,IAAM,EAAA,CAAA,CAAE,IAAM,EAAA,SAAA,EAAW,CAAE,CAAA,SAAA,EAAY,CAAA,CAAA;AAAA,IAAA;AAAA;;;;"}
@@ -3,6 +3,8 @@ export interface ConditionItem {
3
3
  text: string;
4
4
  reasoning?: string;
5
5
  }
6
+ /** Normalize host/API condition values to the string shape used by the form store. */
7
+ export declare const normalizeConditionValue: (value: unknown) => string;
6
8
  export declare const hasMeaningfulText: (text?: string | null) => boolean;
7
9
  export declare const splitConditions: (raw: string, keyPrefix: string) => ConditionItem[];
8
10
  //# sourceMappingURL=conditionText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditionText.d.ts","sourceRoot":"","sources":["../../../../../src/schema-driven/utils/conditionText.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,eAAO,MAAM,iBAAiB,UAAW,MAAM,GAAG,IAAI,YAAwC,CAAC;AAM/F,eAAO,MAAM,eAAe,QAAS,MAAM,aAAa,MAAM,KAAG,aAAa,EAUS,CAAC"}
1
+ {"version":3,"file":"conditionText.d.ts","sourceRoot":"","sources":["../../../../../src/schema-driven/utils/conditionText.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,sFAAsF;AACtF,eAAO,MAAM,uBAAuB,UAAW,OAAO,KAAG,MAgBxD,CAAC;AAIF,eAAO,MAAM,iBAAiB,UAAW,MAAM,GAAG,IAAI,YAAwC,CAAC;AAM/F,eAAO,MAAM,eAAe,QAAS,MAAM,aAAa,MAAM,KAAG,aAAa,EAUS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-llm-studio/instant-learning",
3
- "version": "1.3.31",
3
+ "version": "1.3.32",
4
4
  "author": "Devesh Patel",
5
5
  "description": "Reusable React components for Instant Learning.",
6
6
  "license": "MIT",
@@ -178,8 +178,8 @@
178
178
  "unist-util-visit": "^5.1.0",
179
179
  "wavesurfer.js": "^7.12.5",
180
180
  "zustand": "^5.0.13",
181
- "@e-llm-studio/audit-log": "2.1.0",
182
181
  "@e-llm-studio/prompt-editor": "0.1.0",
182
+ "@e-llm-studio/audit-log": "2.1.0",
183
183
  "@e-llm-studio/watch-me-work": "0.0.30",
184
184
  "@e-llm-studio/citation": "0.0.269"
185
185
  },